Вы находитесь на странице: 1из 32

Linux admin interview questions

1.

How do you take a single line of input from the user in a shell
script?
2.
Write a script to convert all DOS style backslashes to UNIX style
slashes in a list of files.
3.
Write a regular expression (or sed script) to replace all
occurrences of the letter f, followed by any number of characters,
followed by the letter a, followed by one or more numeric characters,
followed by the letter n, and replace whats found with the string
UNIX.
4.
Write a script to list all the differences between two directories.
5.
Write a program in any language you choose, to reverse a file.
6.
What are the fields of the password file?
7.
What does a plus at the beginning of a line in the password file
signify?
8.
Using the man pages, find the correct ioctl to send console
output to an arbitrary pty.
9.
What is an MX record?
10.
What is the prom command on a Sun that shows the SCSI
devices?
11.
What is the factory default SCSI target for /dev/sd0?
12.
Where is that value controlled?
13.
What happens to a child process that dies and has no parent
process to wait for it and whats bad about this?
14.
Whats wrong with sendmail? What would you fix?
15.
What command do you run to check file system consistency?
16.
Whats wrong with running shutdown on a network?
17.
What can be wrong with setuid scripts?
18.
What value does spawn return?
19.
Write a script to send mail from three other machines on the
network to root at the machine youre on. Use a here doc, but include
in the mail message the name of the machine the mail is sent from and
the disk utilization statistics on each machine?
20.
Why cant root just cd to someones home directory and run a
program called a.out sitting there by typing a.out, and why is this
good?
21.
What is the difference between UDP and TCP?
22.
What is DNS?
23.
What does nslookup do?
24.
How do you create a swapfile?
25.
How would you check the route table on a workstation/server?
26.
How do you find which ypmaster you are bound to?

27.
over
28.
29.

How do you fix a problem where a printer will cutoff anything


1MB?
What is the largest file system size in solaris? SunOS?
What are the different RAID levels?

Interview questions for Linux admin


1.

Advantages/disadvantages of script vs compiled program.

Scripting vs. programming: is there a difference?


The short answer: These days, the line between a scripting language
and a programming language is blurred. As such, in practical
application, the differences are meaningless. So the answer is: no.
Some details what a nerd might tell you: Scripting or writing
scripts, is programming within a program. Traditionally you would write
scripts to automate certain functionality within another program.
Traditionally scripts would have very specific task like for example:
reading a text file to extract all the email addresses.
Why use a scripting language?

Easy to learn - compared to traditional programming languages.


It takes much less code to do something with scripting than when
using a traditional programming language.

Another characteristic of a scripting language, is that they are


processed from scratch every time you run them. A nerd would say:
scripting languages are not compiled.
What is a compiled language?
A compiled language (like Java and C,) are processed once (think of a
food processor) and reduced (if you will,) to a simpler form that allows
it to run faster than a script that has to be reprocessed every time. - -

MORE ABOUT PROGRAMMING LANGUAGES


With programming, you are writing software that runs independent of
an exterior (or parent) program. Also, when people would say they
were programming, they were usually involved in some project that
produced much more functionality than a traditional script.
Things have changed
I keep saying traditionally because the lines between scripting and
programming are very blurred these days - scripting is now very
powerful and is doing the work that once belonged to the realm of full
blown programming - in a traditional sense.
Lets look at some examples:
PHP: People refer to software written in PHP as scripts because PHP
runs inside another program - the PHP script engine. But unlike
traditional simple scripts, PHP software can be very complex and very
powerful. Java: Most people would refer to Java as a full-blown
programming language because its compiled. But, Java (like PHP) runs
inside another program, something called the Java Virtual Machine. So
here we see the first of those blurry lines I mentioned above.
To summarize:

Scripting languages run inside another program.


Scripting languages are not compiled.
Scripting languages are easy to use and easy to write.

but

Very popular programming languages (Java, C#) run inside a


parent program - like scripting languages.
Scripting languages today are used to build complex software.
Computers are so fast these days, and scripting languages are so
efficient, that for most business operations, there is no practical
speed advantage (that there once was,) with a compiled
programming language.

Conclusion
Today the difference between scripting and programming is largely and
academic thing. You shouldnt have to concern yourself with what
broad category a particular language may fall in.

2.

Name a replacement for PHP/Perl/MySQL/Linux/Apache and show


main differences.

3.
4.

Why have you chosen such a combination of products?


Differences between two last MySQL versions. Which one would
you choose and when/why?
Main differences between Apache 1.x and 2.x. Why is 2.x not so
popular? Which one would you choose and when/why?
Which Linux distros do you have experience with?
Which distro you prefer? Why?
Which tool would you use to update Debian / Slackware /
RedHat / Mandrake / SuSE ?

5.
6.
7.
8.

To update the tool is debian apt-get update


To update redhat we use up2date --nox configure
To update slackware we use slackpkg update
To update SuSE we use YaST

To update Mandrake we use


The syntax for using rsync in this fashion looks like:
rsync -switches --options [host]::[rsyncmodule/path/srcfile] [destination]
9.

Youre asked to write an Apache module. What would you do?

10.
11.
12.

Which tool do you prefer for Apache log reports?


Your portfolio. (even a PHP guest book may work well)
What does route command do?

Route manipulates the kernel's IP routing tables. Its primary use is to set up static routes
to specific hosts or networks via an interface after it has been configured with the
ifconfig(8) program.
When the add or del options are used, route modifies the routing tables. Without these
options, route displays the current contents of the routing tables.

Differences between iptables and ipchains


At first glance, ipchains and iptables appear to be quite similar. After all, both
methods of packet filtering use chains of rules operating within the Linux kernel to
decide not only which packets to let in or out, but also what to do with packets that match
certain rules, however, iptables offer a much more extensible way of filtering packets,
giving an administrator a finer grained level of control without building too much
complexity into the entire system.
Specifically, users comfortable with ipchains should be aware of the following
significant differences between ipchains and iptables before attempting to use
iptables:

Under iptables, each filtered packet is only processed using rules from one
chain rather than multiple chains. In other words, a FORWARD packet coming
into a system using ipchains would have to go through the INPUT, FORWARD,
and OUTPUT chains in order to move along to its destination. However,
iptables only sends packets to the INPUT chain if they are destined for the local
system and only sends them to the OUTPUT chain if the local system generated
the packets. For this reason, you must be sure to place the rule designed to catch a
particular packet in the correct chain that will actually see the packet.
The advantage is that you now have finer-grained control over the disposition of
each packet. If you are attempting to block access to a particular website, it is now
possible to block access attempts from clients running on hosts which use your
host as a gateway. An OUTPUT rule which denies access will no longer prevent
access for hosts which use your host as a gateway.

The DENY target has been changed to DROP. In ipchains, packets that matched
a rule in a chain could be directed to the DENY target, which silently dropped the
packet. This target must be changed to DROP in iptables to have the same
effect.
Order matters when placing options in a chain rule. Previously, with ipchains, it
did not matter very much how you ordered the rule options when typing the rule.
The iptables command is a bit pickier about where some options may go. For
example, you must now specify the source or destination port after the protocol
(ICMP, TCP, or UDP) to be used in a chain's rule.
When specifying network interfaces to be used with a rule, you must only use
incoming interfaces (-i option) with INPUT or FORWARD chains and outgoing
interfaces (-o option) with FORWARD or OUTPUT chains. This is necessary due
to the fact that OUTPUT chains are no longer used by incoming interfaces, and
INPUT chains are not seen by packets moving through outgoing interfaces.

13.

Whats eth0, ppp0, wlan0, ttyS0, etc.


Loopback: lo
Ethernet: eth0, eth1, ...
Wi-Fi: wlan0, wlan1, wifi0, .
Token Ring: tr0, tr1, ...
PPP: ppp0, ppp1, ...

14.
15.

What are different directories in / for?


Partitioning scheme for new webserver. Why?

Unix/Linux administration interview questions


What is LILO?
LILO stands for Linux boot loader. It will load the MBR, master boot
record, into the memory, and tell the system which partition and hard
drive to boot from.
What is the main advantage of creating links to a file instead
of copies of the file?
A: The main advantage is not really that it saves disk space (though it
does that too) but, rather, that a change of permissions on the file is
applied to all the link access points. The link will show permissions of
lrwxrwxrwx but that is for the link itself and not the access to the file to
which the link points. Thus if you want to change the permissions for a
command, such as su, you only have to do it on the original. With
copies you have to find all of the copies and change permission on
each of the copies.
Write a command to find all of the files which have been
accessed within the last 30 days.
find / -type f -atime -30 > December.files

This command will find all the files under root, which is /, with file
type is file. -atime -30 will give all the files accessed less than 30 days
ago. And the output will put into a file call December.files.
What is the most graceful way to get to run level single user
mode?
A: The most graceful way is to use the command init s.
If you want to shut everything down before going to single user mode
then do init 0 first and from the ok prompt do a boot -s.
What does the following command line produce? Explain each
aspect of this line.
$ (date ; ps -ef | awk {print $1} | sort | uniq | wc -l ) >> Activity.log

A: First lets dissect the line: The date gives the date and time as the
first command of the line, this is followed by the a list of all running
processes in long form with UIDs listed first, this is the ps -ef. These are
fed into the awk which filters out all but the UIDs; these UIDs are piped
into sort for no discernible reason and then onto uniq (now we see the
reason for the sort - uniq only works on sorted data - if the list is A, B,
A, then A, B, A will be the output of uniq, but if its A, A, B then A, B is
the output) which produces only one copy of each UID.
These UIDs are fed into wc -l which counts the lines - in this case the
number of distinct UIDs running processes on the system. Finally the
results of these two commands, the date and the wc -l, are appended
to the file "Activity.log". Now to answer the question as to what this
command line produces. This writes the date and time into the file
Activity.log together with the number of distinct users who have
processes running on the system at that time. If the file already exists,
then these items are appended to the file, otherwise the file is created.

Solaris interview questions


List the files in current directory sorted by size ?
- ls -l | grep ^- | sort -nr
List the hidden files in current directory ?
- ls -a1 | grep "^\."
Delete blank lines in a file ?
- cat sample.txt | grep -v ^$ > new_sample.txt
Search for a sample string in particular files ?
- grep .Debug. *.confHere grep uses the string .Debug. to search in all
files with extension..conf. under current directory.
Display the last newly appending lines of a file during
appendingdata to the same file by some processes ?
- tail .f Debug.logHere tail shows the newly appended data into
Debug.log by some processes/user.
Display the Disk Usage of file sizes under each directory in
currentDirectory ?
- du -k * | sort .nr (or) du .k . | sort -nr
Change to a directory, which is having very long name ?
- cd CDMA_3X_GEN*Here original directory name is .
.CDMA_3X_GENERATION_DATA..
Display the all files recursively with path under current
directory ?
- find . -depth -print
Set the Display automatically for the current new user ?
- export DISPLAY=`eval who am i | cut -d"(" -f2 | cut -d")" -f1`Here in
above command, see single quote, double quote, grave ascent is used.
Observe carefully.

Display the processes, which are running under yourusername ?


- ps .aef | grep MaheshvjHere, Maheshvj is the username.
List some Hot Keys for bash shell ? - Ctrl+l .
Clears the Screen. Ctrl+r . Does a search in previously given commands
in shell. Ctrl+u - Clears the typing before the hotkey. Ctrl+a . Places
cursor at the beginning of the command at shell. Ctrl+e . Places cursor at
the end of the command at shell. Ctrl+d . Kills the shell. Ctrl+z . Places
the currently running process into background.
Display the files in the directory by file size ?
- ls .ltr | sort .nr .k 5
How to save man pages to a file ?
- man <command> | col .b > <output-file>Example : man top | col .b >
top_help.txt
How to know the date & time for . when script is executed ?
- Add the following script line in shell script.eval echo "Script is executed
at `date`" >> timeinfo.infHere, .timeinfo.inf. contains date & time details
ie., when script is executed and history related to execution.
How do you find out drive statistics ?
- iostat -E
Display disk usage in Kilobytes ?
- du -k
Display top ten largest files/directories ?
- du -sk * | sort -nr | head
How much space is used for users in kilobytes ?
- quot -af
How to create null file ?
- cat /dev/null > filename1

Access common commands quicker ?


- ps -ef | grep -i $@
Display the page size of memory ?
- pagesize -a
Display Ethernet Address arp table ?
- arp -a
Display the no.of active established connections to localhost ?
- netstat -a | grep EST
Display the state of interfaces used for TCP/IP traffice ?
- netstat -i
Display the parent/child tree of a process ?
- ptree <pid> Example: ptree 1267
Show the working directory of a process ?
- pwdx <pid> Example: pwdx 1267
Display the processes current open files ?
- pfiles <pid> Example: pfiles 1267
Display the inter-process communication facility status ?
- ipcs
Display the top most process utilizing most CPU ?
- top .b 1
Alternative for top command ?
- prstat -a

1.

How do you take a single line of input from the user in a shell script?

2.

Write a script to convert all DOS style backslashes to UNIX style


slashes in a list of files.

3.

Write a regular expression (or sed script) to replace all occurrences


of the letter 'f', followed by any number of characters, followed by the
letter 'a', followed by one or more numeric characters, followed by
the letter 'n', and replace what's found with the string "UNIX".

4.

Write a script to list all the differences between two directories.

5.

Write a program in any language you choose, to reverse a file.

6.

What are the fields of the password file?

7.

What does a plus at the beginning of a line in the password file


signify?

8.

Using the man pages, find the correct ioctl to send console output to
an arbitrary pty.

9.

What is an MX record?

10.

What is the prom command on a Sun that shows the SCSI devices?

11.

What is the factory default SCSI target for /dev/sd0?

12.

Where is that value controlled?

13.

What happens to a child process that dies and has no parent


process to wait for it and what's bad about this?

14.

What's wrong with sendmail? What would you fix?

15.

What command do you run to check file system consistency?

16.

What's wrong with running shutdown on a network?

17.

What can be wrong with setuid scripts?

If the script begins "#!/bin/sh" and a link (symbolic or


otherwise) can be made to it with the name "-i", a setuid shell can
be immediately obtained because the script will be invoked:
"#!/bin/sh -i", ie: an interactive shell.
Many kernels suffer from a race condition which can allow you
to exchange the shellscript for another executable of your choice
between the times that the newly exec()ed process goes setuid, and
when the command interpreter gets started up. If you are persistent
enough, in theory you could get the kernel to run any program you
want.
The IFS bug: the IFS shell variable contains a list of characters
to be treated like whitespace by a shell when parsing command
names. By changing the IFS variable to contain the "/" character,
the command "/bin/true" becomes "bin true".

All you need do is export the modified IFS variable, install a


command called "bin" in your path, and run a setuid script which
calls "/bin/true". Then "bin" will be executed whilst setuid.

What value does spawn return?


18.

Ans:
Process ID

19.

Write a script to send mail from three other machines on the network
to root at the machine you're on. Use a 'here doc', but include in the
mail message the name of the machine the mail is sent from and the
disk utilization statistics on each machine?

20.

Why can't root just cd to someone's home directory and run a


program called a.out sitting there by typing "a.out", and why is this
good?

21.

What is the difference between UDP and TCP?

22.

What is DNS?

23.

What does nslookup do?


How do you create a swapfile?

24.

# mkdir /files
# mkfile 100m /files/swapfile
# swap -a /files/swapfile
# vi /etc/vfstab
(An entry is added for the swap file):
/files/swapfile
swap
# swap l

no

Another method (redhat)


$ dd if=/dev/zero of=/extra-swap bs=1024
count=1024
$ mkswap /extra-swap 1024

25.

How would you check the route table on a workstation/server?

26.

How do you find which ypmaster you are bound to?

27.

How do you fix a problem where a printer will cutoff anything over
1MB?

28.

What is the largest file system size in solaris? SunOS?

29.

What are the different RAID levels?

30.

Advantages/disadvantages of script vs compiled program.

31.

Name a replacement for PHP/Perl/MySQL/Linux/Apache and show


main differences.

32.

Why have you choosen such a combination of products?

33.

Differences between two last MySQL versions. Which one would you
choose and when/why?

34.

Main differences between Apache 1.x and 2.x. Why is 2.x not so
popular? Which one would you choose and when/why?

35.

Which Linux distros do you have experience with?

36.

Which distro you prefer? Why?

37.

Which tool would you use to update Debian / Slackware / RedHat /


Mandrake / SuSE ?

38.

You're asked to write an Apache module. What would you do?

39.

Which tool do you prefer for Apache log reports?

40.

Your portfolio. (even a PHP guest book may work well)

41.

What does 'route' command do?

42.

Differences between ipchains and iptables.

43.

What's eth0, ppp0, wlan0, ttyS0, etc.

44.

What are different directories in / for?

45.

Partitioning scheme for new webserver. Why?

46.

How do you list all files in a directory, including the hidden files?

47.

How do you find out all processes that are currently running?

48.

How do you find out the processes that are currently running or a
particular user?

49.

How do you kill a process?

50.

What would you use to view contents of the file?

51.

How can you gather statistics on a table?

52.

What would you use to edit contents of the file?

53.

What would you use to view contents of a large error log file?

54.

How do you log in to a remote Linux box?

56.

How do you get help on a Linux terminal?

57.

How do you list contents of a directory including all of its


subdirectories, providing full details and sorted by modification time?

58.

How do you create a symbolic link to a file (give some reasons of

doing so)?
59

What is a filesystem?

60.

How do you get its usage (a filesystem)?

61.

How do you check the sizes of all users home directories (one
command)?

62.

How do you check for processes started by user 'pat'?

63.

How do you start a job on background?

64.

What utility would you use to replace a string '2001' for '2002' in a
text file?

65.

What utility would you use to cut off the first column in a text file?

66.

How to copy file into directory?

67.

How to remove directory with files?

68.

What is the difference between internal and external commands?

69.

List the three main parts of an operating system command:

70.

What is the difference between an argument and an option (or


switch)?

71.

What is the purpose of online help?

72.

Name two forms of security.

73.

What command do you type to find help about the command who?

74.

What is the difference between home directory and working


directory?

75.

Which directory is closer to the top of the file system tree, parent
directory or current directory?

76.

Given the following pathname:


$ /business/acctg/payable/supplier/april
a) If you were in the directory called acctg, what would be the
relative pathname name for the file called april?
b) What would be the absolute pathname for april?

