For the following it is necessary to be logged in as root
!
In this subsection we create the "deputy" administrator.
Creating a new user is very simple:
__# adduser tom
With adduser a user and a group with the same name is created. This is followed by assigning a password and repeating it for security. Finally, more details can be added to tom
. I enter this simply by and confirm at the end with y
.
Output:
Adding user `tom' ...
Adding new group `tom' (1001) ...
Adding new user `tom' (1001) with group `tom' ...
Creating home directory `/home/tom' ...
Copying files from `/etc/skel' ...
New password:
Retype new password:
passwd: password updated successfully
Changing the user information for tom
Enter the new value, or press ENTER for the default
Full Name []:
Room Number []:
Work Phone []:
Home Phone []:
Other []:
Is the information correct? [Y/n] y
A new user folder has been created under /home
:
__# ls -l /home
In the list you can see the automatically created tom
folder. The owner is tom
and the group membership is tom
. Therefore tom:tom
.
Before we log in as tom
, we add it to the sudo
group with the command usermod. Users who belong to the sudo
group are granted root
privileges. The sudo
keyword can be used to execute commands with root
privileges.
__# usermod -aG sudo tom
The -G
option alone would cause tom to be removed from all other groups. With the additional option -a
, he remains in all other groups as well. Hence the concatenation of -a
and -G
to -aG
.
Now tom
is in the sudo
group and thus has root
privileges. Let's switch back to tom
with the command su (switch user).
__# su tom
A password prompt comes up and finally the shell changes to the familiar colorless scheme. Instead of #
the input line ends with $
, which means that the current user is not root
.
Let's also quickly set up the little extras for tom
, as in the basic settings chapter. But this time on the fly with the sed and >> command. sed
can search and replace with regular expressions. adds a file with the echo input that comes before the angle brackets. This way we don't have to use nano to open, edit, save and close the files first.
Set tab stops to 2:
__$ echo 'set tabsize 2' >> ~/.nanorc
Shell-Farben aktivieren:
__$ sed -i '/^#force_color_prompt *=/s/^#//' ~/.bashrc
If you want to be sure if this worked, you can use nano or less to print the contents of the file. less
reads the content and prints it to the shell. So for this purpose it is quite sufficient. The ~/.bashrc
output will probably be longer than the terminal window. Use the arrow keys to scroll and q
to end the output.
__$ less ~/.nanorc
__$ less ~/.bashrc
In order for these settings to become active, tom
must log in again. To do this, we briefly change to the root
user:
__$ su root
And right back to tom
.
__# su tom
The shell should now have some more color for tom
as well.