master_linux_monthly assignemnts,question answers,commands,64 interview q-a,

Upload: shilpa-jain

Post on 09-Apr-2018

222 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/7/2019 Master_Linux_Monthly Assignemnts,Question Answers,Commands,64 Interview Q-A,

    1/42

    Linux Unix Questions and Their Answers

    1. To display the contents of a executable file the followingcommand can be used(a) cat (b) od (c) vi (d) ed ans : b

    2. Assume the current directory contains 10 files and does'ntcontain 'temp'. What will be the output of the follwingcommands?$ls > temp$wc -l temp(a) 9 (b) 10 (c) 11 (d) undefined. ans : b3. If one wants the output of one command( command1) to be

    printed inthe printer as well as to be added to another file(outfile) which one of the following is a currect commandhe can give?(a) $command1 >>outfile|tee lpr

    (b) $tee -a command1 | lpr (c) $ command1 | tee outfile | lpr (d) $ command | tee -a outfile |lpr ans : d(4) In the shell program set -x will causeA. Execution of the commands in the backgroundB. Execution of the commands in verbose modeC. Exit from the shell program.D. Exit from the shell program after executing the next command(5) ACL in UNIX refers toA. Acces Control ListB. Action Control List

    C. Application Command LanguageD. Advanced C lanuage(6) The command echo*A. will print * on the screenB. will print contents of all the files in the currentdirectoryC. will list the files in the current directoryD. will print the contents of all shell variables(7) ls || date willA. print the name of the files in the current directoryB. print today's date and timeC. (A) followed by (B)D. none of the above(8) The built-in shell variable $$ refers toA. printing numbers in dollar formatB. proces id_ of last commandC. proces id_ of last background command issuedD. proces-id of current shell(9) dd is mainly used for

  • 8/7/2019 Master_Linux_Monthly Assignemnts,Question Answers,Commands,64 Interview Q-A,

    2/42

    A. dealing with raw, unformated data, whatever the sourceB. dealing with data dictionaryC. deleting a directoryD. none of the above(10) vis in UNIX is

    A. a command that takes only one inputB. a command for deleting strange or unwanted charectors thatmay have crept into files.C. points non-printable characters in understandable formatD. all of the above(11) Which of the following is true regarding the UNIX(i) Multiuser Operating System(ii)Multitasking Operating System(iii) Real timing Operating SystemA. i only B. i and ii only C. i and ii and iii onlyD. i and ii

    (12) ln command is used toA. link object codes into a executable codeB. give two names to the same fileC. set line numbers for the fileD. none of the above(13) nohup command is used for A. protecting the execution of programmes from aborting whenhangup signal is receivedB. changing the execution priority of the programesC. not hanging up of the modemD. disconnecting a node from the system(14) SCCS is aA. Tool for maintaining large programmes in a productionenvironmentB. Communication ProtocolC. Shell Programming LanguageD. String processing utility(15) Which one of the following is true as long as UNIX isconcernedA. One can do programming in C onlyB. It can support terminals capable of printing only uppercasecharactersC. The text files are sorted as it is in MS-DOSD. None of the above(16) Inside vi editor to replace the string /10/$/94 with10/$$/92 globally the following command can be usedA. :1,$ s/\/10\/\$\/94/10\/\$\$\/92/gB. :1,$ s/\/10\/\$\/94/10\/\$\/$92/C. :s/10/$/94/10/$$/92/gD. :1,$ s/\/10\/$\/94/10\/$$\/92/g

  • 8/7/2019 Master_Linux_Monthly Assignemnts,Question Answers,Commands,64 Interview Q-A,

    3/42

    (17) The ed command without any argumentA. will print the current working directoryB. will make the home directory as current directoryC. will ask for the directory to be used as the current

    directory

    D. will go to the previous directory(18) nice command is usedA. to increase/decrease execution priority of a commandB. to compress a fileC. to run a programme at latter timeD. to set the key board responce slower (19) What will be the output of the following command sequence

    $ x='I am x'$sh$echo $x

    A. I am x B. Blank line C. x D. None of the above

    (20) The command tr a-z 0-9 < xA. converts all the digits to lowercase alphabetsB. converts all the lowercase alphabets to digitsC. will give syntax error D. none of the above

    I

    Absolutely Important Linux UNIX Commands

    at f List contents of file

    cat f1 f2 >f3Concatenates f1(file 1) & f2(file 2) into f3(file 3)

    cd returns you to your home or main directorycd / takes you to the root, as far up (to the left) as far as possiblecd to move down (right in the pathname) a directorycd .. moves you up (left in pathname) a directory; likewise,cd ../../.. moves you up (left in the pathname) 3 directory levels

    chmod ###

    changes your protections. The order is: you|group|universe (rwxrwxrwx).There will be either a d or - before it. If there's a d, then it's a directory. If there's not, then it's a file.You set the protections in the order rwx (read=1, write=2, execute=4). So,to set the protections for thedirectory directoryname: you rwx, group r-x, universe r--, you would enter:chmod 751 .

    clear to clear screen

    compress compresses the file filename and puts a .Z extension on it. To uncompressit, type uncompresscp f1 f2 Copy file f1 into f2cp -r D1D2 copies the directory D1 and renames it D2

  • 8/7/2019 Master_Linux_Monthly Assignemnts,Question Answers,Commands,64 Interview Q-A,

    4/42

    ^-c (ctrl-c) to kill a running process^-d (ctrl-d) to close an open windowdf gives disk usagediff f1 f2 Lists file differencesdig host domain name, IP address, and alias information for the given host.dosdir to do a "dir" (~ls in UNIX) on a DOS floppy in the disk drivedosread to read a file from a DOS floppy to your computer accountdoswrite to write a file from your computer account to a DOS floppy

    du lists all subdirectories and their sizes (in blocks?) and total directory size (in blocks?) (takes a long time)

    du -a lists all files and their sizes (in blocks?) in present directory and totaldirectory size (in blocks?) (takes a long time)du -s lists overall directory size (in blocks?) (long but clean)env shows current environment set-up

    find

    Searches the named directory and it"s sub-directories for files. Most

    frequently called like this:find ./ -name "t*" -print

    Which searches the current directory ( and all of its sub-directories ) for anyfiles that begin with the letter "t" and then prints them out. If you are lookingfor a specific filename, then replace "t*" with "filename", and "find" will

    print out all incidences of this file.

    finger @. (e.g., finger [email protected] fingers Johndoe at Kent State University)ftp establishes an ftp link with machinenamegzip produces files with a .gz extension.gunzip decompress files created by gzip, compress or pack.

    ispell f Interactively checks the spelling of the file f, giving logical alternatives tothe misspelled words. Type "?" to get help. "ispell" can be accessed from thecommand line, and also through emacs with M-x ispell-buffer.

    kill -9 -1(from a remotely logged-in site) kills all running processes (essentiallyforces a logout) *not to be used unless nothing else works*kill -9 process-id# - kills a running process

    lpq shows UNIX print queuelpr to print the filelpqrm job# removes job from printer queuels shows listing of files in present directoryls -a shows listing of all files in present directoryls -l shows long listing of files in present directoryls -la | more shows long listing of all files in present directoryman command shows help on a specific command.mkdir D creates a new directory called D

    more to view the contents of a file without making changes to it one screen at atime. Hit q to quit more.mv f1 f2 Rename file f1 as f2

  • 8/7/2019 Master_Linux_Monthly Assignemnts,Question Answers,Commands,64 Interview Q-A,

    5/42

    mv f1D moves the file called f1 to the directory D

    nslookup host domain name, IP address, and alias information for the given host.e.g., nslookup www.kent.edu gives related data for www.kent.edu passwd to change your password (takes an hour or so to take effect on all machines) ping host to test if the host is up and running. pwd present working directory ps Shows processes running ps -flu Shows detailed description of processes runningpquota Shows printer quotaquota -v Shows current disk usage and limits.

    rlogin allows you to remotely log in to another machine on which you have access privilegesrm f Delete (removes) the file f.

    rm -i f To be prompted for confirmation before you remove a file f, at the UNIX prompt, type

    rm dir D Delete (removes) the empty directory Drm - r D removes the directory named D and its contents - use with cautions f Alphabetically sort f.talk establishes an e-talk session with user@machinenametar combines multiple files into one or vice-versa

    telnet allows you to remotely log in to another machine on which you have access privilegesuncompress uncompresses filename.Zusers shows who's logged in on the machinevi to open the file called filename in the vi text editor

    who Shows who is currently logged on the system.whoami shows username of person logged in that windowwhoisdomain_name

    lists the domain registration record, e.g., whois kent.edu will produce thedomain record for kent.edu

    * wild card character representing any # or charactersdate shows the time and datedate -u shows grewich mean time

    . a short cut that stands for the location you are at in a pathway. ex. cp (file(though a pathway) (. (the location you are at)

    .. move to parent directory from any comand ex. mv (file name) .. or cd .. etc.

    pwd shows where you are in the pathway? wild card character representing one character, can be used in succesion

    ~ abbreviation for the home file ex. ls ~ lists files in home dir w/o movingtherezip best compression for IBM files.

    DOS UNIXattrib chmod

  • 8/7/2019 Master_Linux_Monthly Assignemnts,Question Answers,Commands,64 Interview Q-A,

    6/42

    backup tar dir lscls clear copy cpdel rm

    deltree rm -R rmdir edit vi

    picoformat Fdformat

    mountumount

    move / rename mvtype less cd cd

    chdir

    more < file more filemd mkdir win startx

    Basic UNIX commands Note: not all of these are actually part of UNIX itself, and you may not find them on allUNIX machines. But they can all be used on turing in essentially the same way, bytyping the command and hitting return. Note that some of these commands are differenton non-Solaris machines - see SunOS differences .If you've made a typo, the easiest thing to do is hit CTRL-u to cancel the whole line. But

    you can also edit the command line (see the guide to More UNIX ).UNIX is case-sensitive.

    Files ls --- lists your files

    ls -l --- lists your files in 'long format', which contains lots of useful information,e.g. the exact size of the file, who owns the file and who has the right to look at it,and when it was last modified.ls -a --- lists all files, including the ones whose filenames begin in a dot, whichyou do not always want to see.There are many more options, for example to list files by size, by date, recursivelyetc.

    more filename --- shows the first part of a file, just as much as will fit on onescreen. Just hit the space bar to see more or q to quit. You can use / pattern tosearch for a pattern.

    emacs filename --- is an editor that lets you create and edit a file. See the emacs page .

  • 8/7/2019 Master_Linux_Monthly Assignemnts,Question Answers,Commands,64 Interview Q-A,

    7/42

    mv filename1 filename2 --- moves a file (i.e. gives it a different name, or movesit into a different directory (see below)

    cp filename1 filename2 --- copies a file

    rm filename --- removes a file. It is wise to use the option rm -i, which will ask you for confirmation before actually deleting anything. You can make this your default by making an alias in your .cshrc file.

    diff filename1 filename2 --- compares files, and shows where they differ

    wc filename --- tells you how many lines, words, and characters there are in a file

    chmod options filename --- lets you change the read, write, and execute permissions on your files. The default is that only you can look at them andchange them, but you may sometimes want to change these permissions. For example, chmod o+r filename will make the file readable for everyone, andchmod o-r filename will make it unreadable for others again. Note that for someone to be able to actually look at the file the directories it is in need to be atleast executable. See help protection for more details.

    File Compression

    o gzip filename --- compresses files, so that they take up much less space.Usually text files compress to about half their original size, but it dependsvery much on the size of the file and the nature of the contents. There areother tools for this purpose, too (e.g. compress ), but gzip usually gives thehighest compression rate. Gzip produces files with the ending '.gz'appended to the original filename.

    o gunzip filename --- uncompresses files compressed by gzip.

    o gzcat filename --- lets you look at a gzipped file without actually havingto gunzip it (same as gunzip -c ). You can even print it directly, usinggzcat filename | lpr

    printing

    o lpr filename --- print. Use the -P option to specify the printer name if youwant to use a printer other than your default printer. For example, if youwant to print double-sided, use 'lpr -Pvalkyr-d', or if you're at CSLI, you

    may want to use 'lpr -Pcord115-d'. See 'help printers' for more informationabout printers and their locations.

    o lpq --- check out the printer queue, e.g. to get the number needed for removal, or to see how many other files will be printed before yours willcome out

    o lprm jobnumber --- remove something from the printer queue. You canfind the job number by using lpq. Theoretically you also have to specify a

  • 8/7/2019 Master_Linux_Monthly Assignemnts,Question Answers,Commands,64 Interview Q-A,

    8/42

    printer name, but this isn't necessary as long as you use your default printer in the department.

    o genscript --- converts plain text files into postscript for printing, and givesyou some options for formatting. Consider making an alias like alias ecop'genscript -2 -r \!* | lpr -h -Pvalkyr' to print two pages on one piece of

    paper.

    o dvips filename --- print .dvi files (i.e. files produced by LaTeX). You canuse dviselect to print only selected pages. See the LaTeX page for moreinformation about how to save paper when printing drafts.

    DirectoriesDirectories, like folders on a Macintosh, are used to group files together in a hierarchicalstructure.

    mkdir dirname --- make a new directory

    cd dirname --- change directory. You basically 'go' to another directory, and youwill see the files in that directory when you do 'ls'. You always start out in your 'home directory', and you can get back there by typing 'cd' without arguments.'cd ..' will get you one level up from your current position. You don't have to walk along step by step - you can make big leaps or avoid walking around byspecifying pathnames .

    pwd --- tells you where you currently are.

    Finding things ff --- find files anywhere on the system. This can be extremely useful if you've

    forgotten in which directory you put a file, but do remember the name. In fact, if you use ff -p you don't even need the full name, just the beginning. This can also

    be useful for finding other things on the system, e.g. documentation.

    grep string filename(s) --- looks for the string in the files. This can be useful a lotof purposes, e.g. finding the right file among many, figuring out which is the rightversion of something, and even doing serious corpus work. grep comes in severalvarieties ( grep , egrep , and fgrep ) and has a lot of very flexible options. Check out the man pages if this sounds good to you.

    About other people w --- tells you who's logged in, and what they're doing. Especially useful: the 'idle'

    part. This allows you to see whether they're actually sitting there typing away attheir keyboards right at the moment.

    who --- tells you who's logged on, and where they're coming from. Useful if you're looking for someone who's actually physically in the same building as you,

  • 8/7/2019 Master_Linux_Monthly Assignemnts,Question Answers,Commands,64 Interview Q-A,

    9/42

    or in some other particular location.

    finger username --- gives you lots of information about that user, e.g. when theylast read their mail and whether they're logged in. Often people put other practicalinformation, such as phone numbers and addresses, in a file called .plan . Thisinformation is also displayed by 'finger'.

    last -1 username --- tells you when the user last logged on and off and fromwhere. Without any options, last will give you a list of everyone's logins.

    talk username --- lets you have a (typed) conversation with another user

    write username --- lets you exchange one-line messages with another user

    elm --- lets you send e-mail messages to people around the world (and, of course,read them). It's not the only mailer you can use, but the one we recommend. Seethe elm page , and find out about the departmental mailing lists (which you canalso find in /user/linguistics/helpfile).

    About your (electronic) self whoami --- returns your username. Sounds useless, but isn't. You may need to

    find out who it is who forgot to log out somewhere, and make sure *you* havelogged out.

    finger & .plan filesof course you can finger yourself, too. That can be useful e.g. as a quick check whether you got new mail. Try to create a useful .plan file soon. Look at other

    people's .plan files for ideas. The file needs to be readable for everyone in order to

    be visible through 'finger'. Do 'chmod a+r .plan' if necessary. You should realizethat this information is accessible from anywhere in the world, not just to other people on turing.

    passwd --- lets you change your password, which you should do regularly (atleast once a year). See the LRB guide and/or look at help password .

    ps -u yourusername --- lists your processes. Contains lots of information aboutthem, including the process ID, which you need if you have to kill a process.

    Normally, when you have been kicked out of a dialin session or have otherwisemanaged to get yourself disconnected abruptly, this list will contain the processesyou need to kill. Those may include the shell (tcsh or whatever you're using), andanything you were running, for example emacs or elm. Be careful not to kill your current shell - the one with the number closer to the one of the ps command you'recurrently running. But if it happens, don't panic. Just try again :) If you're using anX-display you may have to kill some X processes before you can start them again.These will show only when you use ps -efl , because they're root processes.

    kill PID --- kills (ends) the processes with the ID you gave. This works only for your own processes, of course. Get the ID by using ps . If the process doesn't 'die'

  • 8/7/2019 Master_Linux_Monthly Assignemnts,Question Answers,Commands,64 Interview Q-A,

    10/42

  • 8/7/2019 Master_Linux_Monthly Assignemnts,Question Answers,Commands,64 Interview Q-A,

    11/42

    Miscellaneous tools webster word --- looks up the word in an electronic version of Webster's

    dictionary and returns the definition(s)

    date --- shows the current date and time. cal --- shows a calendar of the current month. Use e.g., 'cal 10 1995' to get that for

    October 95, or 'cal 1995' to get the whole year.

    You can find out more about these commands by looking up their manpages:man commandname --- shows you the manual page for the command

    For further ways of obtaining help, look at the pages with electronic sources of information and non-electronic sources .

    More UNIX commands

    Back up to the Main Computing Page

    More UNIX Commands I have noticed that the overwhelming majority of visitors come to this page via a Lycos search. This page is probably *not* what you're looking for - see the links at the bottomof this page for more useful information!

    jobs --- lists your currently active jobs (those that you put in the background) andtheir job numbers. Useful to determine which one you want to foreground if you

    have lots of them. bg --- background a job after suspending it.

    fg % jobnumber --- foreground a job

    !! --- repeat the previous command (but CTRL-p , is safer, because you have hitreturn in addition)

    ! pattern --- repeat the last command that starts with pattern

    echo $ VARIABLE --- shows the value of an environment variable

    setenv --- lets you set environment variables. For example, if you typed a wrongvalue for the TERM variable when logging in, you don't have to log out and startover, but you can just do setenv TERM vt100 (or whatever). To see what all your environment variables are set to, type env . The one that you're most likely to haveto set is the DISPLAY variable, when using an X-display.

    unset VAR --- lets you un-set environment variables. Useful, for example, if you've usually set autologout but want to stay logged on for a while without

  • 8/7/2019 Master_Linux_Monthly Assignemnts,Question Answers,Commands,64 Interview Q-A,

    12/42

    typing for some reason, or if you set the DISPLAY variable automatically but wantto avoid opening windows for some reason.

    source filename --- you need to source your dotfiles after making changes for them to take effect (or log off and in again)

    load --- will show you the load average graphically

    ispell filename --- will check the spelling in your file. If you're running it on aLaTeX file use the -T option to tell it to ignore the LaTeX commands. You cancreate and use your own dictionary to avoid having it tell you that your ownname, those of fellow linguists, and linguistics terminology are a typos in every

    paper you write.

    weblint --- checks the syntax of html files

    latex2html --- translates LaTeX files into HTML

    wn word option --- lets you access the WordNet database and display, for example, synonyms, hypernyms, or hyponyms, depending on the option youselect

    Command editing in the tcsh

    These things are the same as in emacs:Backspace --- delete previous character CTRL-d --- delete next character CTRL-k --- delete rest of line

    CTRL-a --- go to start of lineCTRL-e --- go to end of lineCTRL-b --- go backwards without deletingCTRL-f --- go forward without deleting

    Other useful thingsTAB --- complete filename or command up to the point of uniquenessCTRL-u --- cancel whole lineCTRL-p --- show the last command typed, then the one before that, etc.

    (you can also use the cursor up key for this)CTRL-n --- go forwards in the history of commands

    (you can also use the cursor down key for this)CTRL-c --- cancel the processes after it has startedCTRL-z --- suspend a running process (e.g. in order to do something else in between)

    you can then put the process in the background with bg CTRL-l --- redraws the screen| (piping ) --- Lets you execute any number of commands in a sequence.

    The second command will be executed once the first is done, and so forth, usingthe previous command's output as input. You can achieve the same effect by

  • 8/7/2019 Master_Linux_Monthly Assignemnts,Question Answers,Commands,64 Interview Q-A,

    13/42

    putting the output in a file and giving the filename as an argument to the secondcommand, but that would be much more complicated, and you'd have toremember to remove all the junkfiles afterwards. Some examples that show theusefulness of this:ls | more --- will show you one screenful at a time, which is useful with any

    command that will produce a lot of output, e.g. also ps -aux man ls | grep time --- checks whether the man page for ls has something tosay about listing files by time - very useful when you have a suspicion somecommand may be capable of doing what you want, but you aren't sure.ls -lR | grep dvi --- will show you all your dvi files - useful to solve disk space problems, since they're large and usually can be deleted.

    UNIX Command SummaryOverview

    This document describes basic commands on the shared UNIX workstations(Cardinal, Tree, Junior, Power, Wisdom, and remote workstations).

    Introductory Information about UNIX

    UNIX is a computer operating system, like DOS for PCs. An operating systemconsists of commands that let you manage information in the form of files or runprograms that perform tasks such as word processing, email, or data analysis.

    A UNIX file is a collection of information stored on disk, be it the text of adocument, data for statistical analysis, or the executable code for a program. A

    file is referenced by a name. A filename in UNIX can consist of any combinationof characters on the keyboard except for the space bar and all of the following:* ? ! | \ / ' " { } < > ; , ^ ( ) $ ~. These characters cannot be used in filenamesbecause they have special meaning to the shell. For example, the first twosymbols are used as "wildcard" characters when you're issuing commands: the *will match any string of characters in a filename, whereas the ? matches anysingle character.

    How to Issue Commands in UNIX

    The UNIX environment is interactive. When you type a command at the keyboardand then press the Enter or Return key, UNIX immediately begins to act on thecommand. More accurately, UNIX interprets the command using a specialprogram of its own called the shell. On the Leland Systems, the default shell istcsh. All shells produce a shell prompt to let you know that UNIX is awaiting your next command. The Leland System's shell prompt has the form host:~> , wherehost is the name of the UNIX system you are using (e.g. Elaine38:~> or Cardinal:~>). Whenever you see this prompt, you know that the UNIX shell isready for your next command.

  • 8/7/2019 Master_Linux_Monthly Assignemnts,Question Answers,Commands,64 Interview Q-A,

    14/42

    UNIX is case-sensitive. That is, UNIX distinguishes between upper and lower case letters in the names of files and programs. Thus, while ls is a valid UNIXcommand, LS is not. Login names and passwords are also case-sensitive.

    Some programs, such as Pico, have their own commands that you type withinthe program rather than at the UNIX shell prompt. However, the shell promptreappears whenever you exit such programs.

    Basic File Commands

    These are typed at the shell prompt host:~>.ls List the files in the current directoryls-a List all the files in the current directory, even the hidden

    onesls-F As above, but indicate sub-directories by appending a

    backslash (/) to their namecp FILE1 FILE2 Make a copy of FILE1 and call the copy FILE2mv FILE1 FILE2 Rename a file from old name FILE1 to new name FILE2mv FILE1 DIR/ Move a file from it's present directory into another directory

    (DIR)rm FILE Remove or delete FILEmore FILE Display the contents of FILE, pausing after each screenful--More--(18%)

    Whenever you see something like the above at the bottom of your screen, you can:press the space bar To see the next screenful of texttype b To go back one screenfultype q To quit the listing of text and return to the UNIX shell

    promptCorrecting Typing Mistakes: (at the Shell Prompt)Delete or Backspace Erase the last character you typedCtrl-u Delete the last line you typed

    Basic Directory Commands

    These are typed at the shell prompt host:~>.In UNIX, your files are organized in directories and subdirectories. When you firstlog in to your account, you are placed in your home directory which you can refer to with the character ~.cd DIR Go to the directory called DIRcd.. Go to the directory above the current directorymkdir DIR Create a new directory called DIRrmdir DIR Remove the directory DIR (must be empty first; if not, use

    rm -r )cd or cd ~ Go to your home directorymv DIR1 DIR2 Move or rename a directory from old name DIR1 to new

  • 8/7/2019 Master_Linux_Monthly Assignemnts,Question Answers,Commands,64 Interview Q-A,

    15/42

    name DIR2Use the / character to separate directory and file names when specifying a path.

    Printing

    You can print UNIX files and mail messages to your own printer and a networkprinter. The latter is easier, but requires that you walk to the network printer topick up your output.

    Printing On a Sweet Hall Printer

    To print a UNIX text or PostScript file, type the following command at the systemprompt: lpr -P NAME FILE ->

    where NAME is the name of the printer, e.g., sweet0.

    Printing to Your Own Printer

    To print a UNIX file on your own printer, you must first "download" it to your desktop computer. Exactly how you do this depends on which communicationpackage you use, as well as which type of computer you have. Theseinstructions apply only to PCs (and compatibles) that are running under DOS, arelinked to SUNet via Ethernet, and have the ftp protocol installed.

    At the DOS prompt (assumed here to be C:\>), enter:C:\> ftp HOSTNAME Connects your PC to HOSTNAME(username) userid Your account on the hostPassword: xxxxxx Replace xxxxxx with your passwordftp> cd DIRECTORY Change to DIRECTORYftp> get FILENAME Copies FILENAME to PCftp> quit Exit ftp and go to DOSC:\> copy FILENAMElpt1

    Prints FILENAME on lpt1

    Useful Commandsexit Ends your work on the UNIX systemCtrl-l or clear Clears the screenCtrl-c Stops the program currently runningCtrl-p Retrieves the last shell command you typedCtrl-z Pauses the currently running program

    man COMMAND Looks up the UNIX command COMMAND in the onlinemanual pages

    find . -name FILE -print Finds all paths containing FILE in the current directory or below it

    fgrep -i PATTERN FILE Searches for and displays all lines in file that containPATTERN (case insensitive)

    finger USER@ADDRESS

    Displays login/email status of a user at another host

  • 8/7/2019 Master_Linux_Monthly Assignemnts,Question Answers,Commands,64 Interview Q-A,

    16/42

    jobs Lists background jobs started during your current loginsession

    ps Lists all jobs (background and foreground) started duringyour login session

    du Displays disk usage in kbytes by directory, starting in the

    current directory and working downdu -s Displays total disk usagefs listquota Displays your current disk space usage and quota in

    kbytestelnet ADDRESS Logs on to another machine on the Internet on which you

    have an accountftp ADDRESS Begins a file transfer session with another computer on the

    Internetwc FILE Counts the lines, words, and characters in FILEspell FILE Reports possible misspelled words in FILEwebster WORD | more Looks up a word via the online version of Webster's

    dictionaryUNIX Shell Short Cuts

    The UNIX shell keeps a record of the commands you type during your loginsession. Here are a few commands that take advantage of this history facility. Allare typed at the shell prompt host:~>.history List all commands typed so far (default maximum

    number=20)!! Repeat the last command!n Repeat command n from the history list!PATTERN Repeat last command beginning with PATTERN^PATTERN1^PATTERN2 Repeat last command but replace PATTERN1 (usually a

    typo) with PATTERN2 (the correction)This document was based on originals prepared by Lynn Gale and Patrick Goebel, Center for Advanced Study in the Behavioral Sciences.

    Last modified Friday, 23-Jun-2006 10:19:58 AM

    IT Services | Computing and Communication | Computing Self-Help | HelpSU Stanford University. All Rights Reserved. Stanford, CA 94305. (650) 723-2300.Terms of Use | Copyright Complaints

  • 8/7/2019 Master_Linux_Monthly Assignemnts,Question Answers,Commands,64 Interview Q-A,

    17/42

    LINUX / UNIX COMMANDS

    * See our our complete overview page for a brief description on each of thebelow commands.

    Aa2p | alias | ac | ar | arch | as | at | awk

    Bbasename | bash | bc | bdiff | bfs | bg | biff | break | bs | bye

    Ccal | calendar | cancel | cat | cc | cd | chdir | checkeq | checknr | chfn | chgrp| chkey | chmod | chown | chsh | cksum | clear | cls | cmp | col | comm |

    compress | continue | copy | cp | cpio | crontab | csh | csplit | ctags | cu | cut

    Ddate | dc | df | deroff | diff | dircmp | dpost | du

    Eecho | ed | edit | egrep | elm | emacs | enable | env | eqn | ex | exit |expand | expr

    F

    fc | fg | fgrep | file | find | finger | fmt | fold | for | foreach | ftp

    Ggetfacl | gprof | grep | groupadd | groupdel | groupmod | gunzip | gview | gvim| gzip

    Hhalt | hash | hashstat | head | help | history | hostid | hostname

    Iid | ifconfig | isalist

    Jjobs | join

    K keylogin | kill | ksh

    Lld | ldd | less | lex | ln | lo | locate | login | logname | logout | lp | lpadmin |lpc | lpq | lpr | lprm | lpstat | ls

  • 8/7/2019 Master_Linux_Monthly Assignemnts,Question Answers,Commands,64 Interview Q-A,

    18/42

    Mmach | mail | mailcompat | mailx | make | man | merge | mesg | mkdir | more| mount | mt | mv

    Nneqn | netstat | newalias | newform | newgrp | nice | niscat | nischmod |nischown | nischttl | nisdefaults | nisgrep | nismatch | nispasswd | nistbladm |nohup | nroff | nslookup

    Oon | onintr | optisa

    P

    pack | pagesize | passwd | paste | pax | pcat | perl | pg | pgrep | pico | ping |pkill | poweroff | pr | priocntl | printf | ps | pvs | pwd

    Q quit

    R rcp | reboot | red | rehash | remsh | repeat | rgview | rgvim | rlogin | rm |rmail | rmdir | rn | rpcinfo | rsh | rview | rvim

    Ss2p | sag | sar | script | sdiff | sed | sendmail | set | setenv | setfacl | settime| sh | shutdown | sleep | sort | spell | split | stop | stty | su | sudo | sysinfo

    Ttabs | tail | talk | tar | tbl | tcopy | tee | telnet | time | timex | touch | tput |tr | traceroute | tree | troff

    Uul | umask | unalias | unhash | uname | uncompress | uniq | unmount | unpack| untar | until | uptime | useradd | userdel | usermod

    Vvacation | vedit | vgrind | vi | view | vim | vipw | vmstat

    Wwait | wc | wget | whereis | while | which | who | whois | write

    XX | xargs | xfd | xlsfonts | xset | xterm | xrdb

    Yyacc | yppasswd

  • 8/7/2019 Master_Linux_Monthly Assignemnts,Question Answers,Commands,64 Interview Q-A,

    19/42

    Zzcat

  • 8/7/2019 Master_Linux_Monthly Assignemnts,Question Answers,Commands,64 Interview Q-A,

    20/42

    Good Linux-Unix Sample Questions1. How are devices represented in UNIX?

    Answer:

    All devices are represented by files called special files that are located in/dev directory. Thus,device files and other files are named and accessed in the same way. A 'regular file' is just anordinary data file in the disk. A 'block special file' represents a device with characteristics similar toa disk (data transfer in terms of blocks). A 'character special file' represents a device withcharacteristics similar to a keyboard (data transfer is by stream of bits in sequential order).

    2. What is 'inode'?

    Answer:

    All UNIX files have its description stored in a structure called 'inode'. The inode contains info aboutthe file-size, its location, time of last access, time of last modification, permission and so on.Directories are also represented as files and have an associated inode. In addition to descriptionsabout the file, the inode contains pointers to the data blocks of the file. If the file is large, inode hasindirect pointer to a block of pointers to additional data blocks (this further aggregates for larger files). A block is typically 8k.

    Inode consists of the following fields:

    o File owner identifier

    o File type

    o File access permissions

    o File access times

    o Number of links

    o File size

    o Location of the file data

    3. Brief about the directory representation in UNIX

    Answer:

    A Unix directory is a file containing a correspondence between filenames and inodes. A directory isa special file that the kernel maintains. Only kernel modifies directories, but processes can readdirectories. The contents of a directory are a list of filename and inode number pairs. When newdirectories are created, kernel makes two entries named '.' (refers to the directory itself) and '..'(refers to parent directory). System call for creating directory is mkdir (pathname, mode).

    4. What are the Unix system calls for I/O?

    Answer:

    o open(pathname,flag,mode) - open file

    o creat(pathname,mode) - create file

    o close(filedes) - close an open file

    o read(filedes,buffer,bytes) - read data from an open file

    o write(filedes,buffer,bytes) - write data to an open file

  • 8/7/2019 Master_Linux_Monthly Assignemnts,Question Answers,Commands,64 Interview Q-A,

    21/42

    o lseek(filedes,offset,from) - position an open file

    o dup(filedes) - duplicate an existing file descriptor

    o dup2(oldfd,newfd) - duplicate to a desired file descriptor

    o fcntl(filedes,cmd,arg) - change properties of an open file

    o ioctl(filedes,request,arg) - change the behaviour of an open file

    The difference between fcntl anf ioctl is that the former is intended for any open file, while the latter is for device-specific operations.

    5. How do you change File Access Permissions?

    Answer:

    Every file has following attributes:

    o owner's user ID ( 16 bit integer )

    o owner's group ID ( 16 bit integer )

    o File access mode word'r w x -r w x- r w x'(user permission-group permission-others permission)r-read, w-write, x-execute

    To change the access mode, we use chmod(filename,mode).

    Example 1:

    To change mode of myfile to 'rw-rw-r--' (ie. read, write permission for user - read,write permissionfor group - only read permission for others) we give the args as:chmod(myfile,0664) .Each operation is represented by discrete values'r' is 4'w' is 2

    'x' is 1Therefore, for 'rw' the value is 6(4+2).

    Example 2:To change mode of myfile to 'rwxr--r--' we give the args as:chmod(myfile,0744).

    6. What are links and symbolic links in UNIX file system?

    Answer:

    A link is a second name (not a file) for a file. Links can be used to assign more than one name to afile, but cannot be used to assign a directory more than one name or link filenames on differentcomputers.

    Symbolic link 'is' a file that only contains the name of another file.Operation on the symbolic link is

    directed to the file pointed by the it.Both the limitations of links are eliminated in symbolic links.Commands for linking files are:Link ln filename1 filename2Symbolic link ln -s filename1 filename2

    7. What is a FIFO?

    Answer:

    FIFO are otherwise called as 'named pipes'. FIFO (first-in-first-out) is a special file which is said to

  • 8/7/2019 Master_Linux_Monthly Assignemnts,Question Answers,Commands,64 Interview Q-A,

    22/42

    be data transient. Once data is read from named pipe, it cannot be read again. Also, data can beread only in the order written. It is used in interprocess communication where a process writes toone end of the pipe (producer) and the other reads from the other end (consumer).

    8. How do you create special files like named pipes and device files?

    Answer:

    The system call mknod creates special files in the following sequence.1. kernel assigns new inode,

    2. sets the file type to indicate that the file is a pipe, directory or special file,

    3. If it is a device file, it makes the other entries like major, minor device numbers.

    For example:If the device is a disk, major device number refers to the disk controller and minor device number isthe disk.

    9. Discuss the mount and unmount system calls

    Answer:

    The privileged mount system call is used to attach a file system to a directory of another filesystem; the unmount system call detaches a file system. When you mount another file system on toyour directory, you are essentially splicing one directory tree onto a branch in another directorytree. The first argument to mount call is the mount point, that is , a directory in the current filenaming system. The second argument is the file system to mount to that point. When you insert acdrom to your unix system's drive, the file system in the cdrom automatically mounts to /dev/cdromin your system.

    10. How does the inode map to data block of a file?

    Answer:

    Inode has 13 block addresses. The first 10 are direct block addresses of the first 10 data blocks inthe file. The 11th address points to a one-level index block. The 12th address points to a two-level(double in-direction) index block. The 13th address points to a three-level(triple in-direction)indexblock. This provides a very large maximum file size with efficient access to large files, but also

    small files are accessed directly in one disk read.11. What is a shell?

    Answer:

    A shell is an interactive user interface to an operating system services that allows an user to enter commands as character strings or through a graphical user interface. The shell converts them tosystem calls to the OS or forks off a process to execute the command. System call results andother information from the OS are presented to the user through an interactive interface. Commonlyused shells are sh,csh,ks etc.

    12. Brief about the initial process sequence while the system boots up.

    Answer:

    While booting, special process called the 'swapper' or 'scheduler' is created with Process-ID 0. The

    swapper manages memory allocation for processes and influences CPU allocation.The swapper inturn creates 3 children:the process dispatcher,vhand anddbflushwith IDs 1,2 and 3 respectively.

    This is done by executing the file /etc/init. Process dispatcher gives birth to the shell. Unix keepstrack of all the processes in an internal data structure called the Process Table (listing command isps -el).

  • 8/7/2019 Master_Linux_Monthly Assignemnts,Question Answers,Commands,64 Interview Q-A,

    23/42

    13. What are various IDs associated with a process?

    Answer:

    Unix identifies each process with a unique integer called ProcessID. The process that executes therequest for creation of a process is called the 'parent process' whose PID is 'Parent Process ID'.Every process is associated with a particular user called the 'owner' who has privileges over theprocess. The identification for the user is 'UserID'. Owner is the user who executes the process.Process also has 'Effective User ID' which determines the access privileges for accessingresources like files.getpid() -process idgetppid() -parent process idgetuid() -user idgeteuid() -effective user id

    14. Explain fork() system call.

    Answer:

    The 'fork()' used to create a new process from an existing process. The new process is called thechild process, and the existing process is called the parent. We can tell which is which by checkingthe return value from 'fork()'. The parent gets the child's pid returned to him, but the child gets 0returned to him.

    15. Predict the output of the following program code16. main()17. {18. fork();19. printf("Hello World!");

    }

    Answer:

    Hello World!Hello World!

    Explanation:

    The fork creates a child that is a duplicate of the parent process. The child begins from the fork().Allthe statements after the call to fork() will be executed twice.(once by the parent process and other by child). The statement before fork() is executed only by the parent process.

    20. Predict the output of the following program code

    21. main()22. {23. fork(); fork(); fork();24. printf("Hello World!");

    }

    Answer:

    "Hello World" will be printed 8 times.

    Explanation:

    2^n times where n is the number of calls to fork()

    17. List the system calls used for process management:

    Answer:

    System calls Descriptionfork() To create a new processexec() To execute a new program in a processwait() To wait until a created process completes its executionexit() To exit from a process executiongetpid() To get a process identifier of the current processgetppid() To get parent process identifier

  • 8/7/2019 Master_Linux_Monthly Assignemnts,Question Answers,Commands,64 Interview Q-A,

    24/42

    nice() To bias the existing priority of a processbrk() To increase/decrease the data segment size of a process

    18. How can you get/set an environment variable from a program?

    Answer:

    Getting the value of an environment variable is done by using 'getenv()'.

    Setting the value of an environment variable is done by using 'putenv()'.19. How can a parent and child process communicate?

    Answer:

    A parent and child can communicate through any of the normal inter-process communicationschemes (pipes, sockets, message queues, shared memory), but also have some special ways tocommunicate that take advantage of their relationship as a parent and child. One of the mostobvious is that the parent can get the exit status of the child.

    20. What is a zombie?

    Answer:

    When a program forks and the child finishes before the parent, the kernel still keeps some of itsinformation about the child in case the parent might need it - for example, the parent may need to

    check the child's exit status. To be able to get this information, the parent calls 'wait()'; In theinterval between the child terminating and the parent calling 'wait()', the child is said to be a'zombie' (If you do 'ps', the child will have a 'Z' in its status field to indicate this.)

    21. What are the process states in Unix?

    Answer:

    As a process executes it changes state according to its circumstances. Unix processes have thefollowing states:Running : The process is either running or it is ready to run .Waiting : The process is waiting for an event or for a resource.Stopped : The process has been stopped, usually by receiving a signal.Zombie : The process is dead but have not been removed from the process table.

    22. What Happens when you execute a program?

    Answer:

    When you execute a program on your UNIX system, the system creates a special environment for that program. This environment contains everything needed for the system to run the program as if no other program were running on the system. Each process has process context, which iseverything that is unique about the state of the program you are currently running. Every time youexecute a program the UNIX system does a fork, which performs a series of operations to create aprocess context and then execute your program in that context. The steps include the following:Allocate a slot in the process table, a list of currently running programs kept by UNIX. Assign aunique process identifier (PID) to the process. iCopy the context of the parent, the process thatrequested the spawning of the new process. Return the new PID to the parent process. Thisenables the parent process to examine or control the process directly.After the fork is complete, UNIX runs your program.

    23. What Happens when you execute a command?

    Answer:

    When you enter 'ls' command to look at the contents of your current working directory, UNIX does aseries of things to create an environment for ls and the run it: The shell has UNIX perform a fork.This creates a new process that the shell will use to run the ls program. The shell has UNIXperform an exec of the ls program. This replaces the shell program and data with the program anddata for ls and then starts running that new program. The ls program is loaded into the new processcontext, replacing the text and data of the shell. The ls program performs its task, listing thecontents of the current directory.

    24. What is a Daemon?

  • 8/7/2019 Master_Linux_Monthly Assignemnts,Question Answers,Commands,64 Interview Q-A,

    25/42

    Answer:

    A daemon is a process that detaches itself from the terminal and runs, disconnected, in thebackground, waiting for requests and responding to them. It can also be defined as the backgroundprocess that does not belong to a terminal session. Many system functions are commonlyperformed by daemons, including the sendmail daemon, which handles mail, and the NNTPdaemon, which handles USENET news. Many other daemons may exist. Some of the mostcommon daemons are: init: Takes over the basic running of the system when the kernel hasfinished the boot process. inetd: Responsible for starting network services that do not have their own stand-alone daemons. For example, inetd usually takes care of incoming rlogin, telnet, and ftpconnections. cron: Responsible for running repetitive tasks on a regular schedule.

    25. What is 'ps' command for?

    Answer:

    The ps command prints the process status for some or all of the running processes. Theinformation given are the process identification number (PID),the amount of time that the processhas taken to execute so far etc.

    26. How would you kill a process?

    Answer:

    The kill command takes the PID as one argument; this identifies which process to terminate. ThePID of a process can be got using 'ps' command.

    27. What is an advantage of executing a process in background?

    Answer:

    The most common reason to put a process in the background is to allow you to do something elseinteractively without waiting for the process to complete. At the end of the command you add thespecial background symbol, &. This symbol tells your shell to execute the given command in thebackground.

    Example:cp *.* ../backup& (cp is for copy)

    28. How do you execute one program from within another?

    Answer: The system calls used for low-level process creation are execlp() and execvp(). The execlp calloverlays the existing program with the new one , runs that and exits. The original program getsback control only when an error occurs.execlp(path,file_name,arguments..); //last argument must be NULLA variant of execlp called execvp is used when the number of arguments is not known in advance.execvp(path,argument_array); //argument array should be terminated by NULL

    29. What is IPC? What are the various schemes available?

    Answer:

    The term IPC (Inter-Process Communication) describes various ways by which different processrunning on some operating system communicate between each other. Various schemes availableare as follows:

    Pipes:One-way communication scheme through which different process can communicate. The problemis that the two processes should have a common ancestor (parent-child relationship). However thisproblem was fixed with the introduction of named-pipes (FIFO).

    Message Queues :Message queues can be used between related and unrelated processes running on a machine.

    Shared Memory:This is the fastest of all IPC schemes. The memory to be shared is mapped into the address spaceof the processes (that are sharing). The speed achieved is attributed to the fact that there is no

  • 8/7/2019 Master_Linux_Monthly Assignemnts,Question Answers,Commands,64 Interview Q-A,

    26/42

    kernel involvement. But this scheme needs synchronization.

    Various forms of synchronisation are mutexes, condition-variables, read-write locks, record-locks,and semaphores.

    30. What is the difference between Swapping and Paging?

    Answer: Swapping:Whole process is moved from the swap device to the main memory for execution. Process sizemust be less than or equal to the available main memory. It is easier to implementation andoverhead to the system. Swapping systems does not handle the memory more flexibly ascompared to the paging systems.

    Paging:Only the required memory pages are moved to main memory from the swap device for execution.Process size does not matter. Gives the concept of the virtual memory. It provides greater flexibilityin mapping the virtual address space into the physical memory of the machine. Allows morenumber of processes to fit in the main memory simultaneously. Allows the greater process sizethan the available physical memory. Demand paging systems handle the memory more flexibly.

    31. What is major difference between the Historic Unix and the new BSD release of Unix System V in

    terms of Memory Management?Answer:

    Historic Unix uses Swapping entire process is transferred to the main memory from the swapdevice, whereas the Unix System V uses Demand Paging only the part of the process is movedto the main memory. Historic Unix uses one Swap Device and Unix System V allow multiple SwapDevices.

    32. What is the main goal of the Memory Management?

    Answer:

    It decides which process should reside in the main memory, Manages the parts of the virtualaddress space of a process which is non-core resident, Monitors the available main memory andperiodically write the processes into the swap device to provide more processes fit in the mainmemory simultaneously.

    33. What is a Map?

    Answer:

    A Map is an Array, which contains the addresses of the free space in the swap device that areallocatable resources, and the number of the resource units available there. This allows First-Fitallocation of contiguous blocks of a resource. Initially the Map contains one entry address(block offset from the starting of the swap area) and the total number of resources.

    Kernel treats each unit of Map as a group of disk blocks. On the allocation and freeing of theresources Kernel updates the Map for accurate information.

    34. What scheme does the Kernel in Unix System V follow while choosing a swap device among themultiple swap devices?

    Answer: Kernel follows Round Robin scheme choosing a swap device among the multiple swap devices inUnix System V.

    35. What is a Region?

    Answer:

    A Region is a continuous area of a process's address space (such as text, data and stack). Thekernel in a 'Region Table' that is local to the process maintains region. Regions are sharableamong the process.

  • 8/7/2019 Master_Linux_Monthly Assignemnts,Question Answers,Commands,64 Interview Q-A,

    27/42

    36. What are the events done by the Kernel after a process is being swapped out from the mainmemory?

    Answer:

    When Kernel swaps the process out of the primary memory, it performs the following:

    o Kernel decrements the Reference Count of each region of the process. If the reference

    count becomes zero, swaps the region out of the main memory,o Kernel allocates the space for the swapping process in the swap device,

    o Kernel locks the other swapping process while the current swapping operation is going on,

    o The Kernel saves the swap address of the region in the region table.

    37. Is the Process before and after the swap are the same? Give reason.

    Answer:

    Process before swapping is residing in the primary memory in its original form. The regions (text,data and stack) may not be occupied fully by the process, there may be few empty slots in any of the regions and while swapping Kernel do not bother about the empty slots while swapping the

    process out.After swapping the process resides in the swap (secondary memory) device. The regions swappedout will be present but only the occupied region slots but not the empty slots that were presentbefore assigning.

    While swapping the process once again into the main memory, the Kernel referring to the ProcessMemory Map, it assigns the main memory accordingly taking care of the empty slots in the regions.

    38. What do you mean by u-area (user area) or u-block?

    Answer:

    This contains the private data that is manipulated only by the Kernel. This is local to the Process,i.e. each process is allocated a u-area.

    39. What are the entities that are swapped out of the main memory while swapping the process out of the main memory?

    Answer:

    All memory space occupied by the process, process's u-area, and Kernel stack are swapped out,theoretically.

    Practically, if the process's u-area contains the Address Translation Tables for the process thenKernel implementations do not swap the u-area.

    40. What is Fork swap?

    Answer:

    fork() is a system call to create a child process. When the parent process calls fork() system call,the child process is created and if there is short of memory then the child process is sent to the

    read-to-run state in the swap device, and return to the user state without swapping the parentprocess. When the memory will be available the child process will be swapped into the mainmemory.

    41. What is Expansion swap?

    Answer:

    At the time when any process requires more memory than it is currently allocated, the Kernelperforms Expansion swap. To do this Kernel reserves enough space in the swap device. Then theaddress translation mapping is adjusted for the new virtual address space but the physical memoryis not allocated. At last Kernel swaps the process into the assigned space in the swap device. Later

  • 8/7/2019 Master_Linux_Monthly Assignemnts,Question Answers,Commands,64 Interview Q-A,

    28/42

    when the Kernel swaps the process into the main memory this assigns memory according to thenew address translation mapping.

    42. How the Swapper works?

    Answer:

    The swapper is the only process that swaps the processes. The Swapper operates only in the

    Kernel mode and it does not uses System calls instead it uses internal Kernel functions for swapping. It is the archetype of all kernel process.

    43. What are the processes that are not bothered by the swapper? Give Reason.

    Answer:

    Zombie process: They do not take any up physical memory.Processes locked in memories that are updating the region of the process. Kernel swaps only thesleeping processes rather than the 'ready-to-run' processes, as they have the higher probability of being scheduled than the Sleeping processes.

    44. What are the requirements for a swapper to work?

    Answer:

    The swapper works on the highest scheduling priority. Firstly it will look for any sleeping process, if

    not found then it will look for the ready-to-run process for swapping. But the major requirement for the swapper to work the ready-to-run process must be core-resident for at least 2 seconds beforeswapping out. And for swapping in the process must have been resided in the swap device for atleast 2 seconds. If the requirement is not satisfied then the swapper will go into the wait state onthat event and it is awaken once in a second by the Kernel.

    45. What are the criteria for choosing a process for swapping into memory from the swap device?

    Answer:

    The resident time of the processes in the swap device, the priority of the processes and the amountof time the processes had been swapped out.

    46. What are the criteria for choosing a process for swapping out of the memory to the swap device?

    Answer:

    The process's memory resident time,Priority of the process andThe nice value.

    47. What do you mean by nice value?

    Answer:

    Nice value is the value that controls {increments or decrements} the priority of the process. Thisvalue that is returned by the nice () system call. The equation for using nice value is:Priority = ("recent CPU usage"/constant) + (base- priority) + (nice value)Only the administrator can supply the nice value. The nice () system call works for the runningprocess only. Nice value of one process cannot affect the nice value of the other process.

    48. What are conditions on which deadlock can occur while swapping the processes?

    Answer:

    All processes in the main memory are asleep.All 'ready-to-run' processes are swapped out.There is no space in the swap device for the new incoming process that are swapped out of themain memory.There is no space in the main memory for the new incoming process.

    49. What are conditions for a machine to support Demand Paging?

    Answer:

    Memory architecture must based on Pages,

  • 8/7/2019 Master_Linux_Monthly Assignemnts,Question Answers,Commands,64 Interview Q-A,

    29/42

    The machine must support the 'restartable' instructions.

    50. What is 'the principle of locality'?

    Answer:

    It's the nature of the processes that they refer only to the small subset of the total data space of theprocess. i.e. the process frequently calls the same subroutines or executes the loop instructions.

    51. What is the working set of a process?

    Answer:

    The set of pages that are referred by the process in the last 'n', references, where 'n' is called thewindow of the working set of the process.

    52. What is the window of the working set of a process?

    Answer:

    The window of the working set of a process is the total number in which the process had referredthe set of pages in the working set of the process.

    53. What is called a page fault?

    Answer:

    Page fault is referred to the situation when the process addresses a page in the working set of theprocess but the process fails to locate the page in the working set. And on a page fault the kernelupdates the working set by reading the page from the secondary device.

    54. What are data structures that are used for Demand Paging?

    Answer:

    Kernel contains 4 data structures for Demand paging. They are,

    o Page table entries,

    o Disk block descriptors,

    o Page frame data table (pfdata),

    o Swap-use table.

    55. What are the bits that support the demand paging?

    Answer:

    Valid, Reference, Modify, Copy on write, Age. These bits are the part of the page table entry, whichincludes physical address of the page and protection bits.

    Pageaddress Age

    Copy onwrite Modify Reference Valid Protection

    56. How the Kernel handles the fork() system call in traditional Unix and in the System V Unix, whileswapping?

    Answer:

    Kernel in traditional Unix, makes the duplicate copy of the parent's address space and attaches it tothe child's process, while swapping. Kernel in System V Unix, manipulates the region tables, pagetable, and pfdata table entries, by incrementing the reference count of the region table of sharedregions.

    57. Difference between the fork() and vfork() system call?

    Answer:

    During the fork() system call the Kernel makes a copy of the parent process's address space andattaches it to the child process.

  • 8/7/2019 Master_Linux_Monthly Assignemnts,Question Answers,Commands,64 Interview Q-A,

    30/42

    But the vfork() system call do not makes any copy of the parent's address space, so it is faster thanthe fork() system call. The child process as a result of the vfork() system call executes exec()system call. The child process from vfork() system call executes in the parent's address space (thiscan overwrite the parent's data and stack ) which suspends the parent process until the childprocess exits.

    58. What is BSS(Block Started by Symbol)?

    Answer: A data representation at the machine level, that has initial values when a program starts and tellsabout how much space the kernel allocates for the un-initialized data. Kernel initializes it to zero atrun-time.

    59. What is Page-Stealer process?

    Answer:

    This is the Kernel process that makes rooms for the incoming pages, by swapping the memorypages that are not the part of the working set of a process. Page-Stealer is created by the Kernel atthe system initialization and invokes it throughout the lifetime of the system. Kernel locks a regionwhen a process faults on a page in the region, so that page stealer cannot steal the page, which isbeing faulted in.

    60. Name two paging states for a page in memory?

    Answer:

    The two paging states are:The page is aging and is not yet eligible for swapping,The page is eligible for swapping but not yet eligible for reassignment to other virtual addressspace.

    61. What are the phases of swapping a page from the memory?

    Answer:

    Page stealer finds the page eligible for swapping and places the page number in the list of pages tobe swapped.

    Kernel copies the page to a swap device when necessary and clears the valid bit in the page tableentry, decrements the pfdata reference count, and places the pfdata table entry at the end of thefree list if its reference count is 0.

    62. What is page fault? Its types?

    Answer:

    Page fault refers to the situation of not having a page in the main memory when any processreferences it.

    There are two types of page fault :Validity fault,Protection fault.

    63. In what way the Fault Handlers and the Interrupt handlers are different?

    Answer:

    Fault handlers are also an interrupt handler with an exception that the interrupt handlers cannotsleep. Fault handlers sleep in the context of the process that caused the memory fault. The faultrefers to the running process and no arbitrary processes are put to sleep.

    64. What is validity fault?

    Answer:

    If a process referring a page in the main memory whose valid bit is not set, it results in validity fault.

    The valid bit is not set for those pages: that are outside the virtual address space of a process, that

  • 8/7/2019 Master_Linux_Monthly Assignemnts,Question Answers,Commands,64 Interview Q-A,

    31/42

    are the part of the virtual address space of the process but no physical address is assigned to it.

    65. What does the swapping system do if it identifies the illegal page for swapping?

    Answer:

    If the disk block descriptor does not contain any record of the faulted page, then this causes theattempted memory reference is invalid and the kernel sends a "Segmentation violation" signal tothe offending process. This happens when the swapping system identifies any invalid memoryreference.

    66. What are states that the page can be in, after causing a page fault?

    Answer:

    On a swap device and not in memory,On the free page list in the main memory,In an executable file,Marked "demand zero",Marked "demand fill".

    67. In what way the validity fault handler concludes?

    Answer:

    It sets the valid bit of the page by clearing the modify bit.It recalculates the process priority.

    68. At what mode the fault handler executes?

    Answer:

    At the Kernel Mode.

    69. What do you mean by the protection fault?

    Answer:

    Protection fault refers to the process accessing the pages, which do not have the accesspermission. A process also incur the protection fault when it attempts to write a page whose copyon write bit was set during the fork() system call.

    70. How the Kernel handles the copy on write bit of a page, when the bit is set?

    Answer:

    In situations like, where the copy on write bit of a page is set and that page is shared by more thanone process, the Kernel allocates new page and copies the content to the new page and the other processes retain their references to the old page. After copying the Kernel updates the page tableentry with the new page number. Then Kernel decrements the reference count of the old pfdatatable entry.

    In cases like, where the copy on write bit is set and no processes are sharing the page, the Kernelallows the physical page to be reused by the processes. By doing so, it clears the copy on write bitand disassociates the page from its disk copy (if one exists), because other process may share thedisk copy. Then it removes the pfdata table entry from the page-queue as the new copy of thevirtual page is not on the swap device. It decrements the swap-use count for the page and if countdrops to 0, frees the swap space.

    71. For which kind of fault the page is checked first?

    Answer:

  • 8/7/2019 Master_Linux_Monthly Assignemnts,Question Answers,Commands,64 Interview Q-A,

    32/42

    The page is first checked for the validity fault, as soon as it is found that the page is invalid (valid bitis clear), the validity fault handler returns immediately, and the process incur the validity page fault.Kernel handles the validity fault and the process will incur the protection fault if any one is present.

    72. In what way the protection fault handler concludes?

    Answer:

    After finishing the execution of the fault handler, it sets the modify and protection bits and clears thecopy on write bit. It recalculates the process-priority and checks for signals.

    73. How the Kernel handles both the page stealer and the fault handler?

    Answer:

    The page stealer and the fault handler thrash because of the shortage of the memory. If the sum of the working sets of all processes is greater that the physical memory then the fault handler willusually sleep because it cannot allocate pages for a process. This results in the reduction of thesystem throughput because Kernel spends too much time in overhead, rearranging the memory inthe frantic pace.

  • 8/7/2019 Master_Linux_Monthly Assignemnts,Question Answers,Commands,64 Interview Q-A,

    33/42

    How to AnswerThe 64 Toughest

    Interview

    Questions

    From:www.apfreshers.com

  • 8/7/2019 Master_Linux_Monthly Assignemnts,Question Answers,Commands,64 Interview Q-A,

    34/42

    THIS BOOK IS DESIGNED TO PROVIDE ACCURATE INFORMATION ON THE SUBJECTSCOVERED. HOWEVER, IT IS DONE WITH THE UNDERSTANDING THAT THE PUBLISHER IS

    NOT ENGAGED IN RENDERING LEGAL, ACCOUNTING OR PROFESSIONAL SERVICES. IFLEGAL ADVICE OR OTHER PROFESSIONAL ASSSTANCE IS REQUIRED, THE SERVICESOF A COMPETENT, PROFESSIONAL PERSON SHOUID BE SOUGHT. ANY NAMES USED INTHE TEXT ARE FICTITIOUS AND FOR ILLUSTRATIVE PURPOSES ONLY. ANYRESEMBLANCE TO ACTUAL PERSONS OR COMPANIES IS PURELY COINCIDENTAL ANDUNINTENTIONAL.

  • 8/7/2019 Master_Linux_Monthly Assignemnts,Question Answers,Commands,64 Interview Q-A,

    35/42

    From:www.apfreshers.com

    Dedication:

    This report is dedicated to courage and knowledge,the two qualities most needed

    to succeed in any human challenge,especially a job search.

    Table of Contents

    General Guidelines in Answering Interview Questions...................................................................3Q1 Tell me about yourself....................................................................................................5Q2 What are your greatest strengths?..................................................................................6Q3 What are your greatest weaknesses?.............................................................................6Q4 Tell me about something you did or failed to do that you now feel a little ashamed

    of. 7Q5 Why are you leaving (or did you leave) this position?.....................................................8Q6 The Silent Treatment....................................................................................................9Q7 Why should I hire you?...................................................................................................9Q8 Arent you overqualified for this position?.....................................................................10Q9 Where do you see yourself five years from now?.........................................................11Q10 Describe your ideal company, location and job.............................................................12Q11 Why do you want to work at our company?..................................................................12

    Q12 What are your career options right now?......................................................................12Q13 Why have you been out of work so long?.....................................................................13Q14 Tell me honestly about the strong points and weak points of your boss (company,

    management team, etc.)...........................................................................................13Q15 What good books have you read lately?.......................................................................14Q16 Tell me about a situation when your work was criticized..............................................14Q17 What are your outside interest?....................................................................................15Q18 The Fatal Flaw question.............................................................................................15Q19 How do you feel about reporting to a younger person (minority, woman, etc)?............16Q20 On confidential matters.............................................................................................16Q21 Would you lie for the company?....................................................................................17Q22 Looking back, what would you do differently in your life?.............................................17Q23 Could you have done better in your last job?................................................................18Q24 Can you work under pressure?.....................................................................................18Q25 What makes you angry?...............................................................................................18Q26 Why arent you earning more money at this stage of your career?...............................19Q27 Who has inspired you in your life and why?..................................................................19Q28 What was the toughest decision you ever had to make?..............................................20Q29 Tell me about the most boring job youve ever had......................................................20Q30 Have you been absent from work more than a few days in any previous position?......20Q31 What changes would you make if you came on board?................................................21Q32 Im concerned that you dont have as much experience as wed like in....................21Q33 How do you feel about working nights and weekends?................................................22

  • 8/7/2019 Master_Linux_Monthly Assignemnts,Question Answers,Commands,64 Interview Q-A,

    36/42

    Q34 Are you willing to relocate or travel?.............................................................................23Q35 Do you have the stomach to fire people? Have you had experience firing many

    people?.........................................................................................................................23Q36 Why have you had so many jobs?................................................................................24Q37 What do you see as the proper role/mission of a good (job title youre seeking); a

    good manager; an executive in serving the community; a leading company in our industry; etc..................................................................................................................25

    Q38 What would you say to your boss if hes crazy about an idea, but you think it stinks?..25Q39 How could you have improved your career progress?..................................................26Q40 What would you do if a fellow executive on your own corporate level wasnt pulling

    his/her weightand this was hurting your department?............................................. ..26Q41 Youve been with your firm a long time. Wont it be hard switching to a new company?

    27Q42 May I contact your present employer for a reference?..................................................27Q43 Give me an example of your creativity (analytical skillmanaging ability, etc.)............28Q44 Where could you use some improvement?...................................................................28Q45 What do you worry about?............................................................................................28Q46 How many hours a week do you normally work?..........................................................28Q47 Whats the most difficult part of being a (job title)?.......................................................29Q48 The Hypothetical Problem..........................................................................................29Q49 What was the toughest challenge youve ever faced?..................................................29Q50 Have you consider starting your own business?...........................................................30Q51 What are your goals?....................................................................................................31Q52 What do you for when you hire people?.......................................................................31Q53 Sell me this stapler(this pencilthis clockor some other object on interviewers

    desk).............................................................................................................................31Q54 The Salary Question How much money do you want?............................................33Q55 The Illegal Question......................................................................................................33Q56 The Secret Illegal Question........................................................................................34Q57 What was the toughest part of your last job?................................................................35Q58 How do you define successand how do you measure up to your own definition?.....35Q59 The Opinion Question What do you think about AbortionThe PresidentThe

    Death Penalty(or any other controversial subject)?...................................................36

    Q60 If you won $10 million lottery, would you still work?......................................................36Q61 Looking back on your last position, have you done your best work?............................37Q62 Why should I hire you from the outside when I could promote someone from within?..37Q63 Tell me something negative youve heard about our company.................................38Q64 On a scale of one to ten, rate me as an interviewer......................................................38

  • 8/7/2019 Master_Linux_Monthly Assignemnts,Question Answers,Commands,64 Interview Q-A,

    37/42

    General Guidelinesin Answering Interview Questions

    Everyone is nervous on interviews. If you simply allow yourself to feel nervous, you'll do muchbetter. Remember also that it's difficult for the interviewer as well.

    In general, be upbeat and positive. Never be negative.Rehearse your answers and time them. Never talk for more than 2 minutes straight.

    Don't try to memorize answers word for word. Use the answers shown here as a guide only, anddon't be afraid to include your own thoughts and words. To help you remember key concepts, jotdown and review a few key words for each answer. Rehearse your answers frequently, and theywill come to you naturally in interviews.

    As you will read in the accompanying report, the single most important strategy in interviewing, asin all phases of your job search, is what we call: "The Greatest Executive Job Finding Secret." And that is...

    Find out what people want, than show them how you can help them get it.

    Find out what an employer wants most in his or her ideal candidate, then show how you meetthose qualifications.

    In other words, you must match your abilities, with the needs of the employer. You must sell what the buyer is buying . To do that, before you know what to emphasize in your answers, you mustfind out what the buyer is buying... what he is looking for. And the best way to do that is to ask afew questions yourself.

    You will see how to bring this off skillfully as you read the first two questions of this report. Butregardless of how you accomplish it, you must remember this strategy above all: before blurting out your qualifications, you must get some idea of what the employer wants most . Once you knowwhat he wants, you can then present your qualifications as the perfect key that fits the lock of that position.

    10. Other important interview strategies:

    11. Turn weaknesses into strengths (You'll see how to do this in a few moments.)

    12. Think before you answer. A pause to collect your thoughts is a hallmark of a thoughtfulperson.

    As a daily exercise, practice being more optimistic. For example, try putting a positive spin onevents and situations you would normally regard as negative. This is not meant to turn you into aPollyanna, but to sharpen your selling skills. The best salespeople, as well as the best likedinterview candidates, come off as being naturally optimistic, "can do" people. You will dramaticallyraise your level of attractiveness by daily practicing to be more optimistic.

    Be honest...never lie.

    Keep an interview diary. Right after each interview note what you did right, what could have gonea little better, and what steps you should take next with this contact. Then take those steps. Don'tbe like the 95% of humanity who say they will follow up on something, but never do.

    About the 64 questions...

    You might feel that the answers to the following questions are canned, and that they will seldommatch up with the exact way you are asked the questions in actual interviews. The questions and

  • 8/7/2019 Master_Linux_Monthly Assignemnts,Question Answers,Commands,64 Interview Q-A,

    38/42

    answers are designed to be as specific and realistic as possible. But no preparation cananticipate thousands of possible variations on these questions. What's important is that youthoroughly familiarize yourself with the main strategies behind each answer. And it will beinvaluable to you if you commit to memory a few key words that let you instantly call to mind your best answer to the various questions. If you do this, and follow the principles of successfulinterviewing presented here, you're going to do very well.

    Good luck...and good job-hunting!

  • 8/7/2019 Master_Linux_Monthly Assignemnts,Question Answers,Commands,64 Interview Q-A,

    39/42

    Question 1 Tell me about yourself.

    TRAPS : Beware, about 80% of all interviews begin with this innocent question. Manycandidates, unprepared for the question, skewer themselves by rambling, recapping their lifestory, delving into ancient work history or personal matters.

    BEST ANSWER: Start with the present and tell why you are well qualified for the position.Remember that the key to all successful interviewing is to match your qualifications to what theinterviewer is looking for. In other words you must sell what the buyer is buying. This is the singlemost important strategy in job hunting.

    So, before you answer this or any question it's imperative that you try to uncover your interviewer's greatest need, want, problem or goal.

    To do so, make you take these two steps:

    13. Do all the homework you can before the interview to uncover this person's wants andneeds (not the generalized needs of the industry or company)

    14. As early as you can in the interview, ask for a more complete description of what theposition entails. You might say: I have a number of accomplishments I'd like to tell youabout, but I want to make the best use of our time together and talk directly to your needs. To help me do, that, could you tell me more about the most important priorities of this position? All I know is what I (heard from the recruiter, read in the classified ad, etc.)

    Then, ALWAYS follow-up with a second and possibly, third question , to draw out his needs evenmore. Surprisingly, it's usually this second or third question that unearths what the interviewer ismost looking for.

    You might ask simply, "And in addition to that?..." or, "Is there anything else you see as essentialto success in this position?:

    This process will not feel easy or natural at first, because it is easier simply to answer questions,

    but only if you uncover the employer's wants and needs will your answers make the most sense.Practice asking these key questions before giving your answers, the process will feel morenatural and you will be light years ahead of the other job candidates you're competing with .

    After uncovering what the employer is looking for, describe why the needs of this job bear strikingparallels to tasks you've succeeded at before. Be sure to illustrate with specific examples of your responsibilities and especially your achievements, all of which are geared to present yourself as aperfect match for the needs he has just described.

    Question 2 What are your greatest strengths?

    TRAPS: This question seems like a softball lob, but be prepared. You don't want to come acrossas egotistical or arrogant. Neither is this a time to be humble.

    BEST ANSWER: You know that your key strategy is to first uncover your interviewer's greatestwants and needs before you answer questions. And from Question 1, you know how to do this.

    Prior to any interview, you should have a list mentally prepared of your greatest strengths. Youshould also have, a specific example or two, which illustrates each strength, an example chosenfrom your most recent and most impressive achievements.

    You should, have this list of your greatest strengths and corresponding examples from your achievements so well committed to memory that you can recite them cold after being shakenawake at 2:30AM.

  • 8/7/2019 Master_Linux_Monthly Assignemnts,Question Answers,Commands,64 Interview Q-A,

    40/42

    Then, once you uncover your interviewer's greatest wants and needs, you can choose thoseachievements from your list that best match up.

    As a general guideline, the 10 most desirable traits that all employers love to see in their employees are:

    15. A proven track record as an achiever... especially if your achievements match up withthe employer's greatest wants and needs.

    16. Intelligence...management "savvy".

    17. Honesty...integrity...a decent human being.

    18. Good fit with corporate culture...someone to feel comfortable with...a team player who meshes well with interviewer's team.

    19. Likeability...positive attitude...sense of humor.

    20. Good communication skills.

    21. Dedication...willingness to walk the extra mile to achieve excellence.

    22. Definiteness of purpose...clear goals.

    23. Enthusiasm...high level of motivation.

    24. Confident...healthy...a leader.

    Question 3 What are your greatest weaknesses?

    TRAPS : Beware - this is an eliminator question, designed to shorten the candidate list. Anyadmission of a weakness or fault will earn you an A for honesty, but an F for the interview.

    PASSABLE ANSWER: Disguise a strength as a weakness.

    Example: I sometimes push my people too hard. I like to work with a sense of urgency andeveryone is not always on the same wavelength.

    Drawback: This strategy is better than admitting a flaw, but it's so widely used, it is transparent toany experienced interviewer.

    BEST ANSWER : (and another reason it's so important to get a thorough description of your interviewer's needs before you answer questions): Assure the interviewer that you can think of nothing that would stand in the way of your performing in this position with excellence. Then,quickly review you strongest qualifications.

    Example: Nobody's perfect, but based on what you've told me about this position, I believe I' dmake an outstanding match. I know that when I hire people, I look for two things most of all. Dothey have the qualifications to do the job well, and the motivation to do it well? Everything in mybackground shows I have both the qualifications and a strong desire to achieve excellence inwhatever I take on. So I can say in all honesty that I see nothing that would cause you even asmall concern about my ability or my strong desire to perform this job with excellence.

    Alternate strategy (if you don't yet know enough about the position to talk about such a perfect fit):

    Instead of confessing a weakness, describe what you