Posted: . At: 8:49 AM. This was 4 years ago. Post ID: 14053
Page permalink. WordPress uses cookies, or tiny pieces of information stored on your computer, to verify who you are. There are cookies for logged in users and for commenters.
These cookies expire two weeks after they are set.



Sponsored



How to add a new user on Ubuntu 20.04.


This is how to add a new user account on your Ubuntu Linux machine. This is very simple using the useradd command. Useradd takes parameters instead of asking for details like adduser, this means it is better to use in a script.

4.4 Wed Feb 12 jason@Yog-Sothoth 0: $ sudo useradd test6 -m -s /bin/bash -G users
1) All commands run with root privileges are always dangerous.
2) Never run commands on an environment you are not willing to destroy, or able to restore.
3) Do not become root until you know what you are going to do.
4) Be sure of your command and what is going to be affected by it.
[sudo] password for jason:

This added the user test6 to the Linux system, now we need a password for the user.

4.4 Wed Feb 12 jason@Yog-Sothoth 0: $ sudo passwd test6
Enter new UNIX password: 
Retype new UNIX password: 
passwd: password updated successfully

This user is now ready to use.

To lock the account once it is no longer needed, use this command.

4.4 Wed Feb 12 jason@Yog-Sothoth 0: $ sudo usermod --expiredate 1 test6

The sudo passwd -l test6. command will also work, but the user could still login using an SSH key for example, the usermod example is better. This set the accounts expiry date to Jan 2, 1970. The password expiry information is stored in the /etc/shadow file, this can only be edited by the superuser of course.

The /etc/login.defs file contains all defaults for user logins unless it is overridden by PAM. An administrator can set many options for user logins in this file.

To delete a user account on Linux, use this command.

4.4 Wed Feb 12 jason@Yog-Sothoth 0: $ sudo userdel -r mrpres
userdel: mrpres mail spool (/var/mail/mrpres) not found

This will remove the home directory as well as the user account.


Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.