Linux System Administration Basics
Since Linux is a multi-user operating system, several people may be logged in and actively working on a given machine at the same time. Security-wise, it is never a good idea to allow users to share the credentials of the same account. In fact, best practices dictate the use of as many user accounts as people needing access to the machine.
At the same time, it is to be expected that two or more users may need to share access to certain system resources, such as directories and files. User and group management in Linux allows us to accomplish both objectives.
Add new users
It creates an user thisuser
belonging to the group thisgroup
and using /bin/bash
as default shell. By default on ubuntu it's /bin/sh
.
useradd -G thisgroup -s /bin/bash thisuser
Modify the password of an user named thisuser
passwd thisuser
Check password of thisuser
on the user list
grep thisuser /etc/passwd
Modify the default shell of an user named thisuser
chsh -s /bin/bash thisuser
It displays the list of all users on the system
awk -F':' '{ print $1}' /etc/passwd
Add new groups to an user
It creates a group thisgroup
groupadd thisgroup
It defines premiergroup
as the primary group of user thisuser
usermod -g premiergroup thisuser
It defines secondgroup
as a supplementary group of user thisuser
usermod -a -G secondgroup thisuser
It displays members of the group thisgroup
getent group thisgroup
It displays the list of all groups on the system
cut -d: -f1 /etc/group | sort
Grant sudo privileges to an user
It adds the user thisuser
to the sudo
group. Members of this group can execute any command as root via sudo
and prompted to authenticate themselves with their password when using sudo
usermod -a -G sudo thisuser
delete Users and groups
It deletes an user called thisuser
deluser thisuser
It delete a group called thisgroup
groupdel thisgroup
References
Learning the bash Shell: Unix Shell Programming
Cameron Newham and Bill Rosenblatt
O'Reilly Media, 1995. ISBN‑13: 978-0596009656
Relevant Tags
About the Author
Latest Articles
-
Chado: the GMOD Database Schema
Chado is a relational database schema that underlies many GMOD installations. It is capable of representing many of the general classes of data frequently encountered in modern biology such as sequence, sequence comparisons, phenotypes, genotypes, ontologies, publications, and phylogeny. It has been designed to handle complex representations of biological knowledge and is the most sophisticated relational schemas currently available in molecular biology.JAN 2025 · PIERRE-EDOUARD GUERIN -
Error Messages with a CLI
I am an anxious person. So error messages always makes my heart beat faster. Hopefully, following the Pareto Principle, 80% of error messages are mild while 20% are the really tough one. The point is to solve the first kind as quickly as possible and effortless. To do so, allow the user to solve the issue by himself with clear messages and hints (in the case of errors related to input files or parameters). Clear presentation of the context and precise localization of the error in the code will save a lot of useless and tedious work to the developer. The time spared on the easy errors just by having better messages, then can be reallocated to the second kind of errors, the troublemakers.NOV 2024 · PIERRE-EDOUARD GUERIN -
Generative AI: Integrate openAI API with Python
I was fortunate to follow the course of Sven Warris about software tools to integrate genAI into your own work and applications. The course is aimed at data scientists and bioinformaticians.MAY 2024 · PIERRE-EDOUARD GUERIN