How to change the default runlevel of your Linux machine

By default when you install a linux operating sustem with GUI you are logged into the graphical user interface rather than CLI (Command Line Interface). So what if you directly want to login to CLI instead of GUI. Is it possible?

Yes it is possible

If you want to switch to CLI then it is all about terminals. In Red Hat the default graphical terminal is tty7 and for some SUSE machines I have observed the default graphical terminal is tty8 so it might vary but that would not be a problem.

NOTE:Before going further I would assume that you have a good idea about all the run levels in Linux as I won't be explaining much about them in this post.

To check the current run level

# runlevel
N 5M
# who -r
run-level 5 2012-09-28 11:21
So this means I am currently in run level 5 which is used for GUI and CLI.

To change the default run level of your linux machine just type the runlevel you want to be in using this format# init 3This will take you to CLI

# init 5This will take you to GUI

Once you switch your runlevel you can check your last run level using this command
# runlevel
3 5
According to this you just switched your machine from runlevel 3 to runlevel 5

But again using init every time is not a good idea if you want to be in CLI after you reboot your machine so to make permanent changes, change the default run level
# vi /etc/inittab
Default runlevel. The runlevels used 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
5:initdefault:Here 5 denotes the default runlevel where you are taken after your system reboots. So if you want to login to CLI directly after reboot then change the runlevel to 3

Reboot your machine to make the changes affect.

To check the current terminal you are logged on
# tty
If you want to change your terminal from GUI to CLI without affecting the current session then press Ctrl+Alt+F1, This will switch you to another terminal having CLI

You can do the same from F1 to F12 using Ctrl+Alt

Follow the below links for more tutorials

What is the difference/comparison between Unix and Linux ?
What are the maximum and minimum limits for RHEL 4 vs 5 vs 6 ?
Step by Step Linux Boot Process Explained In Detail
What is the difference between ext3 and ext4 filesystem in Linux ?
How to configure Private Network in VMware Workstation
10 examples to help you understand top command usage in Unix/Linux
Configure Red Hat Cluster using VMware, Quorum Disk, GFS2, Openfiler
Tutorial for Monitoring Tools SAR and KSAR with examples in Linux
15 tips to enhance security of your Linux machine
Why is Linux more secure than windows and any other OS
Understanding Load Average in Linux and when to be worried about it?
Disk Attachment Technology FC vs SAS vs iSCSI
Understanding UMASK value in Linux
How to keep a track of all the commands run by any user in Linux
How do you check Linux machine is Physical or Virtual remotely?