:: ADDUSER


Nome del pacchetto:   [funzionalità del sistema operativo]

:: Descrizione della funzionalità

La gestione di un mail server prevede, come è facile immaginare, la gestione degli account di sistema.
In questo HOWTO non trattiamo la gestione di database di utenti attraverso sistemi quali LDAP o altre tecnologie ma facciamo riferimento al tradizionale meccanismo di autenticazione di Unix basato sull'attivazione di user "di sistema".

Per gestire un utente possiamo utilizzare i seguenti comandi:

  • adduser
  • passwd
  • chpass
  • rmuser
  • pw
ed intervenire nei seguenti file di configurazione:
  • /etc/login.conf
  • /etc/auth.conf
  • /etc/passwd
  • /etc/master.password
  • /usr/share/skel/*
  • /etc/shells
  • /etc/group
1) Iniziamo con la creazione di uno username. Se eseguiamo il comando adduser, il sistema ci indicherà come prima cosa i default contenuti nel file /etc/adduser.conf permettendoci di modificarli, come seconda ci chiederà tutte le informazioni relative all'utente che stiamo attivando.
Qui di seguito riportiamo la creazione dell'utente mailtest. Abbiamo evidenziato in grassetto le risposte da noi digitate in seguito alle richieste da parte del comando.

# adduser
Use option ``-silent'' if you don't want to see all warnings and questions.

Check /etc/shells
Check /etc/master.passwd
Check /etc/group
Usernames must match regular expression:
[^[a-z0-9_][a-z0-9_-]*$]: [invio]
Enter your default shell: bash csh date no sh tcsh [sh]: [invio]
Your default shell is: sh -> /bin/sh
Enter your default HOME partition: [/home]: [invio]
Copy dotfiles from: /usr/share/skel no [/usr/share/skel]:
Send message from file: /etc/adduser.message no
[/etc/adduser.message]: [invio]
Use passwords (y/n) [y]: [invio]

Ok, let's go.
Don't worry about mistakes. I will give you the chance later to correct any input.
Enter username [^[a-z0-9_][a-z0-9_-]*$]: mailtest
Enter full name []: Utente di prova
Enter shell bash csh date no sh tcsh [sh]: sh
Enter home directory (full path) [/home/mailtest]: [invio] Uid [1002]: [invio]
Enter login class: default []: [invio]
Login group mailtest [mailtest]: [invio]
Login group is ``mailtest''. Invite mailtest into other groups: guest no
[no]: [invio]
Enter password []: _________
Enter password again []: __________

Name: mailtest
Password: ****
Fullname: Utente di prova
Uid: 1002
Gid: 1002 (mailtest)
Class:
Groups: mailtest
HOME: /home/mailtest
Shell: /nonexistent
OK? (y/n) [y]: y
Added user ``mailtest''
Send message to ``mailtest'' and: no root second_mail_address [no]: [invio]

your account ``mailtest'' was created.
Have fun!

See also chpass(1), finger(1), passwd(1)

Add anything to default message (y/n) [n]: n
Send message (y/n) [y]: n
Copy files from /usr/share/skel to /home/mailtest
Add another user? (y/n) [y]: n
Goodbye!

Adduser accetta in input le opzioni --silent e --verbose per evitare o includere la visualizzazione dei default per la creazione degli account.


2) Con il comando passwd possiamo cambiare una password assegnata ad un utente. Ecco un esempio:

# passwd mailtest
Changing local password for mailtest.
New password:
Please enter a password at least 6 characters in length.
New password:
Retype new password:
passwd: updating the database...
passwd: done


3) Il comando chpass permette la modifica delle impostazioni dell'utente. Un esempio:

# chpass mailtest [FILE TEMPORANEO CON I DATI DELL'UTENTE - EDITOR PREDEFINITO [vi] ]
#Changing user database information for mailtest.
Login: mailtest
Password: YF.EIhtPe2wcw
Uid [#]: 1002
Gid [# or name]: 1002
Change [month day year]:
Expire [month day year]:
Class:
Home directory: /home/mailtest
Shell: /bin/bash
Full Name: Utente di prova
Office Location:
Office Phone:
Home Phone:
Other information:

Una volta modificati i parametri di interesse, uscite dal file salvando. Il database degli utenti verrà aggiornato automaticamente.


4) Il comando rmuser permette la cancellazione dell'utente abilitato. Un esempio:

# rmuser mailtest
Matching password entry:

mailtest::1002:1002::0:0:mailtest:/home/mailtest:/bin/sh

Is this the entry you wish to remove? y
Remove user's home directory (/home/mailtest)? y
Updating password file, updating databases, done.
Updating group file: (removing group mailtest -- personal group is empty) done.
Removing user's home directory (/home/mailtest): done.
Removing files belonging to mailtest from /tmp: done.
Removing files belonging to mailtest from /var/tmp: done.
Removing files belonging to mailtest from /var/tmp/vi.recover: done.


5) Il comando pw permette la creazione, modifica e cancellazione di utenti e gruppi. Alcuni esempi:

Attivazione di un nuovo utente
# pw useradd mailtest -c "Prova" -d /home/mailtest -s sh

Cancellazione dell'utente e della sua home directory
# pw userdel mailtest -r

Modifica della shell e del "comment" di un utente già attivo
# pw usermod mailtest -c "Prova2" -s tcsh

Pw è un comando in grado di gestire diverse funzioni relative alla gestione di un utente e ha numerose opzioni. Consultate la man page per ulteriori informazioni.

[ Pagina principale ]