This user now has a /home/test directory. In order to create a user with the default home directory use the following option: This is intentionally difficult, because you should not do it! Just use the passwd command. Note that the -p option doesn't allow you to input a plaintext password, it expects you to encrypt it first. There is an option for adding an encrypted password via the -p option on useradd, but this is not recommended for security purposes. This will prompt you to enter a password for the user. You then add a password for the test user by using the passwd command: passwd test. This will create a user called test, but it's a limited operation and will not create other useful things like their home directory or password! Add a password The simple format for this command is useradd USERNAME.įor example useradd test (as the root user - prefix with sudo if you are not logged in as root). You can get a full overview of the various options available to you by viewing the man page for the utility: man useraddīut if that is overwhelming, here's a breakdown of some of the common options you might use when creating a user.
So even as a solo dev on your own machine, you may find yourself reaching for these commands when you install MySQL or something similar.
If more than one person is using your Linux machine at home, or you are managing a server that provides access to multiple users, the useradd command is essential for creating users.Īlso, many of the services you use as a developer may require their own user accounts to function.