10

My computer is freezing from time to time. It's because I make few mistakes and I ruined my system. I don't have any time to reinstall the system now. While my PC is frozen, it still works when I press Ctrl+Alt+F1. Is there any way to reboot system using it?

Eliah Kagan
  • 116,445
  • 54
  • 318
  • 493
KonradDos
  • 2,851
  • 3
  • 11
  • 13
  • so, do you want shutdown / reboot use command line? – ryanw Jan 16 '17 at 08:08
  • Related (but not a duplicate): [How do I shut down or reboot from a terminal?](https://askubuntu.com/questions/187071/how-do-i-shut-down-or-reboot-from-a-terminal) – Eliah Kagan Oct 16 '17 at 09:12

3 Answers3

10

Pressing Ctrl+Alt+F1 brought you from X11 (the GUI) to a virtual console. You can certainly reboot from here.

  • The easiest way to reboot from a virtual console is to just press Ctrl+Alt+Delete. You don't even need to log in first, though it would not be a problem if you did. Unlike on the old DOS systems, pressing Ctrl+Alt+Delete in a GNU/Linux system like Ubuntu actually performs a proper shutdown and clean reboot.

    This doesn't work in the GUI (unless you've set it up to, or you're running a really old distro). But it does work in any virtual console that doesn't have X11 running in it (unless you've set it up not to, which is rare).

  • Another way is to log in and run sudo reboot. You'll be asked for your password to log in on the virtual console, and you'll be asked for it again for sudo. It's the same password both times, and you won't see any placeholder characters (like *) appear as you're typing it. Type it in and press Enter.

However, instead of rebooting, you might consider:

  • Restarting just the GUI. Your desktop environment and all running programs will swiftly quit (so you must usually be as careful with this as with a reboot), the GUI will be restarted, and the graphical login screen will come back up, when you run:

    sudo service lightdm restart
    

    This works by stopping and starting the display manager. That particular command actually only works if your display manager is LightDM, which it is by default on most Ubuntu systems. The main exception is if you are running Ubuntu GNOME, which uses GDM:

    sudo service gdm restart
    
  • Attempting to close just the offending program. Though no program should cause the whole GUI to freeze, it can occasionally happen. You can log in (see above) and run top see the currently running processes, sorted by CPU usage. (Press Q to quit top itself.) A program that's causing the GUI to freeze is not necessarily using lots of CPU, but this is a place to start.

    You can also use the ps command to find the process ID or name of a program you know you want to try to quit, and the kill or killall command to quit it by number or name, respectively. As suggested by its name, killall attempts to kill all processes that have the name you give it. (The name of a process is not necessarily the same as the name shown to you in its launcher icon or title bar.)

Be careful when rebooting, no matter how you do it:

  • If you have programs with unsaved documents, your documents will be lost. If you need to attempt to save data first, then don't rush to reboot.
  • And this applies to restarting the display manager, too, except for documents open in other virtual consoles (but including those open in terminals accessed through terminal windows on your graphical desktop).

See also What should I do when Ubuntu freezes?

Eliah Kagan
  • 116,445
  • 54
  • 318
  • 493
7

Run following command:

sudo reboot

Or

sudo shutdown -r now

Both command will perform a reboot/restart on your system. If that does not work, hold the power key down for a couple of seconds, release it and press it again to start the pc.

If the system happens to running 16.04 release (you can check it with lsb_release -r), then no need for sudo privilege on restart command. Simply run reboot will do the jobs.

Liso
  • 15,217
  • 3
  • 50
  • 80
2

Once in console mode, run the following: sudo init 6

init 6 basically tells the init process to shutdown all of the spawned processes/daemons as written in the init files (in the inverse order they started) and lastly invoke the shutdown -r now command to reboot the machine

Nisheet
  • 963
  • 1
  • 6
  • 19
  • Although this is a perfectly good answer and running `init 6` works fine, [just running `shutdown -r now` (or `reboot`) does all that same cleanup, too](https://askubuntu.com/a/175490/22949). On a modern GNU/Linux system, `init 6`, `shutdown -r now`, and `reboot` (though not `reboot -f`) [all execute the appropriate init scripts for stopping running daemons properly](https://unix.stackexchange.com/a/64385/11938), so there rarely any reason to prefer `init 6` over other methods. – Eliah Kagan Jan 16 '17 at 09:36
  • I definitely agree, however shutdown and restart are part of upstart package. In case of something gone wrong and both being unavailable, init 6 is a foolproof way. – Nisheet Jan 16 '17 at 09:49
  • `init` is *also* provided by the `upstart` package, on releases where Upstart is installed by default. [As of 15.04, SystemD is used instead](https://wiki.ubuntu.com/SystemdForUpstartUsers), and the `systemd-sysv` package provides `init`, `shutdown`, and `reboot`. It's possible but odd for `dpkg -S /sbin/{init,shutdown,reboot}` to show different packages for those three; do you have an Ubuntu system where it does? (`restart` *is* Upstart-specific, but [has nothing to do with rebooting](http://manpages.ubuntu.com/manpages/trusty/en/man8/restart.8.html) and shouldn't be confused with `reboot`.) – Eliah Kagan Jan 16 '17 at 10:26