Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

When I run the command startx it launches me immediately into Gnome without having to login and if I attempt to go back to the command line interface by typing in the comamnd init 3 in the x-terminal it does nothing.

If I attempt to hit CTRL-ALT-Backspace it does nothing however if I were to run init 5 it launches me into the Gnome Display Manager and expects me to login and if I run init 3 in the x-terminal it shutdowns the x-server and returns me to the command line interface.

share|improve this question
    
What distro are you using? –  frabjous Aug 11 '11 at 2:08
    
@frabjous - CentOS –  PeanutsMonkey Aug 11 '11 at 3:36

3 Answers 3

up vote 2 down vote accepted

Theoretically you're doing the right-ish thing. In theory being in runlevel N means that all of the services associated with number N are running, and those that are not are not running.

In practice you can't make that transition without telling the system explicitly to make the transition for you.

You did confuse running startx with what typically happens in runlevel 5 though. When you enter runlevel 5, the system starts a display manager login (gdm, kdm, etc.). This is a simple display manager that will then start X as you once you log in (similar to what you did with startx... the differences are pretty small).

If you started gdm as root from runlevel 3, it is conceivable that some implementation of runlevel transitioning / management would stop gdm if you then indicated that you wanted to be in runlevel 3. I wouldn't count on it working that way in real life. First, the system might ignore you because no-one told it that it was in runlevel 5 even though gdm is running. Second, the system might not deal with the process you started in the same way it would deal with a process that was started automatically.

share|improve this answer
    
Thanks. I didn't quite follow what you meant by If you started gdm as root from runlevel 3, it is conceivable that some implementation of runlevel transitioning / management would stop gdm if you then indicated that you wanted to be in runlevel 3. I wouldn't count on it working that way in real life. First, the system might ignore you because no-one told it that it was in runlevel 5 even though gdm is running. Second, the system might not deal with the process you started in the same way it would deal with a process that was started automatically. –  PeanutsMonkey Aug 14 '11 at 21:18
    
Sorry for the delay in responding. That paragraph was talking about the differences between runlevels in theory and practice. In short: I could conceive of an implementation that behaves as you expect, but there are a few reasons not to do it that way. –  Slartibartfast Aug 25 '11 at 2:00

init 5 is a runlevel. A runlevel basically initializes the system by starting software. Runlevel 5 is usually used to start in graphical mode.

If you start in a non-graphical mode, or you open a tty (in general Ctrl-F1 through Ctrl-F6) startx can start X in another tty (F7 - F9). When you run startx you are already logged into the system, so there is no need to start a login manager. When running in graphical mode, the system starts a login manager to authenticate a user how might login.

When you run init 3 from a console, either tty or pts, you are telling the system that you are changing its runlevel (not definitively, just this time) and then (simply put) every piece of software is stopped and the only those programs that run on runlevel 3 are started.

share|improve this answer
    
Thanks Torian. I understand that running starx from the command line doesn't require me to login because I am already logged in runlevel 3 however why is that once I am in Gnome and I type in the command init 3 in the x-terminal, it doesn't take be back to the command line? –  PeanutsMonkey Aug 11 '11 at 2:29
    
I'm not entirely sure, but is has something to do with how gnome-session/gdm work. If you try this from a tty, you'll have no problem. –  Torian Aug 11 '11 at 2:40
    
Thanks. When you say try from a tty what do you mean exactly especially if I have a session running in tty7. –  PeanutsMonkey Aug 11 '11 at 3:13
    
A tty is just a terminal, typically a console attached to the monitor (not an xterm, gnome-console, etc. those are pts - pseudo terminals). Unless you modified /etc/inittab you only have 6 TTYs, so running a session on tty7 means you have done startx on a runlevel different from 5, or you'r running in runlevel 5. Either way, doing "init N" from a pts is a bad idea IMHO. –  Torian Aug 16 '11 at 4:56

Short answer, since I don't have my linux system in front of me:

Startx executes the script at .xinitrc which probably isn't very customized so it most likely just starts X under the current user.

Init 5 switches to runlevel 5 which, depending on /etc/inittab/, runs scripts contained in /etc/rc5.d (or somewhere similar)

See:
startx: http://www.xfree86.org/current/startx.1.html

init:
http://wiki.linuxquestions.org/wiki/Run_Levels#Configuring_each_run_level
https://wiki.archlinux.org/index.php/Init_and_inittab#inittab

share|improve this answer
    
Thanks. Can you please explain the question I posted to Torian? –  PeanutsMonkey Aug 11 '11 at 2:30

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.