"How many types of files are there and what are they?" This is a common question to every person who started learing Linux.
Why is this so much important to know file types?
Ans : This is because Linux will consider every thing as files. The Answer to this question is little bit confusing with different answers.
Let me put it in this way to clarify. By default Unix have only 3 types of files..
They are.
1. Regular files
2. Directory files
3. Special files(This is the file type who is the culprit for different answers. This catagory is having 5 sub types.)
So Total file types in Linux are 7. Remeber I am saying in linux there are only 7 types of files but if it comes to unix it is 8 types.
Here are those files. And you can see the file type indication at leftmost part of “ls -l” command
1. Regular file(-)
2. Directory files(d)
Special files
3. Block file(b)
4. Character device file(c)
5. Named pipe file or just a pipe file(p)
6. Symbolic link file(l)
7. Socket file(s)
For your information there is one more file called door files(D) which is present in Sun Solaris. A door is a special file for inter-process communication between a client and server(so total 8 types in Unix machines.).
Regular files : These are the files are indicated with "-" in ls -l output. And these files are.1. Readable files or
2. A binary files or
3. Image files or
4. Compressed files etc.
How to create them?
Ans : Use touch command.
Example listing of regular files :-rw-r--r-- 1 krishna krishna 20986522 2010-01-31 13:48 test.wmv
-rw-r--r-- 1 krishna krishna 173448 2010-01-30 21:20 Transformers-Teaser-Wallpaper-310.jpg
-r-xr-xr-x 1 root root 135168 2009-12-12 19:14 VIDEO_TS.VOB
-rw-r--r-- 1 krishna krishna 2113536 2009-12-01 13:32 Aditya 365 – Janavule.mp3
-rwxrwxrwx 1 root root 168 2010-02-14 14:12 xyz.sh
Directory files : These contains the name and location of files/folders/special files stored on a physical device. And this type of files will be in blue in color.
How to create them?
Ans : Use mkdir command
Example listing of directories.drwxr-xr-x 2 surendra surendra 4096 2010-01-19 18:37 bin
drwxr-xr-x 5 surendra surendra 4096 2010-02-15 18:46 Desktop
drwxr-xr-x 2 surendra surendra 4096 2010-01-18 14:36 Documents
drwxr-xr-x 2 surendra surendra 4096 2010-02-13 17:45 Downloads
Block files : These files are hardware files most are present in /dev
How to create them?
Ans : Use fdisk command or create virtual partition.
Example listing of Block files(for you to see these file, they are located in /dev).
brw-rw---- 1 root disk 8, 1 2010-02-15 09:35 sda1
brw-rw---- 1 root disk 8, 2 2010-02-15 09:35 sda2
brw-rw---- 1 root disk 8, 5 2010-02-15 09:35 sda5
Character devices files : Provide only a serial stream of input or output.
Example listing of character files(located in /dev)
crw-rw-rw- 1 root tty 5, 0 2010-02-15 16:52 tty
crw--w---- 1 root root 4, 0 2010-02-15 09:35 tty0
crw------- 1 root root 4, 1 2010-02-15 09:35 tty1
Pipe files : The other sort of pipe is a “named” pipe, which is sometimes called a FIFO. FIFO stands for “First In, First Out” and refers to the property that the order of bytes going in is the same coming out. The “name” of a named pipe is actually a file name within the file system. --www.linux.com
How to create them?Ans : Use mkfifo command.
Example listing of pipe files
prw-r----- 1 root root 0 2010-02-15 09:35 /dev/.initramfs/usplash_outfifo
prw-r----- 1 root root 0 2010-02-15 09:35 /dev/.initramfs/usplash_fifo
prw------- 1 syslog syslog 0 2010-02-15 15:38 /var/run/rsyslog/kmsg
Sybolic link files : These are linked files to other files.
How to create them?
Ans : use ln command
Example listing of linked files
lrwxrwxrwx 1 root root 24 2010-02-15 09:35 sndstat -> /proc/asound/oss/sndstat
lrwxrwxrwx 1 root root 15 2010-02-15 09:35 stderr -> /proc/self/fd/2
lrwxrwxrwx 1 root root 15 2010-02-15 09:35 stdin -> /proc/self/fd/0
lrwxrwxrwx 1 root root 15 2010-02-15 09:35 stdout -> /proc/self/fd/1
Socket files : A socket file is used to pass information between applications for communication purpose
How to create them?
Ans : You can create a socket file using socket() system call avialable under
Example
int sockfd = socket(AF_INET, SOCK_STREAM, 0);
You can refer to this socket file using the sockfd. This is same as the file descriptor, and you can use read(), write() system calls to read and write from the socket.
Example listing of socket files.
srw-rw-rw- 1 root root 0 2010-02-15 09:35 /dev/log
srwxrwxrwx 1 root root 0 2010-02-15 10:07 /var/run/cups/cups.sock
srwxrwxrwx 1 root root 0 2010-02-15 09:35 /var/run/samba/winbindd_privileged/pipe
srwxrwxrwx 1 mysql mysql 0 2010-02-15 09:35 /var/run/mysqld/mysqld.sock
A tip for you guys.
How to find your desired type of a file ?Ans : Use find command with -type option.
For example if you want to find socket file, just use below command.find / -type sIf you want to find linked file then how?Find / -type l
How To Install YUM Server In Redhat(RHEL5)
In linux you can install packages through many ways like.
1. Through RPM,
2. Through shell script
3. Through source tar balls etc.
YUM(Yellow-dog Updater and Modifier) is another and advanced way of installing the packages in Linux distros such as Red-hat, Fedora.
In RHEL4 installing packages is a tedious process, some times its headache to install all the dependencies. So Red-hat people come with a solution to overcome this problem in most situations, i.e. nothing but YUM implementation which will resolve this dependency issue. Here I am going to present some basic way how to use YUM utility to install packages locally(there are so many ways to install packages from different sources such as ftp, http etc). You can get the full details about YUM in my google docs here. One Two Three Four Five Six Seven Eight Nine Ten
Basic YUM implementation locally:
Step1 : Copy the entire OS cd's content to Hard-drive as below.
#cp -ar /media/cdrom/* /destinationfolder
Example : #cp -ar /media/cdrom/* /var/ftp/pub
Note :
1. From second cd on words no need to copy entire cd contents to drive just copy Server content in to drive.
2. Here please take destination folder as /var/ftp/pub so that we can implement FTP server to share our reposatory.
3. If you have RHEL5 DVD then just continue with second step.
#cp -ar /media/cdrom/Server/* /var/ftp/pub/Server/
Step2 : Now change the directory to /destinationfolder/Server and install the createrepo package #rpm -ivh createrepo.0.4.4-2 --aid
Step3 : Specify the reposatory location to YUM.
#createrep -v /destinationfolder/
Step4 : Create a file with repo as extention and specify the YUM details in /etc/yum.repos.d folder
#cd /etc/yum.repos.d/ #vi testing.repo
Note : The directory /etc/yum.repos.d/ contaions two .repo files which should be moved or removed to other directory, so that YUM server will check default .repo file it self. The new file which is created contains as follows
[station1.example.com]
comment ="test"
baseurl=file:///destinationfolder
gpgcheck=0
After entring these entries save and exit from the file.
Let me explain what acutally this four entries mean.
[station1.example.com] ==>This informs what is the reposatory name.
Comment ==> Its used to see the inforamtion about the repo.
Baseurl ==> This is the server and path of the repo(here its a local repo so the base url is just a file:///
For example you are creating YUM server through FTP then base url should be like this
baseurl=ftp://station1.example.com/pub/Server gpgcheck ==> This is to check the authentication of the repository, which is disabled in this case.
Local YUM repository is created, now you can install any package you want with yum command. In order to know more about YUM, Please see man pages for YUM.
Basic YUM Server Reposatory through FTP server :
So what about Installing packages remotly by using this reposatory?
Let us see how to configure client to access this repository. Before doing client configuration we have to share this reposatory through FTP or HTTP.
Step1 : Install vsftpd server on server
#yum install vsftpd
Step2 : Start the ftp service and on it
#service vsftpd restart
#chkconfig vsftpd on
Thats it on the server side every thing configured properly, Now move on to client machine Confugration on client side :
Step3 : Remove/move the local reposatory file from /etc/yum.repo.d/ folder to some other location #mv /etc/yum.repo.d/* /safe-loc/
Step4 : Create server.repo file in /etc/yum.repo.d/ with following contents [station1.example.com]
comment ="test"
baseurl=ftp://station1.example.com/pub/Server
gpgcheck=0
Save and exit the file Now start using yum to install packages, as follows.
#yum install packagename
Example : #yum install httpd
To uninstall a package through YUM
#yum remove httpd
To see the info of a package
#yum info packagename
To see the package is already installed or not
#rpm -qa grep packagename
1. Through RPM,
2. Through shell script
3. Through source tar balls etc.
YUM(Yellow-dog Updater and Modifier) is another and advanced way of installing the packages in Linux distros such as Red-hat, Fedora.
In RHEL4 installing packages is a tedious process, some times its headache to install all the dependencies. So Red-hat people come with a solution to overcome this problem in most situations, i.e. nothing but YUM implementation which will resolve this dependency issue. Here I am going to present some basic way how to use YUM utility to install packages locally(there are so many ways to install packages from different sources such as ftp, http etc). You can get the full details about YUM in my google docs here. One Two Three Four Five Six Seven Eight Nine Ten
Basic YUM implementation locally:
Step1 : Copy the entire OS cd's content to Hard-drive as below.
#cp -ar /media/cdrom/* /destinationfolder
Example : #cp -ar /media/cdrom/* /var/ftp/pub
Note :
1. From second cd on words no need to copy entire cd contents to drive just copy Server content in to drive.
2. Here please take destination folder as /var/ftp/pub so that we can implement FTP server to share our reposatory.
3. If you have RHEL5 DVD then just continue with second step.
#cp -ar /media/cdrom/Server/* /var/ftp/pub/Server/
Step2 : Now change the directory to /destinationfolder/Server and install the createrepo package #rpm -ivh createrepo.0.4.4-2 --aid
Step3 : Specify the reposatory location to YUM.
#createrep -v /destinationfolder/
Step4 : Create a file with repo as extention and specify the YUM details in /etc/yum.repos.d folder
#cd /etc/yum.repos.d/ #vi testing.repo
Note : The directory /etc/yum.repos.d/ contaions two .repo files which should be moved or removed to other directory, so that YUM server will check default .repo file it self. The new file which is created contains as follows
[station1.example.com]
comment ="test"
baseurl=file:///destinationfolder
gpgcheck=0
After entring these entries save and exit from the file.
Let me explain what acutally this four entries mean.
[station1.example.com] ==>This informs what is the reposatory name.
Comment ==> Its used to see the inforamtion about the repo.
Baseurl ==> This is the server and path of the repo(here its a local repo so the base url is just a file:///
For example you are creating YUM server through FTP then base url should be like this
baseurl=ftp://station1.example.com/pub/Server gpgcheck ==> This is to check the authentication of the repository, which is disabled in this case.
Local YUM repository is created, now you can install any package you want with yum command. In order to know more about YUM, Please see man pages for YUM.
Basic YUM Server Reposatory through FTP server :
So what about Installing packages remotly by using this reposatory?
Let us see how to configure client to access this repository. Before doing client configuration we have to share this reposatory through FTP or HTTP.
Step1 : Install vsftpd server on server
#yum install vsftpd
Step2 : Start the ftp service and on it
#service vsftpd restart
#chkconfig vsftpd on
Thats it on the server side every thing configured properly, Now move on to client machine Confugration on client side :
Step3 : Remove/move the local reposatory file from /etc/yum.repo.d/ folder to some other location #mv /etc/yum.repo.d/* /safe-loc/
Step4 : Create server.repo file in /etc/yum.repo.d/ with following contents [station1.example.com]
comment ="test"
baseurl=ftp://station1.example.com/pub/Server
gpgcheck=0
Save and exit the file Now start using yum to install packages, as follows.
#yum install packagename
Example : #yum install httpd
To uninstall a package through YUM
#yum remove httpd
To see the info of a package
#yum info packagename
To see the package is already installed or not
#rpm -qa grep packagename
IPTables In Linux Explained
IPtables (Netfilter) :
IPtables is the default firewall for Linux. Its a vast subject which can not be covered in one post. I will try to give as much info as possible at the same time not to make it complex. Lets start with basics.
What is a firewall?
Ans : A firewall is a part of a computer system or network that is designed to block unauthorized access while permitting authorized communications --Wikipedia.org
A IPtables firewall contains tables which in tern contains rules to block or unblock a perticular communication.
A table can be a
1.Filter table -- Used to filter packets.
2.NAT(Network Adress Translator) table -- Used for NATing of source and destination ip address(Used for sharing internet)
3.Mangale table -- Its a combination of Filter and NAT tables
4.RAW table -- Used to for marking packets not to track.
1.Filter table : This is the default table which contaions three chains.
a.INPUT Chain : To apply a rule on packets which are coming into the system.
b.FORWARD Chain : For packets being routed through the system
c.OUTPUT Chain : For packets locally generated which are going out from the system.
2.NAT table : This table is having three chains.
a.PREROUTING Chain : For altering the packets as soon as they come in to the system
b.OUTPUT Chain : For packets locally generated which are going out from the system.
c.POSTROUTING Chain : For altering the packets which are about to go out from the system.
3.MANGLE Table : This is a combination of forwording, security and translating packets. We can say this one as hybride table of both FILTER and NAT table. This contains five chains.
1.PREROUTING
2.OUTPUT
3.INPUT
4.FORWARD
5.POSTROUTING
4.RAW Table : Contaions two chains.
1.PREROUTING
2.OUTPUT
So lets go to the configuration of IPTables : In the following examples I will be taking FILTER Table to explain.
Example1 : To see/list what are the rules configured in the system
#iptables -L -t filter
This will list all the rules which are created under FILTER Table
-L for listing
-t for specifying table type(here table type is FILTER)
#iptables -L -t nat
#iptables -L -t mangle
#iptables -L -t raw
These three iptables are self explantory.
Example2 : Inserting a rule in to a table
#iptables -I INPUT 2 -t filter -s 192.168.0.1/24 -j DROP
-I for inserting a rule in to a table, so in this example I am inserting an INPUT rule and position two(2). So depending on number we can insert a rule in any position of a table.
-s for specifying the source of this packet. This source may be a IP adress/netmaks or a network-adress/netmask. -j for specifying what to do on the target packet. Here we specified to drop any packet which comes from 192.168.0.1, so there is no reply to the source about the packet status. With -j these are the options we can specify.
1.DROP -- For droping a packet with out informing the status of this packets to the source/destination. So there is no inforamtion to source/destination about the status of the packet.
2.REJECT -- Will reject the packets and information is sent to source/destantion about the rejection of packet by the server.
3.ACCEPT -- Will accpet for the delevery of the packet to designated destination.
4.QUEUE -- this is used to queue the packets to user space. Let me put in this way.. this is just to forward all the packets to some other utility(such as SNORT) which take care of packet filtering.
What actually this rule is specifying?
Ans : This rule specifies its an input rule at second position of the filter table to drop all the communication which is originating from 192.168.0.1
Example3 : To append a rule in to a table
#iptables -A INPUT -t filter -d 132.160.0.0/16 -j REJECT
-A for append a rule at the end of a table
-d for specifying the destination of this packet. This destination may be a IP adress/netmaks or a network-adress/netmask.
What actually this rule is specifing?
Ans : This rule specifies its an input rule which is appended to a filter table to reject all the packets which are destinated to 132.160.0.0 network.
Example4 : Deleting perticular rule
#iptables -D INPUT 3 -t filter
-D for specifing deletion of a rule
What actually this rule is specifing?
Ans : This rule specifies delete an input rule which is in third position of the filter table.
Example5 : Flushing/removeing entire table
#iptables -F -t filter
-F for specifing to flush/remove a table from iptables configuration.
What actually this rule is specifing?
Ans : This rule specifies flush/remove all the rules which are in filter table.
From here we will see how to block a
1.Blocking network
2.Blocking an ip address
3.Blockign Entire protocal stack
4.Blocking protocol
5.Blocking port(source port or Destination port)
Example6 : Blocking(Rejecting) a perticular network
#iptables -A INPUT -t filter -s 192.168.0.0/24 -j REJECT
What actually this rule do?
Ans : This rule specifies under filter table please block(REJECT) all traffic from 192.168.0.0 to 192.168.0.225 ip addresses, nothing but entire 192.168.0.0/24 network.
Example7 : Blocking(Rejecting) a perticular ip address
#iptables -A INPUT -t filter -s 123.45.0.1 -j REJECT
What acutally this rule do?
Ans : This rule specifies under filter table please block(REJECT) all the traffic originating from 192.168.0.1 ip address.
Example8 : Blocking(Rejecting) entire protocol stack.
#iptables -A INPUt -t filter -s 192.168.0.1 -p all -j REJECT
What acutally this rule do?
Ans : This rule specifies under filter table please block all the traffic with all the protocols(such as TCP,UDP,ICMP etc) which are origenating from 192.168.0.1 ip address.
Example9 : Blocking a perticular protocol
#iptables -A INPUT -t filter -s 192.168.0.1 -p tcp -j REJECT
What acutally this rule do?
Ans : This rule specifies under filter table please block all the traffic which uses tcp protocol to communicate from 192.168.0.1 ip address.
Example10 : Blocking perticular destination port
#iptables -A INPUT -t filter -s 192.168.0.1 -p tcp -dport 21 -s 192.168.0.1 -j REJECT
What acutally this rule do?
Ans : This rule specifies under filter table please block all the FTP(port no:21) traffic orignating from 192.168.0.1 ip address.
Example11 : Blocking perticular source port
#iptables -A OUTPUT -t filter -d 192.168.0.1 -p udp -sport 1929 -j REJECT
What acutally this rule do?
Ans : This rule specifies under filter table please block all the traffic which is origanting from server through port 1929 destinated to 192.168.0.1 to be blocked.
5.Saving iptable :
#service iptables save
Why we actually require to save iptables?
Ans : Most of the services in linux have their own configuration files so same will be applicable for the iptables. So when ever we do iptables save the configuration by default will be saved to /etc/sysconfig/iptables
6.Satrting iptables :
#service iptables start
7.Restarting iptables :
#service iptables restart
Checking wether iptables is running or not
#service iptables status
IPtables is the default firewall for Linux. Its a vast subject which can not be covered in one post. I will try to give as much info as possible at the same time not to make it complex. Lets start with basics.
What is a firewall?
Ans : A firewall is a part of a computer system or network that is designed to block unauthorized access while permitting authorized communications --Wikipedia.org
A IPtables firewall contains tables which in tern contains rules to block or unblock a perticular communication.
A table can be a
1.Filter table -- Used to filter packets.
2.NAT(Network Adress Translator) table -- Used for NATing of source and destination ip address(Used for sharing internet)
3.Mangale table -- Its a combination of Filter and NAT tables
4.RAW table -- Used to for marking packets not to track.
1.Filter table : This is the default table which contaions three chains.
a.INPUT Chain : To apply a rule on packets which are coming into the system.
b.FORWARD Chain : For packets being routed through the system
c.OUTPUT Chain : For packets locally generated which are going out from the system.
2.NAT table : This table is having three chains.
a.PREROUTING Chain : For altering the packets as soon as they come in to the system
b.OUTPUT Chain : For packets locally generated which are going out from the system.
c.POSTROUTING Chain : For altering the packets which are about to go out from the system.
3.MANGLE Table : This is a combination of forwording, security and translating packets. We can say this one as hybride table of both FILTER and NAT table. This contains five chains.
1.PREROUTING
2.OUTPUT
3.INPUT
4.FORWARD
5.POSTROUTING
4.RAW Table : Contaions two chains.
1.PREROUTING
2.OUTPUT
So lets go to the configuration of IPTables : In the following examples I will be taking FILTER Table to explain.
Example1 : To see/list what are the rules configured in the system
#iptables -L -t filter
This will list all the rules which are created under FILTER Table
-L for listing
-t for specifying table type(here table type is FILTER)
#iptables -L -t nat
#iptables -L -t mangle
#iptables -L -t raw
These three iptables are self explantory.
Example2 : Inserting a rule in to a table
#iptables -I INPUT 2 -t filter -s 192.168.0.1/24 -j DROP
-I for inserting a rule in to a table, so in this example I am inserting an INPUT rule and position two(2). So depending on number we can insert a rule in any position of a table.
-s for specifying the source of this packet. This source may be a IP adress/netmaks or a network-adress/netmask. -j for specifying what to do on the target packet. Here we specified to drop any packet which comes from 192.168.0.1, so there is no reply to the source about the packet status. With -j these are the options we can specify.
1.DROP -- For droping a packet with out informing the status of this packets to the source/destination. So there is no inforamtion to source/destination about the status of the packet.
2.REJECT -- Will reject the packets and information is sent to source/destantion about the rejection of packet by the server.
3.ACCEPT -- Will accpet for the delevery of the packet to designated destination.
4.QUEUE -- this is used to queue the packets to user space. Let me put in this way.. this is just to forward all the packets to some other utility(such as SNORT) which take care of packet filtering.
What actually this rule is specifying?
Ans : This rule specifies its an input rule at second position of the filter table to drop all the communication which is originating from 192.168.0.1
Example3 : To append a rule in to a table
#iptables -A INPUT -t filter -d 132.160.0.0/16 -j REJECT
-A for append a rule at the end of a table
-d for specifying the destination of this packet. This destination may be a IP adress/netmaks or a network-adress/netmask.
What actually this rule is specifing?
Ans : This rule specifies its an input rule which is appended to a filter table to reject all the packets which are destinated to 132.160.0.0 network.
Example4 : Deleting perticular rule
#iptables -D INPUT 3 -t filter
-D for specifing deletion of a rule
What actually this rule is specifing?
Ans : This rule specifies delete an input rule which is in third position of the filter table.
Example5 : Flushing/removeing entire table
#iptables -F -t filter
-F for specifing to flush/remove a table from iptables configuration.
What actually this rule is specifing?
Ans : This rule specifies flush/remove all the rules which are in filter table.
From here we will see how to block a
1.Blocking network
2.Blocking an ip address
3.Blockign Entire protocal stack
4.Blocking protocol
5.Blocking port(source port or Destination port)
Example6 : Blocking(Rejecting) a perticular network
#iptables -A INPUT -t filter -s 192.168.0.0/24 -j REJECT
What actually this rule do?
Ans : This rule specifies under filter table please block(REJECT) all traffic from 192.168.0.0 to 192.168.0.225 ip addresses, nothing but entire 192.168.0.0/24 network.
Example7 : Blocking(Rejecting) a perticular ip address
#iptables -A INPUT -t filter -s 123.45.0.1 -j REJECT
What acutally this rule do?
Ans : This rule specifies under filter table please block(REJECT) all the traffic originating from 192.168.0.1 ip address.
Example8 : Blocking(Rejecting) entire protocol stack.
#iptables -A INPUt -t filter -s 192.168.0.1 -p all -j REJECT
What acutally this rule do?
Ans : This rule specifies under filter table please block all the traffic with all the protocols(such as TCP,UDP,ICMP etc) which are origenating from 192.168.0.1 ip address.
Example9 : Blocking a perticular protocol
#iptables -A INPUT -t filter -s 192.168.0.1 -p tcp -j REJECT
What acutally this rule do?
Ans : This rule specifies under filter table please block all the traffic which uses tcp protocol to communicate from 192.168.0.1 ip address.
Example10 : Blocking perticular destination port
#iptables -A INPUT -t filter -s 192.168.0.1 -p tcp -dport 21 -s 192.168.0.1 -j REJECT
What acutally this rule do?
Ans : This rule specifies under filter table please block all the FTP(port no:21) traffic orignating from 192.168.0.1 ip address.
Example11 : Blocking perticular source port
#iptables -A OUTPUT -t filter -d 192.168.0.1 -p udp -sport 1929 -j REJECT
What acutally this rule do?
Ans : This rule specifies under filter table please block all the traffic which is origanting from server through port 1929 destinated to 192.168.0.1 to be blocked.
5.Saving iptable :
#service iptables save
Why we actually require to save iptables?
Ans : Most of the services in linux have their own configuration files so same will be applicable for the iptables. So when ever we do iptables save the configuration by default will be saved to /etc/sysconfig/iptables
6.Satrting iptables :
#service iptables start
7.Restarting iptables :
#service iptables restart
Checking wether iptables is running or not
#service iptables status
SERVER CONFIGURATION FILE SYNTAX CHECKING COMMANDS
Basically configuring servers in Linux/*nix include editing of configuration files and saving them. Once editing the files if any syntax error is there and when we start the service they will show some wearied errors which we cant resolve.
For counter attacking this type of issues for each service there will be one command to check this syntax errors before starting of the service/server, I have collected these commands from my experience and from some of my friends. Please feel free to comment on this if you know some other commands so that I will update my post.
SSHD server check for syntax error
=========================
sshd -t
FTP server check for syntax error
=========================
#vsftpd
DNS server check for syntax error
==========================
For checking syntax errors in main configuration file..
#named-checkconf main-config-file
Example:
#named-checkconf named.conf
Syntax OK
#named-checkzone domain zonefile-loc
Example:
#named-checkzone example.com /var/named/chroot/var/named/exaple-zone.frd
SAMBA server check for syntax error
=============================
#testparm
APACHE server check for syntax error
=============================
httpd -t
For virtual hosts
httpd -t -D DUMP_VHOSTS
TCP Wrappers check for syntax error
============================
tcpdchk
tcpdchk -v
Postfox server check for syntax error
============================
postfix check
postfix -vv
LIGHTTPD server check for syntax error
=============================
lighttpd -t -f /etc/lighttpd/lighttpd.conf
Squid server check for syntax error
==========================
squid -k check
squid -k parse
/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
For counter attacking this type of issues for each service there will be one command to check this syntax errors before starting of the service/server, I have collected these commands from my experience and from some of my friends. Please feel free to comment on this if you know some other commands so that I will update my post.
SSHD server check for syntax error
=========================
sshd -t
FTP server check for syntax error
=========================
#vsftpd
DNS server check for syntax error
==========================
For checking syntax errors in main configuration file..
#named-checkconf main-config-file
Example:
#named-checkconf named.conf
Syntax OK
#named-checkzone domain zonefile-loc
Example:
#named-checkzone example.com /var/named/chroot/var/named/exaple-zone.frd
SAMBA server check for syntax error
=============================
#testparm
APACHE server check for syntax error
=============================
httpd -t
For virtual hosts
httpd -t -D DUMP_VHOSTS
TCP Wrappers check for syntax error
============================
tcpdchk
tcpdchk -v
Postfox server check for syntax error
============================
postfix check
postfix -vv
LIGHTTPD server check for syntax error
=============================
lighttpd -t -f /etc/lighttpd/lighttpd.conf
Squid server check for syntax error
==========================
squid -k check
squid -k parse
NAGIOS server check for syntax error
====================================/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
Mail system explained
Sl.no | Agent | Description from Wikipedia |
1 | Mail User Agent(MUA) | An e-mail client (also mail user agent (MUA) or e-mail reader) is a frontend computer program used to manage e-mail. |
2 | Mail Transfer Agent(MTA) | A mail transfer agent (MTA) (also called a mail transport agent, message transfer agent, or smtpd (short for SMTP daemon), is a computer program or software agent that transfers electronic mail messages from one computer to another.The term mail server is also used to mean a computer acting as an MTA that is running the appropriate software. The term mail exchanger (MX), in the context of the Domain Name System formally refers to an IP address assigned to a device hosting a mail server, and by extension also indicates the server itself. |
3 | Mail Delivery Agent(MDA) | A Mail delivery agent (MDA) is software that delivers e-mail messages after they have been accepted on a server, distributing them to recipients' individual mailboxes. |
4 | Mail Access Agent(MAA) | A way of remotely accessing a mail-spool, for example POP3 or IMAP. |
A short description how a Mail communication will work:
Here I will take an example how a mail from ravi(ravi@ravi.com) to his friend satish(satish@satish.com) will be delivered.
Step1:first ravi has to write a e-mail by specifying who is the receiver of this mail(in this case it is satish).So things like composing mails will be taken care by MUA.this MUA( A mail client such as MS outlook,Thunder-bird etc) knows how to deals with mail transportation,Once ravi press send and receive in e-mail client,MUA initiate talk with its MTA(A SMTP server which is listening on 25 port for receiving mails).
Step2:Once MTA(such as SEND-MAIL,Qmail,Post-Fix etc) get the request from MUA, MTA will take care of all the activity such as communicate with MUA and fetching mails from MUA etc.
Step3:Once MTA got the mails from MUA, it has to segregate all the mails according to different domains. for example ravi is sending 4 mails(one to satish@satish.com, one to prasad@satish.com, one to prahu@yahoo.com and one to raja@gmail.com) this MTA will segregate these 4 mails in to 3 pools(satish and prasad mails will be pooled in same pool so that they will be delivered to satish.com,prahu mail will be pooled to yahoo.com and raja's mail will be pooled to gmail.com)
Step4:Once the segregation has happened MDA(nothing but again its a send-mail which will take care of )will delivered these mails to respective MAA(such as Dovecot ).
Step5:Now suppose mail has delivered to their respective MAA's. Once the mail reaches, MAA will try to segregate the mails according to users(here for example satish and prasad mails has arrived to satish.com MAA) then this MAA will put the mails of satish and prasad in respective mails boxes in a Mail Store(MS) as shown in Figure.
Step6:Now MUA will come in to picture in downloading these mails from MAA, so MUA will communicate with MAA and download the mails to MUA(like outlook and thunder-bird).
How To Install YUM Server In Redhat(RHEL5)
In linux you can install packages through many ways like.
1. Through RPM,
2. Through shell script
3. Through source tar balls etc.
YUM(Yellow-dog Updater and Modifier) is another and advanced way of installing the packages in Linux distros such as Red-hat, Fedora.
In RHEL4 installing packages is a tedious process, some times its headache to install all the dependencies. So Red-hat people come with a solution to overcome this problem in most situations, i.e. nothing but YUM implementation which will resolve this dependency issue. Here I am going to present some basic way how to use YUM utility to install packages locally(there are so many ways to install packages from different sources such as ftp, http etc). You can get the full details about YUM in my google docs here. One Two Three Four Five Six Seven Eight Nine Ten
Basic YUM implementation locally:Step1 : Copy the entire OS cd's content to Hard-drive as below.
#cp -ar /media/cdrom/* /destinationfolder
Example : #cp -ar /media/cdrom/* /var/ftp/pub
Note :
1. From second cd on words no need to copy entire cd contents to drive just copy Server content in to drive.
2. Here please take destination folder as /var/ftp/pub so that we can implement FTP server to share our reposatory.
3. If you have RHEL5 DVD then just continue with second step.
#cp -ar /media/cdrom/Server/* /var/ftp/pub/Server/
Step2 : Now change the directory to /destinationfolder/Server and install the createrepo package #rpm -ivh createrepo.0.4.4-2 --aid
Step3 : Specify the reposatory location to YUM.
#createrep -v /destinationfolder/
Step4 : Create a file with repo as extention and specify the YUM details in /etc/yum.repos.d folder
#cd /etc/yum.repos.d/ #vi testing.repo
Note : The directory /etc/yum.repos.d/ contaions two .repo files which should be moved or removed to other directory, so that YUM server will check default .repo file it self. The new file which is created contains as follows
[station1.example.com]
comment ="test"
baseurl=file:///destinationfolder
gpgcheck=0
After entring these entries save and exit from the file.
Let me explain what acutally this four entries mean.
[station1.example.com] ==>This informs what is the reposatory name.
Comment ==> Its used to see the inforamtion about the repo.
Baseurl ==> This is the server and path of the repo(here its a local repo so the base url is just a file:///
For example you are creating YUM server through FTP then base url should be like this
baseurl=ftp://station1.example.com/pub/Server gpgcheck ==> This is to check the authentication of the repository, which is disabled in this case.
Local YUM repository is created, now you can install any package you want with yum command. In order to know more about YUM, Please see man pages for YUM.
Basic YUM Server Reposatory through FTP server :So what about Installing packages remotly by using this reposatory?
Let us see how to configure client to access this repository. Before doing client configuration we have to share this reposatory through FTP or HTTP.
Step1 : Install vsftpd server on server
#yum install vsftpd
Step2 : Start the ftp service and on it
#service vsftpd restart
#chkconfig vsftpd on
Thats it on the server side every thing configured properly, Now move on to client machine Confugration on client side :
Step3 : Remove/move the local reposatory file from /etc/yum.repo.d/ folder to some other location #mv /etc/yum.repo.d/* /safe-loc/
Step4 : Create server.repo file in /etc/yum.repo.d/ with following contents [station1.example.com]
comment ="test"
baseurl=ftp://station1.example.com/pub/Server
gpgcheck=0
Save and exit the file Now start using yum to install packages, as follows.
#yum install packagename
Example : #yum install httpd
To uninstall a package through YUM
#yum remove httpd
To see the info of a package
#yum info packagename
To see the package is already installed or not
#rpm -qa grep packagename
1. Through RPM,
2. Through shell script
3. Through source tar balls etc.
YUM(Yellow-dog Updater and Modifier) is another and advanced way of installing the packages in Linux distros such as Red-hat, Fedora.
In RHEL4 installing packages is a tedious process, some times its headache to install all the dependencies. So Red-hat people come with a solution to overcome this problem in most situations, i.e. nothing but YUM implementation which will resolve this dependency issue. Here I am going to present some basic way how to use YUM utility to install packages locally(there are so many ways to install packages from different sources such as ftp, http etc). You can get the full details about YUM in my google docs here. One Two Three Four Five Six Seven Eight Nine Ten
Basic YUM implementation locally:Step1 : Copy the entire OS cd's content to Hard-drive as below.
#cp -ar /media/cdrom/* /destinationfolder
Example : #cp -ar /media/cdrom/* /var/ftp/pub
Note :
1. From second cd on words no need to copy entire cd contents to drive just copy Server content in to drive.
2. Here please take destination folder as /var/ftp/pub so that we can implement FTP server to share our reposatory.
3. If you have RHEL5 DVD then just continue with second step.
#cp -ar /media/cdrom/Server/* /var/ftp/pub/Server/
Step2 : Now change the directory to /destinationfolder/Server and install the createrepo package #rpm -ivh createrepo.0.4.4-2 --aid
Step3 : Specify the reposatory location to YUM.
#createrep -v /destinationfolder/
Step4 : Create a file with repo as extention and specify the YUM details in /etc/yum.repos.d folder
#cd /etc/yum.repos.d/ #vi testing.repo
Note : The directory /etc/yum.repos.d/ contaions two .repo files which should be moved or removed to other directory, so that YUM server will check default .repo file it self. The new file which is created contains as follows
[station1.example.com]
comment ="test"
baseurl=file:///destinationfolder
gpgcheck=0
After entring these entries save and exit from the file.
Let me explain what acutally this four entries mean.
[station1.example.com] ==>This informs what is the reposatory name.
Comment ==> Its used to see the inforamtion about the repo.
Baseurl ==> This is the server and path of the repo(here its a local repo so the base url is just a file:///
For example you are creating YUM server through FTP then base url should be like this
baseurl=ftp://station1.example.com/pub/Server gpgcheck ==> This is to check the authentication of the repository, which is disabled in this case.
Local YUM repository is created, now you can install any package you want with yum command. In order to know more about YUM, Please see man pages for YUM.
Basic YUM Server Reposatory through FTP server :So what about Installing packages remotly by using this reposatory?
Let us see how to configure client to access this repository. Before doing client configuration we have to share this reposatory through FTP or HTTP.
Step1 : Install vsftpd server on server
#yum install vsftpd
Step2 : Start the ftp service and on it
#service vsftpd restart
#chkconfig vsftpd on
Thats it on the server side every thing configured properly, Now move on to client machine Confugration on client side :
Step3 : Remove/move the local reposatory file from /etc/yum.repo.d/ folder to some other location #mv /etc/yum.repo.d/* /safe-loc/
Step4 : Create server.repo file in /etc/yum.repo.d/ with following contents [station1.example.com]
comment ="test"
baseurl=ftp://station1.example.com/pub/Server
gpgcheck=0
Save and exit the file Now start using yum to install packages, as follows.
#yum install packagename
Example : #yum install httpd
To uninstall a package through YUM
#yum remove httpd
To see the info of a package
#yum info packagename
To see the package is already installed or not
#rpm -qa grep packagename
How To Take The Backup Of MBR(Master Boot Recorder)
1.How to take the backup and restore MBR? Why do you require to take the backup of your MBR?
Ans : MBR (Master Boot Recorder) is a vital part of your hard disk which contains booting information, without it its difficult to boot the system. Suppose you have windows and Linux duel boot on your machine and as you know windows is more prone to virus attacks. So it’s always better to backup your MBR to be in safe place.
2. How to take backup of your MBR?
Ans : Using dd command (dataset definition). Here are the steps to take backup of you MBR and keep it in safe place to restore your system if it get corrupted.
#dd if=/dev/hdx of=/safe/location bs=512 count=1
Let me explain the above command how it will work.
“If” in the command is nothing but to specify Input File, here we are specifying our input file as hard disk(if the hard disk is /dev/hda it is primary master, so for general purpose I given 'x'). “of” in the command is nothing but to specify Output File, here we are specifying our output file as /safe/location. Then “bs” this is nothing but block size to write in to hard disk. And then “count” nothing but how many times you want to write date this many block sizes. Here in this example count=1 that means first 512 bytes of the hard disk is copied to the specified location.
3.How to restore the MBR?
#dd if=/safe/location of=/dev/hdx bs=512 count=1
Note : Please replace “hdx” with your hard disk name.
This is bit complex, Is there any other way to restore MBR?
Yes, if you have Linux or Windows bootable CD, we can easily restore your MBR if you forgot to take backup(And this method is very much easy to do restoration of MBR when compared to previous method).
Method1 : With Redhat Linux bootable CD.
For this you have to boot your system to rescue mode, then mount your file system to rescue mode and execute below command to restore your MBR
#grub-install /dev/hdx
Note : Please replace hdx with your hard disk name. After that you just reboot your system. Your system will be live and working.
Method2 : With Windows XP bootable CD.
Step1 : Boot the system with XP bootable cd
Step2 : Press f8 to go to repair mode in Windows
Step3 : Once you got the c drive prompt just type below command
Fixmbr
This command will fix the MBR record.
Some FAQ’s
1. What is the MBR size?
Ans : MBR size is just 512 bytes.
2.What MBR conations?
Ans : Mainly MBR can be divided in two parts
a.Boot loader information block(which is of 448 bytes)
b. Partition table information(which is of just 64 bytes)
3.How many partition we can create on a hard disk?
Ans : Totally we can create four partitions as below
a.Four primary parathions.
b.Three primary and one extended partition.
c.Two primary and one extended parathion.
d.One primary and one extended parathion.
Note : In extended parathion we can create logical partitions up to 24 in number.
4.Why we cannot create more then 4 partition as mention above?
Ans : In MBR, the partition table info is just stored in 64 bytes, and one parathion information to store in MBR requires 16 bytes of space. So at most you can create only 4 partitions as mention above.
Ans : MBR (Master Boot Recorder) is a vital part of your hard disk which contains booting information, without it its difficult to boot the system. Suppose you have windows and Linux duel boot on your machine and as you know windows is more prone to virus attacks. So it’s always better to backup your MBR to be in safe place.
2. How to take backup of your MBR?
Ans : Using dd command (dataset definition). Here are the steps to take backup of you MBR and keep it in safe place to restore your system if it get corrupted.
#dd if=/dev/hdx of=/safe/location bs=512 count=1
Let me explain the above command how it will work.
“If” in the command is nothing but to specify Input File, here we are specifying our input file as hard disk(if the hard disk is /dev/hda it is primary master, so for general purpose I given 'x'). “of” in the command is nothing but to specify Output File, here we are specifying our output file as /safe/location. Then “bs” this is nothing but block size to write in to hard disk. And then “count” nothing but how many times you want to write date this many block sizes. Here in this example count=1 that means first 512 bytes of the hard disk is copied to the specified location.
3.How to restore the MBR?
#dd if=/safe/location of=/dev/hdx bs=512 count=1
Note : Please replace “hdx” with your hard disk name.
This is bit complex, Is there any other way to restore MBR?
Yes, if you have Linux or Windows bootable CD, we can easily restore your MBR if you forgot to take backup(And this method is very much easy to do restoration of MBR when compared to previous method).
Method1 : With Redhat Linux bootable CD.
For this you have to boot your system to rescue mode, then mount your file system to rescue mode and execute below command to restore your MBR
#grub-install /dev/hdx
Note : Please replace hdx with your hard disk name. After that you just reboot your system. Your system will be live and working.
Method2 : With Windows XP bootable CD.
Step1 : Boot the system with XP bootable cd
Step2 : Press f8 to go to repair mode in Windows
Step3 : Once you got the c drive prompt just type below command
Fixmbr
This command will fix the MBR record.
Some FAQ’s
1. What is the MBR size?
Ans : MBR size is just 512 bytes.
2.What MBR conations?
Ans : Mainly MBR can be divided in two parts
a.Boot loader information block(which is of 448 bytes)
b. Partition table information(which is of just 64 bytes)
3.How many partition we can create on a hard disk?
Ans : Totally we can create four partitions as below
a.Four primary parathions.
b.Three primary and one extended partition.
c.Two primary and one extended parathion.
d.One primary and one extended parathion.
Note : In extended parathion we can create logical partitions up to 24 in number.
4.Why we cannot create more then 4 partition as mention above?
Ans : In MBR, the partition table info is just stored in 64 bytes, and one parathion information to store in MBR requires 16 bytes of space. So at most you can create only 4 partitions as mention above.
Linux Virtual File System
Can we create a file system (i.e. formatting a drive/partition) with in a file system?
Looks little bit strange is int it? So follow me I will show you how to create a virtual partition and file system within a partition.
Step1 : Create a empty file with /dev/zero with size equal to 50Mb.#dd if=/dev/zero of=/temp/vf0 count=102400
Note :
1. By default "dd" command(dataset definition) uses block of 512bytes so the size will be 102400*512=52 428 800=~50MB
2. /dev/zero is a device files which will be used create a file which conations "0" i.e. an empty file.Clipped output:[root@test6 ~]# dd if=/dev/zero of=/temp/vf0 count=102400
102400+0 records in
102400+0 records out
[root@test ~]# ls -lh /temp/vf0
-rw-r--r-- 1 root root 50M Nov 7 12:08 /temp/vf0
Step2 : Create ext3 file system for this virtual partition.#mkfs -t ext3 /temp/vf0
Here it will ask "do you want to format the file or not"?, just say yes.
Step3 : Now we have to create a mount point (nothing but a directory) and mount the created partition.# mkdir /virtdrive
# mount -o loop=/dev/loop0 /temp/vf0 /virtdrive
Note:
/dev/loop is special hardware device used to mount ISO files and virtual file systems. In Linux there are total 8 loop devices numbering from 0 to 7. So you can mount only 8 ISO files/virtual file systems by default.
Step4 : Edit /etc/fstab file to mount permanently, so that it be auto mounted at boot time too. Specify following entry in fstab file./temp/vf0 /virtdrive ext3 rw,loop=/dev/loop0 0 0
Step5 : Specify the fstab changes to kernel.#mount -a
Step6 : Conform Weather mounting happen perfectly or not.
Way1 :#cat /etc/mtab
Way2 : Change the directory to mount point you have to see lost+found folder[root@test ~]# cd /virtdrive/
[root@test virtdrive]# ls
lost+found
[root@test virtdrive]#
Looks little bit strange is int it? So follow me I will show you how to create a virtual partition and file system within a partition.
Step1 : Create a empty file with /dev/zero with size equal to 50Mb.#dd if=/dev/zero of=/temp/vf0 count=102400
Note :
1. By default "dd" command(dataset definition) uses block of 512bytes so the size will be 102400*512=52 428 800=~50MB
2. /dev/zero is a device files which will be used create a file which conations "0" i.e. an empty file.Clipped output:[root@test6 ~]# dd if=/dev/zero of=/temp/vf0 count=102400
102400+0 records in
102400+0 records out
[root@test ~]# ls -lh /temp/vf0
-rw-r--r-- 1 root root 50M Nov 7 12:08 /temp/vf0
Step2 : Create ext3 file system for this virtual partition.#mkfs -t ext3 /temp/vf0
Here it will ask "do you want to format the file or not"?, just say yes.
Step3 : Now we have to create a mount point (nothing but a directory) and mount the created partition.# mkdir /virtdrive
# mount -o loop=/dev/loop0 /temp/vf0 /virtdrive
Note:
/dev/loop is special hardware device used to mount ISO files and virtual file systems. In Linux there are total 8 loop devices numbering from 0 to 7. So you can mount only 8 ISO files/virtual file systems by default.
Step4 : Edit /etc/fstab file to mount permanently, so that it be auto mounted at boot time too. Specify following entry in fstab file./temp/vf0 /virtdrive ext3 rw,loop=/dev/loop0 0 0
Step5 : Specify the fstab changes to kernel.#mount -a
Step6 : Conform Weather mounting happen perfectly or not.
Way1 :#cat /etc/mtab
Way2 : Change the directory to mount point you have to see lost+found folder[root@test ~]# cd /virtdrive/
[root@test virtdrive]# ls
lost+found
[root@test virtdrive]#
How To Get BIOS, FIRMWARE And Installed Drivers Details
How to get the BIOS (Basic Input Output System) information and other information such as
1.Hardware
2.CPU information
3.Drivers installed in Linux machine.
1.Hardware
2.CPU information
3.Drivers installed in Linux machine.
For every operation/work in Linux there will be one command, this is true.(all you need to find out that command is use. Google to get it). So how to get BIOS info without rebooting the system. The command for this is dmidecode(DMI table decoder). Some times BIOS is called as DMI too. Just execute the command, It will just dump lots and lots of information about the sytem.
#dmidecode
To get more presised/cliped information for particular category such as only BIOS or only hardware or only RAM details or just only CPU info we have to specify the type(--tyep or -t option), here are the types list for your reference.
DMI TYPES
The SMBIOS specification defines the following DMI types:
Type Information
----------------------------------------
0 BIOS
1 System
2 Base Board
3 Chassis
4 Processor
5 Memory Controller
6 Memory Module
7 Cache
8 Port Connector
5 Memory Controller
6 Memory Module
7 Cache
8 Port Connector
9 System Slots
10 On Board Devices
11 OEM Strings
12 System Configuration Options
13 BIOS Language
14 Group Associations
15 System Event Log
16 Physical Memory Array
17 Memory Device
18 32-bit Memory Error
19 Memory Array Mapped Address
20 Memory Device Mapped Address
21 Built-in Pointing Device
22 Portable Battery
23 System Reset
24 Hardware Security
25 System Power Controls
26 Voltage Probe
27 Cooling Device
28 Temperature Probe
29 Electrical Current Probe
30 Out-of-band Remote Access
31 Boot Integrity Services
32 System Boot
33 64-bit Memory Error
34 Management Device
35 Management Device Component
10 On Board Devices
11 OEM Strings
12 System Configuration Options
13 BIOS Language
14 Group Associations
15 System Event Log
16 Physical Memory Array
17 Memory Device
18 32-bit Memory Error
19 Memory Array Mapped Address
20 Memory Device Mapped Address
21 Built-in Pointing Device
22 Portable Battery
23 System Reset
24 Hardware Security
25 System Power Controls
26 Voltage Probe
27 Cooling Device
28 Temperature Probe
29 Electrical Current Probe
30 Out-of-band Remote Access
31 Boot Integrity Services
32 System Boot
33 64-bit Memory Error
34 Management Device
35 Management Device Component
36 Management Device Threshold Data
37 Memory Channel
38 IPMI Device
39 Power Supply
37 Memory Channel
38 IPMI Device
39 Power Supply
Here is some examples.
Note : In RHEL4 there are no options for dmidecode command.
To find only BIOS info
#dmidecode –t 0
[root@test ~]# dmidecode --type 0
# dmidecode 2.7
SMBIOS 2.5 present.
Handle 0x0000, DMI type 0, 24 bytes.
BIOS Information
Vendor : Phoenix Technologies, LTD
Version : MS7352 1.14
Release Date : 09/03/2008
Address : 0xE0000
Runtime Size : 128 kB
ROM Size : 1024 kB
Characteristics:
ISA is supported
PCI is supported
PNP is supported
APM is supported
BIOS is upgradeable
BIOS shadowing is allowed
Boot from CD is supported
Selectable boot is supported
BIOS ROM is socketed
EDD is supported
5.25"/360 KB floppy services are supported (int 13h)
5.25"/1.2 MB floppy services are supported (int 13h)
3.5"/720 KB floppy services are supported (int 13h)
3.5"/2.88 MB floppy services are supported (int 13h)
Print screen service is supported (int 5h)
8042 keyboard services are supported (int 9h)
Serial services are supported (int 14h)
Printer services are supported (int 17h)
CGA/mono video services are supported (int 10h)
ACPI is supported
USB legacy is supported
LS-120 boot is supported
ATAPI Zip drive boot is supported
BIOS boot specification is supported
Function key-initiated network boot is supported
Targeted content distribution is supported
BIOS Revision: 1.14
Even we can specify keyword for specifying type if you forget the type number, so just type the keyword to check particular property of the styem.
Keyword Types
------------------------------
bios 0, 13
system 1, 12, 15, 23, 32
baseboard 2, 10
chassis 3
processor 4
memory 5, 6, 16, 17
cache 7
connector 8
slot 9
Suppose we want to see system details
[root@test ~]# dmidecode --type system
# dmidecode 2.7
SMBIOS 2.5 present.
Handle 0x0001, DMI type 1, 27 bytes.
System Information :
Manufacturer : Hewlett-Packard
Product Name : HP Compaq dx7400 Microtower
Version:
Serial Number: SGH83801NJ
UUID: 809AF9C0-17F0-1310-9511-C4681D1F835D
Wake-up Type: Power Switch
SKU Number: GD384AV
Family: 103C_53307F
Handle 0x0024, DMI type 32, 11 bytes.
System Boot Information
Status: No errors detected
[root@test ~]#
Some other useful commands to get system info are
To get CPU info
#cat /etc/cpuinfo
To get HW info
#lshal
or
#lshw
To get PCI info
#lspci
To get USB info
#lsusb
Please comment your thoughts about this post.
To get CPU info
#cat /etc/cpuinfo
To get HW info
#lshal
or
#lshw
To get PCI info
#lspci
To get USB info
#lsusb
RSYNC --The tool every Admin should know
Recently I came accross rsync utility... Its an awesome command it is a sub service under xinetd along with some other services such as tftp, rcp, rsh, rlogin, telnet etc..
Let us list advantages of this command then we will know how to configure it.
Advantages of rsync :
Configuration : rsync
Some points to be remembered when dealing with rsync
#yum install xinetd
Step2 : Configure rsync to allow connections, the configuration file for rsync is located in /etc/xinetd.d
#cd /etc/xinetd.d
#vi rsync
wait = no
user = root
server = /usr/bin/rsync
server_args = --daemon
log_on_failure += USERID
}
Step3 : Start the rsync service, so how to do it? As i mention earlier that rsync is a part of xinetd service so just restart the xinetd service.
#service xinetd restart
Step4 : Permanently on the service
#chkconfig rsync --levels 345 on
Let us list advantages of this command then we will know how to configure it.
Advantages of rsync :
- This tool will keep both the destination and source folder synced.
- rsync is fast, because it will not copy entire data every time it got synced, it just copes the date which got changed from previous copy.
- For security reasons, rsync will support ssh to transfer data between two machines.
- rsync is used to download RPM updated repository to local machine.
Configuration : rsync
Some points to be remembered when dealing with rsync
- This utility is the part of xinetd so there is no special package for this.
- When we are doing rsync between two systems, both the systems should be configured to allow rsync connections.
- rsync uses 873.
#yum install xinetd
Step2 : Configure rsync to allow connections, the configuration file for rsync is located in /etc/xinetd.d
#cd /etc/xinetd.d
#vi rsync
# default : off
# description: The rsync server is a good addition to an ftp server, as it \
# allows crc checksumming etc.
service rsync
{
disable = yes
socket_type = stream
wait = no
user = root
server = /usr/bin/rsync
server_args = --daemon
log_on_failure += USERID
}
# description: The rsync server is a good addition to an ftp server, as it \
# allows crc checksumming etc.
service rsync
{
disable = yes
socket_type = stream
wait = no
user = root
server = /usr/bin/rsync
server_args = --daemon
log_on_failure += USERID
}
In this configuration file just change disable = yes to no, then save the file and exit. Here is the updated configured file.
# description: The rsync server is a good addition to an ftp server, as it \
# allows crc checksumming etc.
service rsync
{
disable = no
socket_type = stream# allows crc checksumming etc.
service rsync
{
disable = no
wait = no
user = root
server = /usr/bin/rsync
server_args = --daemon
log_on_failure += USERID
}
Step3 : Start the rsync service, so how to do it? As i mention earlier that rsync is a part of xinetd service so just restart the xinetd service.
#service xinetd restart
Step4 : Permanently on the service
#chkconfig rsync --levels 345 on
Linux User-management
MONITORING USERS-I
User-management is always one of the basic tasks for Linux administrators, here we are going to see some basics user related "Monitoring Commands".
1) "finger" is a command which will give full details about user properties such as name, login, shell what he is using etc.
Syntax:
#finger username
Example:[root@localhost ~]# finger root
Login: root Name: root
Directory: /root Shell: /bin/bash
On since Sat Jun 6 19:20 (EDT) on tty1 4 hours 12 minutes idle
On since Sun Jun 7 02:18 (EDT) on pts/0 from :0.0
On since Sun Jun 7 03:48 (EDT) on pts/1 from :0.0
16 minutes 9 seconds idle
New mail received Sun Jun 7 04:02 2009 (EDT)
Unread since Sat Jun 6 22:17 2009 (EDT)
No Plan.
Here you can see so many user related information
one security information you can see is when he loged in last time and from where he loged in etc.
2)"id" is one more command which will show the user details such as his primary group and his secondary group.
Syntax:
#id username
Example:
[root@localhost ~]# id root
uid=0(root) gid=0(root) groups=0(root),1(bin),2(daemon),3(sys),4(adm),6(disk),10(wheel) context=root:system_r:unconfined_t:SystemLow-SystemHigh
[root@localhost ~]#
3)"chage" is one more command which is used to see user related "threshold details" such as user disable time etc.
Syntax:
#chage -l username
Example:
[root@localhost ~]# chage -l root
Last password change : Jun 06, 2009
Password expires : never
Password inactive : never
Account expires : never
Minimum number of days between password change : 0
Maximum number of days between password change : 99999
Number of days of warning before password expires : 7
[root@localhost ~]#
4)"who" is one more command to see who other people logged in and from where they logged in.
Syntax:#who
Example:
[root@localhost ~]# who
root tty1 2009-06-06 19:20
root pts/0 2009-06-07 02:18 (:0.0)
root pts/1 2009-06-07 03:48 (:0.0)
[root@localhost ~]#
5)"w" is one more command which is similar to "who" command but will give some more details.
Example:
[root@localhost ~]# w
06:36:49 up 11:23, 3 users, load average: 0.54, 0.38, 0.42
USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT
root tty1 - 19:20 4:27m 0.69s 0.69s -bash
root pts/0 :0.0 02:18 0.00s 0.16s 0.02s w
root pts/1 :0.0 03:48 31:25 0.10s 0.10s bash
[root@localhost ~]#
6)"groups" is one more wonderful command which will show which user belongs to what groups, we can say its a subset of id command
Syntax:
#groups username
Example:
[root@localhost ~]# groups root
root : root bin daemon sys adm disk wheel
[root@localhost ~]#
7)"users" is one more monitoring command to see which users loged in at present in to the system
Example:
[root@localhost ~]# groups root
root : root bin daemon sys adm disk wheel
[root@localhost ~]#
Please add if you know some other user related monitoring commands.
User-management is always one of the basic tasks for Linux administrators, here we are going to see some basics user related "Monitoring Commands".
1) "finger" is a command which will give full details about user properties such as name, login, shell what he is using etc.
Syntax:
#finger username
Example:[root@localhost ~]# finger root
Login: root Name: root
Directory: /root Shell: /bin/bash
On since Sat Jun 6 19:20 (EDT) on tty1 4 hours 12 minutes idle
On since Sun Jun 7 02:18 (EDT) on pts/0 from :0.0
On since Sun Jun 7 03:48 (EDT) on pts/1 from :0.0
16 minutes 9 seconds idle
New mail received Sun Jun 7 04:02 2009 (EDT)
Unread since Sat Jun 6 22:17 2009 (EDT)
No Plan.
Here you can see so many user related information
one security information you can see is when he loged in last time and from where he loged in etc.
2)"id" is one more command which will show the user details such as his primary group and his secondary group.
Syntax:
#id username
Example:
[root@localhost ~]# id root
uid=0(root) gid=0(root) groups=0(root),1(bin),2(daemon),3(sys),4(adm),6(disk),10(wheel) context=root:system_r:unconfined_t:SystemLow-SystemHigh
[root@localhost ~]#
3)"chage" is one more command which is used to see user related "threshold details" such as user disable time etc.
Syntax:
#chage -l username
Example:
[root@localhost ~]# chage -l root
Last password change : Jun 06, 2009
Password expires : never
Password inactive : never
Account expires : never
Minimum number of days between password change : 0
Maximum number of days between password change : 99999
Number of days of warning before password expires : 7
[root@localhost ~]#
4)"who" is one more command to see who other people logged in and from where they logged in.
Syntax:#who
Example:
[root@localhost ~]# who
root tty1 2009-06-06 19:20
root pts/0 2009-06-07 02:18 (:0.0)
root pts/1 2009-06-07 03:48 (:0.0)
[root@localhost ~]#
5)"w" is one more command which is similar to "who" command but will give some more details.
Example:
[root@localhost ~]# w
06:36:49 up 11:23, 3 users, load average: 0.54, 0.38, 0.42
USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT
root tty1 - 19:20 4:27m 0.69s 0.69s -bash
root pts/0 :0.0 02:18 0.00s 0.16s 0.02s w
root pts/1 :0.0 03:48 31:25 0.10s 0.10s bash
[root@localhost ~]#
6)"groups" is one more wonderful command which will show which user belongs to what groups, we can say its a subset of id command
Syntax:
#groups username
Example:
[root@localhost ~]# groups root
root : root bin daemon sys adm disk wheel
[root@localhost ~]#
7)"users" is one more monitoring command to see which users loged in at present in to the system
Example:
[root@localhost ~]# groups root
root : root bin daemon sys adm disk wheel
[root@localhost ~]#
Please add if you know some other user related monitoring commands.
Linux Login Problems
When a user/root try to login to Linux system there are so many problems which will prevent the root/user not to login.
Here we will see what are the problems which will prevent user from not to login to system and try to resolve them one by one.
We can divide these problems in to two categories:
Logging in to the system when you are present infront of the system.
Issue1:Check weather the password you are typing is correct or not, what I mean is Case sensitive etc,
here I am considering that you forgot the password for that system, In this case follow these steps
Issue2:Still not able to login to system except runlevel1, so how to resolve this issue?
Step1 : Check the root properties by using finger command.
#finger root
Login: root Name: root
Directory: /root Shell: /sbin/nologin
Never logged in.
this command will give you the properties of the root user, here we have to check what is the shell he is using, the shell should not be nologin shell. If the shell for the root user is no login shell he will not able to login to system so we have to change the login shell from /sbin/nologin shell to some other shells such as /bin/bash.
To do this we can use chsh command
#chsh -l
This command will display all the shell's installed in your system, to change the shell.
#chsh /bin/bash
then execute finger command to check weather shell has been changed to our required shell or not
#finger root
Step2 : Still not able to login? try if there is any age related issues is there on root user
#chage -l root
It will display the age related info for the root user.
Please increase the age of the root user expiry time
#chage root
Step3 : Still unable to login? Check for security related restriction on root user
Check in /etc/securetty file wether all the entries are there or not(in this file there will be entirs of the terminals from where root user can access the system) check weather tty1 to tty7 and vc1 to vc7 are there or not if they are not there add them and try to login.
Here we will see what are the problems which will prevent user from not to login to system and try to resolve them one by one.
We can divide these problems in to two categories:
- Physically present at system.
- Accessing system from remote location(through network).
Logging in to the system when you are present infront of the system.
Issue1:Check weather the password you are typing is correct or not, what I mean is Case sensitive etc,
here I am considering that you forgot the password for that system, In this case follow these steps
Issue2:Still not able to login to system except runlevel1, so how to resolve this issue?
- Check root user properties such as shell type, age and security etc?
Step1 : Check the root properties by using finger command.
#finger root
Login: root Name: root
Directory: /root Shell: /sbin/nologin
Never logged in.
this command will give you the properties of the root user, here we have to check what is the shell he is using, the shell should not be nologin shell. If the shell for the root user is no login shell he will not able to login to system so we have to change the login shell from /sbin/nologin shell to some other shells such as /bin/bash.
To do this we can use chsh command
#chsh -l
This command will display all the shell's installed in your system, to change the shell.
#chsh /bin/bash
then execute finger command to check weather shell has been changed to our required shell or not
#finger root
Step2 : Still not able to login? try if there is any age related issues is there on root user
#chage -l root
It will display the age related info for the root user.
Please increase the age of the root user expiry time
#chage root
Step3 : Still unable to login? Check for security related restriction on root user
Check in /etc/securetty file wether all the entries are there or not(in this file there will be entirs of the terminals from where root user can access the system) check weather tty1 to tty7 and vc1 to vc7 are there or not if they are not there add them and try to login.
Lost the Root password
When you lost root password how you can recover and login back in to the system?
To login in to system there are so many ways to get root access depending on security level of the system.
Method1: When there is no password set to access runlevel 1.
Here are the steps to change your root password the most esiest way is as follows..
1. Start your computer when you see Redhat Linux boot loader(GRUB menu where you can see all the Operating system's in the system) select the redhat linux and press "e", and select second line where you can set the temporary runlevel for the system to boot
2. You will notice that now you can edit boot loader command arguments now again press "e" and edit the line to add single or 1 without quots at the end of line.
3. Press enter to return to previous screen
4. Press b to boot with this new argument which will run Linux into single user mode. Please make sure that you see single at the end of line.
5. Now you will get root login with out asking for a password in single user mode.
6. Use "passwd" command to change your password.
#passwd
here it will not ask previous password so you can just enter new password.
7. When updateing the password in runlevel1 if the server is not allowing you to change password giving you error, this is due to /etc/shadow file issue.
In order to resolve this issue execute the following command and then try to change the password
#pwunconv
7.After changing the password just type exit command which will take you to default runlevel of the system or just Reboot and use the new password.
Method2: When GRUB boot loader is protected with a password.
When the GRUB boot loader is protected by a password the above mentioned method will not work, so how to login to the system?
In order to retrive root password we have to have first RHEL cd or a live CD(may be konpics/Ubuntu) .
It is easy to boot using the first Cd.
then enter into the rescue mode
just type linux rescue and boot prompt with out quoat
Now we will be logged in to a normal shell, do the folowing steps
Step1 : change the root partation to /mnt/sysimage
chroot /mnt/sysimage
Step2 : Now just change the password
passwd
Step3 : Exit from rescue mode
#exit
#exit
then login with the new passwd
And if you don't have the correct version CD, you can boot from a live CD,
Mkdir /a
mount ... /a
vi /a/etc/password
delete the password in /etc/shadow for root
Now it will come up with no root password (change immediately).
Method3: This method will give you how to retrive your lost root password, not for changing the root password
To login in to system there are so many ways to get root access depending on security level of the system.
Method1: When there is no password set to access runlevel 1.
Here are the steps to change your root password the most esiest way is as follows..
1. Start your computer when you see Redhat Linux boot loader(GRUB menu where you can see all the Operating system's in the system) select the redhat linux and press "e", and select second line where you can set the temporary runlevel for the system to boot
2. You will notice that now you can edit boot loader command arguments now again press "e" and edit the line to add single or 1 without quots at the end of line.
3. Press enter to return to previous screen
4. Press b to boot with this new argument which will run Linux into single user mode. Please make sure that you see single at the end of line.
5. Now you will get root login with out asking for a password in single user mode.
6. Use "passwd" command to change your password.
#passwd
here it will not ask previous password so you can just enter new password.
7. When updateing the password in runlevel1 if the server is not allowing you to change password giving you error, this is due to /etc/shadow file issue.
In order to resolve this issue execute the following command and then try to change the password
#pwunconv
7.After changing the password just type exit command which will take you to default runlevel of the system or just Reboot and use the new password.
Method2: When GRUB boot loader is protected with a password.
When the GRUB boot loader is protected by a password the above mentioned method will not work, so how to login to the system?
In order to retrive root password we have to have first RHEL cd or a live CD(may be konpics/Ubuntu) .
It is easy to boot using the first Cd.
then enter into the rescue mode
just type linux rescue and boot prompt with out quoat
Now we will be logged in to a normal shell, do the folowing steps
Step1 : change the root partation to /mnt/sysimage
chroot /mnt/sysimage
Step2 : Now just change the password
passwd
Step3 : Exit from rescue mode
#exit
#exit
then login with the new passwd
And if you don't have the correct version CD, you can boot from a live CD,
Mkdir /a
mount ... /a
vi /a/etc/password
delete the password in /etc/shadow for root
Now it will come up with no root password (change immediately).
Method3: This method will give you how to retrive your lost root password, not for changing the root password
Subscribe to:
Posts (Atom)