77.

78.

Suppose your directory had the following files:


help. 1 help.2 help.3 help.4 help.O1 help.O2 aid.O1 aid.O2 aid.O3
back. 1 back.2 back.3
a) What is the command to list all files ending in 2?
b) What is the command to list all files starting in aid?
c) What is the command to list all "help" files with one character
extension?
What are two subtle differences in using the more and the pg
commands?

79.

When is it better to use the more command rather than cat


command?

80.

What are two functions the move mv command can carry out?

81.

Name two methods you could use to rename a file.

82.

The soccer league consists of boy and girl teams. The boy file
names begin with B, the girl teams begin with G. All of these files are
in one directory called "soccer", which is your current directory:
Bteam.abc Bteam.OOl Bteam.OO2 Bteam.OO4
Gteam.win Gteam.OOl Gteam.OO2 Gteam.OO3
Write the commands to do the following:
a) rename the file Bteam.abc to Bteam.OO3.
b) erase the file Gteam. win after you have viewed the contents of
the file
c) make a directory for the boy team files called "boys", and one for
the girl team files called" girls"
d) move all the boy teams into the "boys" directory
e) move all the girl teams into the "girls" directory
f) make a new file called Gteam.OO4 that is identical to Gteam.OOl
g) make a new file called Gteam.OO5 that is identical to Bteam.OO2

83.
84.

85.

Draw a picture of the final directory structure for the "soccer"


directory, showing all the files and directories.
What metacharacter is used to do the following:
1.1 Move up one level higher in the directory tree structure
1.2 Specify all the files ending in .txt
1.3 Specify one character
1.4 Redirect input from a file
1.5 Redirect the output and append it to a file
Which of the quoting or escape characters allows the dollar sign ($)
to retain its special meaning?

86.

What is a faster way to do the same command?


mv fileO.txt newdir
mv filel.txt newdir
mv file2.txt newdir
mv file3.txt newdir

87.

List two ways to create a new file:

88.

What is the difference between > and >> operators?

89.

Write the command to do the following:


1 Redirect the output from the directory listing to a printer.
2 Add the file efg.txt to the end of the file abc.txt.
3 The file testdata feeds information into the file called program
4 Observe the contents of the file called xyz.txt using MORE.
5 Observe a directory listing that is fo

90.

How do you estimate file space usage?

91.

How can you see all mounted drives?

92.

How can you find a path to the file in the system?

93.

What Linux HotKeys do you know?

94.

What can you tell about the tar Command?

95.

What types of files you know?

96.

How to copy files from on PC to another on the same network?

97.

Please describe information below:


-rw-rw-r-- 1 dotpc dotpc 102 Jul 18 2003 file.buf
drwxr-xr-x 9 dotpc dotpc 4096 Oct 21 09:34 bin
lrwxrwxrwx 1 dotpc dotpc 20 Mar 21 15:00 client -> client-2.9.5
drwxrwxr-x 11 dotpc dotpc 4096 Sep 2 2005 client-2.8.9
drwxrwxr-x 7 dotpc dotpc 4096 Dec 14 12:13 data
drwxr-xr-x 12 dotpc dotpc 4096 Oct 21 09:41 docs
drwxr-xr-x 5 dotpc dotpc 4096 Dec 7 14:22 etc
drwxr-xr-x 11 dotpc dotpc 4096 Mar 21 15:54 client-2.9.5
-rw-r--r-- 1 dotpc dotpc 644836 Mar 22 09:53 client-2.9.5.tar.gz

98.

If you would like to run two commands in sequence what operators


you can use?

99.

How you will uncompress the file?

100
.

How do you execute a program or script, my_script in your current


directory?

101
.

How to find current time configuration in the file my_new.cfg?

102
.

What does grep() stand for?

103

What does the top command display?

104

How can you find configuration on linux?

105

How to find difference in two configuration files on the same


server?

106

What is the best way to see the end of a logfile.log file?

1. What are the main differences between Apache 1.x and 2.x?
2. What does the route command do?
3. What are the read/write/execute bits on a directory mean?
4. What does iostat do?
5. what does vmstat do?
6. What does netstat do?
7. What is the most graceful way to bring a system into single user mode?
8. How do you determine disk usage?
9. What is AWK?
10. What is SED?
11. What is the difference between binaries in /bin, and /usr/bin?

12. What is a dynamically linked file?


Ans 7: kill -TERM 1
Ans 8:
The disk usage can be determined by using the command , du. This command outputs
the number of kilobytes used by each sub-directory.
Ans 9:
AWK is a complete pattern scanning and processing language, it is most commonly
used as a Unix command-line filter to reformat the output of other commands.
For example, to print only the second and sixth fields of the date command (the
month and year) with a space separating them, at the Unix prompt, you would
enter:
date | awk {print $2 $6}

10. What is SED?


SED (which stands for Stream EDitor) is a simple but powerful computer
program used to apply various pre-specified textual transformations to a
sequential stream of text data.
It reads input files line by line, edits each line according to rules specified in its
simple language (the sed script), and then outputs the line.

11. What is the difference between binaries in /bin, and /usr/bin?


/bin - would contains the binaries frequently used by the normal user (as well as
system administrator)
/usr/bin - would contains the binaries rarely used by the normal user (as wel as
system administrator)
1. Under Solaris, there is no difference. /bin is a symbolic link pointing to /usr/bin.
Under Linux (RHAS3) /bin is seemingly for standard unix programs like vi, cp,
mv, rm which youd need in a single user environment where as /usr/bin contains

programs youd want for a multiuser environment. Keep in mind that


sometimes /usr is a different disk partition and when you start up in single user
mode you only have / mounted.
The /sbin directories are *supposed to* contain statically linked programs. This
mas morphed into the idea of bin for user programs, sbin for admin programs.

12. What is a dynamically linked file?


