Sponsored Content
Full Discussion: Linux Changing Run Levels
Operating Systems Linux Debian Linux Changing Run Levels Post 302985771 by hicksd8 on Tuesday 15th of November 2016 04:41:17 AM
Old 11-15-2016
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:

Code:
 
 # /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.
 

9 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Too many levels of symbolic links

Hi, Is there a limit to the number of symbolic links you can have? I tried to vi the symbolic link relating to a file and got the following error: "filename" Too many levels of symbolic links There is only one symbolic link to one file in this case, but there are >2000 other links to... (2 Replies)
Discussion started by: Bab00shka
2 Replies

2. Solaris

RAID Levels

hi, what are the RAID Levels followed for various File systems ? thanks (3 Replies)
Discussion started by: sol8admin
3 Replies

3. Solaris

Init levels

I have a problem, i dont know if its a normal behaviour or not, i can go to a lower init level, but i cant go to a higher one again, for instance i can run the command init 2 while im at init 3 and when i do who -r i find myself go down to 2 but if i type init 3 and wait im still finding myself in... (1 Reply)
Discussion started by: XP_2600
1 Replies

4. UNIX for Advanced & Expert Users

Unix Run Levels confusion

Hi, Could somebody throw some light on the below queries: - For a run-level X, the S* scripts are executed when coming here from X-n run-level. The K* scripts are executed when coming to X runlevel from X+n runlevel. - Does reaching to runlevel X from X-3 executes K* scritps from X-2 & X-1... (4 Replies)
Discussion started by: vibhor_agarwali
4 Replies

5. UNIX for Dummies Questions & Answers

Search through 2 levels of zip

Hi guys, I know I'm missing something simple here. We have about 500 zipped files in a directory which contain more zip files and within those I need to find a file without unzipping everything. I know I can use zipinfo which I'm trying to create a for loop to go through the files and... (4 Replies)
Discussion started by: petef
4 Replies

6. Solaris

Levels of support

Hello, I have a simple question because I can not find the information at oracle.com I want to buy support for OS Solaris and Servers hardware. I need information what are the levels of support and how much they cost? I need a help. Have a nice day (3 Replies)
Discussion started by: bieszczaders
3 Replies

7. Cybersecurity

Unable to run 'su' and 'sudo' after changing permissions on /etc

Hello, I'm running rhel6 64bit. Accidentally I ran % chmod -R 777 /etc and after that I have a problem to do 'su' or 'sudo'. When I did sudo it complained that /etc/sudoers has 777 while it should be 0440. I changed that and also restored right permission for: -rw-r--r-- 1 root root 1966 May 19... (2 Replies)
Discussion started by: susja
2 Replies

8. AIX

AIX How to run a Shell Script by changing the User

