2.3 Set up sudo

sudo is a package that you need to install. When used incorrectly, sudo can cause security issues. The default sudo configuration is safe, so don’t worry about that.

As root, run visudo. This opens an editor to change the file sudoers. Add the following line:

oneilj ALL = (root) NOPASSWD: /bin/tar cf - -C / home var  
    

This line specifies that the user oneilj can run the command /bin/tar cf - -C / home var as root without being prompted to enter the password of oneilj. On this line, ALL refers to the host name of the machines where oneilj can elevate its privileges.

For experimentation purposes, I suggest that you pick a folder with fewer files, otherwise, each test will take a long time.

The command itself (/bin/tar cf - -C / home var) takes all the files in /home and /var, and creates the archive file to the standard output file. This makes it easier to include this command as a part of a string of commands.

You can test this set up. As root, run su oneilj to change privileges (down) to oneilj temporarily. You can use exit to get out of the reduced privilege mode. Then run the following command to confirm the configuration:

tar cf - -C / home var > /dev/null  
    

If this command runs (which may take a long while), it means the configuration is successful. You can, then, use exit to return to root privileges.

This concludes the last step to perform on the server to be backed up. The only additional security exposure is the oneilj account. This is no more exposure than the root account itself.