soft link (created with ln -s). Source and destination files will have the different
inode. If dest removed source will be available. If source removed dest also will
available but no where to go.
This is confusing because of the use of the word file. A dynamically linked
program is one that, when executed, loads shared libraries from /lib or /usr/lib in
order to execute. The idea is that most programs use many of the same functions,
so include a copy of a common function in *every* program on the file system.
Instead, the function is placed in a shared library and when the program starts
executing, the library is loaded which provides the program access to the function.
13. What is a statically linked file?
hard link (created with ln). Source and dest will have the same inode. Making two
different copies causes more disk space due to redundancy.
As above, confusing due to the use of the word file. A statically linked program
is one that contains all the information (libraries) it needs to run. It does not need to load
additional libaries in order to execute.
Mutex:
Short for mutual exclusion object. In computer programming, a mutex is a program
object that allows multiple program threads to share the same resource, such as file
access, but not simultaneously. When a program is started, a mutex is created with a
unique name. After this stage, any thread that needs the resource must lock the mutex
from other threads while it is using the resource. The mutex is set to unlock when the data
is no longer needed or the routine is finished.
INode:
a unique number associated with each filename. This number is used to look up an entry
in the inode table which gives information on the type, size, and location of the file and
the userid of the owner of the file.

how do you configure linux system as a router?


Enable packet forwarding For that we should
echo "1" > /proc/sys/net/ipv4/ip_forward
apply the above command
Make it permanent by adding "net.ipv4.ip_forward = 1"
to /etc/sysctl.conf

or
# /etc/sysctl.conf
enable ip packet forwarding
net.ipv4.ip_forward = 1

In IIS Version 6.0 Through application pool we can provide


different -2 applications for the client.
Is it right?
If yes then how to provide the application to the client
and what kind of application it can be ?
If you are running your IIS server with 2 different versions of
framework(1.1 & 2.0)you can create 2 different application pools and
point your application to the required framework you want to run.
yes it is correct The problem might be a application pool will be
associated with 2 different application that uses different frameworks.

What is Linux and why is it so popular?


Answer
Linux is an operating system that uses UNIX like Operating system. However, unlike UNIX, Linux is an open
source and free software. Linux was originally created by Linus Torvalds and commonly used in servers.
Popularity of Linux is because of the following reasons

It is free and open source. We can download Linux for free and customize it as per our needs.
It is very robust and adaptable.
Immense amount of libraries and utilities

What is Linux and why is it so popular?


Linux is a multiuser, multitask GUI based open source operating system developed by Linus Torvalds
Torvalds has invited the community to enhance the Linux kernel and thousands of system programmers
worked on to enhance.
Prior to Linux, there is UNIX. The desktop work stations from various companies were based on UNIX. Later
a numerous companies entered and each one of them had their own UNIX version. As the proprietary
authority is owned by each company and the lack of central authority weaken UNIX. As Linux is free and
runs on any PC platform it gained the popularity very quickly. The following are few more reasons for its
popularity:
- People who are familiar with UNIX can work on Linux with ease and comfort.
- People who want great control over network security and on operating system

What is LILO?
Answer
LILO is Linux Loader is a boot loader for Linux. It is used to load Linux into the memory and start the
Operating system. LILO can be configured to boot other operating systems as well. LILO is customizable,
which means that if the default configuration is not correct, it can be changed. Config file for LILO is
lilo.conf.

What is LILO?
LILO stands for Linux Loader which is a bootstrap program. LILO is a code snippet which loads PC BIOS
into the main memory at the time of starting the computer system. LILO handles the following tasks:
-Locating Linux kernel
-Identifying other supporting programs and loading them in the memory
-Staring Kernel
The selection of various kernel images and boot routines is supported by LILO. For this reason, LILO is
known as boot manager.

What is the difference between home directory and working directory?


Answer
Home directory is the default working directory when a user logs in. On the other hand, working directory is
the users current directory. Working directory can be changed. It can be changed using cd command.
Home directory in Linux contains users personal data, configuration files, settings of a software etc. The
content of home directory is private and the user has a complete control of it.

What is the difference between home directory and working directory?


Home Directory: Every user will have one home directory and will have complete control over it. On login,
home is the default working directory for the user. It contains the configuration files and responsible for login
and logout of the user.
Working directory: The directory in which the user is working currently is known as working directory. The
home may also be the working directory, if the user is working in it.

What is the difference between internal and external commands?


Answer
Internal commands are commands that are already loaded in the system. They can be executed any time
and are independent. On the other hand, external commands are loaded when the user requests for them.
Internal commands dont require a separate process to execute them. External commands will have an
individual process. Internal commands are a part of the shell while external commands require a Path. If the
files for the command are not present in the path, the external command wont execute.

What is the difference between internal and external commands?


The commands that are directly executed by the shell are known as internal commands. No separate
process is there to run these commands.
The commands that are executed by the kernel are knows as external commands. Each command has its
unique process id.

Explain the difference between a static library and a dynamic library?


Answer
Static libraries are loaded when the program is compiled and dynamically-linked libraries are loaded in while
the program is running. Dynamic libraries save the RAM space as against the static library because linking
to static libraries includes the actual code for the library function(s)/procedure(s) with the executable. DLL
code is kept at one location and is usually shared among all the processes that use the DLL.

Explain the difference between a static library and a dynamic library.


Static library has functionality that bound to a static program at compile time. Every static program has its
own copy of library.
Dynamic libraries are loaded into the memory and binds at run time. The external functionality is accessed
at runtime. This process reduces the overall footprint of memory.

What is LD_LIBRARY_PATH?
Answer
LD_LIBRARY_PATH is an environment variable. It is used for debugging a new library or a non standard
library. It is also used for which directories to search. Path to search for directories needs to given. The
variable can be set by using setenvLD_LIBRARY_PATH--$PATH
Linux - What is LD_LIBRARY_PATH? - May 11, 2009 at 14:00 pm by Vidya Sagar

What is LD_LIBRARY_PATH?
LD_LIBRARY_PATH is an environment variable. This is used to search for the shared objects / dynamic
libraries by the operating system for extendable functionality at runtime.

What is the file server in Linux server?


