Table des matières

Users

références : https://wiki.archlinux.org/index.php/Users_and_groups

Utilisateurs

cat /etc/passwd

/etc/sudoers

sudo useradd -m -g initial_group -G additional_groups -s login_shell username

-m, --create-home

Create the user's home directory if it does not exist. The files and directories contained in the skeleton directory (which can be defined with the -k option) will be copied to the home directory.

By default, if this option is not specified and CREATE_HOME is not enabled, no home directories are created.

sudo userdel -r username

The -r option specifies that the user's home directory and mail spool should also be deleted.
usermod -u <NEWUID> <LOGIN>    
groupmod -g <NEWGID> <GROUP>
find / -user <OLDUID> -exec chown -h <NEWUID> {} \;
find / -group <OLDGID> -exec chgrp -h <NEWGID> {} \;
usermod -g <NEWGID> <LOGIN>

Groupes

Chaque utilisateur est membre d'un ou plusieurs groupes.

cat /etc/group

getent group groupname

sudo groupadd group

sudo groupmod -n new_group old_group

sudo groupdel group

groups username

En plus détaillé :

id username

sudo usermod -g <primary_group> <user>

sudo usermod -a -G <additional_groups> <user>

If the -a option is omitted in the usermod command above, the user is removed from all groups not listed in additional_groups (i.e. the user will be member only of those groups listed in additional_groups).

-G : Each group is separated from the next by a comma, with no intervening whitespace.

sudo gpasswd -d user group

Partage dossier entre utilisateurs

sudo mkdir /home/public

sudo /usr/sbin/groupadd share

sudo chown -R root.share /home/public

sudo /usr/bin/gpasswd -a user1 share

sudo chmod ug+rwx -R /home/public

# set the SGID bit on the shared directory. Normally whenever you create files in a directory, by default it belongs to the default group or user. When a file is created in a directory with the SGID bit set it belongs to the same group as the directory. The result being that all users of the “share” group can create/alter files in “/home/public” directory.

sudo chmod g+s /home/public

Sudoers

remove user from sudoers group sudo deluser <username> sudo