As mentioned, several of the tips in this book ask you to edit vital configuration files. If you follow the steps precisely this shouldn't present any issues but making backups before is always good idea.13
This doesn't mean just creating a backup of the configuration file itself. If you tweak a particular line within a configuration file, it's a good idea to make a copy-and-pasted copy of the original line too. As mentioned in the previous section, any line in a typical configuration file that's preceded by a hash symbol (#) is ignored. Therefore, you can simply copy and paste the line to a new line beneath, and then precede it with a hash.
Let's look at an example. In Tip 78, on page 137, I discuss removing the login delay that occurs when you type a bad password. Take a quick look now. It involves editing the /etc/pam.d/common-auth file, so before carrying out the tip, you should create a backup of the file. This can be done using the Nautilus file browser but it has to be running in
(for example, #!/bin/bash). But this is the only example of where a hash symbol is used for anything other than a comment.
13. Of course, backing up all valuable files on a regular basis is a good idea. I explain how to backup data in Tip 286, on page 332.
superuser mode because the file in question is in a root-owned folder. Therefore we need to start Nautilus with root powers—hit [Alt +F2 and type gksu nautilus. Type your password when prompted. Then browse to /etc/pam.d and locate the common-auth file. Right-click it, select Copy, as shown in Figure 2.13, then right-click a blank space in the Nautilus window and select Paste. This will automatically create a new file called common-auth (copy). Alternatively, you can select the file and click Edit ^ Duplicate.
If you wish, you can backup the file at the command prompt instead, using the cp command. Just specify a new filename for the copied file, as follows:
$ sudo cp /etc/pam.d/common-auth /etc/pam.d/common-auth-backup
The tip goes on to tell you to open the file in the Gedit text editor and change the line auth requisite pam_unix.so nullok_secure so that it reads auth requisite pam_unix.so nullok_secure nodelay. Before doing this, you should highlight the line, and copy and paste it to a new line just below. Add a hash (#) in front of it. Then make your change to the original line.
The benefit of creating a cut-and-pasted copy of the original line is, in many situations, you have a concrete example of the syntax of how the line should look. This can be particularly useful if you radically change the line.
So if you follow Tip 78, on page 137, you'll end up with two lines that look like this:
auth requisite pam_unix.so nullok_secure nodelay #auth requisite pam_unix.so nullok_secure
Following this, you can save the file and reboot, as the tip says, to test the settings. In the highly unlikely event of anything going wrong, or the system not working as it should, you can once again use Nautilus to restore the original file (delete the old one and then rename the copy so it has the original filename; ensure you perform these two actions immediately after each other as quickly as possible in case the system calls on the file and finds it isn't there). Alternatively, you can open the file again in Gedit and restore the original line.
Once you're sure the tip has worked, you can either delete the backup file, or just leave it there in case it's needed in future.
Was this article helpful?