Answer
File server is used for file sharing. It enables the processes required fro sharing. All the files can be stored at
a centralized location. Linux uses Samba to view the files on the server. Files on this server are backed up
on a regular basis. Rights can be also assigned for the files on a file server.

What is the file server in Linux server?


A file server is dedicated for persisting files in a location from which the networked systems can access.
Certain access privileges can be set for files.
Linux has software named as samba which allows the files to be shared, viewed and edited on any remote
system which may has Windows 9 x/ME/2000/NT or Macintosh computer systems. These files on the file
server are backed up from time to time. If a file is deleted inadvertently, the file can be recovered from the
backup tape.

What is NFS? What is its purpose?


Answer
NFS is Network File system. It is a file system used for sharing of files over a network. Other resources like
printers and storage devices can also be shared. This means that using NFS files can be accessed
remotely. Nfs command in linux can be used to achieve this.
Purpose of NFS:

NFS can be used for sharing of files remotely.


Data can be stored on a single machine and still remain accessible to others over the network.
Reduction of the number of removable media drives throughout the network since they can be
shared.

What is NFS? What is its purpose?


NFS stands for Network File System. NFS is used to partition a disk on a remote machine disk. NFS allows
a quick way of file sharing.
The unwanted people access potential is provided by NFS to access hard drive in a network. So that an
unauthorized user can not access ones email, delete the files. File services from windows can be accessed.
In other words files from one operating system can be shared by another using NFS.

How do I send email with linux?


Answer
Email can be sent in Linux using the mail command.
Mail [options] [users]
Options include: -s for subject, -c for carbon copy, -b for blind carbon copy
E.g. mail user_name s hello

How do I send email with Linux?


Linux supports to work with sending mails using a set of commands called as mail commands. The
command to send email is mail. The mail command is used to send and receive emails.
Syntax:
mail [options] [users]
Options are: -s,-c,-b
Where s for subject, -c for copy and b for blind carbon copy
Ex: mail username s Reports are needed
It prompts displays the subject as Reports are needed.
Similarly if c and b is given the mail will be sent to the corresponding recipients.

Explain RPM (Red Hat Package Manager) features.


Answer
RPM is a package managing system (collection of tools to manage software packages).
Features:

RPM can verify software packages.


RPM can be served as a powerful search engine to search for softwares.
Components, softwares etc can be upgraded using RPM without having to reinstall them
Installing, reinstalling can be done with ease using RPM
During updates RPM handles configuration files carefully, so that the customization is not lost.

Explain RPM (Red Hat Package Manager) features.


RPM is a powerful software management tool for installing, uninstalling, verifying, querying and updating
software packages. RPM is a straight forward program to perform the above software management tasks. It
is available with Fedora, Suse, CentOS, Mandriva Linux and other version of Linux.

What is Kernel? Explain the task it performs.


Answer
Kernel is used in UNIX like systems and is considered to be the heart of the operating system. It is
responsible for communication between hardware and software components. It is primarily used for
managing the systems resources as well.

Kernel Activities:

The Kernel task manager allows tasks to run concurrently.


Managing the computer resources: Kernel allows the other programs to run and use the resources.
Resources include i/o devices, CPU, memory.
Kernel is responsible for Process management. It allows multiple processes to run simultaneously
allowing user to multitask.
Kernel has an access to the systems memory and allows the processes to access the memory
when required.
Processes may also need to access the devices attached to the system. Kernel assists the
processes in doing so.
For the processes to access and make use of these services, system calls are used.

What is Kernel? Explain the task it performs.


Kernel is the component that is responsible for managing the resources of a computer system.
The tasks are:
- Provides the abstraction level for resources such as memory, processors, and I/O devices.
-Performs inter process communication
-Responds to system calls
-Provides methods for synchronization and communication between processes.

What is Linux Shell? What is Shell Script?


Answer
Linux shell is a user interface used for executing the commands. Shell is a program the user uses for
executing the commands. In UNIX, any program can be the users shell. Shell categories in Linux are:
Bourne shell compatible, C shell compatible, nontraditional, and historical.
A shell script, as the name suggests, is a script written for the shell. Script here means a programming
language used to control the application. The shell script allows different commands entered in the shell to
be executed. Shell script is easy to debug, quicker as compared to writing big programs. However the
execution speed is slow because it launches a new process for every shell command executed. Examples of
commands are cp, cn, cd.

What is Linux Shell? What is Shell Script?


Linux shell is the user interface to communicate with Linux operating system. Shell interprets the user
requests, executes them. Shell may use kernel to execute certain programs. Shell Script: A shell script is a
program file in which certain Linux commands are placed to execute one after another. A shell script is a flat
text file. Shell scripts are useful to accept inputs and provide output to the user. Everyday automation
process can be simplified by a shell script.

What are Pipes? Explain use of pipes.


Answer
A pipe is a chain of processes so that output of one process (stdout) is fed an input (stdin) to another. UNIX
shell has a special syntax for creation of pipelines. The commands are written in sequence separated by |.
Different filters are used for Pipes like AWK, GREP.

e.g. sort file | lpr ( sort the file and send it to printer)
Uses of Pipe

Several powerful functions can be in a single statement


Streams of processes can be redirected to user specified locations using >

What are Pipes? Explain use of pipes.


Pipe is a symbol used to provide output of one command as input to another command. The output of the
command to the left of the pipe is sent as input to the command to the right of the pipe. The symbol is |.
For example:
$ cat apple.txt | wc
In the above example the output of apple.txt file will be sent as input for wc command which counts the no.
of words in a file. The file for which the no. of words counts is the file apple.txt.
Pipes are useful to chain up several programs, so that multiple commands can execute at once without
using a shell script.

Explain trap command, shift Command, getopts command of linux.


