Linux runlevel command - output the previous and current runlevels

runlevel command: output the previous and current runlevels

runlevel command Function Description

Use the runlevel command to output the previous and current runlevels. runlevel reads the system UTMP file, and by default uses the /var/run/utmp file if this file is not specified, to find the most recent runlevel record.

runlevel command Syntax

runlevel [Option] [UTMP File]

Option Meaning

The meaning of each option in the command is shown below:

Option Description
–quiet Does not output the current and previous runlevels, and does not output errors in unknown cases

In most linux distributions, there are usually 8 runlevels.

0 Shutdown
1 Single-user mode
2 Multi-user mode, no NFS
3 Full multi-user mode
4 Not used
5 Graphical interface
6 Restart
S s Single user mode

The default runlevel of most desktop linux systems is 5, which is a graphical interface when the user logs in, while the default runlevel of most server versions of linux systems is 3, which is a character interface when the user logs in. runlevel 1 and 2 are rarely used except for debugging, and runlevel s and S are not directly for the user, but are used to prepare for Single user mode.

The advantage of linux run mode over windows boot mode is that you can use the init command to switch the runlevel you are using when the system is idle. In addition, when you shut down or start the linux system you have unknowingly switched your runlevel, the system shutdown process needs to call runlevel(0 or 6) to shut down all running processes.

runlevel command Demo

Displays the current operating level of the computer system

[root@deepinout~]# runlevel   N5   // The current run level of the system is 5 and there is no last run level (indicated by N) 

Switch the Linux system runlevel to 2, and then display the current system runlevel

[root@deepinout ~]# init 2 // Switching operation level to level 2
[root@deepinout ~]# runlevel   52   // The current operating level of the system is 2 and the last operating level was 5
Like(1)
Linux Login Logout Command
Linux login commandLinux logout commandLinux nologin commandLinux exit commandLinux sulogin commandLinux rlogin commandLinux poweroff commandLinux ctrlaltdel CommandLinux shutdown commandLinux halt commandLinux reboot commandLinux init commandLinux runlevel commandLinux telinit command
Linux File Management Command
Linux cat commandLinux tac commandLinux nl commandLinux more commandLinux less commandLinux head commandLinux tail commandLinux rev commandLinux fold commandLinux fmt commandLinux expand commandLinux pr commandLinux sort commandLinux uniq commandLinux cut commandLinux comm commandLinux diff commandLinux join commandLinux diff3 commandLinux cmp commandLinux colrm commandLinux paste commandLinux mkdir commandLinux tr commandLinux split commandLinux csplit commandLinux tee commandLinux unexpand commandLinux patch commandLinux awk commandLinux sed commandLinux od commandLinux pwd commandLinux cd commandLinux ls commandLinux dir commandLinux dirs commandLinux touch commandLinux rmdir commandLinux cp commandLinux mv commandLinux rm commandLinux install commandLinux tmpwatch commandLinux file commandLinux du commandLinux wc commandLinux tree commandLinux cksum commandLinux md5sum commandLinux sum commandLinux dirname commandLinux mkfifo Command
Cron Expressions
Cron Expression to Run Every Day at 12 PMUnderstanding Vue Cron ExpressionsUnderstanding JS Cron ExpressionsA Comprehensive Guide to Cron Expressions for Scheduled TasksUnderstanding Linux Cron ExpressionsUnderstanding Quartz Cron ExpressionsCron ExpressionCron Time ExpressionCron Expression ParsingCron Expression: Executing a Task Every SecondCron Expression for Every Minute ExecutionCron Expression to Execute Every 10 MinutesCron Expression: Executing Every HourCron Expression to Execute Once a YearCron Expression: How to Schedule a Task to Run Daily at Midnight?