Friday, June 29, 2018

Unix Interview Questions & Answers

 Unix Interview Questions & Answers


1.Search a file from root directory.(filename = sample.txt)
find / -name sample.txt

2.Display the numbers in sorted order
sort -nu

3.Display the updated lines in file
tail -f filename

4.How to zip a Directory
gzip -r /hom/bea/app

5.How to kill a prosess.
kill -9 pid

6.Display all java process in unix.
ps -ef |grep java

7.How to delete 10 lines in vi editor.
10dd

8.How to search a string and replace tin  vi editor.
:"%s/old string /new string/ gi"

9.How to search a string in vi editor from bottom to top.
?string name

10.How to insert a line above the current line in vi editor .
esc+o

11.How to rename a file .
mv file1 file2

12. copy the content one directory to another directory.
cp -r dir1/file1 dir2/file2

13. How can delete blank lines in directory.
grep -v "^$" sample > temp
mv temp sample

14.How can replace astring in unix.
sed "s/oldstring/newstring/g" filename

15.Syntax for zip and unzip afile.
gzip filename
guzip filename.gz

16.How can display top 10 disk usage files.
du -sh *|sort -nr|head -10

17.How to retrive a field in a file.
cut -f 1,2 stud.

18.what is command search a string in a file.
grep

19).How to goto the end of the line in Vieditor?
G

20).Copy 10 line in vi editor?
10yy

21).How to go to insert mode in vi editor?
Esc+i

22).How to search a string in a file(filename=sample,string=weblogic)?
grep weblogic sample

23).How to copyfile from one unix to other unix system and syntax (file=sample.txt,target host=192.168.11.128,target file path=/home/bea)?
scp -rp sample.txt username@192.168.11.128:/home/bea

24).How to find out CPU utiligation?
top

25).How to execute ascript using nohup(script name=startweblogic.sh)?
nohup ./startWeblogic.sh &

26).Which command is used to search and replace a string?
sed

27)which command is used to search astring in multiple files?
fgrep

28)How to search a string from top to bottom in vi Editor's(String =weblogic)?
 /weblogic

29)how to save and quit from vi Editor's?
a)WQ!

30)what are the Advantages of nohup command?
nohup will execute the process if you layout system.
Syn:nohup &.

31)Differance b/w the ping and tracert?
ping                              
1)It is check the connectivity.  
2)It is display all at a time.           
tracert
1.It is packet information one place to another place destination.
2.It display only 30 hubs in tracert.

32)How to execute unix commands in vi?
:ls

33)tar dir1 dir2 dir3 and new_dir?
syn:tar -cvf new_dir.tar dir1 dir2 dir3.

34)How to display the ipaddress and portnumber?
netstat -anp

35)how to delete directory with recursion and force?
rm -rf filename.

36)How to Open a file with page to page ?
more filename

37)How to Hide a file (file name=tuxedo)?
mv tuxedo .tuxedo

38)How to do undo in vi Editor's?
u

39)How to goto 100 Line in Vi Editor's?
100L

40)How to display last 100 Line from a file?
tail -100 filename

41)How to Reterive the fields from a file?
cut

42)How to zip a directory?(/home/directory)?
gzip -r /home/directory

43)How to go to end of the line in Vi?
G

44)Display the directiory count in current dir?
ls -lrt !wc -l

45)How to appeand data to the existing file?
cat>>filename

46)How to find out the diskspace of the fileSystem?
df -sh

47)write A syntax for the scp Commands?
Scp filename root@ipaddress:filename.

48)How to display the updated lines in file ?
tail -f filename.

49)How to display the ipaddress and portnumber?
netstat -anp

50)which command is used to connect to the remote server?
telenet ipaddress.

51)How to repalce and String in vi Editor's?
sed %s/oldstring/newstring/g

52)How to repalce and String in unix?
sed s/oldstring/newstring/g filename

53)How to display top 10 lines from a file?
head -10 filename.

54)syntax for tar and untar a file?
tar -cvf filename.tar file1 file2 file3.
tar -Xvf filename.tar

55)How to display hiddean a file?
ls -a.

56)How to Delete a blank line from a filename?
grep "^v" sample >temp
mv temp filename

57)How to display all cuurent running process?
ps -ef

58)syntax for zip and unzip file?
gzip filename.
gunzip filename.gz

No comments:

Post a Comment