Answer
Trap command: controls the action to be taken by the shell when a signal is received.
Trap [OPTIONS] [ [arg] signspec..]
Arg is the action to be taken or executed on receiving a signal specified in signspec.
e.g. trap rm $FILE; exit // exit (signal) and remove file (action)
Shift Command: Using shift command, command line arguments can be accessed. The command causes
the positional parameters shift to the left. Shift [n] where n defaults to 1. It is useful when several parameters
need to be tested.
Getopts command: this command is used to parse arguments passed. It examines the next command line
argument and determines whether it is a valid option
Getopts {optstring} {variable1}. Here, optsring contains letters to be recognized if a letter is followed by a
colon, an argument should be specified. E.g (whether the argument begins with a minus sign and is followed
by any single letter contained inside options ) If not, diagnostic messages are shown. It is usually executed
inside a loop.

Explain trap command; shift Command, getopts command of linux.


trap command is used to catch a signal that is sent to a process. An action is taken based on the signal by
using the action which is defined in the trap command instead of taking the default effect on the process.
Example:
$ trap echo interrupt signal received INT.

shift command is used to replace the parameters that were sent from command line. For example
$ shift will replace $1 by $2
getopts command is used for the purpose of parsing positional parameters.

What Stateless Linux server? What feature it offers?


Answer
A stateless Linux server is a centralized server in which no state exists on the single workstations. There
may be scenarios when a state of a partilcuar system is meaningful (A snap shot is taken then) and the user
wants all the other machines to be in that state. This is where the stateless Linux server comes into picture.
Features:

It stores the prototypes of every machine


It stores snapshots taken for those systems
It stores home directories for those systems
Uses LDAP containing information of all systems to assist in finding out which snapshot (of state)
should be running on which system.

What Stateless Linux server? What feature it offers?


Stateless linux is a way how a system is to run and be managed. Being a stateless system, a system should
be able to be replaced at any time with or without local storage media. In case of hard drive crash, the
command resync can be used to a new drive. If server goes offline, a new virtual instance that is running the
OS image off of the network storage.

What does nslookup do? Explain its two modes.


Answer
Nslookup is used to find details related to a Domain name server. Details like IP addresses of a machine,
MX records, servers etc. It sends a domain name query packet to the corresponding DNS.
Nslookup has two modes. Interactive and non interactive. Interactive mode allows the user to interact by
querying information about different hosts and domains.
Non interactive mode is used to fetch information about the specified host or domain.
Interactive mode:
Nslookup [options] [server]

What does nslookup do? Explain its two modes.


Nslookup is a program used to find information about internet Domain Name server.
The two modes of nslookup are: Interactive and non-interactive.
Using interactive mode user can query the name servers for the information pertaining to hosts and
domains.

Using non-interactive mode the user can just print the name and requested information of a host.

What is Bash Shell?


Answer
Bash is a free shell for UNIX. It is the default shell for most UNIX systems. It has a combination of the C and
Korn shell features. Bash shell is not portable. any Bash-specific feature will not function on a system using
the Bourne shell or one of its replacements, unless bash is installed as a secondary shell and the script
begins with #!/bin/bash. It supports regular and expressions. When bash script starts, it executes commands
of different scripts.

What is Bash Shell?


Bash stands for "Bourne Again Shell. A shell is the user interface. Bash is more convenient shell for users
among others. The scripts written in Bash are portable among machines, distributions and even operating
systems.

Explain some Network-Monitoring Tools in Linux: ping, traceroute, tcpdump, ntop


Answer
Network monitoring tools are used to monitor the network, systems present on the network, traffic etc.
Ping: Ping command is used to check if the system is in the network or not. To check if the host is
operating.
e.g. ping ip_address
When the command is executed, it returns a detailed summary of the host. Packets sent, received, lost by
estimating the round trip time.
Traceroute: the command is used to trace the path taken by the packet across a network. Tracing the path
here means finding out the hosts visited by the packet to reach its destination. This information is useful in
debugging. Roundtrip time in ms is shown for every visit to a host.
Tcpdump: commonly used to monitor network traffic. Tcdump captures and displays packet headers and
matching them against criteria or all. It interprets Boolean operators and accepts host names, ip address,
network names as arguments.
Ntop: Network top shows the network usage. It displays summary of network usage by machines on the
network in a format as of UNIX top utility. It can also be run in web mode, which allows the display to be
browsed with a web browser. It can display network traffic statistics, identify host etc. Interfaces are available
to view such information.

Explain some Network-Monitoring Tools in Linux: ping, traceroute, tcpdump, ntop


ping: Used to check whether the system is in the network or not and sends Internet Control Message
Protocol ECHO_REQUEST packets to the hosts of network.
traceroute: Prints the route packets which were taken by the network host. traceroute utilizes the internet
protocols time to live field and elicits an ICMP TIME_EXCEEDED response. This response is elicited from
every gateway including the path to one of the hosts.

tcpdump: To dump traffic over a network tcpdump command is used. The headers of the packets over a
network interface are printed if the given Boolean expression is true. ntop: Network top program. It displays
the summary of network usage of systems over network in a format which is reminiscent of unix top utility. If
used in web mode, it displays the result on the web browser.

How does the linux file system work?


Answer
Linux file structure is a tree like structure. It starts from the root directory, represented by '/', and then
expands into sub-directories. All the partitions are under the root directory. If a partition is mounted (The
mount point defines the place of a particular data set in the file system) anywhere apart from a device, the
system is not aware of the existence of that partition or device. Directories that are only one level below the
root directory are often preceded by a slash, to indicate their position.
Explain file system of linux. The root "/" filesystem, /usr filesystem, /var filesystem, /home
filesystem, /proc filesystem.
Answer
Root "/" file system: The kernel needs a root file system to mount at start up. The root file system is
generally small and should not be changed often as it may interrupt in booting. The root directory usually
does not have the critical files. Instead sub directories are created. E.g. /bin (commands needed during
bootup), /etc (config files) , /lib(shared libraries).
/usr filesystem : this file system is generally large as it contains the executable files to be shared amongst
different machines. Files are usually the ones installed while installing Linux. This makes it possible to
update the system from a new version of the distribution, or even a completely new distribution, without
having to install all programs again. Sub directories include /bin, /include, /lib, /local (for local executables)
/var filesystem : this file system is specific to local systems. It is called as var because the data keeps
changing. The sub directories include /cache/man (A cache for man pages), /games (any variable data
belong to games), /lib (files that change), /log (log from different programs), /tmp (for temporary files)
/home filesystem: - this file system differs from host to host. User specific configuration files for applications
are stored in the user's home directory in a file. UNIX creates directories for all users directory. E.g
/home/my_name. Once the user is logged in ; he is placed in his home directory.
/proc filesystem : this file system does not exist on the hard disk. It is created by the kernel in its memory to
provide information about the system. This information is usually about the processes. Contains a hierarchy
of special files which represent the current state of the kernel .Few of the Directories include /1 (directory
with information about process num 1, where 1 is the identification number), /cpuinfo (information about
cpu), /devices (information about devices installed), /filesystem (file systems configured), /net (information
about network protocols), /mem (memory usage)

