Databases Reference
In-Depth Information
user by typing the
su -
(switch user) command. When prompted, type in the system
root user's password and press the Enter key:
[adam@eden ~]$
su -
Password:
the_system_root_password
[root@eden ~]#
This is almost identical to the case for Mac OS X:
eden:~ adam$
su -
Password:
the_system_root_password
eden:~ root#
After you type in the password, you'll be logged in as the user
root
on the same com-
puter (in this example,
eden
) and be working from that user's home directory (also
indicated by a tilde).
Notice how the last character of the prompt is a dollar sign (
$
) when you're not the root
user and the hash or pound (
#
) sign when you are. In this topic, we'll use these symbols
to indicate whether you should run a certain command as an ordinary user or as the
root user. When you've finished doing the restricted operations, you can log out from
the system root account by typing
exit
:
#
exit
$
You can generally use the
sudo
command to perform actions with system superuser
privileges, even though you're not actually logged in as
root
. You can also use the
sudo
-s
command to log in as the root user (in place of
su -
). If you log in as the system root
user, you can then omit the
sudo
keyword. Again, we emphasize that you can inadver-
tently do a great deal of damage if you use the root account, and we recommend that
you log in as the system root user as infrequently as you can. Some configuration is
necessary to allow ordinary Linux users to use the
sudo
command, but it's enabled by
default under Mac OS X, and we'll use this approach when discussing installation for
this operating system.
You can add the ampersand symbol (
&
) at the end of a command to start the command
in the background, allowing you to use the shell for other work. It's better to avoid
using this symbol in conjuction with the
sudo
command, since you won't see any system
prompt for you to enter your password. When we want you to run a
sudo
job in the
background, we'll ask you to start the job normally, then press the CTRL-Z key com-
bination to suspend this new job. You can then type the command
bg
to send the
suspended job to the background.
Restricting access to files and directories
Before we end our discussion of the Linux and Mac OS X shell, let's look at how access
to files and directories is controlled under such Unix-like operating systems. Each file
or directory can have read, write, and execute permissions set for the
user
who owns
it, the
group
associated with it, and
every other user
.