Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

Recently, I realized that a certain disk partition on a Linux Server that is only accessed by ssh was full. I tracked down the problem to a VNC log which had filled up the disk. Using lsof, I determined that even though the log was deleted and VNC was restarted the disk space was not returned because various processes related to the window manager had the files opened (nautilus, gnome-ses, gnome-key, metacity, gnome-pan, eggcups, bt-applet, nm-applet, pam-panel, escd, mapping-d, gnome-ter).

The suggestion from the sysadmin is to reboot the server. Actually, the GUI has only been used once to install the packaged software that the server runs so is not required for most of the time. I would rather fix the problem without rebooting if possible.

How can the GUI be restarted or even turned off gracefully from the command line to be restarted later when required?

share|improve this question
    
What platform (distribution) are you using? –  Zanchey Jan 24 '12 at 2:08
    
Makes sense. In Linux you can delete an open file. It'll appear to be gone from the file system but not removed (inode still valid) until all handles to the file have been closed. –  Matt Jan 24 '12 at 3:13
add comment

2 Answers 2

On most major distros, the runlevel 5 is used for GUI environments and 3 is used for text-mode. Because of this you should be able to run the following command to bring it to text-mode:

 telinit 3

That tells the init process to head to runlevel 3. This will terminate the GUI, not terribly gracefully. To terminate it gracefully you'll have to actually connect to the GUI and log out any open sessions. However, if there is no open session and it's just sitting at the GDM login screen the above command is safe.

Changing the run-level the server boots into varies by distribution unfortunately, there is no one way to make it stick.

share|improve this answer
    
On most Fedora-based distros. Ubuntu doesn't work that way nowadays. –  Magellan Jan 24 '12 at 5:38
    
Fedora and SuSE-based at least. –  sysadmin1138 Jan 24 '12 at 12:29
add comment

sudo killall X11 or the like. or killall your wm

share|improve this answer
    
Welcome to Server Fault! We're a community of and for professional system administrators (et al). As such we prefer Answers to completely answer the Question, in a supportable and maintainable fashion. This might put the OP on the right path, but falls somewhat short of our normal standards. Thank you! –  Chris S May 10 at 3:35
add comment

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.