RHEL 7 – Note RHCSA (cheat sheet)
Aggiunta di un account utente
Usa useradd comando per aggiungere un nuovo utente :
# useradd [options] [username]
Le impostazioni predefinite per il nuovo utente possono essere visualizzate e modificate utilizzando l'opzione -D :
# useradd -D GROUP=100 HOME=/home INACTIVE=-1 EXPIRE= SHELL=/bin/bash SKEL=/etc/skel CREATE_MAIL_SPOOL=yes
Ad esempio, per modificare la shell utente predefinita per il nuovo utente in /bin/ksh :
# useradd -D -s /bin/ksh
Esempi
Per aggiungere semplicemente un utente con tutte le opzioni predefinite:
# useradd user01
Per aggiungere un utente con uid 1099, commenta "nuovo utente" e la shell predefinita come /bin/ksh :
# useradd -u 1099 -c "new user" -s /bin/ksh user01
Controlla la voce del nuovo utente in /etc/passwd file :
grep user01 /etc/passwd user01:x:1099:1099:new user:/home/user01:/bin/ksh
Per modificare l'utente esistente (ad es. cambiando il commento):
# usermod -c "modified user" user01
Per assegnare la password a un nuovo utente:
# passwd user01 Changing password for user user01. New password: Retype new password: passwd: all authentication tokens updated successfully.
Visualizza /etc/shadow file :
# grep user01 /etc/shadow user01:$6$dox84xyJ$89DdMcxSlI9OHxUCyY1ryaFsmG6MSEwbmSbZXJoFY.tHgdEEeQQgQjDV0dD8jEiHusrUjj3p8gtMTKR4sXXN5.:17058:0:45:7:::
Per eliminare l'utente :
# userdel user01
shell di accesso
È possibile creare un utente con shell nologin per l'esecuzione di servizi come SMTP, FTP ecc. Un utente senza una shell di accesso non può accedere a un sistema e quindi non può eseguire alcun comando sul sistema in modo interattivo sul sistema. Tuttavia, i processi possono essere eseguiti come tali utenti.
Per aggiungere un nuovo utente "test" con shell nologin :
# useradd -s /sbin/nologin test
Assicurati che la shell nologin sia presente in /etc/shells file :
# cat /etc/shells /bin/sh /bin/bash /sbin/nologin /usr/bin/sh /usr/bin/bash /usr/sbin/nologin