Linux Changing Run Levels

Hi this is my first thread. I use KDE and Gnome on Debian. I configured inittab like what it should be. But when i have an inittab file i can't see anything when i run who -r command.

This is the result of who -r without /etc/inittab

hwpplayer1@build3:~$ who -r
         a�l-seviyesi 5 2016-11-14 06:32

I couldn't understand. Thanks for help

Linux Changing Run Levels

Were you logged in as root when you ran:

who -r

? Yes, your posted output of this command looks strange.

Please post the output of:

# runlevel

What does that say.

I would also add that runlevel 5 in some distributions tells init to shutdown (in an orderly manner) AND power off (if the hardware supports power off).
Runlevel 0 will shutdown and halt the system leaving power on.

1 Like
hwpplayer1@build3:~$ who -r
         a�l-seviyesi 5 2016-11-14 22:55
hwpplayer1@build3:~$ sudo su
[sudo] password for hwpplayer1: 
root@build3:/home/hwpplayer1# run
runcon           runlevel         run-parts        runuser          
run_erl          run-mailcap      runq             run-with-aspell  
root@build3:/home/hwpplayer1# runlevel
N 5
root@build3:/home/hwpplayer1# 

I don't have inittab file and it is the standard configuration on Debian. So what do you think ? It seems normal when i became root.

root@build3:/etc# emacs -nw inittab

i created inittab file and wrote id:5:initdefault: in it. Then i rebooted my computer. But at first couldn't run X Server , sometimes it happens on my distro. Then i rebooted system again. I saw the login screen. And this is the result

hwpplayer1@build3:/etc$ ls inittab
inittab
hwpplayer1@build3:/etc$ cat inittab
id:5:initdefault:
hwpplayer1@build3:/etc$ who -r
         a�l-seviyesi 5 2016-11-14 23:18
hwpplayer1@build3:/etc$ runlevel
bash: runlevel: komut yok
hwpplayer1@build3:/etc$ sudo su
root@build3:/etc# runlevel
N 5

I think there are some bugs in my system but why this feature needs to be root to be executabled or runned. Maybe it is in / root directory that's why.

Thanks for your help. Have a good day.

The bug in your system is that you don't have a /etc/inittab file. As far as I'm aware this file is always created at installation and the most you might do is edit it. Creating one from scratch is laborious and needs in-depth knowledge of exactly how you want the system to behave.

A typical Debian (Squeeze) inittab file looks like this:

 
 # /etc/inittab: init(8) configuration.
# $Id: inittab,v 1.91 2002/01/25 13:35:21 miquels Exp $

# The default runlevel.
id:2:initdefault:

# Boot-time system configuration/initialization script.
# This is run first except when booting in emergency (-b) mode.
si::sysinit:/etc/init.d/rcS

# What to do in single-user mode.
~~:S:wait:/sbin/sulogin

# /etc/init.d executes the S and K scripts upon change
# of runlevel.
#
# Runlevel 0 is halt.
# Runlevel 1 is single-user.
# Runlevels 2-5 are multi-user.
# Runlevel 6 is reboot.

l0:0:wait:/etc/init.d/rc 0
l1:1:wait:/etc/init.d/rc 1
l2:2:wait:/etc/init.d/rc 2
l3:3:wait:/etc/init.d/rc 3
l4:4:wait:/etc/init.d/rc 4
l5:5:wait:/etc/init.d/rc 5
l6:6:wait:/etc/init.d/rc 6
# Normally not reached, but fallthrough in case of emergency.
z6:6:respawn:/sbin/sulogin

# What to do when CTRL-ALT-DEL is pressed.
ca:12345:ctrlaltdel:/sbin/shutdown -t1 -a -r now

# Action on special keypress (ALT-UpArrow).
#kb::kbrequest:/bin/echo "Keyboard Request--edit /etc/inittab to let this work."

# What to do when the power fails/returns.
pf:powerwait:/etc/init.d/powerfail start
pn:powerfailnow:/etc/init.d/powerfail now
po:powerokwait:/etc/init.d/powerfail stop

# /sbin/getty invocations for the runlevels.
#
# The "id" field MUST be the same as the last
# characters of the device (after "tty").
#
# Format:
# <id>:<runlevels>:<action>:<process>
#
# Note that on most Debian systems tty7 is used by the X Window System,
# so if you want to add more getty's go ahead but skip tty7 if you run X.
#
1:2345:respawn:/sbin/getty 38400 tty1
2:23:respawn:/sbin/getty 38400 tty2
3:23:respawn:/sbin/getty 38400 tty3
4:23:respawn:/sbin/getty 38400 tty4
5:23:respawn:/sbin/getty 38400 tty5
6:23:respawn:/sbin/getty 38400 tty6

# Example how to put a getty on a serial line (for a terminal)
#
#T0:23:respawn:/sbin/getty -L ttyS0 9600 vt100
#T1:23:respawn:/sbin/getty -L ttyS1 9600 vt100

# Example how to put a getty on a modem line.
#
#T3:23:respawn:/sbin/mgetty -x0 -s 57600 ttyS3 
 

I suggest you try injecting the above into your inittab at least down to the comment line "# Normally not reached" even if you don't copy the rest. That might restore some resemblance of normality.

Obviously, this whole mechanism is surrounded by security. You couldn't allow an ordinary user to use 'init' to change run levels; only root can do that. Also, why would an ordinary user want to know the runlevel of the system? If they are allowed to read inittab they certainly wouldn't be allowed to write to it. So there may be a simple explanation why 'who -r' doesn't work properly for a non-root user.

Thanks for your support. I understand what you mean. I told that bug to my team leader and we'll try to fix it. Now it is working but i can modify the inittab file.

I couldn't understand that part

# The default runlevel. 
id:2:initdefault:

For KDE or GNOME i think that it should be 5

"Runlevels 2-5 are multi-user (some distro uses RUN level 5 to start X [KDE/Gnome])"

id:5:initdefault:

Have a great day.

Edit :

$ dpkg -S /sbin/init
systemd-sysv: /sbin/init
hwpplayer1@build3:~$ dpkg -S /sbin/init
systemd-sysv: /sbin/init

Your init system is Systemd, not SysVinit. /etc/inittab is a configuration file of SysVinit, it is not used by Systemd. I presume you have this file because this is a jessie system which was upgraded from an earlier jessie or from wheezy with SysVinit.

Systemd doesn't exactly have a concept of runlevels, though it approximates them for compatibility with SysVinit. Systemd has �target units� instead. You can choose the boot-time target unit by setting the symbolic link /etc/systemd/system/default.target. See the Systemd FAQ for more information.

If you don't want to use Systemd, install the sysvinit-core package, which provides a traditional SysVinit (formerly in the sysvinit package, which in jessie is now a front for systemd). As of jessie, Debian defaults to Systemd but still supports SysVinit.