You are on page 1of 12

Linux Interview Questions and Answers

You need to see the last fifteen lines of the files dog, cat and horse. What
command should you use?
tail -15 dog cat horse
The tail utility displays the end of a file. The -15 tells tail to display the last fifteen lines
of each specified file.
Who owns the data dictionary?
The SYS user owns the data dictionary. The SYS and SYSTEM users are created when
the database is created.
You routinely compress old log files. You now need to examine a log from two
months ago. In order to view its contents without first having to decompress it,
use the _________ utility.
zcat
The zcat utility allows you to exaine the contents of a copressed file uch the sae
way that cat displays a file.
You suspect that you have two commands with the same name as the command is
not producing the expected results. What command can you use to determine the
location of the command being run?
which
The which coand searches your path until it finds a coand that atches the
coand you are loo!ing for and displays its full path.
You locate a command in the /bin directory but do not know what it does. What
command can you use to determine its purpose.
whatis
The whatis coand displays a suary line fro the an page for the specified
coand.
You wish to create a link to the /data directory in bobs home directory so you
issue the command ln /data /home/bob/datalink but the command fails. What
option should you use in this command line to be successful.
"se the -# option
$n order to create a lin! to a directory you ust use the -# option.
When you issue the command ls !l, the first character of the resulting display
represents the files ___________.
type
The first character of the perission bloc! designates the type of file that is being
displayed.
What utility can you use to show a dynamic listing of running processes? __________
top
The top utility shows a listing of all running processes that is dynaically updated.
Where is standard output usually directed?
to the screen or display
%y default& your shell directs standard output to your screen or display.
You wish to restore the file memo.ben which was backed up in the tarfile
"y#ackup.tar. What command should you type?
tar xf My%ac!up.tar eo.ben
This coand uses the x switch to extract a file. 'ere the file eo.ben will be
restored fro the tarfile My%ac!up.tar.
You need to view the contents of the tarfile called "y#ackup.tar. What command
would you use?
tar tf My%ac!up.tar
The t switch tells tar to display the contents and the f odifier specifies which file to
exaine.
You want to create a compressed backup of the users home directories. What
utility should you use?
tar
You can use the z odifier with tar to copress your archi(e at the sae tie as
creating it.
What daemon is responsible for tracking events on your system?
syslogd
The syslogd daeon is responsible for trac!ing syste inforation and sa(ing it to
specified log files.
You have a file called phonenos that is almost $,%%% lines long. What text filter can
you use to split it into four pieces each &,%%% lines long?
split
The split text filter will di(ide files into e)ually sized pieces. The default length of each
piece is 1&*** lines.
You would like to temporarily change your command line editor to be vi. What
command should you type to change it?
set -o (i
The set coand is used to assign en(ironent (ariables. $n this case& you are
instructing your shell to assign (i as your coand line editor. 'owe(er& once you log
off and log bac! in you will return to the pre(iously defined coand line editor.
What account is created when you install 'inux?
root
+hene(er you install ,inux& only one user account is created. This is the superuser
account also !nown as root.
What command should you use to check the number of files and disk space used
and each users defined (uotas?
rep)uota
The rep)uota coand is used to get a report on the status of the )uotas you ha(e set
including the aount of allocated space and aount of used space.
In order to run fsck on the root partition, the root partition must be mounted as
readonly
You cannot run fsc! on a partition that is ounted as read-write.
In order to improve your systems security you decide to implement shadow
passwords. What command should you use?
pwcon(
The pwcon( coand creates the file -etc-shadow and changes all passwords to .x. in
the -etc-passwd file.
#ob )rmstrong, who has a username of boba, calls to tell you he forgot his
password. What command should you use to reset his command?
passwd boba
The passwd coand is used to change your password. $f you do not specify a
usernae& your password will be changed.
*he top utility can be used to change the priority of a running process? )nother
utility that can also be used to change priority is ___________?
nice
%oth the top and nice utilities pro(ide the capability to change the priority of a running
process.
What command should you type to see all the files with an extension of mem
listed in reverse alphabetical order in the /home/ben/memos directory.
ls -r -hoe-ben-eos-/.e
The -c option used with ls results in the files being listed in chronological order. You can
use wildcards with the ls coand to specify a pattern of filenaes.
What file defines the levels of messages written to system log files?
!ernel.h
To deterine the (arious le(els of essages that are defined on your syste& exaine
the !ernel.h file.
What command is used to remove the password assigned to a group?
gpasswd -r
The gpasswd coand is used to change the password assigned to a group. "se the -r
option to reo(e the password fro the group.
What command would you type to use the cpio to create a backup called
backup.cpio of all the users home directories?
find -hoe 0 cpio -o 1 bac!up.cpio
The find coand is used to create a list of the files and directories contained in hoe.
This list is then piped to the cpio utility as a list of files to include and the output is
sa(ed to a file called bac!up.cpio.
What can you type at a command line to determine which shell you are using?
echo 2S'E,,
The nae and path to the shell you are using is sa(ed to the S'E,, en(ironent
(ariable. You can then use the echo coand to print out the (alue of any (ariable by
preceding the (ariable.s nae with 2. Therefore& typing echo 2S'E,, will display the
nae of your shell.
What type of local file server can you use to provide the distribution installation
materials to the new machine during a network installation?
A) Inetd
B) FSSTND
C) DNS
D) NNTP
E) NFS
E - You can use an 3#S ser(er to pro(ide the distribution installation aterials to the
achine on which you are perforing the installation. 4nswers a& b& c& and d are all
(alid ites but none of the are file ser(ers. $netd is the superdaeon which controls
all interittently used networ! ser(ices. The #SST35 is the ,inux #ile Syste Standard.
53S pro(ides doain nae resolution& and 33T6 is the transfer protocol for usenet
news.
If you type the command cat dog + , cat what would you see on your display?
Choose one:
a. Any error messages only.
b. The contents o the !le dog.
c. The contents o the !le dog and any error messages.
d. Noth!ng as all o"t#"t !s sa$ed to the !le cat.
d
+hen you use 7 1 for redirection& it redirects both the standard output and standard
error. The output would be sa(ed to the file cat.
You are covering for another system administrator and one of the users asks you
to restore a file for him. You locate the correct tarfile by checking the backup log
but do not know how the directory structure was stored. What command can you
use to determine this?
Choose one:
a. tar % tar!le d!rname
b. tar t$ tar!le !lename
c. tar ct tar!le
d. tar t$ tar!le
d
The t switch will list the files contained in the tarfile. "sing the ( odifier will display the
stored directory structure.
You have the /var directory on its own partition. You have run out of space. What
should you do? -hoose one.
a. &econ!g"re yo"r system to not 'r!te to the log !les.
b. (se !#s to enlarge the #art!t!on.
c. Delete all the log !les.
d. Delete the #art!t!on and recreate !t '!th a larger s!)e.
d
The only way to enlarge a partition is to delete it and recreate it. You will then ha(e to
restore the necessary files fro bac!up.
You have a new application on a -/!01" that you wish to install. What should
your first step be?
Choose one:
a. &ead the !nstallat!on !nstr"ct!ons on the CD*&+,.
b. (se the mo"nt command to mo"nt yo"r CD*&+, as read*'r!te.
c. (se the "mo"nt command to access yo"r CD*&+,.
d. (se the mo"nt command to mo"nt yo"r CD*&+, as read*only.
d
%efore you can read any of the files contained on the 85-9:M& you ust first ount the
85-9:M.
When you create a new partition, you need to designate its si2e by defining the
starting and ending _____________.
cylinders
+hen creating a new partition you ust first specify its starting cylinder. You can then
either specify its size or the ending cylinder.
What key combination can you press to suspend a running 3ob and place it in the
background?
ctrl-z
"sing ctrl-z will suspend a ;ob and put it in the bac!ground.
*he easiest, most basic form of backing up a file is to _____ it to another location.
copy
The easiest ost basic for of bac!ing up a file is to a!e a copy of that file to another
location such as a floppy dis!.
What type of server is used to remotely assign I4 addresses to machines during
the installation process?
A) S,B
B) NFS
C) D-CP
D) FT
E) -TTP
8 - You can use a 5'86 ser(er to assign $6 addresses to indi(idual achines during the
installation process. 4nswers a& b& d& and e list legitiate ,inux ser(ers& but these
ser(ers do not pro(ide $6 addresses. The SM%& or Saba& tool is used for file and print
sharing across ulti-:S networ!s. 4n 3#S ser(er is for file sharing across ,inux net-
wor!s. #T6 is a file storage ser(er that allows people to browse and retrie(e inforation
by logging in to it& and 'TT6 is for the +eb.
Which password package should you install to ensure that the central password
file couldnt be stolen easily?
A) PA,
B) tc#_'ra##ers
C) shado'
D) sec"re#ass
E) ssh
8 - The shadow password pac!age o(es the central password file to a ore secure
location. 4nswers a& b& and e all point to (alid pac!ages& but none of these places the
password file in a ore secure location. 4nswer d points to an in(alid pac!age.
When using useradd to create a new user account, which of the following tasks is
not done automatically.
Choose one:
a. Ass!gn a (ID.
b. Ass!gn a dea"lt shell.
c. Create the "ser.s home d!rectory.
d. De!ne the "ser.s home d!rectory.
c
The useradd coand will use the syste default for the user.s hoe directory. The
hoe directory is not created& howe(er& unless you use the - option.
You want to enter a series of commands from the command!line. What would be
the (uickest way to do this?
Choose +ne
a. Press enter ater enter!ng each command and !ts arg"ments
b. P"t them !n a scr!#t and e%ec"te the scr!#t
c. Se#arate each command '!th a sem!*colon /0) and #ress enter ater the last
command
d. Se#arate each command '!th a 1 and #ress enter ater the last command
c
The sei-colon ay be used to tell the shell that you are entering ultiple coands
that should be executed serially. $f these were coands that you would fre)uently
want to run& then a script ight be ore efficient. 'owe(er& to run these coands
only once& enter the coands directly at the coand line.
You attempt to use shadow passwords but are unsuccessful. What characteristic
of the /etc/passwd file may cause this?
Choose one:
a. The log!n command !s m!ss!ng.
b. The "sername !s too long.
c. The #ass'ord !eld !s blan2.
d. The #ass'ord !eld !s #reaced by an aster!s2.
c
The password field ust not be blan! before con(erting to shadow passwords.
When you install a new application, documentation on that application is also
usually installed. Where would you look for the documentation after installing an
application called "y)pp?
Choose one:
a. 1"sr1,yA##
b. 1l!b1doc1,yA##
c. 1"sr1doc1,yA##
d. In the same d!rectory 'here the a##l!cat!on !s !nstalled.
c
The default location for application docuentation is in a directory naed for the
application in the -usr-doc directory.
What file would you edit in your home directory to change which window manager
you want to use?
A) 3!n!t
B) .%!n!trc
C) 3F45Set"#
D) %start
E) %45!n!t
4nswer< % - The =-.xinitrc file allows you to set which window an-ager you want to use
when logging in to > fro that account.
4nswers a& d& and e are all in(alid files. 4nswer c is the ain > ser(er configuration file.
What command allows you to set a processor!intensive 3ob to use less -45 time?
A) #s
B) n!ce
C) ch#s
D) less
E) more
4nswer< % - The nice coand is used to change a ;ob.s priority le(el& so that it runs
slower or faster. 4nswers a& d& and e are (alid coands but are not used to change
process inforation. 4nswer c is an in(alid coand.
While logged on as a regular user, your boss calls up and wants you to create a
new user account immediately. 6ow can you do this without first having to close
your work, log off and logon as root?
Choose one:
a. Iss"e the command rootlog.
b. Iss"e the command s" and ty#e e%!t 'hen !n!shed.
c. Iss"e the command s" and ty#e logo 'hen !n!shed.
d. Iss"e the command logon root and ty#e e%!t 'hen !n!shed.
4nswer< b
You can use the su coand to iitate any user including root. You will be propted
for the password for the root account. :nce you ha(e pro(ided it you are logged in as
root and can do any adinistrati(e duties.
*here are seven fields in the /etc/passwd file. Which of the following lists all the
fields in the correct order?
Choose one:
a. "sername6 (ID6 7ID6 home d!rectory6 command6 comment
b. "sername6 (ID6 7ID6 comment6 home d!rectory6 command
c. (ID6 "sername6 7ID6 home d!rectory6 comment6 command
d. "sername6 (ID6 gro"# name6 7ID6 home d!rectory6 comment
4nswer< b
The se(en fields re)uired for each line in the -etc-passwd file are usernae& "$5& ?$5&
coent& hoe directory& coand. Each of these fields ust be separated by a colon
e(en if they are epty.
Which of the following commands will show a list of the files in your home
directory including hidden files and the contents of all subdirectories?
Choose one:
a. ls *c home
b. ls *a& 1home1"sername
c. ls *aF 1home1"sername
d. ls *l 1home1"sername
4nswer< b
The ls coand is used to display a listing of files. The -a option will cause hidden files
to be displayed as well. The -9 option causes ls to recurse down the directory tree. 4ll of
this starts at your hoe directory.
In order to prevent a user from logging in, you can add a7n8 ________at the
beginning of the password field.
4nswer< asteric!
$f you add an asteric! at the beginning of the password field in the -etc-passwd file& that
user will not be able to log in.
You have a directory called /home/ben/memos and want to move it to
/home/bob/memos so you issue the command mv /home/ben/memos
/home/bob. What is the results of this action?
Choose one:
a. The !les conta!ned !n 1home1ben1memos are mo$ed to the d!rectory
1home1bob1memos1memos.
b. The !les conta!ned !n 1home1ben1memos are mo$ed to the d!rectory
1home1bob1memos.
c. The !les conta!ned !n 1home1ben1memos are mo$ed to the d!rectory
1home1bob1.
d. The command a!ls s!nce a d!rectory called memos already e%!sts !n the
target d!rectory.
4nswer< a
+hen using the ( coand to o(e a directory& if a directory of the sae nae
exists then a subdirectory is created for the files to be o(ed.
Which of the following tasks is not necessary when creating a new user by editing
the /etc/passwd file?
Choose one:
a. Create a l!n2 rom the "ser.s home d!rectory to the shell the "ser '!ll "se.
b. Create the "ser.s home d!rectory
c. (se the #ass'd command to ass!gn a #ass'ord to the acco"nt.
d. Add the "ser to the s#ec!!ed gro"#.
4nswer< a
There is no need to lin! the user.s hoe directory to the shell coand. 9ather& the
specified shell ust be present on your syste.
You issue the following command useradd !m bobm #ut the user cannot logon.
What is the problem?
Choose one:
a. 8o" need to ass!gn a #ass'ord to bobm.s acco"nt "s!ng the #ass'd
command.
b. 8o" need to create bobm.s home d!rectory and set the a##ro#r!ate
#erm!ss!ons.
c. 8o" need to ed!t the 1etc1#ass'd !le and ass!gn a shell or bobm.s acco"nt.
d. The "sername m"st be at least !$e characters long.
4nswer< a
The useradd coand does not assign a password to newly created accounts. You will
still need to use the passwd coand to assign a password.
You wish to print the file vacations with 9% lines to a page. Which of the following
commands will accomplish this? -hoose one.
a. #r *l59 $acat!ons : l#r
b. #r * $acat!ons : l#r
c. #r *m $acat!ons : l#r
d. #r *l $acat!ons : l#r
4nswer< a
The default page length when using pr is @@ lines. The -l option is used to specify a
different length.
Which file defines all users on your system?
Choose one:
a. 1etc1#ass'd
b. 1etc1"sers
c. 1etc1#ass'ord
d. 1etc1"ser.con
4nswer< a
The -etc-passwd file contains all the inforation on users who ay log into your syste.
$f a user account is not contained in this file& then the user cannot log in.
Which two commands can you use to delete directories?
A) rm
B) rm *r
C) rmd!r
D) rd
E) rd *r
4nswerAsB< %& 8 - You can use rdir or r -rf to delete a directory. 4nswer a is incorrect&
because the r coand without any specific flags will not delete a directory& it will
only delete files. 4nswers d and e point to a non-existent coand.
Which partitioning tool is available in all distributions?
A) D!s2 Dr"!d
B) d!s2
C) Part!t!on ,ag!c
D) FAT;<
E) System Commander
4nswerAsB< % - The fdis! partitioning tool is a(ailable in all ,inux distributions. 4nswers a&
c& and e all handle partitioning& but do not coe with all distributions. 5is! 5ruid is
ade by 9ed 'at and used in its distribution along with soe deri(ati(es. 6artition
Magic and Syste 8oander are tools ade by third-party copanies. 4nswer d is
not a tool& but a file syste type. Specifically& #4TCD is the file syste type used in
+indows EF.
Which partitions might you create on the mail servers hard drive7s8 other than
the root, swap, and boot partitions?
=Choose all correct ans'ers>
A) 1$ar1s#ool
B) 1tm#
C) 1#roc
D) 1b!n
E) 1home
4nswerAsB< 4& %& E - Separating -(ar-spool onto its own partition helps to ensure that if
soething goes wrong with the ail ser(er or spool& the output cannot o(errun the file
syste. 6utting -tp on its own partition pre(ents either software or user ites in the
-tp directory fro o(errunning the file syste. 6lacing -hoe off on its own is ostly
useful for syste re-installs or upgrades& allowing you to not ha(e to wipe the -hoe
hierarchy along with other areas. 4nswers c and d are not possible& as the -proc portion
of the file syste is (irtual-held in 94M-not placed on the hard dri(es& and the -bin
hierarchy is necessary for basic syste functionality and& therefore& not one that you
can place on a different partition.
When planning your backup strategy you need to consider how often you will
perform a backup, how much time the backup takes and what media you will use.
What other factor must you consider when planning your backup strategy?
_________
what to bac!up
8hoosing which files to bac!up is the first step in planning your bac!up strategy.
What utility can you use to automate rotation of logs?
4nswer< logrotate
The logrotate coand can be used to autoate the rotation of (arious logs.
In order to display the last five commands you have entered using the history
command, you would type ___________ .
4nswer< history 5
The history coand displays the coands you ha(e pre(iously entered. %y passing
it an arguent of 5& only the last fi(e coands will be displayed.
What command can you use to review boot messages?
4nswer< desg
The desg coand displays the syste essages contained in the !ernel ring buffer.
%y using this coand iediately after booting your coputer& you will see the boot
essages.
What is the minimum number of partitions you need to install 'inux?
4nswer< D
,inux can be installed on two partitions& one as - which will contain all files and a swap
partition.
What is the name and path of the main system log?
4nswer< -(ar-log-essages
%y default& the ain syste log is -(ar-log-essages.
1f the following technologies, which is considered a client!side script?
A) ?a$aScr!#t
B) ?a$a
C) ASP
D) C@@
4nswer< 4 - Ga(aScript is the only client-side script listed. Ga(a and 8HH are coplete
prograing languages. 4cti(e Ser(er 6ages are parsed on the ser(er with the results
being sent to the client in 'TM,

You might also like