Installation guide

104 Chapter 11. Shell Prompt Basics
Command Function
cd / takes you to the entire system’s root directory
cd /root takes you to the home directory of the root, or superuser,
account created at installation
cd /home takes you to the home directory, where user login
directories are usually stored
cd .. moves you up one directory
cd ~otheruser takes you to otheruser’s login directory, if otheruser has
granted you permission
cd /dir1/subdirfoo regardless of which directory you are in, this absolute path
would take you straight to subdirfoo, a subdirectory of
dir1
cd ../../dir3/X11 this relative path would take you up two directories to
root, then to dir3, then to the X11 directory.
Table 11-1. cd Options
Now that you are starting to understand how to change directories, see what happens when you change
to root’s login directory (the superuser account). Type:
cd /root
If you are not logged in as root, you are denied permission to access that directory.
Denying access to the root and other users’ accounts (or login directories) is one way your Linux
system prevents accidental or malicious tampering. See Section 11.14.
To change to the root login and root directory, use the su command. For example:
[sam@halloween sam]$su
Password:your root password
[root@halloween sam]#cd /root
[root@halloween /root]#
Tip
The command su means substitute users and it allows you to temporarily log in as another user.
When you type su all by itself and press [Enter], you become root (also called the superuser) while
still inside your login shell (your user’s home directory). Typing su - makes you become root with
root’s login shell — that is, it is as if you had logged in as root originally.
As soon as you give the root password, you will see the changes in your command prompt to show
your new, superuser status, the root account designation at the front of the prompt and "#" at the end
(as shown in the prior example).
When you are done working as root, type exit at the prompt and you will return to your user account.
[root@halloween /root]#exit
exit
[sam@halloween sam]$