The usermod command

Earlier we saw that to make any changes we have to remove the user with the useradd command. This can be cumbersome every time we decide on a change; instead, we can leverage another powerful command: the usermod command. The basic syntax of the usermod command is as follows:

usermod <option> username

Using our test user tom, we can change a number of parameters with the usermod command. For example, we can lock the account for the user tom, this will prevent the user tom from being able to log into the system. To lock an account, we would use the -L option:

root@ubuntu:/home/philip# cat /etc/passwdphilip:x:1000:1000:philip,,,:/home/philip:/bin/bashgdm:x:121:129:Gnome Display Manager:/var/lib/gdm3:/bin/falsegeoclue:x:122:130::/var/lib/geoclue:/bin/false ...

Get CompTIA Linux+ Certification Guide now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.