As you learned inSection 7.1, “User Concept”, some tasks in Linux
require root
permissions, otherwise they cannot be executed. In order
to temporarily become root
in a shell, proceed as follows:
Enter su. You are prompted for the root
password.
Enter the password. If you mistyped the root
password, the
shell displays a message. In this case, you have to re-enter
su before retyping the password. If your password is
correct, a hash symbol #
appears at the end of the
prompt, signaling that you are acting as root
now.
Execute your task. For example, transfer ownership of a file to a
new user which only root
is allowed to do:
chown wilber kde_quick.xml
After having completed your tasks as root
, switch back to your
normal user account. To do so, enter
exit
The hash symbol disappears and you are acting as “normal” user again.
Alternatively, you can also use sudo (superuser
“do”) to execute some tasks which normally are for root
s
only. With sudo, administrators can grant certain users root
privileges for some commands. Depending on the system configuration, users
can then run root
commands by entering their normal password only.
Due to a timestamp function, users are only granted a “ticket”
for a restricted period of time after having entered their password. The
ticket usually expires after a few minutes. In openSUSE, sudo requires
the root
password by default (if not configured otherwise by your
system administrator).
For users, sudo is comfortable as it prevents you from switching
accounts twice (to root
and back again). To change the ownership of a
file using sudo, only one command is necessary instead of three:
sudo chown wilber kde_quick.xml
After you have entered the password which you are prompted for, the
command is executed. If you enter a second root
command shortly after
that, you are not prompted for the password again, because your ticket is
still valid. After a certain amount of time, the ticket automatically
expires and the password is required again. This also prevents unauthorized
persons from gaining root
privileges in case a user forgets to switch
back to his normal user account again and leaves a root
shell
open.