Outils du site

L'horreur est humaine. [Eurydice]

04-linux:10-administration:88-users

Différences

Ci-dessous, les différences entre deux révisions de la page.

Lien vers cette vue comparative

Les deux révisions précédentesRévision précédente
Prochaine révision
Révision précédente
04-linux:10-administration:88-users [2016/11/14 17:53] Roge04-linux:10-administration:88-users [2023/03/05 02:15] (Version actuelle) – [Partage dossier entre utilisateurs] Roge
Ligne 1: Ligne 1:
 +====== Users ======
  
 +
 +références : https://wiki.archlinux.org/index.php/Users_and_groups
 +
 +
 +===== Utilisateurs =====
 +
 +
 +  * Liste des utilisateurs :
 +
 +''cat /etc/passwd''
 +
 +  * Liste des sudoers :
 +
 +''/etc/sudoers''
 +
 +  * Ajout d'un utilisateur :
 +
 +''sudo useradd -m -g //initial_group// -G //additional_groups// -s //login_shell username//''
 +
 +<note important>
 +//**-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.
 +</note>
 +
 +  * Suppression d'un utilisateur :
 +
 +''sudo userdel -r //username//'' 
 +
 +<note important>
 +The //**-r**// option specifies that the user's home directory and mail spool should also be deleted.
 +</note>
 +
 +
 +  * Modification des UIDs et GIDs
 +
 +<code bash>
 +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>
 +</code>
 +
 +===== Groupes =====
 +
 +Chaque utilisateur est membre d'un ou plusieurs groupes.
 +
 +
 +  * Liste des groupes :
 +
 +''cat /etc/group''
 +
 +  * Membres d'un groupe :
 +
 +''getent group //groupname//''
 +
 +  * Création d'un groupe :
 +
 +''sudo groupadd //group//''
 +
 +  * Modification d'un nom de groupe :
 +
 +''sudo groupmod -n //new_group// //old_group//''
 +
 +  * Suppression d'un groupe : 
 +
 +''sudo groupdel //group//''
 +
 +  * Groupes d'un utilisateur :
 +
 +''groups //username//''
 +
 +En plus détaillé : 
 +
 +''id //username//''
 +
 +
 +  * Changement du groupe **primaire** d'un utilisateur
 +
 +''sudo usermod -g //<primary_group>// //<user>//''
 +
 +  * Ajout d'un utilisateur à un groupe (groupe secondaire de l'utilisateur)
 +
 +''sudo usermod -a -G //<additional_groups>// //<user>// ''
 +
 + 
 +<note warning>
 +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.
 +</note>
 +
 +  * Suppression d'un utilisateur d'un groupe :
 +
 +''sudo gpasswd -d //user// //group//''
 +
 +
 +===== Partage dossier entre utilisateurs =====
 +
 +<code>
 +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
 +</code>
 +
 +
 +
 +===== Sudoers =====
 +
 +
 +remove user from sudoers group
 +''sudo deluser <username> sudo''