Linux is a multi-user system. This means that the platform can handle multiple user logins. As a system adminstrator, it's important to know how to manage all the users, assign them to groups and manage their permission levels.
In this series, we'll learn how to first create and manage users and groups, then look at all the important files that manage these settings in the background.
There are three types of accounts on any Unix platform, all of may be within a group account:
Creating a user is simple. Simply use
useradd with any of the below options to create a user. Make sure you are root when you perform these actions.
$ useradd -c "Sarah Jones" -d /home/sarah -G intro-unix-course sarah
The skeleton directory holds all the default files to be included when a user is created. The system default skeleton folder is in /etc/skel.
$ mkdir skel $ touch skel/example.txt $ touch skel/example2.txt $ useradd -c "Sarah Goodwill" -m -k /home/skel sarah $ ls /home/ sarah ubuntu user $ ls /home sarah/ example.txt example2.txt
If we forgot to include the
-k option, we can easily create the directory and
chown it to the user.
$ cd /home $ mkdir sarah $ chown sarah:sarah
Or we can use
usermod with the
-d option to assign sarah's new home directory. Note that the user can't be logged in.
$ usermod -d /home/sarah
To modify any existing users, use the
usermod command with any of the above options.
# Set the user account to expire on the last day of 2016 $ usermod -e 2016-12-31 sarah
To set a user's password, simply use the
$ passwd sarah
To delete a user, use the
userdel command. If Sarah spawned any processes, you can send the processes a
kill signal to close them.
$ userdel sarah userdel: user sarah is currently used by process 2381 $ kill 2381 $ userdel -r sarah
-r options removes the user's home directory as well. The safe option is to not use this option, unless you are 100% sure.
chage command is used to manage password expiration time limits. It sets the number of days between required password changes. First, make sure it's installed on your distro:
$ sudo apt-get install chage $ sudo yum install chage
Linux for Beginners doesn't make any assumptions about your background or knowledge of Linux. You need no prior knowledge to benefit from this book. You will be guided step by step using a logical and systematic approach. As new concepts, commands, or jargon are encountered they are explained in plain language, making it easy for anyone to understand.$ Check price
Software expert Robert C. Martin presents a revolutionary paradigm with Clean Code: A Handbook of Agile Software Craftsmanship. Martin has teamed up with his colleagues from Object Mentor to distill their best agile practice of cleaning code "on the fly" into a book that will instill within you the values of a software craftsman and make you a better programmer.$ Check price