Friday, April 30, 2010

Runlevels

Run level defines which services will start during booting. There are seven runlevels (0-6). A runlevel is a software configuration of the system that allows only a selected group of processes to exist. Init can run the system in one of eight runlevels. These runlevels are 0-6 and S or s. The system runs in only one of these runlevels at a time. Runlevels 0,1, and 6 are reserved. The runlevels are as follows:-

0(rc0.d)-halt (Don't set init default to this.)
1(rc1.d)-Single user mode.
2(rc2.d)-Multiuser without network file system(nfs)
3(rc3.d)-Multiuser mode (boot up in text mode.)
4(rc4.d)-Unused
5(rc5.d)-Multi user mode boot up in X-windows.
6(rc6.d)-Shutdown & Reboot(Don't set init default to this.)

Sunday, April 11, 2010

Virtual Console

Here I am talking about how we can create virtual consoles (shell screen):-
In RHEL (Red Hat Enterprise Linux) we have six virtual consoles by default we can switch to any one by pressing Ctrl+Alt+F[1-6] and back to GUI by Ctrl+Alt+F7.
If we want to create some more virtual console(we can create up to 63 virtual consoles) we can:-
Suppose we want to create virtual console no. 22 here are the steps:-
1. Open inttab file the
vim /etc/inittab 
2. Add line in 'Run gettys in standard runlevels'
"22:2345:respawn:/sbin/mingetty tty22" the same parameter we will be follows as given for other consoles.
3. Save the inittab file and exit
4. Run command "init q" to re-examine the inittab file.
5. Now If we give command "chvt 22" at prompt a new shell screen will appear. But we can't login since the user (root) is not allowed to login in the shell.
6. Open "/etc/securetty" file and add line as given "vc/22" and "tty22" in the file.
7. Save the securetty file and exit.
8. Now run the "chvt 22" at the prompt. You can login as user (root).
9. Similarly we can create more consoles. Isn't interesting.

Kernel

Kernel is the core of the LINUX OS. It performs following functions:-
a) Device Detection:- During booting kernel detects connected devices and checks whether they are connected or not.
b)Device Driver Initialization:- After detecting connected devices kernel loads proper driver of corresponding device.
c) Mount Root File system:- It mounts root filesystem in read only mode.
d) Execute Init:- It loads and executes initial process i.e. 'init'.
e) Manage Security:- It constantly verifies filesystem permission, SELinux contexts and firewall rules.

To know about you kernal information type following command at prompt:-
uname -a (a for all info)
uname -r (r for release)
uname -s (s for kernel name)
uname -v (v for kernel version)
uname -m (m for machine name)
uname -o (o for operating system)
There are more options you can easily explore.

Protect GRUB from editing

At first I want to give you a brief intro about what GRUB is :-
GRUB (GRand Unified Bootloader) a default bootloader of LINUX.

It has two stages:-
1. The first stage is very small(446 bytes) and it resides within Master Boot Record or boot sector. It is called IPL (Initial Program Loader).
2. It Loaded from boot partition above 70MB.

Features of GRUB:-
1. Command line interface is available at boot prompt.
2. It supports ext2, ext3, fat, jfs file system.
3. It provides md5 password protection.

Now I am explaining you how you can protect grub from editing:-
a) Login at command prompt and give command grub-md5-crypt (to generate md5 password).
b) Now open grub configuration file i.e. /boot/grub/grub.conf and after the splash image add line
password --md5 md5password(copy the md5 password you get from console and paste it here.)
c) Reboot the system.
d) When the GRUB menu appears it will ask you to press p for password to unlock the menu (mainly to login as single user mode to change the root password.)