Linux-for-Sys-Ads/C2/Creating-user-account/English
Title of script: Creating User Account
Author: Antara Roy Choudhury
Keywords: Creating user account, Different options, Specify user ID, Specify home directory, Specify login shell, Specify comments, /etc/passwd, /etc/shadow
Visual Cue | Narration |
Slide 1: Introduction | Hello and welcome to the spoken tutorial on Creating User Account in Linux. |
Slide 2: Learning Objectives | In this tutorial we will learn about
|
Slide 3: System requirement | To record this tutorial, I am using Ubuntu Linux 16.04 OS |
Slide:4 Prerequisite | To practice this tutorial, *You should have gone through the Linux tutorial series on this website.
|
Slide 5: | In an earlier tutorial on basics of system administration, we have learnt
adduser space option space username*Please note that the option field here, is not mandatory.
|
Press Ctrl+Alt+T | Open the Terminal by pressing Ctrl, Alt and T keys simultaneously on the keyboard. |
Type
sudo su [Enter] |
First, you should login as superuser or root user.
To do so type: sudo space su and press Enter. |
Type
Password of your account [Enter] |
Type your password and then press Enter. |
Highlight # prompt | Notice, our login prompt has changed to a hash symbol.
This indicates that we are in the root user mode. |
Slide with a block diagram to explain the scenario | Now, let’s consider a scenario of a college.
We will have students, departments, etc. As a system administrator, you should first create a user account for individual students. |
adduser amit
[Enter] |
Let’s add one user say Amit using adduser command.
So, on the terminal type: adduser space amit and press Enter |
Type
pass_amit [Enter] |
It will prompt us to type the password for the user Amit.
Let’s type pass underscore amit and press Enter. |
Retype the same password
[Enter] |
Retype the same password and press Enter. |
Type
Amit [Enter] |
When it prompts for the Full Name field, type the name of the user as Amit with A in caps.
Press Enter. Leave the other fields empty by pressing the Enter key. |
Press Y | Press Y to confirm that the information you provided is correct.
Press Enter |
On getting # prompt back | So, we got back our root command prompt.
The user amit is now created. |
Highlight appropriately in the output of previous command | Linux automatically assigns a UID or User ID to the user. |
Highlight appropriately in the output of previous command | It also creates a home directory for the user in the system’s home folder.
In this case, it is /home/amit |
Highlight appropriately in the output of previous command | A group is also created with the same name as the username of the user. |
Slide 6a: | Now, say *we want a customized user ID or group
|
Slide 6b: | *adduser supports options for each of these requirements.
|
Slide 7: | *Hyphen u option is used to set user ID
|
Slide 8: | Let us take an example.
Say we want to add a user Kaushik with *user ID as 1050
|
Type:
adduser -u 1050 -home /home/testdir/ -shell /bin/sh -c "Re-Registered student" kaushik [Enter] |
Switch to the terminal.
Let me clear the terminal. Type the command as shown here Press Enter. |
Type
pass_kaushik [Enter] |
It will ask you to enter the password for Kaushik.
I will type the password as pass underscore kaushik press Enter. |
Type
pass_kaushik [Enter] |
Retype the same password and press Enter. |
Type Kaushik
[Enter] |
Give the Full Name of the user as Kaushik with K in caps
press Enter. |
Press Enter | And proceed as we have done before. |
Show the output | So, the user kaushik is created now. |
Type:
ls /home/ [Enter] |
Now type ls space /home and press Enter.
|
Slide 9: | How can we view other information such as user ID, login shell etc.?*In Linux, all configuration files are stored in simple text files.
|
cat /etc/passwd
[Enter] |
Let us have a look at the /etc/passwd file.
Switch to the terminal Type cat space /etc/passwd and press Enter. |
Show file opened
And scroll down until you see user amit and kaushik Highlight rows |
There will be an entry in this file for every user on the system.
Our passwd file shows this line for user Amit. Each line has seven fields separated by colon. Let us understand the fields one by one. |
Slide | *The first field is the username amit.
You should remember this while you are creating a user account |
Slide | The second field is for password.
An x character indicates that the encrypted hash password is stored in the file /etc/shadow. |
Slide | The third field is user ID for that particular user. |
Slide | *User id 0 is reserved for root user.
|
Slide | The fourth field stores the primary group id for the user.
At the fifth place, we have the comments field. It basically stores information about the user such as name of the user, room number, phone number, etc. |
Slide | The sixth field indicates the home directory for the user.
At the end, we have the login shell of the user. |
Switch to terminal and highlight the rows for amit and kaushik | Notice that, we have default values set for user Amit.
However, user kaushik is created with our customized values. |
Type
cat /etc/shadow |
Now, let’s have a look at the /etc/shadow file, where the encrypted passwords are stored.
Type cat space /etc/shadow and press Enter. |
Show the output and highlight | In this file, every line has information about a particular user.
And each line contains various fields separated by colon. The first field is username, which must correspond to username field in /etc/passwd file. |
(Suppose the entry looks like this
Amit:yh65fgtr) Then highlight yh65fgtr |
Notice, the second field is the encrypted password for that user.
Let us skip the other fields for now. |
Type exit and press Enter | To exit from the root user access, type exit and press Enter. |
Retain same screen | This brings us to the end of this tutorial.
Let us summarize. |
Display Slide 16:
Summary |
In this tutorial we learnt about-*Creating user account with different options like
|
Display Slide 16:
Summary |
We also learnt about some of the fields in the */etc/passwd and
|
Slide 17:
Assignment |
As an assignment
Create user ankit with *User ID as 1500
|
Slide 18: | *Include “Hostel 15” in the comment
|
Slide 19: About Spoken Tutorial project | The video at the following link summarises the Spoken Tutorial project.
Please download and watch it. |
Slide 20: Spoken Tutorial workshops | The Spoken Tutorial Project team conducts workshops and gives certificates.
For more details, please write to us. |
Slide: Forum for specific questions: | Do you have questions in this Spoken Tutorial?
Please visit this site. Choose the minute and second where you have the question. Explain your question briefly. Someone from our team will answer them. |
Slide: Forum for specific questions: | The Spoken Tutorial forum is for specific questions on this tutorial.
Please do not post unrelated and general questions on them. This will help reduce the clutter. With less clutter, we can use these discussion as instructional material. |
Slide 22: Acknowledgement | Spoken Tutorial Project is funded by NMEICT, MHRD, Government of India.
More information on this mission is available at this link. |
Slide 23: Thank You | The script has been contributed by Antara and this is Praveen from IIT Bombay signing off.
Thank you for joining. |