Custom GRUB splash image

  • Log or Switch in to the root account
  • Get an image file to use for the new splash image (can be some wallpaper in jpg, png format)
  • Check whether ImageMagick rpm is installed
[root@server ~]# rpm -q ImageMagick
  • If it's not installed you have to install it first
[root@server ~]# yum -y install ImageMagick
  • Then, Assuming the image is in the root's home folder & the image name is "myboot.jpg"
[root@server ~]# cd
[root@server ~]# convert myboot.jpg -resize 640x480! -colors 14 -depth 8 myboot.xpm
[root@server ~]# ls
  • Now you will be able to see a file call "myboot.xpm"
  • Then you have to gzip it.
[root@server ~]# gzip myboot.xpm
[root@server ~]# ls
  • Now you will be able to see a file call "myboot.xpm.gz"
  • Then you have to copy it to "/boot/grub" folder
[root@server ~]# cp myboot.xpm.gz /boot/grub
  • Then you have to edit "grub.conf" file with your favorite text editor, I'll use "nano" text editor
[root@server ~]# nano /etc/grub.conf

Edit the following line





save & exit
  • Then reboot your system
[root@server ~]# reboot
  • Then you'll be able to see the new GRUB spalsh image during the startup.

Media playback in CentOS5 and RHEL5

Media (DVD, web content, video & audio) playback in CentOS5 and RHEL5

01. Download RPMFORGE repo configuration RPM.



Go to the downloaded location, Install it.

[root@server ~]# rpm -ivh rpmforge-release-0.3.6-1.el5.rf.i386.rpm

[root@server ~]#rpm -ivh rpmforge-release-0.3.6-1.el5.rf.x86_64.rpm

02. DVD playback
[root@server ~]#yum -y install libdvdcss libdvdread libdvdplay libdvdnav lsdvd libdvbpsi

03. Gstreamer and Gstreamer-plugins
[root@server ~]#yum -y install gstreamer gstreamer-plugins-good gstreamer-plugins-bad gstreamer-plugins-ugly

04. Mplayer and Mplayer-plugin
[root@server ~]#yum -y install mplayer mplayerplug-in

05. XMMS with MP3 support and Other codecs
[root@server ~]#yum -y install xmms xmms-crossfade xmms-mp3 xmms-musepack xmms-wma

06. W32codecs


Go to the downloaded location and install
[root@server ~]#rpm -ivh w32codecs-20071007-0.1.i386.rpm

07. Adobe Flash Player


Go to the downloaded location and install
[root@server ~]#rpm -ivh adobe-release-i386-1.0-1.noarch.rpm

Then install the flash player
[root@server ~]#yum -y install flash-plugin

08. Sun Jre (Java Runtime Environment)

Install the dependencies
[root@server ~]# yum -y install compat-libstdc++-33 compat-libstdc++-296

Go to and go to download section download the Linux RPM (self-extracting file)
Go to the downloaded location
[root@server ~]#chmod +x jre-6u12-linux-i586-rpm.bin
[root@server ~]#./jre-6u12-linux-i586-rpm.bin

[root@server ~]#java –version

If the result is some thing like this, every thing is ok.
java version "1.6.0_12"
Java(TM) SE Runtime Environment (build 1.6.0_12-b04)
Java HotSpot(TM) Client VM (build 11.2-b01, mixed mode, sharing)

othewise the result is something like this, that means sun java is not yet default.
java version "1.4.2"
gij (GNU libgcj) version 4.1.2 20071124 (Red Hat 4.1.2-42)

Copyright (C) 2006 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO

To make sun java default
[root@server ~]#alternatives --install /usr/bin/java java $(rpm -ql jre | grep bin/java$) 2
[root@server ~]#alternatives --display java
[root@server ~]#alternatives --config java
type number 2

installing sun java plugin for firefox
first we have to disable selinux protection for the plugin
check the status of selinux
[root@server ~]#getenforce

if the result is "disabled" no need to do the following command, othewise you do
[root@server ~]#chcon -t textrel_shlib_t "$(rpm -ql jre | grep libdeploy\\.so$)"

now we can install the plugin
[root@server ~]#cd /usr/lib/mozilla/plugins
[root@server ~]#ln –s /usr/java/jre1.6.0_12/plugin/i386/ns7/


Forgot your Windows admin password?


  • This is a utility to (re)set the password of any user that has a valid (local) account on your Windows NT/2k/XP/Vista etc system.
  • You do not need to know the old password to set a new one.
  • It works offline, that is, you have to shutdown your computer and boot off a floppydisk or CD or another system.
  • Will detect and offer to unlock locked or disabled out user accounts!
  • There is also a registry editor and other registry utilities that works under linux/unix, and can be used for other things than password editing.


NT stores its user information, including crypted versions of the passwords, in a file called 'sam', usually found in \windows\system32\config. This file is a part of the registry, in a binary format previously undocumented, and not easily accessible. But thanks to a German(?) named B.D, I've now made a program that understands the registry.

This site provides CD and floppy images for end users to easily edit their forgotten passwords. But it also provides full source code and binary builds of the tools to allow others to use as they like for other purposes. Registry format documentation also available.

How to get it

The following is available for download and information:


Accessing Windows partitions from Linux

By default any Linux system will fully support FAT partitions, But when it comes to NTFS some are still NOT supporting by default.

Desktop Editions such as Ubuntu 7.10 and Fedora 8 now fully supporting NTFS (with write support), and the partitions are automatically mounted.

Server Editions such as CentOS 5 and RHEL 5 you have to do the following to access NTFS partitions.

01. Configure RPMFroge 3rd party repository, please read my tutorial about CentOS Repositories.

02. Install the following packages
[root@server ~]# yum install dkms-fuse fuse-ntfs-3g

Accessing the Windows partitions.

01. See what are the current partitions in your system, and figure out what partitions belongs to windows.

[root@server ~]# fdisk -l

Usually NTFS partitions will be displayed with a HPFS/NTFS label, Where as FAT partitions will be labeled as W95 FAT32 or W95 FAT16

In the example I'm assuming,

/dev/hda1 = NTFS
/dev/hda2 = FAT32

02. Create mount points for each windows partition that you have in the system.

[root@server ~]# mkdir /media/ntfs
[root@server ~]# mkdir /media/fat32


[root@server ~]# ls -l /media

Note - The mount point name can be any name that you like.

03. Manually mounting the partitions.


[root@server ~]# mount /dev/hda2 /media/fat32
[root@server ~]# cd /media/fat32
[root@server ~]# ls -l

Note - You'll be having Read/Write access to FAT partitions.


[root@server ~]# mount -t ntfs-3g /dev/hda1 /media/ntfs
[root@server ~]# cd /media/ntfs
[root@server ~]# ls -l

Note - You'll be having Read/Write access to NTFS partitions.

Once you manually mount the partitions, when you shutdown your PC the partitions will be automatically unmounted.

04. Automatically mounting the partition on boot.

[root@server ~]# nano /etc/fstab

at the end of file, enter the following lines.

/dev/hda1 /media/ntfs ntfs-3g defaults 0 0
/dev/hda2 /media/fat vfat defaults 0 0

What we have done is, first we give the partition number then the mount point then the file system then the permissions then whether to check the partition in case of a power failure, 0 (zero) means don't check since we don't have necessary tools to check NTFS or FAT partitions and finally the checking priority.

05. So now every time you boot your PC the partitions will be automatically mounted to the mount points.


yum command: Update / Install Packages

yum command: Update / Install Packages under /RHEL / CentOS Linux Version 5.x

Q. How do I use yum command to update and patch my Red hat Enterprise Linux / CentOS Linux version 5.x server via RHN / Internet? Can I use up2date command under RHEL 5?

A. up2date command was part of RHEL v4.x or older version. You need to use yum command to update and patch the system using RHN or Internet. Use yum command to install critical and non-critical security updates as well as binary packages. Login as the root user to install and update the system.

Task: Register my system with RHN
To register your system with RHN type the following command and just follow on screen instructions (CentOS user skip to next step):
[root@server ~]# rhn_register

Task: Display list of updated software (security fix)
Type the following command at shell prompt:
[root@server ~]# yum list updates

Task: Patch up system by applying all updates
To download and install all updates type the following command:
[root@server ~]# yum update

Task: List all installed packages
List all installed packages, enter:
[root@server ~]# rpm -qa
[root@server ~]# yum list installed

Find out if httpd package installed or not, enter:
[root@server ~]# rpm -qa | grep httpd*
[root@server ~]# yum list installed httpd

Task: Check for and update specified packages
[root@server ~]# yum update {package-name-1}

To check for and update httpd package, enter:
[root@server ~]# yum update httpd

Task: Search for packages by name
Search httpd and all matching perl packages, enter:
[root@server ~]# yum list {package-name}
[root@server ~]# yum list {regex}
[root@server ~]# yum list httpd
[root@server ~]# yum list perl*

Task: Install the specified packages [ RPM(s) ]
Install package called httpd:
[root@server ~]# yum install {package-name-1} {package-name-2}
[root@server ~]# yum install httpd

Task: Remove / Uninstall the specified packages [ RPM(s) ]
Remove package called httpd, enter:
[root@server ~]# yum remove {package-name-1} {package-name-2}
[root@server ~]# yum remove httpd

Task: Display the list of available packages
[root@server ~]# yum list all

Task: Display list of group software
Type the following command:
[root@server ~]# yum grouplist

Task: Install all the default packages by group
Install all 'Development Tools' group packages, enter:
[root@server ~]# yum groupinstall "Development Tools"

Task: Update all the default packages by group
Update all 'Development Tools' group packages, enter:
[root@server ~]# yum groupupdate "Development Tools"

Task: Remove all packages in a group
Remove all 'Development Tools' group packages, enter:
[root@server ~]# yum groupremove "Development Tools"

Task: Install particular architecture package
If you are using 64 bit RHEL version it is possible to install 32 packages:
[root@server ~]# yum install {package-name}.{architecture}
[root@server ~]# yum install mysql.i386

Task: Display packages not installed via official RHN subscribed repos
Show all packages not available via subscribed channels or repositories i.e show packages installed via other repos:
[root@server ~]# yum list extras

Task: Display what package provides the file
You can easily find out what RPM package provides the file. For example find out what provides the /etc/passwd file:
[root@server ~]# yum whatprovides /etc/passwd

You can use same command to list packages that satisfy dependencies:
[root@server ~]# yum whatprovides {dependency-1} {dependency-2}

Refer yum command man page for more information:
[root@server ~]# man yum

Special thanks for nixCraft

Configuring rpmforge third party repository

01. Download the repository configuration file
[root@server ~]# wget
[root@server ~]# ls -l

02. Go to download location and double click on “rpmforge-release-0.3.6-1.el5.rf.i386.rpm” to install it.

03. Check
[root@server ~]# yum repolist

Optionally we can enable centos Plus and Contrib repositories

01. Locate the system file
[root@server ~]# cd /etc/yum.repos.d
[root@server ~]# ls –l

02. Open the file
[root@server ~]#nano CentOS.Base.repo

03. Go to end of file
[centos plus]
enable=0 change to enable=1

enable=0 change to enable=1

04. Save this file
Ctrl + O

05. Exit the file
Ctrl + X

06. Check
[root@server ~]# yum repolist

CentOS 5 Repositories

What is a Repository?

A software repository (sometimes abbreviated as a repo) is a storage location from which software packages may be retrieved and installed on a computer. Many software publishers and other organizations maintain servers on the Internet for this purpose, either free of charge or for a subscription fee.

CentOS Software Repositories (Official)

These repositories are already configured by default in CentOS.

Base repo - The packages that comes with the release media. (CDs or the DVD)
Packages in the Base repo -

Addons repo - The packages used/produced in the build but not released with the release media.
Packages in the Addons repo -

Extras repo - The additional packages that may be useful. (Non Essential)
Packages in Extras repo -

Centosplus repo - This repository is for items that actually upgrade certain base CentOS components. This repo will change CentOS to not be exactly like RHEL. (NOT COMPATIBLE WITH RHEL, DISABLED BY DEFAULT)

Packages in Centosplus repo -

Contrib repo - Packages made by CentOS users (from CentOS 5.3 DISABLED BY DEFAULT)
Packges in Contrib repo -

Updates repo - The updated packages of the above repos.
Packages in Updates repo -

CentOS Software Repositories (3rd Party)

These repositories are not by default configured in CentOS, You have to manually configure them.

RPMForge repo - Maintained by a software developer call "dag wieers". He is a member of the CentOS development team. Contains lots of 3rd party software for CentOS and RHEL.
Packages in RPMForge repo -

To configure the RPMForge repo you have to download and install the following rpm package.

For CentOS 5 i386 -

For CentOS 5 x86_64 -


User and Group management command

  • Create a new user account
[root@server ~]# useradd uddika
[root@server ~]# passwd uddika
Changing password for user uddika.
New UNIX password: ******
Retype new UNIX password: *****
passwd: all authentication tokens updated successfully.

  • Multisession Login(Users can login same time)
Then give a username and password

Count the login users
[root@server ~]# who

  • Changing your own password as a normal user
Login the account
[uddika@server ~]$ passwd
Changing password for user uddika.
Changing password for uddika.
(current) UNIX password: ******
New UNIX password: *******
Retype new UNIX password: *******
passwd: all authentication tokens updated successfully.

  • How to change the password properties of a user
View the current password properties
[uddika@server ~]$ chage -l uddika

Change the current password properties
[root@server ~]# chage uddika

  • The things that happened automatically once you create a user account
Every user will get a private home folder
[root@server ~]# ls -l /home

Every user will get a private group account
Username = Uddika Private Group name = Uddika

Every user will get a user id (uid) and group id (gid)
[root@server ~]# id Uddika

The user account database and the group account database will be automatically updated

  • User account database
View the user account database
[root@server ~]# cat /etc/passwd |more

Display last 10 records
[root@server ~]# tail /etc/passwd

Display last 5 records
[root@server ~]# tail –n5 /etc/passwd

  • Group account database
View the group account database
[root@server ~]# cat /etc/group |more
[root@server ~]# tail /etc/group

  • How to delete user account
View the current account
[root@server ~]# tail /etc/passwd

Delete with home folder
[root@server ~]# userdel –r username

Delete without home folder
[root@server ~]# userdel username

Verify the account
User account - [root@server ~]# tail /etc/group
Home folder - [root@server ~]# ls -l /home

  • Deleting Groups
View current groups
[root@server ~]# tail /etc/group

Delete the group
[root@server ~]# groupdel groupname

Verify group
[root@server ~]# tail /etc/group


Command History

01. Last thousand command display
[root@server ~]# history |more

02. Last ten command display
[root@server ~]# history 10

Once you logout or shutdown your pc your current command history will be saved in to a hidden file in your home folder.

03. See a hidden file
[root@server ~]# cd
[root@server ~]# cat .bash_history


System Information Command

01. Print all information
[root@server ~]# uname –a

02. Print the kernel name
[root@server ~]# uname –s

03. Print the network node hostname
[root@server ~]# uname –n

04. Print the kernel release
[root@server ~]# uname -r

05. Print the kernel version
[root@server ~]# uname -v

06. Print the machine hardware name
[root@server ~]# uname –m

07. Print the processor type
[root@server ~]# uname –p

08. Print the hardware platform
[root@server ~]# uname –i

09. Print the operating system
[root@server ~]# uname –o

10. Display this help and exit
[root@server ~]# uname --help

11. Output version information and exit
[root@server ~]# uname –version

12. PCI Information
[root@server ~]# lspci
[root@server ~]# lspci –v |more

13. USB Information
[root@server ~]# lsusb

14. CPU Information
[root@server ~]# cat /proc/cpuinfo

15. Memory (Ram) Information
[root@server ~]# cat /proc/meminfo |more


File Folder Searching Commands

01. Search for all data (System / Personal)
[root@server ~]#locate filename

02. For any data
Syntax - [root@server ~]# find location option parameterAccordingToOption
[root@server ~]# find / -name ‘inittab’

03. To search system files and there manuals
Syntax - [root@server ~] #whereis filename
[root@server ~]# whereis inittab

04. To locate system commands only
[root@server ~]# which cal


Storage Device Capacity Measuring Commands

01. Hard Disk Drive Storage Measuring Commands
[root@server ~]# df –hT /

02. Boot Partition Storage Measuring Commands
[root@server ~]# df –hT /boot

Removable Media Storage Measuring Commands (First you have to mount it)

03. CD/DVD/CD-RW/DVD-RW Storage Measuring Commands
[root@server ~]# df –hT /dev/scd0

04. Floppy Disk Drive Storage Measuring Commands
[root@server ~]# df –hT /dev/fd0

05. USB Storage Measuring Commands
[root@server ~]# df –hT /dev/sdb1

06. Folder Storage Measuring Commands
[root@server ~]# du –h /etc (Display all file and folder details)
[root@server ~]# du –hs /etc (Display folder details only)

07. File Storage Measuring Commands
[root@server ~]# du –h /boot/grub/grub.conf


Mounting a USB pen

01. Create a mount point – A place to load the data structure of the storage device (One time only)
[root@server ~]# mkdir /media/usb

02. See a mount point
[root@server ~]# ls -l /media

03. Fix the pen and verify the device driver assigned (sdb, sdc, sdd)

04. Mounting the USB
[root@server ~]# mount /dev/sdb1 /media/usb

05. See the pen drive data
[root@server ~]# cd /media/usb
[root@server ~]# ls –l

06. Before you unplug the pen
[root@server ~]# cd
[root@server ~]# umount /dev/sdb1


Mounting a Floppy Disk

01. Create a mount point – A place to load the data structure of the storage device (One time only)
[root@server ~]# mkdir /media/floppy

02. See a mount point
[root@server ~]# ls -l /media

03. Verify the device driver assigned to your Floppy Disk Driver
[root@server ~]# ls -l /dev/fl*
eg - /dev/fd0 , /dev/fd1

04. Mounting the Floppy
[root@server ~]# mount /dev/fd0 /media/floppy

05. See the floppy drive data
[root@server ~]# cd /media/floppy
[root@server ~]# ls –l

06. Before you take out the floppy
[root@server ~]# cd
[root@server ~]# umount /dev/fd0


Mounting a ROM drive

01. Create a mount point – A place to load the data structure of the storage device (One time only)
[root@server ~]# mkdir /media/cdrom

02. See a mount point
[root@server ~]# ls -l /media

03. Verify the device driver assigned to your ROM
[root@server ~]# ls -l /dev/cd*
eg - /dev/scd0 , /dev/scd1 , /dev/scd2

04. Mounting the ROM
[root@server ~]# mount /dev/scd0 /media/cdrom

05. See the ROM data
[root@server ~]# cd /media/cdrom
[root@server ~]# ls –l

06. To take out the media
[root@server ~]# cd
[root@server ~]# eject
[root@server ~]# eject /dev/scd0

07. To take in the media
[root@server ~]# eject –t
[root@server ~]# eject -t /dev/scd0


Object management command

Files (Text Base)

Create new file

#nano filename
#nano /etc filename
#touch filename
#touch /etc filename

To edit file

#nano filename

Read file

#nano filename
#cat filename
#cat filename |more

Read first 10 lines

#head filename
#head –n5 filename (Display first 5 lines)

Read final 10 lines

#tail filename
#tail –n5 filename (Display last 5 lines)

Create folder

#mkdir foldername
#mkdir /etc foldername

