Note

As discussed earlier in the chapter, Ubuntu differs from other Linux distributions in that it allows normal users to work as the system administrator (or super user) when they require, by making use of the sudo command. Using the sudo command temporarily gives you super-user powers in order to carry out whatever command it is you have requested. However, before the command is executed you will be prompted for your password to make sure you want to carry it out. This level of protection will help save you from unwittingly destroying your Ubuntu system!

However there may be instances where you want to work in a root shell, or even enable the root account itself. To work in a root shell simply enter the command sudo -i to get the familiar # prompt, or enter sudo passwd root to allow you to create a password for the root account and therefore enable log in access for root.

When you work in root, you have the ability to destroy a running system with a simple invocation of the rm command like this:

This command line not only deletes files and directories, but also could wipe out file systems on other partitions and even remote computers. This alone is reason enough to take precautions when using root access.

The only time you should run Linux as the super-user is when booting to runlevel 1, or system maintenance mode, to configure the file system, for example, or to repair or maintain the system. Logging in and using Linux as the root operator isn't a good idea because it defeats the entire concept of file permissions.

Knowing how to run commands as root without logging in as root can help avoid serious missteps when configuring your system. Linux comes with a command named sudo that allows you to run one or more commands as root and then quickly return you to normal user status. For example, if you would like to edit your system's file system table (a simple text file that describes local or remote storage devices, their type, and location), you can use the sudo command like this:

$ sudo nano -w /etc/fstab Password:

After you press Enter, you will be 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 will then be editing /etc/fstab using the nano editor with line wrapping disabled.

Was this article helpful?

0 0

Post a comment