Outils pour utilisateurs

Outils du site


issue218:tutoriel1

I recently read a book called Linux Unveiled, that only unveiled that the author, ‘Half-job Hussain’, had no idea how to show newbies around. I did like some of the book somewhat (very little), so I’ll be stealing some of that to do a proper job for our FCM newbies. (No, I will not be using anything from that horrible book). I’ll try to take a more hands-on approach, so I would ask you to keep your terminal emulators open and follow along, just to get the muscle-memory going. Now, obviously I cannot cover a whole book’s worth of stuff on here, but I’m thinking CPU, memory and disk here. This can then tie into some of the LPI stuff we are covering elsewhere. That means there will be homework, but I’ll keep it short.

We chatted about the boot process in the last article, let’s quickly look at shutting down. On my virtual machines, I usually just click the big red “x” and choose “send the shutdown signal” hehehehehehe. However, when you remote to a machine in a data centre, it is not that easy. You may never know, one day you may set up a VPS and it needs a reboot after some updates. Maybe you ran out of space and need to make some? I don’t know, there are lots of reasons to shut down a Linux box or reboot it. Failing hardware is the number one reason. Usually, one should not need to. I went to a monkey-pality, where the Red Hat mail server had been running for nine years, without rebooting (as it should!). With all the security intrusions lately, you may even need to shut it down to get rid of pests. From the command line, you can use the ‘shutdown’ or ‘poweroff’ command, depending on the type of Linux server you connect to.

If you look at the man page for ‘poweroff’, you will also see the deprecated command ‘halt’. They did not used to be, but these days they are the same. I usually use the mnemonic “halt, who goes there”. You see, when you type halt at the command line, you will usually be asked for your password. Poweroff, not so much. This is not the case for all Linux distributions though. Also, halt is problematic, usually just hanging up Ubuntu.

(Ubuntu hanging after ‘halt’)

You see, when you shut down or reboot, the system goes through a list of things to make sure that it does a clean shutdown, flushing caches, making sure processes exit cleanly, etcetera. If you yank out the power cord, this does not happen.

The same goes for the reboot command; on Ubuntu, it is instant, like ‘poweroff -r now’. (If you do not use ‘now’, the default is 60 seconds)

The ‘shutdown’ command is the one you should be using on Ubuntu. The shutdown command incorporates all the others with a hyphen/tack, so for instance, shutdown -r is equal to reboot. But! It is safer. Using shutdown on a multi-user system should let everyone know that the system is being shut down. When in doubt, use shutdown! The shutdown command has its own quirks though, that you need to be aware of. When you type ‘shutdown’ to halt the system, you can use -h and -H; however, one requires authentication.

My suggestion is to navigate to the man page, and try the options out for yourself, as they differ in different flavours and versions of Ubuntu.

As to the time, you can set the time in minutes or use the twenty-four hour clock to set when you want the system to reboot. For example: shutdown -r 21:00 for it to reboot at 9pm.

My poor cousin has a lot of power failures, and I have to help the man recover quite often, so I know all about repairing after a dirty shutdown. Proper power down is essential if you have low memory and use a swap-file, if you don’t you may end up with a corrupt system. Ubuntu has a rather nice rescue mode or recovery mode, whatever you want to call it. You can access it via the GRUB menu; if you look under “Advanced options” you should see an entry tagged with (recovery mode). When you click that you are taken to the magenta screen with options to repair your system, like: ‘make free space’. This may not always work, and you may need to boot from a live medium to actually make space.

Also be aware that while you are in recovery mode, it is a single user target and no-one else will be able to log in. It will also not respond to the shutdown signals, so you may need the ‘reboot’ command. Also some systems drop you to busybox, not bash, so you need to always check which commands are at your disposal. It’s a lot to remember, so make a note. :)

If you know you are in a bad power area, you should make sure your data is on another partition or drive. (Something I should have done for my cousin, but he had generators, etc, so I did not think it would be needed.) <insert clown face>

Since we covered booting and shutting down, maybe we should also look at startup applications. In vanilla Ubuntu, one can simply navigate to the startup applications program and have a look at what is starting when you log in. It is not as comprehensive as say XFCE, where you get to see items like bluetooth as well, but it is safe, as it only affects user applications, not system applications. On the Ubuntu Gnome version, you may see nothing, depending on what you have installed. (I’m not going to go through all the flavours).

This is where gnome-tweaks comes in, allowing you further customization of startup items, but as both these applications cover only logged-on user applications, yours may be empty (mine has only virtualbox, so there is no point for me to add screen-shots.) I want to segue into startup services, but that will have to be an article on its own.

So until next time… misc@fullcirclemagazine.org if you feel I missed something.

issue218/tutoriel1.txt · Dernière modification : 2025/06/14 16:01 de philou511