Create Symlink (Short cut)
Symlink pointing to folder

Create a symlink in your home folder to access “/usr/share/background/images” folder

Syntax - [root@server ~]# ln -s DestinationFolderPath SymlinkName

01. Change your home folder

02. Create symlink (symlink name uddika)
#ln –s /usr/share/background/images uddika

03. Check the link
#ls –l

04. Go to symlink
#cd uddika

Symlink pointing to file

Create a symlink in your home folder to access “/boot/grub/grub.conf”

Syntax - [root@server ~]# ln -s DestinationFilePath SymlinkName

01. Change your home folder

02. Create symlink (symlink name uddika)
#ln –s /boot/grub/grub.conf uddika

03. Check the link
#ls –l

04. Go to symlink
#nano uddika

Renaming the object (File, Folder and Symlink)

Syntax - [root@server ~]# mv CurrentObjectName NewObjectName
[root@server ~]# mv Grub GrubConf

Moving object (Cut & Paste)

Syntax - [root@server ~]# mv ObjectName NewLocation
[root@server ~]# mv bat /usr/share/background/images

Copying object
Syntax - [root@server ~]# cp FileName NewLocation
[root@server ~]# cp ball /usr/share/background/images

Syntax - [root@server ~]# cp -r FolderName NewLocation
[root@server ~]# cp -r /home/samba /tmp

Syntax - [root@server ~]# cp -d FileName NewLocation
[root@server ~]# cp -d /home/samba /tmp

Deleting Object

Files and Symlinks
Syntax - [root@server ~]# rm -f ObjectName
[root@server ~]# rm -f text1

Syntax - [root@server ~]# rm -rf FolderName
[root@server ~]# rm -rf ebook


Directory browsing and listing commands

Directory listing commands

01. See a current location (print work directory)

02. List content in the folder

03. List all content in the folder (Hidden file)
#ls -a
#tree -a

Object Color Codes

White Color – Text base files (Htmal , Java, etc….)
Dark Blue – Folders
Green – Executable binary files and executable text file (Scripts) or any files copied from windows to Linux.
Red – Compressed files (gzip, etc….)
Purple – Multimedia files (Mp3, Pictures)
Orange – Device Driver File
Light blue color – Symlinks (Short Cuts)

04. See a long list
#ls -l

05. Long list with a hidden file
#ls -la

06. Long list, with color, and hidden files and fit to screen
#ls --color -la |more

Directory browsing commands

To go to sub folders

Use the relative path of the folder
Don’t type the current location that you are in

Ex - #cd test
#cd uddika

To go to main folders

Use full path
Always start with /

Ex - #cd /etc
#cd /usr/share

07. One folder back
#cd ..

08. To your home folder

09. To previous location
#cd -

10. To root partitions
#cd /


Fedora 10 Enable GUI Root Login

Q. How do I enable root login under Fedora 10 Gnome GUI login screen / manager?

A. Fedora 10 uses pam module called This module is designed to succeed or fail authentication based on characteristics of the account belonging to the user being authenticated. One use is to select whether to load other modules based on this test. This module blocks root login using GUI.

Login as root

01. Then open GUI terminal (bash prompt) and type the following command to become root user:

$ su –

Fedora 10 update GDM config to allow root login

02. Type your root password. Next, make a backup of /etc/pam.d/gdm, enter:
#cp /etc/pam.d/gdm /root

03. Now open /etc/pam.d/gdm using nano or vi text editor, enter:
#nano /etc/pam.d/gdm
#vi /etc/pam.d/gdm

04. Alternatively, you can do everything in a one command:
#su -c 'nano /etc/pam.d/gdm'

05. Find line that read as follows:
auth required user != root quiet

06. Remove or comment out line by prefixing #.
# auth required user != root quiet

07. Save and close the file. Logout from terminal and from GUI itself. Now you should be able login as root user using GDM GUI login manager.


How to Backup MBR - Master Boot Record

