Posted by: Mangesh_Linux_Administrator | July 20, 2010


What is ‘inode’?
ANS: When a file system is created, data structures that contain information about files are created. Each file has an inode and is identified by an inode number (often “i-number” or even shorter, “ino”) in the file system where it resides.
Inodes store information on files such as user and group ownership, access mode (read, write, execute permissions)
and type of file. There is a fixed number of inodes, which indicates the maximum number of files each filesystem can hold.
A file’s inode number can be found using the ls -i command, while the ls -l command will retrieve inode information.
This is description of inode information  which it contain:
* The length of the file in bytes.
* Device ID (this identifies the device containing the
* The User ID of the file’s owner.
* The Group ID of the file.
* The file mode, which determines what users can read,
write, and execute the file.
* Timestamps telling when the inode itself was last
modified (ctime, change time), the file content last
modified (mtime, modification time), and last accessed
(atime, access time).
* A reference count telling how many hard links point to
the inode.
* Pointers to the disk blocks that store the file’s content

***why do you need to have a swap file system?
Linux systems run better with a swap file, even when you have plenty of RAM. The technical reason is that it’s
sometimes easier to swap out “dirty” data than it is to write it to peoperly to the disk.
In general, Linux will fill up as much of your memory as it can, in the hope that those little bits might be needed. You
might as well use it (RAM). If it’s all filled up, then at some point, you’re going to have to free
some of it up.
Data may be sitting around in RAM waiting to be written to disk in an efficient and orderly process.
This is called “dirty” data. Sometimes, just because of the way it works,
it’s faster and easier to leave the “dirty data” in memory, but transfer it to swap, thereby freeing physical RAM.
Ideally, it would be best to just free it from RAM entirely, but this gives the kernel another option.

***What is the difference between Hard Link and Soft Link in Linux?
Hard Link is a mirror copy of the original file. Hard links share the same inode. Any changes made to the original or Hard linked file will reflect the other. Even if you delete any one of the files, nothing will happen to the other.
Hard links can’t cross file systems.

Soft Link is a symbolic link to the original file. Soft Links will have a different Inode value.
A soft link points to the original file. If you delete the original file, the soft link fails. If you delete the soft link, nothing will happen.
Soft links can cross file systems.

**How to put a job in background & bring it to foreground?
Answer:  we can put a job in background by putin & symbol at the end
of the line on the command promt.
Example: #cp -r /var/* /tmp &
We can pull the background job in the foreground by fg  command and pid, before that we have to get the process ID
how to get the process ID see below example.
Example: #jobs
1+    cp -r /var/* /tmp &
now u can get the job ID then u can bring the job in foreground see below example
Example: #fg 1
cp -r /var/* /tmp —-now its show like this

***how do I find out zombie process?
# ps aux | awk ‘{ print $8 ” ” $2 }’ | grep -w Z

Tell me command which is use for create quota database in Linux. –
-quotacheck -cug /home
-1- quotacheck -vu

what is the command for finding the higest memory occupied file in linux?
#du -sh * | sort -nr

Without using w command how can Iknow that who are users logged in and what they are doing and whether they are idle or running mode?

Without Using $date -dyesterday. How I get the yesterday’s date ?
$date –date=’1 day ago’

Difference between nfs soft and hard mouniting points?
hard mount option:- If the client fails to access theserver,then connection hang it, after the system up then it access the server.
Soft:- If the client failed to connect the server it
immediately gives the error report, and close the connection.

why LINUX is fast processing software and why it does not get viruses.
All are consider as ,Files are not executing automatically. & All the files systems are set on different different folders  so….so its really difficult to interlink all the folders …to operate…for the hackers….

how to find the 51th record of a file containing 100 records in unix.
-head -n 51 filename |tail -1

What Is the command to change a file’s creation time. means one file is created at the time 15:19 then time should br changed to 14:14
-$ touch -m 02281414 emp.lst ; ls -l emp.lst   (The -m & -a options chng the modifications & access times)
-rw-r–r– 1 kumar  metal  870 Feb 28 14:14 emp.lst

What command can you use to review boot messages?
Answer: dmesg

When do you need a virtual hosting ?
The term Virtual Host refers to the practice of maintaining more than one server on one machine, as differentiated by their apparent hostname. For example, it is often desirable for companies sharing a web server to have their own domains, with web servers accessible as and, without requiring the user to know any extra path information.

In which port telnet is listening?

How to block and openrelay ?
Open relays are e-mail servers that are configured to accept and transfer e-mail on behalf of any user anywhere, including unrelated third parties.
The qmail-smtpd daemon will consult the rcpthosts control file to determine valid destination addresses, and reject anything else.

What is sandwitch configuration in qmail ?
Qmail + Clam + Spamassassin- This is normally called Sandwitch configuration in qmail.

Advantages of Qmail ?
More secure, better designed, modular, faster, more reliable, easier to configure, don’t have to upgrade it every few months or worry about being vulnerable to something due to some obscure feature being enabled
qmail supports host and user masquerading, full host hiding, virtual domains, null clients, list-owner rewriting, relay control, double-bounce recording, arbitrary RFC 822 address lists, cross-host mailing list loop detection, per-recipient checkpointing, downed host backoffs, independent message retry schedules, etc. qmail also includes a drop-in “sendmail” wrapper so that it will be used transparently by your current UAs.

What is the difference between POP3 and IMAP ?
The Difference
POP3 works by reviewing the inbox on the mail server, and downloading the new messages to your computer. IMAP downloads the headers of the new messages on the server, then retrieves the message you want to read when you click on it.

When using POP3, your mail is stored on your PC. When using IMAP, the mail is stored on the mail server. Unless you copy a message to a “Local Folder” the messages are never copied to your PC.

Scenarios of Use
· You only check e-mail from one computer.
· You want to remove your e-mail from the mail server.
· You check e-mail from multiple locations.
· You use Webmail.

How to drop packets using iptables ?
Iptables -A INPUT -s xx.xx.xx.xx -d xx.xx.xx.xx -j DROP

Daily routines of Linux Administrators ?
*.Check the health of servers
*.Check for updates
*.Check the Backup
*.Check with the trouble ticketing system for any unread ticket.
*.Troubleshoot if there any problem
*.Installation of new servers, if needed.
*.Report to the Boss

How to take the Dump of a MySQL Database ?
Mysqldump databasename > dumpname

How to know the CPU usage of each process ?
Top, uptime

How to bind another IP in a NIC ?
Copy the contents eth0 to eth1, and change the ipaddress. Restart the network. .

Transparently proxy all web-surfing through Squid box
iptables -t nat -A PREROUTING -i eth1 -tcp –dport 80 -j DNAT –to
iptables -t nat -A PREROUTING -i eth1 -tcp –dport 80 -j DNAT –to

Transparently redirect web connections from outside to the DMZ web server.
iptables -t nat -A PREROUTING -i eth0 -d -dport 80 -j DNAT –to

Howto Activate the forwarding
echo 1 >/proc/sys/net/ipv4/ip_forward

Kill spoofed packets
for f in /proc/sys/net/ipv4/conf/*/rp_filter; do
echo 1 > $f
$iptables -A LDROP –proto tcp -j LOG –log-level info \ –log-prefix “TCP Drop”

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 let’s 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 it’s 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.

want to print out a text file called vacations however the lines are of varying length. What text filter could you use to even out the length of the lines?

The fmt text utility attempts to make all the lines the same lenght by joining or splitting lines.

You need to locate a file called salesdata that one of your user’s created in his home directory but you do not know which one. How could you use the find command to locate this file?
Answer: find /home -name salesdata
When using the find command to locate a file by name you must specify the starting place in the directory heirarchy and the -name option to specify the file to search for.

What command would you type to use the cpio to create a backup called backup.cpio of all the users’ home directories?
Answer: find /home | cpio -o > backup.cpio
The find command is used to create a list of the files and directories contained in home. This list is then piped to the cpio utility as a list of files to include and the output is saved to a file called backup.cpio.

You want to create a compressed backup of the users’ home directories so you issue the command gzip /home/* backup.gz but it fails. The reason that it failed is that gzip will only compress one _______ at a time.
Answer: file
The gzip utility cannot compress multiple files in a single operation.

You have three files in the /home/ben/memos directory called letters, tom, betty. How could you determine each file’s type by issuing only one command?
Answer: file letters tom betty

The file utility will display the file’s type for each filename that is passed as an argument.

In order to display the last five commands you have entered using the fc command, you would type ___________.
Answer: fc -5
The fc command can be used to edit or rerun commands you have previously entered. To specify the number of commands to list, use -n.

Each command has two types of output. There are standard output and standard __________.
Answer: error
By default, each command sends its result as standard output and any error messages as standard error.

What can you type at a command line to determine which shell you are using?
Answer: echo $SHELL
The name and path to the shell you are using is saved to the SHELL environment variable. You can then use the echo command to print out the value of any variable by preceding the variable’s name with $. Therefore,
typing echo $SHELL will display the name 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
Answer: E – You can use an NFS server to provide the distribution installation materials to the machine on which you are performing the installation. Answers a, b, c, and d are all valid items but none of them are file servers. Inetd is the superdaemon which controls all intermittently used network services. The FSSTND is the Linux File System Standard. DNS provides domain name resolution, and NNTP is the transfer protocol for usenet news.

What would you type to send the last 20 lines of a text file to STDIN?
A) end -n 20 filename
B) last -n 20 filename
C) head -20 filename
D) end -20 filename
E) tail -20 filename
Answer: E – Use the command tail -20 filename to see the last 20 lines of a file. The answers for a and d both point to an invalid command. The answer for b points to a valid command. Typing this answer in with a valid file name will even give you some output. However, the last command tells you who is logged in, it does not actually list the contents of any file named in the command. The answer for c, the head command, is used to look at the beginning of a file, not the end.

Which command works in almost all distributions to create a boot disk?
A) mkboot
B) make bootdsk
C) make boot
D) mkbootdsk
E) mkbootdisk
Answer: E – The mkbootdisk command creates a boot disk. Answers b and c are incorrect. The make package is used to compile software, not create boot disks. Answers a and d point to invalid commands.

Which command do you use to change runlevels?
A) initlevel
B) runlevel
C) level
D) run
E) init
Answer: E – The command used to change runlevels is init. Answers a, c, and d point to invalid commands. Answer b is a valid command, but does not set the current runlevel. The runlevel command displays the current runlevel, and the one that was used directly before entering this one.

You have a new, empty hard drive that you will use for Linux. What is the first step you use.
Choose one:
a. Create an extended partition to be used for data.
b. Format the hard drive to use the ext2 filesystem.
c. Create a swap partition of type 82.
d. Create a primary partition using fdisk.
Answer: d
You must always first create a primary partition. Operating systems, including Linux, can only be booted from a primary partition.

You have configured logrotate to rotate your logs weekly and keep them for eight weeks. You are running our of disk space. What should you do?
Choose one:
a. Quit using logrotate and manually save old logs to another location.
b. Reconfigure logrotate to only save logs for four weeks.
c. Configure logrotate to save old files to another location.
d. Use the prerotate command to run a script to move the older logs to another location.
Answer: d
You can use the prerotate command to run a script before logs are rotated. You could have this script move the older logs to another location before rotation occurs.
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 of the file dog.
c. The contents of the file dog and any error messages.
d. Nothing as all output is saved to the file cat.
Answer: d
When you use &> for redirection, it redirects both the standard output and standard error. The output would be saved to the file cat.
You have a directory with the following permissions

drw-rw–w- 1 root admin 7202 Sep 17 9:10 administration and need to give everyone except root read only access to it. Which of the following commands will accomplish this?
Choose one:
a. chmod uo=r administration
b. chmod ug+r administration
c. chmod uo+r administration
d. chmod ug=r administration
Answer: d
When using symbols, the equal sign explicitly sets permissions and revokes any pre-existing permissions.

You want to know how much space is being occupied by your user’s home directories. Which of the following will provide you with this information?
Choose one:
a. du -l /home
b. du -b /home
c. du -m /home
d. du -c /home
Answer: d
Using the -c option with the du command will show the grand total of used space for the designated directory.

You have entered the following cronjob. When will it run? 15 * * * 1,3,5 myscript
Choose one:
a. at 15 minutes after every hour on the 1st, 3rd and 5th of each month.
b. at 1:15 am, 3:15 am, and 5:15 am every day
c. at 3:00 pm on the 1st, 3rd, and 5th of each month
d. at 15 minutes after every hour every Monday, Wednesday, and Friday
Answer: d
This would run at 15 minutes after the hour on every Monday, Wednesday, and Friday of every month no matter what the date.

You need to see the last fifteen lines of the files dog, cat and horse. What command should you use?
Answer: 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?
Answer: 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.
Answer: zcat
The zcat utility allows you to examine the contents of a compressed
file much the same 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?
Answer: which
The which command searches your path until it finds a command that matches the command you are looking 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.
Answer: whatis
The whatis command displays a summary line from the man page for the
specified command.

You wish to create a link to the /data directory in bob’s 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.
Answer: Use the -F option
In order to create a link to a directory you must use the -F option.

When you issue the command ls -l, the first character of the resulting display represents the file’s ___________.
Answer: type
The first character of the permission block designates the type of file that is being displayed.

What utility can you use to show a dynamic listing of running processes?
Answer: top
The top utility shows a listing of all running processes that is dynamically updated.

Where is standard output usually directed?
Answer: to the screen or display
By default, your shell directs standard output to your screen or display.

You want to create a compressed backup of the users’ home directories. What utility should you use?
Answer: tar
You can use the z modifier with tar to compress your archive at the same time as creating it.

You wish to restore the file memo.ben which was backed up in the tarfile MyBackup.tar. What command should you type?
Answer: tar xf MyBackup.tar memo.ben
This command uses the x switch to extract a file. Here the file memo.ben will be restored from the tarfile MyBackup.tar.
You need to view the contents of the tarfile called MyBackup.tar. What command would you use?
Answer: tar tf MyBackup.tar
The t switch tells tar to display the contents and the f modifier specifies which file to examine.

What daemon is responsible for tracking events on your system?
Answer: syslogd
The syslogd daemon is responsible for tracking system information and saving it to specified log files.

You have a file called phonenos that is almost 4,000 lines long. What text filter can you use to split it into four pieces each 1,000 lines long?
Answer: split
The split text filter will divide files into equally sized pieces. The default length of each piece is 1,000 lines.

You would like to temporarily change your command line editor to be vi. What command should you type to change it?
Answer: set -o vi
The set command is used to assign environment variables. In this case, you are instructing your shell to assign vi as your command line editor. However, once you log off and log back in you will return to the previously defined command line editor.

What account is created when you install Linux?
Answer: root
Whenever you install Linux, only one user account is created. This is the superuser account also known as root.

What command should you use to check the number of files and disk space used and each user’sdefined quotas?
Answer: repquota
The repquota command is used to get a report on the status of the quotas you have set including the amount of allocated space and amount of used space.

In order to run fsck on the root partition, the root partition must be mounted as ___________.
Answer: readonly
You cannot run fsck on a partition that is mounted as read-write.

In order to improve your system’s security you decide to implement shadow passwords. What command should you use?
Answer: pwconv
The pwconv command creates the file /etc/shadow and changes all passwords to ‘x’ in the /etc/passwd file.

Bob Armstrong, who has a username of boba, calls to tell you he forgot his password. What command should you use to reset his command?
Answer: passwd boba
The passwd command is used to change your password. If you do not specify a username, your password will be changed.
When you look at the /etc/group file you see the group kmem listed. Since it does not own any files and no one is using it as a default group, can you delete this group?
Answer: no
The kmem group manages direct access to kernel memory and is necessary
for your system’s health.

What text filter can you use to display a multi-page file and place numbers at the beginning of each line.
Using the > will redirect the output of the ls /etc command to the
file DirContents.

You have two files each ten lines long. What text filter could you use to combine the two files so that each line of the output contains the corresponding line from each file?
Answer: join
The join text filter will display one line for each pair of input lines from two files.

You have two files in two different directories with the same inode. What type of link is involved?
“,1] ); //–>
Answer: nl
The nl text filter will divide a file into logical pages and number each line.

Question The top utility can be used to change the priority of a running process? Another utility that can also be used to change priority is ___________?
Answer: nice
Both the top and nice utilities provide the capability to change the priority of a running process.

In order to apply a filesystem to your new partitions you must format them. What command would you use to create the ext2 filesystem?
Answer: mke2fs
The mke2fs command creates the new filesystem on your partition.

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.
Answer: ls -r /home/ben/memos/*.mem
The -c option used with ls results in the files being listed in chronological order. You can use wildcards with the ls command to specify a pattern of filenames.
In order to create a file called DirContents containing the contents of the /etc directory you would type ____________.

Answer: ls /etc > DirContents
Using the > will redirect the output of the ls /etc command to the
file DirContents.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s


%d bloggers like this: