Search This Blog

Tuesday, 30 October 2012

Unix commands Interview questions

unix commands :-
<><><><><><><>

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).Copy file from path to other tree structure is given below?
25).How to find out CPU utiligation?
      top
26).How to execute ascript using nohup(script name=startweblogic.sh)?
      nohup ./startWeblogic.sh &
27).Which command is used to search and replace a string?
       sed
28).wich command is used to search astring in multiple files?
      fgrep


1)How to search a string from top to bottom in vi Editor's(String =weblogic)?
A) /weblogic
2)how to save and quit from vi Editor's?
a)WQ!
3)what are the Advantages of nohup command?
A)nohup will execute the process if you layout system.
Syn:nohup &.
4)Differance b/w the ping and tracert?
A) ping                   tracert
1)It is check the connectivity.   1.It is packet information one place to
                    another place destination.
2)It is display all at a time.    2.It display only 30 hubs in tracert.    
5)How to execute unix commands in vi?
A):ls
6)tar dir1 dir2 dir3 and new_dir?
A)syn:tar -cvf new_dir.tar dir1 dir2 dir3.
7)How to display the ipaddress and portnumber?
A)netstat -anp
8)how to delete directory with recursion and force?
A)rm -rf filename.
9)How to Open a file with page to page ?
A)more filename
10)How to Hide a file (file name=tuxedo)?
A)mv tuxedo .tuxedo
11)How to do undo in vi Editor's?
A)u
12)How to goto 100 Line in Vi Editor's?
A)100L
13)How to display last 100 Line from a file?
A)tail -100 filename
14)How to Reterive the fields from a file?
A)cut
15)How to zip a directory?(/home/directory)?
A)gzip -r /home/directory
16)How to go to end of the line in Vi?
A)G
17)Display the directiory count in current dir?
A)ls -lrt !wc -l
18)How to display all files ending with "log"?
19)How to appeand data to the existing file?
A)cat>>filename
20)How to find out the diskspace of the fileSystem?
A)df -sh
21)write A syntax for the scp Commands?
A) Scp filename root@ipaddress:filename.
22)How to display the updated lines in file ?
A)tail -f filename.
23)How to display the ipaddress and portnumber?
A)netstat -anp
24)which command is used to connect to the remote server?
A)telenet ipaddress.
25)How to repalce and String in vi Editor's?
A) sed %s/oldstring/newstring/g
25)How to repalce and String in unix?
A) sed s/oldstring/newstring/g filename
26)How to display top 10 lines from a file?
A) head -10 filename.
27)syntax for tar and untar a file?
A)tar -cvf filename.tar file1 file2 file3.
  tar -Xvf filename.tar
28)How to display hiddean a file?
A)ls -a.
29)How to Delete a blank line from a filename?
A)grep "^v" sample >temp
  mv temp filename
30)How to display all cuurent running process?
A)ps -ef
31)syntax for zip and unzip file?
A)gzip filename.
  gunzip filename.gz




No comments: