Wednesday, December 1, 2010

Swap Space

1. To setup swap space on a newly created partition :
# mkswap /dev/sdb3

2. To enable the swap partition :
# swapon /dev/sdb3

3. To enable the above swap device at boot time, add the below line to /etc/fstab

/dev/sdb3 swap swap defaults 0 0

4 To create a swap file:

a. Create an empty file
# dd if=/dev/zero of=/swapfile bs=1024 count=65536

b. Create swap space on the file
# mkswap /swap-file

c. Enable the swap file
# swapon /swap-file

d. Add the below line to /etc/fstab
/swap-file swap swap defaults 0 0

5. To remove a swap file

a. Disable swap on the file
# rmswap /swap-file
b. Remove the corresponding entry in /etc/fstab
c. Delete the file
# rm /swap-file

Kernel Module

1. To list the currently loaded kernel modules :
# lsmod

2. To load a module :
# modprobe hid
For detailed output:
# modprobe -v hid

3. To unload a module (only the unused and undependent modules) :
# rmmod hid

4. Module files are kept under /lib/modules//kernel/drivers/

5. To display information about a specific module :
# modinfo -d hid

Identifying a system using /proc Filesystem

1. To show the OS (Kernel) version:
# cat /proc/version

2. To identify the processor details :
# cat /proc/cpuinfo

3. To identify the memory information :
# cat /etc/meminfo

4. To show the raid devices :
# cat /proc/mdstat

5. File containing the disk partition details :
/proc/partitions

6. File containing the swap details :
/proc/swaps

7. File containing the uptime details :
/proc/uptime

Starting and Stopping Services

1. To start http service :
# /etc/rc.d/init.d/httpd start
# service sshd start

2. To stop http service :
# /etc/rc.d/init.d/httpd stop
# service sshd stop

3. To restartp http service :
# /etc/rc.d/init.d/httpd restart
# service sshd restart

4. To show the status of http service :
# /etc/rc.d/init.d/httpd status
# service sshd status

5. To show the status of all the services :
# service --status-all

6. To list the state of a service in different run levels :
# chkconfig --list ypxfrd

7. To list the state of all the services in different run levels :
# chkconfig --list

8. To enable SSH service in run levels 2,3 and 4 :
# chkconfig --level 234 sshd on

9. To disable SSH service in run levels 2,3 and 4 :
# chkconfig --level 234 sshd off

Software Management

1. To install a RPM package :
# rpm -ivh foo-1.0-2.i386.rpm

2. To uninstall a RPM package :
# rpm -e foo

3. To upgrade a RMP package :
# rpm -Uvh foo-1.0-2.i386.rpm

4. To query a RPM package :
# rpm -q foo
# rpm -qa | grep foo

5. To display a RPM package information :
# rpm -qi foo

6. To check the signatue of a RPM package :
# rpm --checksig foo

7. To list files in a RPM package :
# rpm -ql foo

8. To list all the installed RPMs :
# rpm -qa

Hardware Information

1. To show the SCSI HDD/CD/VD drive information

# sdparm -i /dev/sda

2. To show the IDE HDD/CD/VD drive information

# hdparm -i /dev/hda