How does the Linux file system work?


At the time of installation of Linux, a file system is assigned and persists in the hard disk. This file system
structure resembles a tree.
A file can be a list of names and numbers or executable programs. Linux treats every program as a file.
Linux treats directories and computer components also as files.
A file could be a list of names and numbers, a cheesecake recipe, or an executable program. But under
Linux, everything is a file. In addition to data and executable files, Linux treats directories and even the
various components of your computer as files. It could be a keyboard, console, and printer, RAM or ROM.
These are referred as special files known as devices. These files are available in /dev directory. Linux
performs the communication with these devices by simply reading from or writing to these special files.

What are the process states in Linux?


Answer
Process states in Linux:

Running: Process is either running or ready to run


Interruptible: a Blocked state of a process and waiting for an event or signal from another process
Uninterruptible: a blocked state. Process waits for a hardware condition and cannot handle any
signal
Stopped: Process is stopped or halted and can be restarted by some other process
Zombie: process terminated, but information is still there in the process table.

Linux - What are the process states in Linux? - August 21, 2008 at 22:00 pm by Rajmeet Ghai

What are the process states in Linux?


The following are the process states:
1. Running: This is a state where a process is either in running or ready to run.
2. Interruptible: This state is a blocked state of a process which awaits for an event or a signal from another
process
3. Uninterruptible: It is also a blocked state. The process is forced to halt for certain condition that a
hardware status is waited and a signal could not be handled.
4. Stopped: Once the process is completed, this state occurs. This process can be restarted
5. Zombie: In this state, the process will be terminated and the information will still be available in the
process table.

What is a zombie?
Answer
Zombie is a process state when the child dies before the parent process. In this case the structural
information of the process is still in the process table. Since this process is not alive, it cannot react to
signals. Zombie state can finish when the parent dies. All resources of the zombie state process are cleared
by the kernel

What is a zombie?
Dead process is called a zombie. The processes will die eventually at the time when they become zombies.
A dead process cannot be killed. The parent process will send a signal to the operating system that is not
needed the zombie by using wait () system call.

Explain each system calls used for process management in linux.


Answer
System calls used for Process management:

Fork () :- Used to create a new process


Exec() :- Execute a new program
Wait():- wait until the process finishes execution
Exit():- Exit from the process
Getpid():- get the unique process id of the process
Getppid():- get the parent process unique id

Nice():- to bias the existing property of process

Explain each system calls used for process management in linux.


Process management uses certain system calls. They are explained below.
1. To create a new process fork () is used.
2. To run a new program = exec () is used.
3. To make the process to wait = wait () is used.
4. To terminate the process exit () is used.
5. To find the unique process id getpid () is used.
6. To find the parent process id getppid () is used.
7. To bias the currently running process property nice () is used.
Which file defines all users on your system?
Choose one:
a. /etc/passwd
b. /etc/users
c. /etc/password
d. /etc/user.conf
Answer: a
The /etc/passwd file contains all the information on users who may log into your system. If 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 -rf
C) rmdir
D) rd
E) rd -rf
Answer(s): B, C - You can use rmdir or rm -rf to delete a directory. Answer a is incorrect,
because the rm command without any specific flags will not delete a directory, it will only
delete files. Answers d and e point to a non-existent command.
Which partitioning tool is available in all distributions?
A) Disk Druid
B) fdisk
C) Partition Magic
D) FAT32
E) System Commander
Answer(s): B - The fdisk partitioning tool is available in all Linux distributions. Answers a, c,
and e all handle partitioning, but do not come with all distributions. Disk Druid is made by Red
Hat and used in its distribution along with some derivatives. Partition Magic and System
Commander are tools made by third-party companies. Answer d is not a tool, but a file system
type. Specifically, FAT32 is the file system type used in Windows 98.
Which partitions might you create on the mail server's hard drive(s) other than the
root, swap, and boot partitions?
[Choose all correct answers]
A) /var/spool
B) /tmp

C) /proc
D) /bin
E) /home
Answer(s): A, B, E - Separating /var/spool onto its own partition helps to ensure that if
something goes wrong with the mail server or spool, the output cannot overrun the file
system. Putting /tmp on its own partition prevents either software or user items in the /tmp
directory from overrunning the file system. Placing /home off on its own is mostly useful for
system re-installs or upgrades, allowing you to not have to wipe the /home hierarchy along
with other areas. Answers c and d are not possible, as the /proc portion of the file system is
virtual-held in RAM-not placed on the hard drives, and the /bin hierarchy is necessary for basic
system 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 backup
Choosing which files to backup is the first step in planning your backup strategy.
What utility can you use to automate rotation of logs?
Answer: logrotate
The logrotate command can be used to automate the rotation of various logs.
In order to display the last five commands you have entered using the history
command, you would type ___________ .
Answer: history 5
The history command displays the commands you have previously entered. By passing it an
argument of 5, only the last five commands will be displayed.
What command can you use to review boot messages?
Answer: dmesg
The dmesg command displays the system messages contained in the kernel ring buffer. By
using this command immediately after booting your computer, you will see the boot messages.
What is the minimum number of partitions you need to install Linux?
Answer: 2
Linux 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?
Answer: /var/log/messages
By default, the main system log is /var/log/messages.
Of the following technologies, which is considered a client-side script?
A) JavaScript
B) Java
C) ASP
D) C++
Answer: A - JavaScript is the only client-side script listed. Java and C++ are complete
programming languages. Active Server Pages are parsed on the server with the results being
sent to the client in HTML

Вам также может понравиться