The MBR (master boot record) is located at cylinder 0, head 0, and sector 1. It's the very first sector of the hard drive and it is 512 bytes in size. When the BIOS boot your machine it looks in the MBR for information on your partitions and the initial boot loader. The MBR contains a partition table and boot code. The boot code executes and then transfers the process to the boot loader program on your active (bootable) partition.

We can take the backup of MBR either to a floppy disk or to a CDROM.

01. Backup to a floppy:
#dd if=/dev/hda of=/dev/fd0 bs=512 count=1

02. Backup to CDR:

First, create the MBR backup to a file on your hard drive.
#dd if=/dev/hda of=mbr.bak bs=512 count=1

Now, burn the file you just created to CDR.


Creating a super user with root rights

Sudo is a program which can be used by normal users to execute programs as super user or any other user. Sudo access is controlled by /etc/sudoers. The users listed in /etc/sudoers file can execute commands with an effective user id of 0 and a group id of root's group.

The file '/etc/sudoers' should be edited with the editor "visudo".

01. First, create a user called "uddika"
#useradd uddika
#passwd uddika

02. To give a specific group of users limited root privileges, edit the file with visudo as follows:
# visudo

03. Go down to the line ‘# User privilege specification‘and add the following line.

uddika ALL=(ALL) ALL


How to disable direct root login.

Direct login for the root user is a major security issue. We can disable direct login access to reduce the security risk. This way we can have two separate passwords for root access which makes the box more secure. Also we are using the protocol 2 which is newer and more secure.

01. SSH into your server as 'admin' and gain root access by su

02. Copy and paste this line to edit the file for SSH logins
#nano /etc/ssh/sshd_config

03. Find the line
Protocol 2, 1

04. Uncomment it and change it to look like
Protocol 2

05. Next, find the line
PermitRootLogin yes

06. Uncomment it and make it look like PermitRootLogin no

07. Save the file Ctrl+o then Ctrl+x then enter

08. Now you can restart SSH
#/etc/rc.d/init.d/sshd restart

Now, no one will be able to login to root with out first loggin in as admin and 'su -' to root.

Be sure that you remember both the passwords!


How to Disable Telnet access on the server

Telnet sends password in plain text passwords and usernames through logins, and hackers can obtain these passwords easily as compared to SSH. TELNET server listens for incoming messages on port 23, and sends outgoing messages to port 23.

01. Login to your server through SSH as a root user.

02. Open file
#nano /etc/xinetd.d/telnet

03. Look for the line: disable = no and replace with disable = yes

04. Now restart the inetd service:
#/etc/rc.d/init.d/xinetd restart

05. Make sure it is turned through chkconfig as well because it can still start through that.
#/sbin/chkconfig telnet off

06. Scan your server to ensure port 23 is closed.
#nmap -sT -O localhost

Also run ps -aux | grep telnet and if you find anything other than “grep telnet” as result kill the process.


How to setup auto logout time in a CLI

We can set up automatic logout for root session so that session gets logged off, if it is idle for a while. It is important to know this as any sneaker can misuse the situation, when a root user leaves the session idle. The method is very simple and as follows:

01. Locate the system file
#nano .bashrc

02. Go to under the “#user specific aliases and functions” line and then type

03. Save this file
Ctrl + O

04. Exit the file
Ctrl + X

Here TMOUT is an environment variable which instructs the bash shell to exit if the session is idle. Here timeout is set as 300 seconds (5 minutes).


How to disable interactive startup in Linux

01. Login as root

02. Edit this system file
#nano /etc/sysconfig/init

03. Go to end of the file
You will see “PROMPT=yes” it’s change to “PROMPT=no”

04. Save this file
Ctrl + O

05. Exit the file
Ctrl + X


How to change the grub password

01. Login as root

02. create an new encrypted password for grub
Password: ****** (uddika)
Encrypted: $1$ZWnke0$1fzDBVjUcT1Mpdd4u/T961 (encrypted password)

03. copy the new encrypted password by highlighting it using the mouse

04. Open the grub configuration file for editing
#nano /etc/grub.conf

05. Find this line
password --md5 $1$gLhU0/$aW78kHK1QfV3P2b2znUoe/

06. Replace with the following line (Right click the mouse to paste new password)
password --md5 $1$ZWnke0$1fzDBVjUcT1Mpdd4u/T961 (encrypted password above)

07. Save this file
Ctrl + O

08. Exit the file
Ctrl + X


Enable user authentication for single user mode

By default you will be automatically logged in to single user mode as root, this can be security risk so better to enable a user login add the single user mode

Note - Debian and therefore Ubuntu both require root password when booting into
single user mode or recovery mode. RHEL and CentOS allows access from the console
into single user mode without a password. This is handy when things get
messed up preventing access to the auth subsystems. To accomplish the
same behavior under Ubuntu, edit the /etc/inittab file and change the line

01. To edit this system file
#nano /etc/inittab

02. Go to a new line at the end of file then type

03. Save this file
Ctrl + O

04. Exit the file
Ctrl + X


Recover root password

It happens sometime that you can't remember root password. On Linux, recovering root password can be done by booting Linux under a specific mode: single user mode.
This tutorial will show how to boot Linux in single user mode when using GRUB and finally how to change root password.

During normal usage, a Linux OS runs under runlevels between 3 and 5 which correspond to various multi-user modes. Booting Linux under runlevel 1 will allow one to enter into a specific mode, single user mode. Under such a level, you directly get a root prompt. From there, changing root password is a piece of cake.

01. Start your PC at the boot loader press the space bar before 5 seconds

02. Press “p” and give the boot loader password

03. Press “a” to modify the kernel arguments before booting

04. At the end of the line add the word single or 1
grub append> ro root=/dev/lvm/logvol01 rhgb quiet 1

05. It will be logged on as root user

06. Change the root password (As root, changing password does not ask for your old password, therefore running the command :)


Disable Ctrl + ALT + Del restart

01. Login as root

02. Edit the following system file (inittab)

03. To locate the system file
#whereis inittab

04. To find out the file type
#file /etc/inittab

05. To edit the text editor
#nano /etc/inittab

06. Comment this line
#ca::ctrlaltdel:/sbin/shutdown –ts –r now

07. Save this file
Ctrl + O

08. Exit the file
Ctrl + X

09. Reload the inittab file in to memory again
#init q
or otherwise we have to restart the system


Changing Run Level of Linux

During the boot process for RHEL and CentOS systems the init command opens the /etc/inittab file to decide what "runlevel" the system should be booted to. The /etc/inittab file is a plain text file that can be opened with your favorite text editor.

01. Login as a root

02. Locate the following system file "inittab" (Initialization Table Tab)

03. Places --> Search for File --> Give a file name and select a looking folder for root

04. To edit the system file double click

This tells the init process that the default run level for the system is run level 5. To change to a different run level simply change the number and save the /etc/inittab file. Before doing this, however, be absolutely sure you know which run level you want. Selecting the wrong run level can have serious consequences. To help with this a detailed description of the individual run levels is outlined below:

Run Levels

0. Run Leve 0 (Halt) - Shutdown for Machine
1. Run Level 01 (Single User Mode) - Risque mode/ safe mode for Linux for trouble shooting
2. Run Level 02 (Multi User, Without NFS) - Only booting to the CLI, Multiple users can logging but no networking services.
3. Run Level 03 (Full Multi User Mode) - Only booting to the CLI, Multiple users can logging, but with enable all Networking services
4. Run Level 04 (Unused) - Custom run level for system developers, Currently unused.
5. Run Level 05 (X11) - Booting to the GUI anybody can logging with all network services enable
6. Run Level 06(Reboot) - Reboot for Machine

05. Change Run Level

06. Save and exit your file and reboot your system

07. After changing the run level, How to go to GUI

08. Manually change desktop with CLI
From Gnome to KDE - #switchdesk kde
You can Check - #startx

From KDE to Gnome - #switchdesk gnome
You can Check - #startx