search by tags

for the user

adventures into the land of the command line

administrating users and granting sudo permissions

to add a new user with a home directory and a group

$ useradd -m -g group user

the group must already exist. you can create a group

$ groupadd group

if the user already exists and you want to add them to a group

usermod -a -G group user

sometimes user accounts will be setup to expire or have a password expiry by default. you can check a user’s account/password expiry

$ chage -l user
Last password change                    : Jun 14, 2015
Password expires                    : Jul 14, 2015
Password inactive                   : never
Account expires                     : Dec 14, 2015
Minimum number of days between password change      : 30
Maximum number of days between password change      : 30
Number of days of warning before password expires   : 7

if you want to create a system user or a user whose account/password will not expire

$ chage -M -1 user
$ chage -I -1 user
$ chage -E -1 user

$ chage -l user
Last password change                    : Jun 14, 2015
Password expires                    : never
Password inactive                   : never
Account expires                     : never
Minimum number of days between password change      : 0
Maximum number of days between password change      : 99999
Number of days of warning before password expires   : 7

if you want to give a user elevated permissions

$ visudo

add this line somewhere near the bottom of the file

user ALL=(ALL) NOPASSWD: ALL

this will allow you to execute commands with sudo at the front. but remember, some commands might not always be in your user’s PATH, so you have to specify the full path to the command. for instance as root, i could do this:

$ service httpd start

but if the ‘service’ command is not in your user’s PATH, you’ll have to do it like this:

$ sudo /sbin/service httpd start