Linux Server Administration

Dhathri Vupparapalli
3 min readJan 20, 2022

--

Welcome!!! In this article, we will be seeing about the administration of Linux servers.

Before going any further on this topic, let’s first understand multi-user OS.

Multi-User OS

A multi-user operating system allows multiple people/users to use a computer without affecting each other’s files and preferences. Linux is a multi-user operating system.

User/Group Management

  • Each user who is using a common computer has a user-ID which is UID.
  • A group is a collection of one or more users.
  • A group makes it easier to share permissions among a group of users.
  • Each group has a group-ID which is GID.
  • To find the UID and GID associated with a person we use the id command.
  • To know which user is currently logged in to the system we use whoami command.

As we can see from the above picture, when we give id command, we got 0 for uid and gid which means uid and gid associated with that user is “0”. The command whoami gave us information about the currently logged-in user.

Important commands to manage users

  • useradd — creates a new user. Eg: useradd john.
  • passwd — Adds or modifies the password of the user. Eg: password secret
  • usermod — Modifies attributes of a user. Use “usermod -h” command to get the list of attributes you can modify.
  • userdel — Deletes a user. Eg: userdel john. This command deletes user from /etc/passwd & /etc/shadow also. You can know more about these folders below.

Important files with users/groups

  • /etc/passwd — stores username, uid, gid, home dir etc.
  • /etc/shadow — stores the password of the users. This file can only be accessed by the root user(Admin).
  • /etc/group — Stores information about different groups of the system.

All the above files can be accessed only by the root user.

Important commands for managing groups

  • groupadd — Creates a new group. Eg: groupadd newgroup. To check if the group is created or not, check /etc/group file.
  • groupmod — modifies attributes of a group.
  • groupdel — Deletes a group.
  • gpasswd — Modifies password for a group.
  • sudo — It is used to run specific commands as the root user. Eg: sudo -l.
  • To add a user to a group, use the following command. Let’s add user john into a group called newgroup.
usermod -a -G newgroup john
  • You can also switch users in Linux, using “su” command, which means substitute. Let’s try to switch from root to user “john”.
su -john

Points to remember while switching the user

  • su john — doesnot change current directory.
  • su -john — changes current directory completely while switching to user john. (Recommended way)

Now, the user is john and if we now try to access /etc/shadow file, we cannot access it because the folder is sensitive and require root user. But how to provide super or root privileges to other users? For this, we need to add the new user to a group which has root privileges. “wheel” is a group in redhat linux with such privilags.

usermid -a -G wheel john

Now, john has the root privileges because he is added into “wheel” group which has root privileges. Now, if john tries to access /etc/shadow the file will open.

Conclusion

All the above mentioned commands are the basic commads to know to maintain the linux server.

Recommended articles

--

--