Hi All, Currently our application is running on the server having AIX 5.3 OS. What we intend to do is to run a shell script owned by another user and needs to be run as that particular user. I was trying to create a shell script using the su command before running the actual script (which... (4 Replies)
Discussion started by: acoomer
4 Replies

9. Solaris

Run levels in Solaris 11

Hi Guys, I need to change the following script ( which is good for Linux) for Solris 11 #start oracle start on runlevel stop on runlevel What it should be for Solrais 11. Thanks for your help. Regards Terry (2 Replies)
Discussion started by: terrykhatri531
2 Replies
inittab(4)							   File Formats 							inittab(4)

NAME
inittab - script for init DESCRIPTION
The /etc/inittab file controls process dispatching by init. The processes most typically dispatched by init are daemons. It is no longer necessary to edit the /etc/inittab file directly. Administrators should use the Solaris Service Management Facility (SMF) to define services instead. Refer to smf(5) and the System Administration Guide: Basic Administration for more information on SMF. To modify parameters passed to ttymon(1M), use svccfg(1M) to modify the SMF repository. See ttymon(1M) for details on the available SMF properties. The inittab file is composed of entries that are position dependent and have the following format: id:rstate:action:process Each entry is delimited by a newline; however, a backslash () preceding a newline indicates a continuation of the entry. Up to 512 charac- ters for each entry are permitted. Comments may be inserted in the process field using the convention for comments described in sh(1). There are no limits (other than maximum entry size) imposed on the number of entries in the inittab file. The entry fields are: id One to four characters used to uniquely identify an entry. Do not use the characters "r" or "t" as the first or only character in this field. These characters are reserved for the use of rlogin(1) and telnet(1). rstate Define the run level in which this entry is to be processed. Run-levels effectively correspond to a configuration of processes in the system. That is, each process spawned by init is assigned a run level(s) in which it is allowed to exist. The run levels are represented by a number ranging from 0 through 6. For example, if the system is in run level 1, only those entries having a 1 in the rstate field are processed. When init is requested to change run levels, all processes that do not have an entry in the rstate field for the target run level are sent the warning signal SIGTERM and allowed a 5-second grace period before being forcibly terminated by the kill sig- nal SIGKILL. The rstate field can define multiple run levels for a process by selecting more than one run level in any combina- tion from 0 through 6. If no run level is specified, then the process is assumed to be valid at all run levels 0 through 6. There are three other values, a, b and c, which can appear in the rstate field, even though they are not true run levels. Entries which have these characters in the rstate field are processed only when an init or telinit process requests them to be run (regardless of the current run level of the system). See init(1M). These differ from run levels in that init can never enter run level a, b or c. Also, a request for the execution of any of these processes does not change the current run level. Further- more, a process started by an a, b or c command is not killed when init changes levels. They are killed only if their line in inittab is marked off in the action field, their line is deleted entirely from inittab, or init goes into single-user state. action Key words in this field tell init how to treat the process specified in the process field. The actions recognized by init are as follows: respawn If the process does not exist, then start the process; do not wait for its termination (continue scanning the init- tab file), and when the process dies, restart the process. If the process currently exists, do nothing and continue scanning the inittab file. wait When init enters the run level that matches the entry's rstate, start the process and wait for its termination. All subsequent reads of the inittab file while init is in the same run level cause init to ignore this entry. once When init enters a run level that matches the entry's rstate, start the process, do not wait for its termination. When it dies, do not restart the process. If init enters a new run level and the process is still running from a previous run level change, the program is not restarted. boot The entry is to be processed only at init's boot-time read of the inittab file. init is to start the process and not wait for its termination; when it dies, it does not restart the process. In order for this instruction to be meaningful, the rstate should be the default or it must match init's run level at boot time. This action is useful for an initialization function following a hardware reboot of the system. bootwait The entry is to be processed the first time init goes from single-user to multi-user state after the system is booted. init starts the process, waits for its termination and, when it dies, does not restart the process. powerfail Execute the process associated with this entry only when init receives a power fail signal, SIGPWR (see sig- nal(3C)). powerwait Execute the process associated with this entry only when init receives a power fail signal, SIGPWR, and wait until it terminates before continuing any processing of inittab. off If the process associated with this entry is currently running, send the warning signal SIGTERM and wait 5 seconds before forcibly terminating the process with the kill signal SIGKILL. If the process is nonexistent, ignore the entry. ondemand This instruction is really a synonym for the respawn action. It is functionally identical to respawn but is given a different keyword in order to divorce its association with run levels. This instruction is used only with the a, b or c values described in the rstate field. sysinit Entries of this type are executed before init tries to access the console (that is, before the Console Login: prompt). It is expected that this entry will be used only to initialize devices that init might try to ask the run level question. These entries are executed and init waits for their completion before continuing. process Specify a command to be executed. The entire process field is prefixed with exec and passed to a forked sh as sh -c 'exec com- mand'. For this reason, any legal sh syntax can appear in the process field. SEE ALSO
sh(1), who(1), init(1M), svcadm(1M), svc.startd(1M), ttymon(1M), exec(2), open(2), signal(3C), smf(5) System Administration Guide: Basic Administration NOTES
With the introduction of the service management facility, the system-provided /etc/inittab file is greatly reduced from previous releases. The initdefault entry is not recognized in Solaris 10. See smf(5) for information on SMF milestones, and svcadm(1M), which describes the "svcadm milestone -d" command; this provides similar functionality to modifying the initdefault entry in previous versions of the Solaris OS. SunOS 5.11 9 Dec 2004 inittab(4)
All times are GMT -4. The time now is 04:52 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy