unix commands in interviews

Upload: manoj-kumar

Post on 04-Jun-2018

243 views

Category:

Documents


1 download

TRANSCRIPT

  • 8/13/2019 Unix Commands in Interviews

    1/24

    Re: How to find and replace the below command?

    Answer

    # 2Using sed command:

    sed 's/searchword/replaceword/g' filename --[Itfinds theword in file and replaces and displays in thecommand line]

    sed -i '/s/searchword/replaceword/g' filename -- [Iteditsthe file, finds and replaces the word and saves itand nexttime when u open the file it displays the file withreplacedword]

    Re: what is the default signal kill in unix?

    Answer

    # 2signal no:! or terminate

    Re: How many bits use for MA address?

    Answer

    # !"# $its

    Re: How does one process we can start an executable file? How to get the "$process% which we started?

    Answer

    # &ps -ef%grep username

    gives the process started $y the user&

    Re: 'hich is the command used to find out currently executing "rocess in ()*?

    Answer# !

    ps -ef

    Re: 'hat is the output of : + ps,e + ps,a commands

    Answer

    # 2ps -e will give all the processes running it is alsosimilarto ps -&ps -a is for running application on terminal only&

    Re: 'hat is the output of : + ps,e + ps,a commands

    http://www.allinterview.com/viewpost/345862.htmlhttp://www.allinterview.com/viewpost/335888.htmlhttp://www.allinterview.com/viewpost/335317.htmlhttp://www.allinterview.com/viewpost/227592.htmlhttp://www.allinterview.com/viewpost/330361.htmlhttp://www.allinterview.com/viewpost/333325.htmlhttp://www.allinterview.com/viewpost/335888.htmlhttp://www.allinterview.com/viewpost/335317.htmlhttp://www.allinterview.com/viewpost/227592.htmlhttp://www.allinterview.com/viewpost/330361.htmlhttp://www.allinterview.com/viewpost/333325.htmlhttp://www.allinterview.com/viewpost/345862.html
  • 8/13/2019 Unix Commands in Interviews

    2/24

    Answer

    # -( ps -ell )rocesses including User and *ystem )rocess&( ps -a)rocesses of all Users excluding processes notassociate with terminal

    Re: How to check whether some ser.ices are running in another ser.er or not?/uppose i am currently in a ser.er named A0 want to check whether some ser.icesare running in ser.er 1 without logging into the ser.er 10

    Answer

    # !ssuming that server is reacha$le from server +and viceversa:

    e can execute the command remotely using rshand $y using

    admin credentials of server + as $elow from server:

    rsh server + I). -l admin login name. -n ps-eaf % grep -i service0name.

    1or eg2 to find httpd service we can use thefollowingcommand assuming server + I) is 3&3&3&3 androot hasadmin previledges:

    rsh 3&3&3&3 -l root -n ps -eaf % grep -i httpd

    Re: what these two commands prints echo test%cat test?

    Answer

    # 2echo test, echo simply prints test&cat test cat command will searches for a file astestin the )4& if it finds any file called test, then it

    will prints the contents of the test file& else willthrough the error as file not exisiting

    Re: How to add content of one file into another file at the beginning

    Answer

    # &concatenate file and file5, in the $elow commandfile content will $e insert in front of that in file5,and then com$ined content will $e redirected tofile6

    cat file file5 . file6

    http://www.allinterview.com/viewpost/360564.htmlhttp://www.allinterview.com/viewpost/326519.htmlhttp://www.allinterview.com/viewpost/387457.htmlhttp://www.allinterview.com/viewpost/398649.htmlhttp://www.allinterview.com/viewpost/360564.htmlhttp://www.allinterview.com/viewpost/326519.htmlhttp://www.allinterview.com/viewpost/387457.htmlhttp://www.allinterview.com/viewpost/398649.html
  • 8/13/2019 Unix Commands in Interviews

    3/24

    Re: 'hat does mkdir up2date3 touch outdated up2date do?

    Answer

    # !m7dir up5date2this command used to ma7e a directory namedup5date&&&

    Re: their is a file!%file2 and i want to append file! data to file2?

    Answer

    # 2cat file .. file5

    Re: 'hat is the difference between udp and tcp?

    Answer

    # !89) gives guaranteed 4elivery, U4) does not89) is connection oriented, U4) is not89) provides 1low 9ontrol, U4) does not&

    Usually U4) is used to send data while streamingetc sinceit ta7es less time, $ut important data is always sentusing 89)&

    Re: what is the use of ls ,l command 4 what is the information it gi.es about user ?

    Answer

    # !ls -l given the sorted file in long listing format&itgives the information such as typefile/directory;,permissions

    given to file,lin7s,owner,group user detail,date

    Re: Hi All% an you please let me know how to grep for a particular pattern in unix0 want to print the dates from the file exp0txt0 the date pattern is $$:MM:5555%

    6ust want to print all the dates from the file exp0txt0

    Answer# &

    $ove answers allow 3?:5665:?#?# input alsoto display&

    http://www.allinterview.com/viewpost/418467.htmlhttp://www.allinterview.com/viewpost/375741.htmlhttp://www.allinterview.com/viewpost/363915.htmlhttp://www.allinterview.com/viewpost/205725.htmlhttp://www.allinterview.com/viewpost/212781.htmlhttp://www.allinterview.com/viewpost/226440.htmlhttp://www.allinterview.com/viewpost/237112.htmlhttp://www.allinterview.com/viewpost/418467.htmlhttp://www.allinterview.com/viewpost/375741.htmlhttp://www.allinterview.com/viewpost/363915.htmlhttp://www.allinterview.com/viewpost/205725.htmlhttp://www.allinterview.com/viewpost/212781.htmlhttp://www.allinterview.com/viewpost/226440.htmlhttp://www.allinterview.com/viewpost/237112.html
  • 8/13/2019 Unix Commands in Interviews

    4/24

    1ollowing may use to avoid that issuegrep -o '[3-?][3-?]:[3-?][3-?]:[3-?][3-?][3-?][3-?]'infile&txt

    Re: How to set sticky bit% or it ha.e any seperate directory to create sticky bit insunfir ser.ers0 "lease help me % i don7t no the exact answer?

    Answer

    # !8ypically the stic7y $it is set on most @nix systemsin the/tmp directory& Aou can set the $it on any directorywiththe commands:

    chmod Bt /dirname

    CD

    chmod >"" /dirname

    Eere is is the stic7y $it and >"" are yourcommondirectory permissions& 8he /tmp dir for example isusuallyset to FFF&

    -greg

    Re: what is the command to print last 8 lines of any text file0

    Answer

    # 2tail -n # file-name.

    Re: what is ls ,ltd?

    Answer

    # !ls - ltd

    current directory information&

    Cption l: Gong listingt: 8ime *tampd: Information a$out current directoryUseed with -l Cption;

    http://www.allinterview.com/viewpost/227467.htmlhttp://www.allinterview.com/viewpost/249744.htmlhttp://www.allinterview.com/viewpost/248397.htmlhttp://www.allinterview.com/viewpost/227467.htmlhttp://www.allinterview.com/viewpost/249744.htmlhttp://www.allinterview.com/viewpost/248397.html
  • 8/13/2019 Unix Commands in Interviews

    5/24

    Re: what is ls ,ltd?

    Answer

    # 2l -- 1or long listing example as $elowt -- for latest time stamp -- fter you ma7e the

    changesetc&d -- stands for the information a$out the currentdirectoryas shown $elow

    =x o/p as $elow :

    drwxrwxr-x 6 oi oi 5F> Har 5! :"F &

    6 a$ove stands for no& of directories in the currentdirectory minus 5 , 8his means a$ove directory hasonechild directory

    when o/p shows as $elow :

    ls -ltddrwxrwxr-x ! oi oi 6?? Har 5! :!! &

    8his would mean parent directory has 6 childdirectoriesi&e !-5 6 child directories;

    hy minus 5 -- 9urrent directory has 5 lin7s so thesame num$er need to $e deducted from the totalnum$er

    Re: 1y using which command we can find the "( utili9ation time?

    Answer

    # &

    top - display top 9)U processes

    4=*9DI)8ICJ

    top provides an ongoing loo7 at processor activityin real time& It displays a listing of the most 9)U-intensive tas7son the system, and can provide an interactiveinterface formanipulating processes& It can sort the tas7s $y9)U usage,memory usage and runtime& can $e $etterconfigured than thestandard top from the procps suite& Host features

    http://www.allinterview.com/viewpost/249563.htmlhttp://www.allinterview.com/viewpost/330439.htmlhttp://www.allinterview.com/viewpost/249563.htmlhttp://www.allinterview.com/viewpost/330439.html
  • 8/13/2019 Unix Commands in Interviews

    6/24

    can either$e selected $y an interactive command or $yspecifying thefeature in the personal or system-wideconfiguration file&

    *ee $elow for more information&

    Re: How to find the files that are accessed before ! minutes?

    Answer

    # !find -type f -amin -3

    =xplanation: 1ind all files excluding directories;from thecurrent directory which have $een accessed nomore-; than3 minutes ago&

    Re: 'hat is the difference between pipe and xargs?

    Answer

    # 2xargs command+uild and execute command lines from standardinput

    find & -type f -mtime - -print % xargs ls

    )ipe is a techniKue to use for Loining two/more

    commandsone command output as input to othercommand &&so on% is a symo$ol for pipe;

    ls -al % more

    Re: 'hat is the difference between pipe and xargs?

    Answer

    # !)ipe is used to connect $etween two commandMargs redirect the output of second command tothe first one

    Re: 'rite a grep ;or grep< command that selects the lines from a file that ha.eexactly three characters0

    Answer

    # -grep N&&&( filename.

    Re: Assume the following files are in the working directory prompt= ls ,l

    tasks ,rw,r,,r,, ! alex student !>2& eb 2! !>:! tasks 'hat command canAlex use to gi.e e.eryone permission to write to the file? 'hat will the ls ,l

    http://www.allinterview.com/viewpost/328062.htmlhttp://www.allinterview.com/viewpost/335343.htmlhttp://www.allinterview.com/viewpost/333200.htmlhttp://www.allinterview.com/viewpost/196979.htmlhttp://www.allinterview.com/viewpost/328062.htmlhttp://www.allinterview.com/viewpost/335343.htmlhttp://www.allinterview.com/viewpost/333200.htmlhttp://www.allinterview.com/viewpost/196979.html
  • 8/13/2019 Unix Commands in Interviews

    7/24

    command display if he does so?

    Answer

    # 2chmod >>> tas7s will give all users owner,group andothers; the read-write permission&r "w 5x therefore rw "B5 >

    ls -l : lists a large amount of information of allnon-hidden files and directories in the currentwor7ingdirectory& eg permissions, owners, siOe, andwhen last

    modified&;

    Re: Assume the following files are in the working directory prompt= ls ,l tasks ,rw,r,,r,, ! alex student !>2& eb 2! !>:! tasks 'hat command can Alex use to gi.ee.eryone permission to write to the file? 'hat will the ls ,l command display if hedoes so?

    Answer

    # >chmod >>> tas7s

    -rw-rw-rw- alex student "56 1e$ 5 ":3 tas7s

    Re: @he rm command remo.es links to file0 'hat does this mean? How then is a filedeleted from the file system?

    Answer

    # 2rm never delete the lin7& only file get removed fromindex&so it will not come when you will use ls command

    Re: @he rm command remo.es links to file0 'hat does this mean? Howthen is a file deleted from the file system?

    Answer

    # >

    I thin7 he is as7ing a$out this :

    - when we remove a file what happens actuallythat it will$e removed from the inode ta$le

  • 8/13/2019 Unix Commands in Interviews

    8/24

    Re: 'hen the shell is reading the command line what is the difference between textenclosed between double uotes ; B < and text enclosed between signal uotes ; C

  • 8/13/2019 Unix Commands in Interviews

    9/24

    # ! process is Oom$ie

    Re: 'hat is type command in unix?what is the functionality??

    Answer

    # !

    type [-aftp)] name [name &&&]

    ith no options, indicate how each namewould $einterpreted if used as a command name&

    Re: how to find largest file?

    Answer

    # 2In the 4irectry Qive&&&&

    ls -ls%sort -nr%head -

    that gives the largest file statistics&&&

    Re: 'hat is the difference between A'D and /E$ commands? "l9 gi.e exampleand explain000

    Answer

    # !*=4 which stands for *tream =4itor; is a simple$utpowerful computer program used to apply variouspre-specified textual transformations to aseKuential streamof text data&

    It reads input files line $y line, edits each lineaccordingto rules specified in its simple language the sedscript;,and then outputs the line&

    R is a complete pattern scanning andprocessing language,it is most commonly used as a Unix command-linefilter toreformat the output of other commands&

    1or example, to print only the second and sixthfields ofthe date command the month and year; with aspaceseparating them, at the Unix prompt, you wouldenter:date % aw7 STprint (5 (>VW

    Re: s there any command in (nix% other than:ls% to list the files in a directory? @heanswer will be highly appreciated000

    Answer echo @ will list the files inside the dir

    http://www.allinterview.com/viewpost/179814.htmlhttp://www.allinterview.com/viewpost/178966.htmlhttp://www.allinterview.com/viewpost/173454.htmlhttp://www.allinterview.com/viewpost/172938.htmlhttp://www.allinterview.com/viewpost/179814.htmlhttp://www.allinterview.com/viewpost/178966.htmlhttp://www.allinterview.com/viewpost/173454.htmlhttp://www.allinterview.com/viewpost/172938.html
  • 8/13/2019 Unix Commands in Interviews

    10/24

    # F

    Re: 'hat s the command to change a file7s creation time0 means one file is createdat the time !-:!G then time should be changed to !>:!>

    Answer# !

    use touch command to change the date

    Re: 'hat s the command to change a file7s creation time0 means one file is createdat the time !-:!G then time should br changed to !>:!>

    Answer

    # 2touch :- used to change the time stamps

    *yntax :- touch options expression filenames;where expression consists of eight digit num$erusing the format HH44hhmmmonth,day,hr & *oc7et file:s;:5 communicate $etn 5 processesrunning ondifferent system in a networ7F& 9haracter special file:c;:handles only charactedformatted dataeg&stdin, stdout, stderr

    Re: 'hat is the functions of 9ambie process?Answer

    # &guys, we can thin7 of Oom$ie process as aQEC*8& when aperson having some unfinished $usiness onearth; dies they$ecome ghost, means they are dead $ut they havethereexistence on this earth& Yust li7e that if a processdied$ut it's existence remains in the process entryta$le thenthat process $ecame Pom$ie&

    now who is going to clean this messZso it is the wor7 of the parent process to clean thisthing$y waiting on the child process&if the parent process don't clean up this mess thenit would$e the wor7 of operating system to release theseresources

    when process entry ta$le would $e loo7ed upagain

    http://www.allinterview.com/viewpost/42937.htmlhttp://www.allinterview.com/viewpost/71032.htmlhttp://www.allinterview.com/viewpost/149290.htmlhttp://www.allinterview.com/viewpost/42937.htmlhttp://www.allinterview.com/viewpost/71032.htmlhttp://www.allinterview.com/viewpost/149290.html
  • 8/13/2019 Unix Commands in Interviews

    14/24

    Re: 'hat is )$% IRE" and /E$ ? ould you please gi.e me the differencebetween all the three? 'here we use this commnands?

    Answer

    # >

    1IJ4 < QD=)

    +asically 1IJ4 < QD=) are the UJIM commandsshared throughthe 1IG8=D* &here is *=4 *8D=H; is one ofthe maineditor&

    1IJ4 : 1ind is an exclusive command used to findfiles/folders are other information&and this ispowerfullthen windows&

    ex : find /raLa -name she7ar -printoutput : raLa/she7ar

    Qrep : 8his is also one of the important commandused toglo$ally searching the regular expression in the file&Q=D) is grepping the information character $ycharacter&i&e; from file &

    ex ; : QD=) cat raLa5; : QD=) -i cat raLa for case sensitive;5; : QD=) -v cat raLa v represent negative ;

    CU8)U8 :if we have an file raLa with dataregarding cat wecan clearly explain&

    1inally *=4 *8D=H;

    *=4 : It is an editor $ut non interactive &

    ex : sed -e 'd/chain/dog/f' raLa . she7ar

    Re: 'hat is file system in unix??

    Answer

    # FUfs filesysten is a unix default filesystem&

    Unix Cs having different flavours,

    &ix unix

    http://www.allinterview.com/viewpost/103380.htmlhttp://www.allinterview.com/viewpost/146441.htmlhttp://www.allinterview.com/viewpost/103380.htmlhttp://www.allinterview.com/viewpost/146441.html
  • 8/13/2019 Unix Commands in Interviews

    15/24

    Lfs < Lfs5 is aix unix default file system andcommanfilesystem is cdrfs,rmfs

    5&Ginux

    ext5

  • 8/13/2019 Unix Commands in Interviews

    16/24

    chmod FFF filename&extn

    Re: what is mount %tell me about mount %how can u use in real time pro6ect??

    Answer

    # &8he process of adding or lin7ing or mapping theformatteddis7 space to a folder is called mounting&Gi7e the $oot partition is formatted in ext5/6filesystemand then it is mounted to /$oot folder&Aou cannotuse anypartition or dis7 without mounting

    Re: Ii.e the command to display space usage on the ()* file system0

    Answer

    # 2df -7 &

    Re: Ii.e the command to display space usage on the ()* file system0

    Answer

    # F du -h /dev/filename filename is the name ofthe file li7esda and hda;

    d -dis7u -usage-h -human-reada$le

    Re: 'hat is the difference between /hell "rogramming and /hell scripting?

    Answer

    # 2

    *hell programming is wrong terminology& Its shell

    scripting&

    8here is difference $etween scripting andprogramming& Unixis shell scripting&

    Re: 'hat is the difference between /hell "rogramming and /hellscripting?

    Answer

    # &8he term *hell programming is not true&*hell scriptingis the term which is a collection of command to

    do aspecific tas7& 8he shell act as a Interpreter&hen weexecute a shell script, a temporary shell iscreated and theinterpreter interprete and execute one line at atime& ifany error in the line then it exit from that line&Jo nextline will $e read&

    Qetting error and Lump to next line is happenin case of

    http://www.allinterview.com/viewpost/118555.htmlhttp://www.allinterview.com/viewpost/101544.htmlhttp://www.allinterview.com/viewpost/131257.htmlhttp://www.allinterview.com/viewpost/106598.htmlhttp://www.allinterview.com/viewpost/115918.htmlhttp://www.allinterview.com/viewpost/118555.htmlhttp://www.allinterview.com/viewpost/101544.htmlhttp://www.allinterview.com/viewpost/131257.htmlhttp://www.allinterview.com/viewpost/106598.htmlhttp://www.allinterview.com/viewpost/115918.html
  • 8/13/2019 Unix Commands in Interviews

    17/24

    9ompiler&

    Re: How to setup $isk space as well as memory in solaris!?

    Answer

    # &

    top is not recognisa$le in *olaris 3 $y default&

    prstat can $e used only to see the statistics ofmemory andprocesses&format command can $e used to setup the dis7space $ut notmemory&swap memory can $e added later $y using theswap commandwith some options&

    Re: how unix kernel distinguishes between a normal file and de.ice file ?

    Answer

    # !8his information file type; is stored in the inode ofafile, as one of the fields&

    Re: how unix kernel distinguishes between a normal file and de.ice file ?

    Answer

    # -for normal file in the ls -l listing there is a '-' asfirst character li7e '-rw-r--r- '&

    -rw-r--r-- $atch sy$ase 3 4ec " ":!3 test8his identifies it as normal file&

    +ut for device files , they are saved ascharacter or else$loc7s & *o the first letter is 'c' for character ,and '$'for $loc7s&

    Re: what will this do +cat = file0c ?;file0c is a file in current directoryUJIM; JonQUI

    5; 1ile *ystem *84&=DD, *84&IC;

    6; 9ommand +ased

    "; Jot =vent 4riven

    !; Hulti )rocessing

    http://www.allinterview.com/viewpost/68336.htmlhttp://www.allinterview.com/viewpost/39001.htmlhttp://www.allinterview.com/viewpost/179118.htmlhttp://www.allinterview.com/viewpost/68334.htmlhttp://www.allinterview.com/viewpost/12402.htmlhttp://www.allinterview.com/viewpost/23712.htmlhttp://www.allinterview.com/viewpost/14018.htmlhttp://www.allinterview.com/viewpost/43006.htmlhttp://www.allinterview.com/viewpost/68336.htmlhttp://www.allinterview.com/viewpost/39001.htmlhttp://www.allinterview.com/viewpost/179118.htmlhttp://www.allinterview.com/viewpost/68334.htmlhttp://www.allinterview.com/viewpost/12402.htmlhttp://www.allinterview.com/viewpost/23712.htmlhttp://www.allinterview.com/viewpost/14018.htmlhttp://www.allinterview.com/viewpost/43006.html
  • 8/13/2019 Unix Commands in Interviews

    23/24

    IJ4C*

    ; QUI +ased5; 1865, J81*

    6; Henu +ased"; =vent4riven!; Jo Hulti )rocessing

    Re: 'hat is the basic difference between unix and windows operating systems?

    Answer

    # -unix :- multi user, multi processing and multitas7ingoperating system

    Re: 'hat is the basic difference between unix and windows operating systems?

    Answer

    # F

    ; indows is licenced C*, It means you have to

    $uy it5 ; Unix is 1ree-source C*, you can Hodify codeof C* asper your $usiness re

    Re: 'hat is the basic difference between unix and windows operating systems?

    Answer

    # Gunix is more secure than windows& In unix we canrestrictthe permission of each user

    Re: 'hat is the basic difference between unix and windows operatingsystems?

    Answer

    # LUnix is the multi user operating system&windows is single user operating system&

    Re: How to get a particular string as your prompt ? Ii.e syntax of that command?

    Answer

    # 2)*string.

    Re: 'rite a command to find all of the files which ha.e been accessed within thelast & days0

    Answer

    # -find -type f -atime -63 -print

    Re: how to list all the hidden files?

    Answer

    # &ls-a

    Re: how you know the ip address of user system?

    Answer

    # 2mr lipun &&&&&&&&u really hvn't any idea a$out unix&&&&&

    u can't see the ip address from the hostname -i

    cmd&&&&

    http://www.allinterview.com/viewpost/68338.htmlhttp://www.allinterview.com/viewpost/107125.htmlhttp://www.allinterview.com/viewpost/119419.htmlhttp://www.allinterview.com/viewpost/102442.htmlhttp://www.allinterview.com/viewpost/68333.htmlhttp://www.allinterview.com/viewpost/35287.htmlhttp://www.allinterview.com/viewpost/381202.htmlhttp://www.allinterview.com/viewpost/378054.htmlhttp://www.allinterview.com/viewpost/68338.htmlhttp://www.allinterview.com/viewpost/107125.htmlhttp://www.allinterview.com/viewpost/119419.htmlhttp://www.allinterview.com/viewpost/102442.htmlhttp://www.allinterview.com/viewpost/68333.htmlhttp://www.allinterview.com/viewpost/35287.htmlhttp://www.allinterview.com/viewpost/381202.htmlhttp://www.allinterview.com/viewpost/378054.html
  • 8/13/2019 Unix Commands in Interviews

    24/24

    the command is

    ifconfig -a

    Re: how you know the ip address of user system?

    Answer

    # ! hostname -i

    http://www.allinterview.com/viewpost/373480.htmlhttp://www.allinterview.com/viewpost/373480.html