Contact us

Print

Virtual terminals

Table of contents:


Exercise 1


Preamble - To change the default runlevel


As a result of the options you choose during the installation of your system, your system should have been configured to automatically boot into runlevel 5 (i.e. a windowing environment). Here you will learn how to change the default runlevel. This is useful for times when you have difficulties starting the X server and you need access to the console to fix or troubleshoot the problem. In particular you will change the system’s startup runlevel from 5 to 3. You will then configure the X server from scratch in the following exercises.

1. Open up the “/etc/inittab” file with any text editor you are comfortable with.

2. Look for a line in the file that looks like the one below:


id:5:initdefault:


Edit the above line to look like the one below. i.e. change the value of the 2nd field from 5 to 3.


id:3:initdefault:


This will make the system boot up into runlevel 3 henceforth. This forces the system to henceforth NOT automatically start the X server.

3. Save your changes to the file and close it. Reboot the system when done.


Virtual terminals


Linux provides you with several other virtual terminals with which you can interact with your system. The virtual terminals are numbered 1 through 64.

You may log into any of the virtual terminals to run your commands and programs or use the virtual terminals to view log messages.

To switch between virtual terminals


1. While logged in as root, take your system down to runlevel 3; if you are not in that runlevel. Type:


[root@localhost root]# init 3


Please note that the above command will kill/end any current windowing/GUI applications you have running. Although the previous exercise would have ensured this already if you rebooted.

2. Switch to the 2nd virtual terminal. Press the ALT and F2 keys simultaneously on your keyboard:


<ALT> <F2>


3. You will be presented with a login screen if you were not already logged in. Log in as root.


4. Find out your current tty. Type:


[root@localhost root]# tty

/dev/tty2



What is a “tty”?


5. After logging in, use the echo command to display a simple message on your current tty. Type:


[root@localhost root]# echo "Hello- second virtual terminal"

Hello - second virtual terminal


6. Switch to the 1st tty. Press:


<ALT> <F1>



7. Logon to “tty 1” as root, if you are not already logged on. Use the echo command to display a
different message on that tty. Type:


[root@localhost root]# echo "Hello- first virtual terminal"

Hello - first virtual terminal


8. Find out your current tty. Type:


[root@localhost root]# tty


9. While still logged on at “tty 1”, use the echo command to display a simple message on tty 2. Type:


[root@localhost root]# echo –n “Hello from tty1 to tty2” > /dev/tty2


10. Switch to the 2nd tty to view the message you sent there. Type:


<ALT> <F2>

[root@localhost root]# Hello from tty1 to tty2



11. Now switch to the 7th virtual console. What are the key strokes to do this?

12. By default you won’t have any login prompt on the 7th virtual console while in runlevel 3. So switch
back to the 1st console. The 7th virtual console is usually reserved for the X server, as you will see in
the next exercise.


Created by: system. Last Modification: Wednesday 19 of November, 2008 20:24:24 EST by wale.

...