Labels

hpunix (63) marathi kavita (52) linux (21) solaris11 (11) AWS (5) numerology (5)

Monday, March 6, 2017

Linux Query or Interview question - 5

Query 1. How to check run level of your system. Can we change runlevel and how?

Ans: A run level is a software program which tells your machine to run/process/allows defined group of processes. The default run level can be checked by below command:

[root@ testmachine ~]# who -r
         run-level 5  2015-12-08 16:39

Here we are having run level 5.

USe of runlevel:

#   0 - halt (Do NOT set initdefault to this); otherwise system will be in halt/power-down state permanently
#   1 - Single user mode - for administrative purpose
#   2 - Multiuser, without NFS (The same as 3, if you do not have networking)
#   3 - Full multiuser mode
#   4 - unused
#   5 - X11
#   6 - reboot (Do NOT set initdefault to this); otherwise system will keep on rebooting.

We can get default run level information from /etc/inittab as well.

[root@ testmachine ~]# grep initdefault /etc/inittab |grep -v reboot |grep -v halt
id:5:initdefault:

If we want keep default run level 3 means after reboot the system should come in run level 3 then edit /etc/inittab.

[root@ testmachine ~]# vi /etc/inittab
id:3:initdefault:

And then reboot the machine to re read the inittab file & see the changes.

[root@ testmachine ~]# reboot
Or
[root@ testmachine ~]# init 6

So if in your project, if someone ask you to reboot the machine then you can use either #reboot command or #init 6 command because

init 6 = reboot in /etc/inittab file

Or if someone asked you to halt/powerdown your machine then use below command:

[root@ testmachine ~]# init 0

Note: Please take necessary output (like #ifconfig –a, /etc/hosts etc..) before rebooting/halting machine. 

I will cover this point in next post J

Query 2. Is root account is main administrator account?

Ans: This kind of tricky question interviewer may ask you. The answer is “No”. root is not the main administrator.

The user who is having UID=0 will be your admin user.

By default, root has UID=0 which we can change and can assign different or any UID to him.

We can create user kiran with UID=0 and then user kiran will act as admin user.
[root@ testmachine ~]# grep root /etc/passwd
kiran:x:0:0:root:/kiran:/bin/bash


Thanks & Regards,
Kiran Jadhav 

No comments:

Post a Comment