syntax.us Let the syntax do the talking
Blog Contact Posts Questions Tags Hire Me

You are here: Linux101 > linux101_cclud_account
Question:
In Linux101 how to CCLUD Linux Accounts?

When I create a new Linux instance from an installation ISO, the installer will ask me my name.

It will then create an account called 'dan'.

After the installation is done I often create an account called 'fox'.

I use the fox account to surf the web using Firefox.

How do I create an account named 'fox' on Linux?

The easy way is to use the GUI so that is your homework.

I can also create a fox account using two shell commands (useradd then passwd) from the root account.

The demo below uses a short-cut to create an account and a home folder with one useradd-shell command. Usually I create an account with one shell command then I create the home folder with another command:
root@feb:/home/dan$ 
root@feb:/home/dan$ 
root@feb:/home/dan$ useradd -m fox -s /bin/bash
root@feb:/home/dan$ 
root@feb:/home/dan$ passwd fox
Enter new UNIX password: 
Retype new UNIX password: 
passwd: password updated successfully
root@feb:/home/dan$ 
root@feb:/home/dan$ exit


Now I should be able to login to the fox account:

dan@feb ~ $ 
dan@feb ~ $ ssh fox@localhost
fox@localhost''s password: 
Welcome to Ubuntu 14.04.1 LTS (GNU/Linux 3.13.0-45-generic x86_64)

 * Documentation:  https://help.ubuntu.com/

19 packages can be updated.
8 updates are security updates.


The programs included with the Ubuntu system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Ubuntu comes with ABSOLUTELY NO WARRANTY, to the extent permitted by
applicable law.

fox@feb:~$ 
fox@feb:~$ 
fox@feb:~$ ls -la
total 36
drwxr-xr-x 3 fox  fox  4096 Feb 11 04:27 .
drwxr-xr-x 5 root root 4096 Feb 11 04:27 ..
-rw-r--r-- 1 fox  fox   220 Apr  9  2014 .bash_logout
-rw-r--r-- 1 fox  fox  3637 Apr  9  2014 .bashrc
drwx------ 2 fox  fox  4096 Feb 11 04:27 .cache
-rw-r--r-- 1 fox  fox  8980 Oct  4  2013 examples.desktop
-rw-r--r-- 1 fox  fox   675 Apr  9  2014 .profile
fox@feb:~$ 
fox@feb:~$ 
fox@feb:~$ ps
  PID TTY          TIME CMD
22894 pts/45   00:00:00 bash
22988 pts/45   00:00:00 ps
fox@feb:~$ 
fox@feb:~$ 
fox@feb:~$ exit
logout
Connection to localhost closed.
dan@feb ~ $ 
dan@feb ~ $ 


Q: How do I make a copy of the fox account?
A: Just do the above two commands again but on a different computer.


Q: How do I list the accounts on a Linux instance?
A: A list of accounts is kept in a file called /etc/passwd.


Q: How do I make an update to an account?
A: I cannot think of a reason to 'update' an account but Linux offers a shell command named usermod which might be useful for entertainment if you are really bored.
Often, though, I change the password of an account. If I want to change the password of the fox account, I login as fox and type in the command:
passwd

Another way to change the fox password is to login as root and type the command:
passwd fox


Q: How do I delete the fox account?
A: I need to login as root and issue 2 shell commands:
dan@feb ~ $
dan@feb ~ $ su
Password:
root@feb:/home/dan$
root@feb:/home/dan$
root@feb:/home/dan$ ls -la /home/
total 36
drwxr-xr-x  5 root root  4096 Feb 11 04:27 .
drwxr-xr-x 23 root root  4096 Feb  2 04:21 ..
drwx------ 60 dan  dan  20480 Feb 11 02:52 dan
drwxr-xr-x  3 fox  fox   4096 Feb 11 04:28 fox
root@feb:/home/dan$
root@feb:/home/dan$ userdel fox
root@feb:/home/dan$
root@feb:/home/dan$ rm -rf /home/fox/
root@feb:/home/dan$
root@feb:/home/dan$ ls -la /home/
total 32
drwxr-xr-x  4 root root  4096 Feb 11 06:11 .
drwxr-xr-x 23 root root  4096 Feb  2 04:21 ..
drwx------ 60 dan  dan  20480 Feb 11 02:52 dan
root@feb:/home/dan$
root@feb:/home/dan$


The above delete-demo shows a subtle point about Linux accounts.

An account usually has a home folder but an account does not need a home folder.

Also this means that if I delete an account, the home folder still exists. Notice in the above demo that I delete the fox account and then I remove the /home/fox/ folder in two separate commands.

The main point to remember is that an account and its home folder are separate Linux objects.

CCLUD of Files is the next topic of Linux101:
linux101_cclud_file


You are here: Linux101 > linux101_cclud_account
syntax.us Let the syntax do the talking
Blog Contact Posts Questions Tags Hire Me