Você está na página 1de 11

Top 50 Unix Interview Questions

RHEL 5 vs RHEL 6 ?
If by any chance you are appearing for an interview for a position if Linux Administrator
then the most common question which is asked is what is the difference between RHEL5
and RHEL !
Virtualization: In RHEL "#$ %"erne& based #irtua& $achine' was used as a
hypervisor but in the ear&ier re&eases of RHEL (E) was used as a hypervisor* +he
main advantage of "#$ is that it supports the insta&&ation of many virtua&
machines,operating systems &ike -indows. Linux. /o&aris and a&so it is very easy
to manage those virtua& machines*
Seurit!: RHEL has an enhanced version of /ELinux%/ecurity Enhanced Linux'
now. 0asica&&y now the features are more improved and there are various new set
of ru&es which are added to /ELinux one of such ru&e,feature is of /#irt which
provides security to virtua& machines from hackers*
E"T#: It stands for Extended 1. It has various new advantages then E(+2,3
which were used in ear&ier version%s' of RHEL* E(+1 is comparative&y more
faster and easy to manage then previous fi&e systems*
I$v6: RHEL supports I4v*
%&S#: It uses )5/v1 %)etwork 5i&e +ransfer' the &atest version of )5/ for the
sharing of fi&es in the network rather than )5/v3*
'UI: It has a far better 67I%6raphica& 7ser Interface' then RHE5 or any of its
prior version%s'*
(0 )ista*es new Linux a+)inistrators
)a*e
5or many. migrating to Linux is a rite of passage that equates to a thing of 8oy* 5or others.
it9s a nightmare waiting to happen* It9s wonderfu& when it9s the former: it9s a rea& show
stopper when it9s the &atter* 0ut that nightmare doesn9t have to happen. especia&&y when
you know. first hand. the most common mistakes new Linux administrators make* +his
artic&e wi&& he&p you avoid those mistakes by &aying out the most typica& Linux missteps*
Note: This information is also available as a PDF download.
,(: Installin- appliations .ro) various t!pes
+his might not seem &ike such a bad idea at first* ;ou are running 7buntu so you know
the package management system uses *deb packages* 0ut there are a number of
app&ications that you find on&y in source form* )o big dea& right! +hey insta&&. they work*
-hy shou&dn9t you! /imp&e. your package management system can9t keep track of what
you have insta&&ed if it9s insta&&ed from source* /o what happens when package A %that
you insta&&ed from source' depends upon package 0 %that was insta&&ed from a *deb
binary' and package 0 is upgraded from the update manager! 4ackage A might sti&& work
or it might not* 0ut if both package A and 0 are insta&&ed from *debs. the chances of them
both working are far higher* A&so. updating packages is much easier when a&& packages
are from the same binary type*
,/: %e-letin- up+ates
<kay. this one doesn9t point out Linux as much as it does poor administration ski&&s* 0ut
many admins get Linux up and running and think they have to do nothing more* It9s so&id.
it9s secure. it works* -e&&. new updates can patch new exp&oits* "eeping up with your
updates can make the difference between a compromised system and a secure one* And
8ust because you can rest on the security of Linux doesn9t mean you shou&d* 5or security.
for new features. for stabi&ity = the same reasons we have a&& grown accustomed to
updating with -indows = you shou&d a&ways keep up with your Linux updates*
,0: $oor root passwor+ 1oie
<kay. repeat after me> ?+he root password is the key to the kingdom*@ /o why wou&d you
make the key to the kingdom simp&e to crack! /ure. make your standard user password
something you can easi&y remember and,or type* 0ut that root password = you know. the
one that9s protecting your enterprise database server = give that a much higher difficu&ty
&eve&* $ake that password one you might have to store. encrypted. on a 7/0 key.
requiring you to s&ide that 7/0 key into the machine. mount it. decrypt the password. and
use it*
,#: 2voi+in- t1e o))an+ line
)o one wants to have to memoriAe a bunch of commands* And for the most part. the 67I
takes care of a vast ma8ority of them* 0ut there are times when the command &ine is
easier. faster. more secure. and more re&iab&e* Avoiding the command &ine shou&d be
considered a cardina& sin of Linux administration* ;ou shou&d at &east have a so&id
understanding of how the command &ine works and a sma&& arsena& of commands you can
use without having to R+5$* -ith a sma&& se&ection of commandB&ine too&s on top of the
67I too&s. you shou&d be ready for 8ust about anything*
,5: %ot *eepin- a wor*in- *ernel installe+
Let9s face it. you don9t need C2 kerne&s insta&&ed on one machine* 0ut you do need to
update your kerne&. and the update process doesn9t de&ete previous kerne&s* -hat do you
do! ;ou keep at &east the most recent&y working kerne& at a&& times* Let9s say you have
2**22 as your current working kerne& and 2**2D as your backup* If you update to 2**2
and a&& is working we&&. you can remove 2**2D* If you use an rpmBbased system. you can
use this method to remove the o&d kerne&s> rpm -qa | grep -i kernel fo&&owed by rpm-e
kernel-{!"#$%N&*
,6: %ot 3a*in- up ritial on.i-uration .iles
How many times have you upgraded (CC on&y to find the new version fubar9d your
xorg*conf fi&e to the point where you can no &onger use (! It used to happen to me a &ot
when I was new to Linux* 0ut now. anytime ( is going to be updated I a&ways back up
'et(')**'+org.(onf in case the upgrade goes bad* /ure. an ( update tries to back up
+org.(onf. but it does so within the 'et(')** directory* And even though this often works
seam&ess&y. you are better off keeping that backup under your own contro&* I a&ways back
up +org.(onf to the 'root directory so I know on&y the root user can even access it* 0etter
safe than sorry* +his app&ies to other critica& backups. such as /amba. Apache. and
$y/EL. too*
,4: 5ootin- a server to "
-hen a machine is a dedicated server. you might want to have ( insta&&ed so some
administration tasks are easier* 0ut this doesn9t mean you shou&d have that server boot to
(* +his wi&& waste precious memory and F47 cyc&es* Instead. stop the boot process at
run&eve& 3 so you are &eft at the command &ine* )ot on&y wi&& this &eave a&& of your
resources to the servers. it wi&& a&so keep prying eyes out of your machine %un&ess they
know the command &ine and passwords to &og in'* +o &og into (. you wi&& simp&y have to
&og in and run the command start+ to bring up your desktop*
,6: %ot un+erstan+in- per)issions
4ermissions can make your &ife rea&&y easy. but if done poor&y. can make &ife rea&&y easy
for hackers* +he simp&est way to hand&e permissions is using the rw+ method* Here9s
what they mean> rGread. wGwrite. xGexecute* /ay you want a user to be ab&e to read a fi&e
but not write to a fi&e* +o do this. you wou&d issue (hmod ,-r.,-w+ filename* -hat often
happens is that a new user sees an error saying they do not have permission to use a fi&e.
so they hit the fi&e with something akin to (hmod /// filename to avoid the prob&em* 0ut
this can actua&&y cause more prob&ems because it gives the fi&e executab&e privi&eges*
Remember this> HHH gives a fi&e rwx permissions to a&& users %root. group. and other'.
gives the fi&e rw privi&eges to a&& users. 555 gives the fi&e rx permissions to a&& users. 111
gives r privi&eges to a&& users. 333 gives wx privi&eges to a&& users. 222 gives w privi&eges
to a&& users. CCC gives x privi&eges to a&& users. and DDD gives no privi&eges to a&& users*
,7: Lo--in- in as root user
I can9t stress this enough* Io )<+ &og in as root* If you need root privi&eges to execute or
configure an app&ication. s, to root in a standard user account* -hy is &ogging in as root
bad! -e&&. when you &og on as a standard user. a&& running ( app&ications sti&& have
access on&y to the system &imited to that user* If you &og in as root. ( has a&& root
permissions* +his can cause two prob&ems> C' if you make a big mistake via a 67I. that
mistake can be catastrophic to the system and 2' with ( running as root that makes your
system more vu&nerab&e*
,(0: I-norin- lo- .iles
+here is a reason 'var'log exists* It is a sing&e &ocation for a&& &og fi&es* +his makes it
simp&e to remember where you first need to &ook when there is a prob&em* 4ossib&e
security issue! Fheck ,var,&og,secure* <ne of the very first p&aces I &ook is
'var'log'messages. +his &og fi&e is the common &og fi&e where a&& generic errors and such
are &ogged to* In this fi&e you wi&& get messages about networking. media changes. etc*
-hen administering a machine you can a&ways use a thirdBparty app&ication such as
&ogwatch that can create various reports for you based on your 'var'log fi&es*
Si+estep t1e pro3le)s
+hese CD mistakes are pretty common among new Linux administrators* Avoiding the
pitfa&&s wi&& take you through the Linux migration rite of passage faster. and you wi&&
come out on the other side a much better administrator*
C' 81at is U%I"?
It is a portab&e operating system that is designed for both efficient mu&tiBtasking and mu&tB
user functions* Its portabi&ity a&&ows it to run on different hardware p&atforms* It was
written is F and &ets user do processing and contro& under a she&&*
/9 81at are .ilters?
+he term 5i&ter is often used to refer to any program that can take input from standard
input. perform some operation on that input. and write the resu&ts to standard output* A
5i&ter is a&so any program that can be used between two other programs in a pipe&ine*
09 81at is a t!pial s!ntax 3ein- .ollowe+ w1en issuin- o))an+s in s1ell?
+ypica& command syntax under the 7)I( she&& fo&&ows the format>
Fommand JBargumentK JBargumentK JBBargumentK Jfi&eK
#9 Is t1ere a wa! to erase all .iles in t1e urrent +iretor!: inlu+in- all its su3;
+iretories: usin- onl! one o))an+?
;es. that is possib&e* 7se ?rm Lr M@ for this purpose* +he rm command is for de&eting
fi&es* +he Lr option wi&& erase directories and subdirectories. inc&uding fi&es within* +he
asterisk represents a&& entries*
59 81at is t1e 1ie. +i..erene 3etween t1e <v an+ <x option s to set?
+he Lv option echoes each command before arguments and variab&es have been
substituted for: the Lx option echoes the commands after substitution has taken p&ace*
69 81at is =ernel?
Kernel is the UNIX operating system. It is the master program that controls the
computers resources, allotting them to different users and to different tasks. However,
the kernel doesnt deal directly with a user. Instead, it starts up a separate, interactive
program, called a shell, for each user when heshe logs on.
49 81at is S1ell?
A she&& acts as an interface between the user and the system* As a command interpreter.
the she&& takes commands and sets them up for execution*
6 9 81at are t1e *e! .eatures o. t1e =orn S1ell?
B history mechanism with bui&tBin editor that simu&ates emacs or vi
B bui&tBin integer arithmetic
B string manipu&ation capabi&ities
B command a&iasing
B arrays
B 8ob contro&
79 81at are so)e o))on s1ells an+ w1at are t1eir in+iators?
sh L 0ourne she&&
csh L F /He&&
bash L 0ourne Again /he&&
tcsh L enhanced F /he&&
Ash L N /He&&
ksh L "orn /He&&
(09 >i..erentiate )ultiuser .ro) )ultitas*?
$u&tiuser means that more than one person can use the computer at the same time*
$u&titask means that even a sing&e user can have the computer work on more than one
task or program at the same time*
((9 81at is o))an+ su3stitution?
Fommand substitution is one of the steps being performed every time commands are
processed by the she&&* Fommands that are enc&osed in backquotes are executed by the
she&&* +his wi&& then rep&ace the standard output of the command and disp&ayed on the
command &ine*
(/9 81at is a +iretor!?
Every fi&e is assigned to a directory* A directory is a specia&iAed form of fi&e that
maintains a &ist of a&& fi&es in it*
(09 81at is ino+e?
An inode is an entry created on a section of the disk set aside for a fi&e system* +he inode
contains near&y a&& there is to know about a fi&e. which inc&udes the &ocation on the disk
where the fi&e starts. the siAe of the fi&e. when the fi&e was &ast used. when the fi&e was &ast
changed. what the various read. write and execute permissions are. who owns the fi&e.
and other information*
(#9 @ou 1ave a .ile alle+ ton*! in t1e +iretor! 1on*!? Later !ou a++ new )aterial
to ton*!? 81at 1an-es ta*e plae in t1e +iretor!: ino+e: an+ .ile?
+he directory entry is unchanged. since the name and inode number remain unchanged*
In the inode fi&e. the fi&e siAe. time of &ast access. and time of &ast modification are
updated* In the fi&e itse&f. the new materia& is added*
(59 >esri3e .ile s!ste)s in U%I"
7nderstanding fi&e systems in 7)I( has to do with knowing how fi&es and inodes are
stored on a system* -hat happens is that a disk or portion of a disk is set aside to store
fi&es and the inode entries* +he entire functiona& unit is referred to as a fi&e system*
(69 >i..erentiate relative pat1 .ro) a3solute pat1?
Re&ative path refers to the path re&ative to the current path* Abso&ute path. on the other
hand. refers to the exact path as referenced from the root directory*
(49 Explain t1e i)portane o. +iretories in a U%I" s!ste)
5i&es in a directory can actua&&y be a directory itse&f: it wou&d be ca&&ed a subdirectory of
the origina&* +his capabi&ity makes it possib&e to deve&op a treeB&ike structure of
directories and fi&es. which is crucia& in maintaining an organiAationa& scheme*
(69 5rie.l! +esri3e t1e S1ellAs responsi3ilities
B program execution
B variab&e and fi&e name substitution
B I,< redirection
B pipe&ine hookup
B environment contro&
B interpreted programming &anguage
(79 81at are s1ell varia3les?
/he&& variab&es are a combination of a name % identifier'. and an assigned va&ue. which
exist within the she&&* +hese variab&es may have defau&t va&ues. or whose va&ues can be
manua&&y set using the appropriate assignment command* Examp&es of she&& variab&e are
4A+H. +ER$ and H<$E*
/09 81at are t1e +i..erenes a)on- a s!ste) all: a li3rar! .untion: an+ a U%I"
o))an+?
A system ca&& is part of the programming for the kerne&* A &ibrary function is a program
that is not part of the kerne& but which is avai&ab&e to users of the system* 7)I(
commands. however. are standBa&one programs: they may incorporate both system ca&&s
and &ibrary functions in their programming*
/(9 81at is 5as1 S1ell?
It is a free she&& designed to work on the 7)I( system* 0eing the defau&t she&& for most
7)I(Bbased systems. it combines features that are avai&ab&e both in the F and "orn
/he&&*
//9 Enu)erate so)e o. t1e )ost o))onl! use+ networ* o))an+s in U%I"
B te&net L used for remote &ogin
B ping L an echo request for testing connectivity
B su L user switching command
B ftp L fi&e transfer protoco& used for copying fi&es
B finger L information gathering command
/09 >i..erentiate )p o))an+ .ro) +i.. o))an+?
+he cmp command is used main&y to compare two fi&es byte by byte. after which the first
encountered mismatch is shown* <n the other hand. the diff command is used to indicate
the changes that is to be made in order to make the two fi&es identica& to each other*
/#9 81at is t1e use o. ;l w1en listin- a +iretor!?
B&. which is norma&&y used in &isting command &ike &s. is used to show fi&es in a &ong
format. one fi&e per &ine* Long format refers to additiona& information that is associated
with the fi&e. such as ownership. permissions. data and fi&esiAe*
/59 81at is pipin-?
4iping. represented by the pipe character ?O@. is used to combine two or more commands
together* +he output of the first command serves as input the next command. and so on*
/69 81at is a superuser?
A superuser is a specia& type user who has open access to a&& fi&es and commands on a
system* )ote that the superuser9s &ogin is usua&&y root. and is protected by a soBca&&ed root
password*
/49 How +o !ou +eter)ine an+ set t1e pat1 in U%I"?
Each time you enter a command. a variab&e named 4A+H or path wi&& define in which
directory the she&& wi&& search for that command* In cases wherein an error message was
returned. the reason maybe that the command was not in your path. or that the command
itse&f does not exist* ;ou can a&so manua&&y set the path using the ?set path G Jdirectory
pathK@ command*
/69 Is it possi3le to see in.or)ation a3out a proess w1ile it is 3ein- exeute+?
Every process is unique&y identified by a process identifier* It is possib&e to view detai&s
and status regarding a process by using the ps command*
/79 81at is t1e stan+ar+ onvention 3ein- .ollowe+ w1en na)in- .iles in U%I"?
<ne important ru&e when naming fi&es is that characters that have specia& meaning are not
a&&owed. such as M , P and Q* A directory. being a specia& type of fi&e. fo&&ows the same
naming convention as that of fi&es* Letters and numbers are used. a&ong with characters
&ike underscore and dot characters*
009 81! is it t1at it is not a+visa3le to use root as t1e +e.ault lo-in?
+he root account is very important. and with abusive usage. can easi&y &ead to system
damage* +hat9s because safeguards that norma&&y app&y to user accounts are not
app&icab&e to the root account*
0(9 81at is t1e use o. t1e tee o))an+?
+he tee command does two things> one is to get data from the standard input and send it
to standard output: the second is that it redirects a copy of that input data into a fi&e that
was specified*
0/9 >i..erentiate at o))an+ .ro) )ore o))an+?
-hen using the cat command to disp&ay fi&e contents. &arge data that does not fit on the
screen wou&d scro&& off without pausing. therefore making it difficu&t to view* <n the
other hand. using the more command is more appropriate in such cases because it wi&&
disp&ay fi&e contents one screen page at a time*
009 81at is parsin-?
4arsing is the process of breaking up of a command &ine into words* +his is made
possib&e by using de&imiters and spaces* In the event that tabs or mu&tip&e spaces are part
of the command. these are eventua&&y rep&aced by a sing&e space*
0#9 81at is pi+?
4id is short for 4rocess II* It is used primari&y to identify every process that runs on the
7)I( system. whether it runs on the foreground or runs at the background* Every pid is
considered unique*
059 How +oes t1e s!ste) *now w1ere one o))an+ en+s an+ anot1er 3e-ins?
)orma&&y. the new&ine character. which is generated by the E)+ER or RE+7R) key. acts
as the signpost* However. the semico&on and the ampersand characters can a&so serve as
command terminators*
049 81at is wil+;ar+ interpretation?
-hen a command &ine contains wi&dBcard characters such as RM9 or R!9. these are rep&aced
by the she&& with a sorted &ist of fi&es whose pattern matches the input command* -i&dB
card characters are used to setup a &ist of fi&es for processing. instead of having it
specified one at a time*
069 81at is t1e output o. t1is o))an+? Bw1o C sort <lo-.ile D new.ile
In this command. the output from the command ?who@ becomes the input to the ?sort@
command* At the same time. ?sort@ opens &ogfi&e. arranges it together with the output
from the command ?who@. and p&aces the fina& sorted output to the fi&e newfi&e*
079 How +o !ou swit1 .ro) an! user t!pe to a super user t!pe?
In order to switch from any user type to a superuser. you use the su command* However.
you wi&& be asked to key in the correct superuser password before fu&& access privi&eges
are granted to you*
#09 81at woul+ 3e t1e e..et o. 1an-in- t1e value o. $2TH to:
?:EusrE+ellaE3in: E3in: EusrE3in
+his wou&d cause the she&& to &ook in the ,usr,de&&a,bin directory after &ooking in the
current directory and before &ooking in the ,bin directory when searching for a command
fi&e*
#(9 8rite a o))an+ t1at will +ispla! .iles in t1e urrent +iretor!: in a olore+:
lon- .or)at?
Answer> &s B& Lco&or
#/9 8rite a o))an+ t1at will .in+ all text .iles in a +iretor! su1 t1at it +oes not
ontain t1e wor+ Fa)azin-G in an! .or) Ht1at is: it )ust inlu+e t1e wor+s
2)azin-: 2I2JI%': or aI2JI%-9
Answer> grep Lvi amaAing M*txt
#09 8rite a o))an+ t1at will output t1e sorte+ ontents o. a .ile na)e+ I%?T"T
an+ plae t1e output in anot1er .ile na)e+ KUT?T"T: w1ile at t1e sa)e ti)e
exlu+in- +upliate entries?
Answer> sort I)*+(+ O uniq S <7+*+(+
##9 8rite a o))an+ t1at will allow a U%I" s!ste) to s1ut +own in (5 )inutes:
a.ter w1i1 it will per.or) a re3oot?
Answer> ,sbin,shutdown Lr TCD
#59 81at o))an+ will 1an-e !our pro)pt to I@$RKI$T: ?
+o change a prompt. we use the 4/C command. such as this>
4/C G R$;4R<$4+>9
#69 81at +oes t1is o))an+ +o? at .oo+ ( D *itt!
Answer> it redirects the output of cat food into the fi&e kitty: the command is the same as>
cat food S kitty
#49 81at is wron- wit1 t1is interative s1ell sript?
echo -hat month is this!
read Umonth
echo Umonth is as good a month as any*
Answer> Initia&&y. the question mark shou&d be escaped %V!' so that it is not interpreted as
a she&& metacharacter* /econd. it shou&d be read month. not read Umonth*
#69 8rite a s1ell sript t1at reLuests t1e userAs a-e an+ t1en e1oes it: alon- wit1
so)e suita3le o))ent?
Answer>
echo He&&oW -hatV9s your ageV!
read age
echo UageW IV9&& be obso&ete by that ageW
#79 8rite a sript t1at prints out +ate in.or)ation in t1is or+er: ti)e: +a! o. wee*:
+a! nu)3er: )ont1: !ear
Hsa)ple output: (4:0#:5( $>T Sun (/ &e3 /0(/9
Answer>
set Rdate9
echo U1 U5 UC U3 U2 U
509 8rite a sript t1at will s1ow t1e .ollowin- as output:
'ive )e a UM
UM
'ive )a a %M
%M
'ive )e a IM
IM
'ive )e a "M
"M
Answer>
for i in 7 ) I (
do
echo 6ive me a UiW
echo UiW
done

Você também pode gostar