Linux 101 : Adding users - User's parameters -



Adding users:

When we create a Linux user, unless we explicitly mention a parameter, the user gets the default value.

To display the default values of a user, we use the below command:


Creating a user with a home directory:

We use the below command to create a user with a "home" directory:


-m : will create a home directory and copy the needed configuration files into "Albert's" directory "/home/Albert".

We then need to define a password for our user using the below command:


Remark:

The command "useradd Albert" doesn't create a "home" directory for the user "Albert".

Changing the default parameters for a user:

For example, we could set a specific "user ID" and "group ID" for a user, using the below command:


-u: user ID
-g: group ID
-m: instructs the "useradd" to create a "home" directory for the user.

Changing the system's defaults:

For example, we could change the default expiry date for the passwords using the below command:


YYYY: the year, "2022" for example.
MM: the month, "06" for example.
DD: the day of the month, "01" for example.

Modifying the parameters of the users:

We could use the "usermod" command to change a user's parameters.
For example, we could change the "shell" of a user, using the below:


Locking and unlocking user' accounts:

To prevent a user from logging into the system, we use:


Or, we could use the below command:


To allow the same "locked" user to log into to the system, we use the below command:


Or, we could use the below command:


Preventing a user for logging in:

To prevent a user for logging in directly on the machine, we use:


To user could still get logged in remotely.

To set an expiry date to the "22-05-09" for a user's password, we could use the below command:


Comments

Leave as a comment:

Archive