LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 03-01-2011, 06:46 AM   #1
vjackcon
LQ Newbie
 
Registered: Jan 2011
Posts: 3

Rep: Reputation: 0
Runlevel of unix or Linux system


How do I find out runlevel of unix or Linux system?

Last edited by onebuck; 03-02-2011 at 05:47 PM. Reason: disable spam sig
 
Old 03-01-2011, 06:48 AM   #2
repo
LQ 5k Club
 
Registered: May 2001
Location: Belgium
Distribution: Arch
Posts: 8,529

Rep: Reputation: 899Reputation: 899Reputation: 899Reputation: 899Reputation: 899Reputation: 899Reputation: 899
At the prompt type
Code:
runlevel
Kind regards

Last edited by repo; 03-13-2011 at 06:13 AM.
 
0 members found this post helpful.
Old 03-01-2011, 06:50 AM   #3
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983
Code:
who -r
 
Old 03-02-2011, 02:47 PM   #4
devUnix
Member
 
Registered: Oct 2010
Posts: 606

Rep: Reputation: 59
Check out this file:

Code:
more /etc/inittab
and here is the extracted info from it:

Code:
grep id /etc/inittab
id:5:initdefault:
Yet more:

Code:
# Default runlevel. The runlevels used by RHS are:
#   0 - halt (Do NOT set initdefault to this)
#   1 - Single user mode
#   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)
#
id:5:initdefault:
You can see above how many runlevels are there in Linux and what each of them means.

To enter any other desired runlevel, issue this command:

Code:
init 3
to reboot the system and get into runlevel 3.

To restart:

Code:
init 6

To shutdown:

Code:
init 0

Do not set the above 2 values in the following line:

Code:
id:5:initdefault:
Guess why?

Last edited by devUnix; 03-02-2011 at 02:52 PM.
 
Old 03-02-2011, 03:14 PM   #5
TobiSGD
Moderator
 
Registered: Dec 2009
Location: Germany
Distribution: Whatever fits the task best
Posts: 17,148
Blog Entries: 2

Rep: Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886
Keep in mind that there is no real standard about what to run in which runlevel. For example, Debian is running in runlevel 2 with GUI and network enabled, and runlevels 2-5 are actually all the same.
 
Old 03-02-2011, 05:46 PM   #6
onebuck
Moderator
 
Registered: Jan 2005
Location: Central Florida 20 minutes from Disney World
Distribution: SlackwareŽ
Posts: 13,925
Blog Entries: 44

Rep: Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159
Hi,

Quote:
Originally Posted by vjackcon View Post
How do I find out runlevel of unix or Linux system?
If you wish to advertise please contact LQ Admin. Your signature is in violation of the LQ Rules;
Quote:
There is no advertising allowed in the forums. If you are interested in advertising, please contact us.
 
Old 03-13-2011, 06:05 AM   #7
archtoad6
Senior Member
 
Registered: Oct 2004
Location: Houston, TX (usa)
Distribution: MEPIS, Debian, Knoppix,
Posts: 4,727
Blog Entries: 15

Rep: Reputation: 234Reputation: 234Reputation: 234
Quote:
Originally Posted by repo View Post
At the prompt type
Quote:
runlevel
Kind regards
I don't know if using [QUOTE][/QUOTE] tags for a code snippet was deliberate or an accident, I suspect the latter because I don't recall seeing you make that mistake before. Please edit your post to put your code in a Code block, i.e. inside BBcode [CODE][/CODE] tags. Thanks.


Also, FWIW, runlevel doesn't work on my MEPIS 8.0 box, but who -r does.

Code:
$ runlevel
bash: runlevel: command not found
Code:
$ who -r
        run-level 5  2011-03-12 09:44                   last=S
Which works for you, the readers of this thread?
 
Old 03-13-2011, 06:15 AM   #8
repo
LQ 5k Club
 
Registered: May 2001
Location: Belgium
Distribution: Arch
Posts: 8,529

Rep: Reputation: 899Reputation: 899Reputation: 899Reputation: 899Reputation: 899Reputation: 899Reputation: 899
Quote:
Please edit your post to put your code in a Code block,
Done
Quote:
Also, FWIW, runlevel doesn't work on my MEPIS 8.0 box, but who -r does.
Code:
root@cannabis opt]# runlevel
N 4
root@cannabis opt]#
Code:
root@cannabis opt]# who -r
         run-level 4  Mar 13 10:37                   last=S
root@cannabis opt]#
@aarchtoad6
Just curious, did you marked my post "not helpfull"?

Kind regards

Last edited by repo; 03-13-2011 at 06:35 AM.
 
Old 03-13-2011, 01:27 PM   #9
archtoad6
Senior Member
 
Registered: Oct 2004
Location: Houston, TX (usa)
Distribution: MEPIS, Debian, Knoppix,
Posts: 4,727
Blog Entries: 15

Rep: Reputation: 234Reputation: 234Reputation: 234
Quote:
Originally Posted by repo View Post
...
@archtoad6
Just curious, did you marked my post "not helpfull"?
...
I don't remember doing that, nor do I remember clicking "No" instead of "Yes".
 
Old 03-13-2011, 01:30 PM   #10
repo
LQ 5k Club
 
Registered: May 2001
Location: Belgium
Distribution: Arch
Posts: 8,529

Rep: Reputation: 899Reputation: 899Reputation: 899Reputation: 899Reputation: 899Reputation: 899Reputation: 899
Quote:
I don't remember doing that, nor do I remember clicking "No" instead of "Yes".
No problem, just wondering.

Kind regards
 
Old 03-13-2011, 01:34 PM   #11
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682
Looking at the manpage for "runlevel", it shows three ways of determining the runlevel:
/sbin/runlevel
who -r
The environment variables RUNLEVEL & PREVLEVEL.

On openSUSE
I looked in the service startup scripts in /etc/init.d/ and they use $RUNLEVEL and $PREVLEVEL.
The file /etc/rc.status has a function rc_runlevel() that defines these two variables if they don't exist:

Code:
rc_runlevel()
   395  {
   396      test -z "$RUNLEVEL" || return
   397      set -- $(/sbin/runlevel)
   398      PREVLEVEL=$1
   399      RUNLEVEL=$2
   400      export PREVLEVEL RUNLEVEL
   401  }
If you want to know a runlevel in a startup script, examine startup scripts in your system to see how they do it. Be aware whether the RUNLEVEL and PREVLEVEL environment variables exist when your script is run.

Last edited by jschiwal; 03-13-2011 at 01:36 PM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: Unix - System VI Release Notes - More Linux and Unix Humor LXer Syndicated Linux News 0 12-06-2008 03:30 PM
LXer: Securing Your Linux Or Unix System - Part 4a LXer Syndicated Linux News 0 06-23-2008 01:30 AM
Unix or Linux operating system seamalady Linux - General 3 05-05-2006 08:04 AM
Is all Unix & Linux system is made by C++? Lancelot1914 Programming 24 06-21-2005 04:36 PM
SpyWare - Linux/UNIX system vulnerable? cmf5150 General 5 01-16-2004 07:25 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 08:26 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration