defeats the entire concept of file permissions.
Knowing how to run commands as the super user (root) without logging in as
root can help avoid serious missteps when configuring your system. In
Ubuntu, you can use sudo to execute single commands as root and then
immediately return to normal user status. For example, if you would like to
edit your system’s file system table (a text file that describes local or remote
storage devices, their type, and location), you can use sudo like this:
Click here to view code image
matthew@seymour:~$ sudo nano -w /etc/fstab
[sudo] password for matthew:
After you press Enter, you are prompted for a password that gives you access
to root. This extra step can also help you think before you leap into the
command. Enter the root password, and you are then editing /etc/fstab,
using the nano editor with line wrapping disabled (thanks to the -w).
CAUTION
Before editing any important system or software service configuration file,
make a backup copy. Then make sure to launch your text editor with line
wrapping disabled. If you edit a configuration file without disabling line
wrapping, you could insert spurious carriage returns and line feeds into its
contents, causing the configured service to fail when restarting. By
convention, nearly all configuration files are formatted for 80-character text
width, but this is not always the case. By default, the vi and emacs editors
don’t use line wrapping.
Understanding and Fixing sudo
Most Ubuntu users never have problems with sudo, but sometimes, people
who like to experiment break things, especially while learning. This section
helps you understand more completely how sudo works and also how to
restore sudo access to a specific user when, for some reason, it has ceased to
function for that user.
NOTE
You usually can tell that a problem has occurred because an error message
like this appears when a user tries to issue a command using sudo:
Click here to view code image
matthew@seymour:~$ sudo shutdown -h now
[sudo] password for matthew: