Originally Published: Thursday, 19 October 2000 Author: Mike Baker
Published to: interact_articles_irc_recap/IRC Recap Page: 1/1 - [Printable]

Best of IRC for Thursday, October 19th!

It's time once again for another edition of Best of IRC. As always, we'll be taking an in-depth look at some of the questions asked on #Linuxhelp. If you haven't already been to #Linuxhelp, you'll find instructions on how to get there at the bottom of the Live! page. Feel free to stop by!

   Page 1 of 1  


How do I add more terminals?
<Slade> Quick question
<Slade> I'm using RH 6.2
<Slade> now isn't there supposed to be as many shells as F-keys?
<Sect0r> Slade - nope
<Slade> i.e i can hit ALT f1 and go to tty1
<Slade> etc
<Slade> alt f2 tty2
<Sect0r> Slade - only up to 8 if I remember correctly
<Slade> goes up to 6
<Sect0r> ok 6
<Slade> 7 is XWin
<[spectre]> i'm back
<Sect0r> [spectre] - do you know how to help Slade get more than 6 virtual consoles?
<[spectre]> Sect0r - yup
<[spectre]> Slade - ok, edit you inittab
<Sect0r> ahh I see it
<Sect0r> the gettys section
<Slade> mingetty?
<Sect0r> [spectre] - should 7 be avoided if he's going to run X?
<[spectre]> Sect0r - yup
<[spectre]> Sect0r - just add more, but increment the numbers
<[spectre]> Sect0r - yup
<Slade> coolio
<[spectre]> Sect0r - I normally have 1-6 and 10-12
<[spectre]> Sect0r - 7&8 for X
<[spectre]> Sect0r - and 9 for syslog
<Sect0r> what does the 2345 mean?
<[spectre]> Sect0r - the runlevels
<Sect0r> which runlevels are valid for that getty?
<Sect0r> that's a statement..not a q
<[spectre]> yes
<Slade> [spectre]: ok should it work automatically or do i have toreboot/
<[spectre]> Slade - init q
<Sect0r> will init 9 kick users currently logged in?
<[spectre]> Sect0r - i said init q, not init 9
<Sect0r> err init q
<[spectre]> Sect0r - no it won't
<Sect0r> typo
<Sect0r> wohoo, always wondered about that
* Sect0r proclaims [spectre] a venerable oracle of knowledge
* [spectre] bows

When you load Linux, the first process to load after the kernel initialization is a process called init. Within init there are several modes of operation, these modes of opperation are called runlevels. The common runlevels tend to be 0 (shutdown), 1 (single user), 3 (multiuser), 5 (X11), 6 (reboot). The idea being that you can set the runlevel depending on the task to be performed; if you want to bootup and fix something without any programs loading that's runlevel 1. If you want to boot directly into an X11 login screen that's usually runlevel 5.

So how do you use the various runlevels? When you're booting Linux and you get the LILO boot: prompt, type in the name of the kernel you wish to boot, typically "linux" followed by a runlevel: LILO boot: linux 1

Linux will proceed to boot and switch into the appropriate runlevel. Note that if your system simply says LILO on bootup, hit ctrl to get a prompt. The other way to switch runlevels is via the init command. The init command will allow you to dynamically change your runlevel without restarting, e.g.: init 5

So, what does this all mean? If you want to add anything to the startup procees the places to look are the init config files, namely /etc/inittab. The inittab is 4 fields separated by a colon (:). The fields represented are <name>:<runlevels>:<action>:<command>. The names given are arbitrary, the important fields are the runlevels, action and command. A typical inittab might look something like this:


Init default, this is your default runlevel.


System initalization; this is a command that gets run when init first loads:

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

These lines are used to start and stop processes when switching runlevels. Typically, these will parse through /etc/rc<runlevel>.d/ (/etc/rc.d/rc<runlevel>.d/ on some distributions) and process the Start and Kill scripts. Scripts starting with a K are killed when entering that runlevel, scripts starting with an S are started when entering that runlevel. To save on complexity these scripts seen in the /etc/rcc<runlevel>.d/ directories are really just links to /etc/init.d/, the S or K simply specify if the argument given to the script is to be "start" or "stop".

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

Here we see the answer to the question of how to add more virtual terminals. What you see here is what initalizes the terminals in the first place. The names 1, 2, 3, 4 are arbirary, they could easily be called X, Y, Z but for accounting purposes they are named after the terminals the represent. The next field is the runlevel. Note how tty1 is available in runlevels 2 through 5 where the rest of the terminals are only available in runlevels 2 and 3, the thought being that if you're in runlevel 5 (X11) you probably don't need the overhead of extra terminals. The keyword "respawn" seen in the action field specifies to init to relaod these programs should they ever be killed. The last field is the program itself to be run, getty.

So, you want to add another virtual terminal? Simple, just edit /etc/inittab and add one. 7:23:respawn:/sbin/getty 38400 tty7

After editing inittab you'll need to run the command init q for changes to take effect. Note that with a terminal on tty7 your X will relocate to tty8 which is the first terminal not in use. CTRL-(left)ALT-F1 through CTRL-(left)ALT-F12 will give you the first 12 terminals, CTRL-(right)ALT-F1 through CTRL-(right)ALT-F12 gives you the next 12. Technically it's ALT-F* to switch consoles but CTRL-ALT-F* works regardless of if you're in X11 or not. It's also possible to switch terminals with ALT-LEFTARROW and ALT-RIGHTARROW.

   Page 1 of 1