Aggiungi un utente su Ubuntu Server

Aggiungi un utente su Ubuntu Server
Aggiungi un utente su Ubuntu Server

Video: Aggiungi un utente su Ubuntu Server

Video: Aggiungi un utente su Ubuntu Server
Video: Come Installare un pacchetto in DEB da terminale - YouTube 2024, Aprile
Anonim

Ubuntu Server è come qualsiasi altra varietà Linux e ha capacità multiutente complete, e un'attività comune su qualsiasi server è l'aggiunta di utenti.

useradd

Il comando useradd ti permetterà di aggiungere un nuovo utente facilmente dalla riga di comando:

useradd

Questo comando aggiunge l'utente, ma senza opzioni extra l'utente non avrà una password o una home directory.

Nota:se ricevi un messaggio che dice che il comando non è stato trovato, prova a utilizzare il percorso completo, come questo:

/usr/sbin/useradd

È possibile utilizzare l'opzione -d per impostare la directory home dell'utente. L'opzione -m costringerà useradd a creare la directory home. Proveremo a creare un account utente con queste opzioni e quindi utilizzare il comando passwd per impostare la password per l'account. In alternativa puoi impostare una password usando -p sul comando useradd, ma preferisco impostare la password usando passwd.

sudo useradd -d /home/testuser -m testuser

sudo passwd testuser

Questo creerà l'utente nominato testuser e darà loro la propria home directory in / home / testuser. I file nella nuova directory home vengono copiati dalla cartella / etc / skel, che contiene i file di directory home predefiniti. Se si desidera impostare valori predefiniti per i propri utenti, lo si fare modificando o aggiungendo file in tale directory. Se diamo un'occhiata alla nuova directory home per l'utente:

geek@ubuntuServ:/etc/skel$ ls -la /home/testuser total 20 drwxr-xr-x 2 testuser testuser 4096 2006-12-15 11:34. drwxr-xr-x 5 root root 4096 2006-12-15 11:37.. -rw-r–r– 1 testuser testuser 220 2006-12-15 11:34.bash_logout -rw-r–r– 1 testuser testuser 414 2006-12-15 11:34.bash_profile -rw-r–r– 1 testuser testuser 2227 2006-12-15 11:34.bashrc

Noterai che ci sono degli script di bash in questa directory. Se si desidera impostare le opzioni di percorso predefinite per tutti i nuovi utenti, lo si fare modificando i file in / etc / skel, che verrebbero quindi utilizzati per creare questi file tramite il comando useradd.

Aggiungi utente

Il comando adduser è ancora più semplice del comando useradd, perché ti richiede ogni informazione. Trovo un po 'strano che ci siano due comandi virtualmente identici che fanno la stessa cosa, ma questo è Linux per te. Ecco la sintassi:

adduser

Esempio:

geek@ubuntuServ:/etc/skel$ sudo adduser thegeek Password: Adding user `thegeek’… Adding new group `thegeek’ (1004). Adding new user `thegeek’ (1004) with group `thegeek’. Creating home directory `/home/thegeek’. Copying files from `/etc/skel’ Enter new UNIX password: Retype new UNIX password: No password supplied Enter new UNIX password: Retype new UNIX password: passwd: password updated successfully Changing the user information for thegeek Enter the new value, or press ENTER for the default Full Name : The Geek Room Number : 0 Work Phone : 555-1212 Home Phone : 555-1212 Other : Is the information correct? [y/N] y

Consigliato: