System Admin Q & A – IV

Ques 1: – How to build the rpm in Linux from the source rpm ?

In order to build a source RPM you need to use rpmbuild command. rpmbuild is used to build both binary and source software packages. A package consists of an archive of files and meta-data used to install and erase the archive files. The meta-data includes helper scripts, file attributes, and descriptive information about the package. Packages come in two varieties: binary packages, used to encapsulate software to be installed, and source packages, containing the source code and recipe necessary to produce binary packages.

You need to use .spec file to build the RPM file. Next type rpmbuild command as follows:

#rpmbuild -ba pakagename.spec

# rpmbuild –rebuild –define build_centos5=1 –define build_mysql=1 bacula-5.0.3-1.src.rpm

Ques 2: – What is the difference between home directory and working directory?

Home directory is the default working directory when a user logs in. On the other hand, working directory is the user’s current directory. Working directory can be changed. It can be changed using cd command.
Home directory in Linux contains user’s 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.

Ques 3: – How are devices represented in UNIX?

A correlated sub query is a type of sub query. Unlike sub query, a correlated sub query is dependent upon the outer query, which returns a value. When a reference to the outer query is found in the sub query, then the outer query will execute first, and the result will be returned to the correlated sub query. The sub query is executed alter for every row that is selected in the outer query.

Ques 4: – What are the process states in Unix?

Ans: – As a process executes it changes state according to its circumstances.

Unix processes have the following states:

Running : The process is either running or it is ready to run .

Waiting : The process is waiting for an event or for a resource.

Stopped : The process has been stopped, usually by receiving a signal.

Zombie : The process is dead but have not been removed from the process table

Ques 5: – What is ‘inode’?

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

Inode consists of the following fields:

File owner identifier
File type
File access permissions
File access times
Number of links
File size
Location of the file data

Ques 6: – What is vitrual hosting in Linux/Unix ?

Ans: – The term Virtual Hosting refers to the practice of running more than one web site (such as and on a single machine. Virtual hosts can be “IP-based”, meaning that you have a different IP address for every web site, or “name-based”, meaning that you have multiple names running on each IP address. The fact that they are running on the same physical server is not apparent to the end user.

Ques 7: – How to disable ping response in Linux/Unix ?

Add the following line to your init script for the network (the name depends on the distribution you use):

#echo 1 >/proc/sys/net/ipv4/icmp_echo_ignore_all

This disables ping responses.

To re-enable, use the following command:

#echo 0 >/proc/sys/net/ipv4/icmp_echo_ignore_all

To make this permanent set the following into

/etc/sysctl.conf (if you have such a file)

et.ipv4.conf.icmp_echo_ignore_all = 1

Ques 8: – How To Masquerade On Linux (Internet connecti- on Sharing) ?

It’s very simple to masquerade (internet connection sharing in Windows language ) on Linux with a few lines of iptables and ip_forward commands.
First of all you have to flush and delete existing firewall rules.

So flush rules by typing in terminal:

#iptables -F
#iptables -t nat -F
#iptables -t mangle -F

Now delete these chains:

#iptables -X
#iptables -t nat -X
#iptables -t mangle -X

Now it’s time to save the iptables rules so type:

#service iptables save
#service iptables restart

Now all rules and chains have been cleared!
Check it in /etc/sysconfig/iptables which has all default rules set to accept.
echo “1” > /proc/sys/net/ipv4/ip_forward
And then save and close the file.
Now asuming that your internet interface is eth0, type:

#iptables -t nat -A POSTROUTING -o eth0  -j MASQUERADE
#service iptables save
#service iptables restart

Note: check if iptables is set to start during boot up.
Or check the status of your iptables service:

#chkconfig –list iptables

Leave a Reply