Posted: . At: 9:09 AM. This was 5 years ago. Post ID: 13394
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.


Changing user account settings with the command line is very easy.


The default user account settings may easily be changed with the command line, here is an example. Changing the default login shell with the command line.

4.4 Mon Jul 22 jason@Yog-Sothoth 0: $ sudo useradd -D -s /bin/bash

Get the default settings like this, we can see that the /bin/bash shell is set as the default.

4.4 Mon Jul 22 jason@Yog-Sothoth 0: $ sudo useradd -D
GROUP=100
HOME=/home
INACTIVE=-1
EXPIRE=
SHELL=/bin/bash
SKEL=/etc/skel
CREATE_MAIL_SPOOL=no

This usage of useradd will do the same as above, but will also set the account to be disabled 3 days after the password expiry date if the password is not changed.

4.4 Mon Jul 22 jason@Yog-Sothoth 0: $ sudo useradd -D -s /bin/bash -f 3

And even the expiry date may be set to have a deadline for changing passwords before accounts are locked.

4.4 Mon Jul 22 jason@Yog-Sothoth 0: $ sudo useradd -D -s /bin/bash -f 3 -e "2019-07-30"

Your user account will now be locked, unless the password is changed before this date.

Viewing the settings now, we can see the new changes in the /etc/default/useradd file.

4.4 Mon Jul 22 jason@Yog-Sothoth 0: $ sudo useradd -D
GROUP=100
HOME=/home
INACTIVE=3
EXPIRE=2019-07-30
SHELL=/bin/bash
SKEL=/etc/skel
CREATE_MAIL_SPOOL=no

To change a user password, run this command, and follow the prompts.

4.4 Mon Jul 22 jason@Yog-Sothoth 0: $ sudo passwd jason
Enter new UNIX password: 
Retype new UNIX password: 
passwd: password updated successfully

Create a new user account like this.

4.4 Mon Jul 22 jason@Yog-Sothoth 0: $ sudo useradd -m -g jimkirk -c "Barak Obama" obama

The user account is being added to an existing group named “jimkirk”. But a password has not been set yet.

Set a password like this.

4.4 Mon Jul 22 jason@Yog-Sothoth 0: $ sudo passwd obama
Enter new UNIX password: 
Retype new UNIX password: 
passwd: password updated successfully

And then the account is ready to use.


Leave a Comment

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