Users and Groups

ORDER OF THE STARTUP FILES


© 2022 edX Inc.


Most often, ~/.basrh contains the aliases, customised commands or a modification of the behaviour of the already existing ones.

$ alias
To list the current aliases

Key files for Users and Groups:
  • /etc/group
  • /etc/passwd
  • /etc/group


USERS

id
Displays info of the user. The logged one if with no argument. 

$ useradd -m -c VISUALISED-NAME -s /bin/bash USERNAME
-m creates the home directory
-s select the shell to use. To see the available shells, view the file /etc/shells

When using useradd, the default settings are written in /etc/default/useradd
The initiation config files to create a new home directory are located in /etc/skel

$ userdel -r USERNAME
-r to remove the home directory

SUDO privileges
Config file: /etc/sudoers
Config directory, empty by default: /etc/sudoers.d


GROUPS

$ group USERNAME
To list the groups the username belong to

$ groupadd GROUPNAME

$ groupdel GROUPNAME

$ usermode -a -G USERNAME GROUPNAME
To add a user to a group
-a to be sure to append the user to the group list instead replacing the group list with the new addition
-G to have the list group the user belong to after the new addition


FILE OWNERSHIP

$ chown ug+w, o-r NOMEFILE
Adds Write permission to the User and the Group, and removes Read permission to Other

Alternatively:

  • 4 if read permission is desired
  • 2 if write permission is desired
  • 1 if execute permission is desired
In this way:
$ chmod 165 NOMEFILE
sets only execute for the user (1), read and write for group (4+2=6), and read and execute for others (4+1=5).

$ chown NEWUSER:NEWGROUP FILENAME
changes the user and the group the file currently belong to.

chown NEWUSER FILENAME
changes the user the file currently belong to.

chown :NEWGROUP FILENAME
changes the group the file currently belong to.

$ chgrp NEWGROUP FILENAME
changes the the group the file currently belong to.

Comments