onsa
2/4/2017 - 4:14 PM

Linux user management

Linux user management

# the file containing user information is /etc/passwd structure

  [username]:x[instead of the old convention of storing encrypted passwords]:[userid]:[groupid]:[user description]:[home directory]:[default shell]

# add new user

  sudo adduser [username]
  
# reset password

  sudo passwd [username]

# to add user to administrators, add a file called [username] to /etc/sudoers.d with the following content

  [username] [host]=([operatoruser]:[operatorgroup]) [comamnd]                # operators is a list of users/groups user must be running commands as or a runas alias
  e.g.:
  root ALL=(ALL:ALL) ALL                                                      # root can execute as any user all commands
  
  otheruser ALL=(otheruser:others) NOPASSWD:/bin/ls, PASSWD:/bin/mkdir        # otheruser can execute only ls without password
                                                                              # mkdir with password, nothing else