Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

If I want to disable my GUIs completely to save battery life, how would I proceed?

I know that I can hit Ctrl + Alt + F3 and be on the command line, but the desktop manager would be in the background still (I suppose).

So, after Ctrl + Alt + F3, I need three commands to:

  • tell me battery life from the command line
  • close desktop environments

Does this make sense?

share|improve this question
add comment

6 Answers

If I want to disable my GUIs completely to save battery life, how would I proceed?

You can just disable your Display Manager (be it kde, lightdm, gdm, etc.) to run at boot, just run depending of your system:

sudo update-rc.d gdm remove
sudo update-rc.d kdm remove
sudo update-rc.d lightdm remove

With this you don't have to stop the desktop manager after booting. But if you don't want this, sudo /etc/init.d/<display_manager_name> stop will close the desktop manager after booting:

sudo service gdm stop
sudo service kdm stop
sudo service lightdm stop

This will work in any system that uses upstart, like Debian and derivatives.

In case your system uses systemd, you can use systemctl:

## All the next lines are executed as root
systemctl disable gdm ## or gdm3
systemctl disable kdm
systemctl disable lightdm
systemctl disable <name_of_the_service>

tell me battery life from the command line

For seeing your battery status you could either, install and run screen/byobu (which is a screen manager, and will show the percentage of the battery + other statistics) or running acpi -b.

close desktop environments

Check my previous response.

I know that I can hit Ctrl + Alt + F3 and be on the command line, but the desktop manager would be in the background still (I suppose).

Ctrl + Alt + F1-6 just switch you to one of the tty. All the programs you are running will continue executing on background.

share|improve this answer
2  
sudo service gdm stop will not disable it on boot, but just stop the service. For Upstart jobs, sudo mv /etc/init/gdm.conf{,.norun} to disable. –  bonsaiviking Aug 11 '13 at 20:51
    
@bonsaiviking there is no configuration file in /etc/init for gdm, kdm, or lightdm, gdm store theirs in /etc/dbus-1/system.d/, kdm in /etc/default. –  Braiam Aug 11 '13 at 21:49
    
then they are not Upstart jobs. That may be where they store configuration, but the service is then probably a System V init script in /etc/init.d/ managed by rc symlinks. Use sudo update-rc.d gdm disable instead. –  bonsaiviking Aug 11 '13 at 22:20
    
Ah, okay. I didn't see that - but just for the record, Debian is not an Upstart distro. Debian still uses SysV init. –  strugee Aug 12 '13 at 3:37
    
As noted above Debian does not use Upstart but still uses Sys V init. There is currently a raging debate whether to adopt Systemd or Upstart (or other init systems) for future releases. –  haziz Jan 22 at 0:26
add comment

Someone alluded to init so why not use it with the specified runlevel? On Xubuntu latest 1 works for me.

$ runlevel  \\just to show your actual runlevel, expect N 2.
$ sudo telinit $runlevel
   where $runlevel is either:
    0 : System halt.
    1 : Single-User mode.
    2 : Graphical multi-user plus networking (DEFAULT)
    3 : Same as "2", but not used.
    4 : Same as "2", but not used.
    5 : Same as "2", but not used.
    6 : System reboot.

Then it's possible to stop the desktop managers as a prior reply states or change the configuration in various ways.

Lastly if you were on Solaris or similar, you would use either init or svcadm and "who -r" to display the current runlevel.

share|improve this answer
    
I agree. For a while I had a system that defaulted to runlevel 3 and I would change the runlevel to 5 when I wanted a gui, and back when I was done. –  Kevin Aug 5 '13 at 19:52
add comment

The problem is that on most Linux distributions, the init process launches the window manager on a terminal of its own, so:

  1. To kill all graphical interface, you'll have to be root
  2. Even if you kill the X server as root, init will restart it automatically as it occupies one of your virtual terminal

So, you'll have to configure your system so that the graphical interface is not launched by init when it starts, which will able you to launch and terminate it manually in a regular tty. That's not really convenient but it's feasible. Look for a file called /etc/inittab and refer to your distribution specific documentation to know how to prevent init from starting a graphical interface. It may just be a line to remove or comment.

Concerning your other question, you can know your battery status just typing the command acpi.

share|improve this answer
add comment

The "telling battery life" part is easier, I'd use byobu or similar utility for that. These managers are great in that they will separate the sessions from the terminals, which means that you can even start your work in DE in byobu, then just zap the DE and continue in tty.

Or you can implement this within shell (thinking $PS1 and a bash function).

For the zapping part, to close DE means to close all programs running within that, which can mean a loss of data. That can be seen as a reason why you need root access.

However, if you really want this, and want to be able to do it quickly anytime, you can write a script for that, "give" it to root and set setuid bit so that if anyone runs this particular script, it will run as root without any further authentication. What makes this little more complicated is that some distros won't let you do this with scripts. This can be solved by creating a C wrapper that will exec the script for you and use that wrapper instead.

I'd probably go with this approach plus consider additional features like not zapping if ran from inside the DE, not zapping anything immediately (like 60s period) or mapping it to a key in Byobu.

share|improve this answer
add comment

I recently discovered a nice package called grml-rescueboot which when installed on your computer allows you to place an ISO image into the /boot/grml directory and then when you issue the update-grub command will add that to your grub boot as something to boot.

IF you use their ISO image and boot from that its totally text based. But the beauty of this solution is you can always boot back into your normal setup when you are near a power source.

More info here on how to install as this package is available from most distributions just install it and read the man page.

share|improve this answer
add comment

Just init 3 run the system in Text mode.

or edit /etc/inittab and change the run level to 3 if you want a GUI change the run level to 5

share|improve this answer
    
If you want to run your system with out GUI. just run #init 3 or if you want to run your system in text mode change the /etc/inittab to level 3 always can change to Init 5. –  Bill Aug 6 '13 at 6:12
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.