Hello and welcome to the Spoken Tutorial on Basics of System Administration in Linux.
In this tutorial, we will learn the following.
adduser su
usermod userdel
id du
df
I am using Ubuntu 10.10 for this tutorial.
As a prerequisite please go through the spoken tutorial on General Purpose Utilities in Linux
which is available on this website.
One must have "admin" access in order to execute the commands shown.
Let us first learn how to create a new user.
The "adduser" command will create a new user login for us along with authentication.
We can add any user account with the help of “sudo” command.
Let me give you a brief explanation about the “sudo” command.
"Sudo" command allows the administrative user to execute a command as a super user.
The "sudo" command has many options. We will learn about the options as we go further in this tutorial.
Lets now learn how to create a “New User”.
Open the “Terminal” by pressing the keys “Ctrl, Alt and t” simultaneously on your keyboard.
I have already invoked the “Terminal” here.
Here, type the command “sudo space adduser” and press Enter.
You will be prompted for a password.
I will give the “Admin” password here and Enter.
The typed password on the terminal is not visible.
So we have to type the password carefully.
Once done, a message “adduser: Only one or two names allowed” is displayed.
So, let us create a new user account named “duck”.
Type the command:
sudo space adduser space duck and press Enter.
We have created a new user called “duck”.
In the process of creating a new user, a separate “home” directory for that user has also been created.
Please note that we will be prompted for a new password for the user “duck”.
Type the password of your choice. In my case, I am going to type “duck” as the password and press Enter.
Please type the new password again.
The password is asked twice for security reasons and for confirmation.
Now our password for the new user is updated.
We will be asked for other details too.
But for the time being, I will enter only the “Full Name” as “duck” and leave the rest of the details blank by pressing the Enter key.
Enter. I will confirm this by entering “y”.
This is to confirm that all the information is correct.
Let us now check if the user account has been created.
To do this, please type at the command prompt:
“ls space /(slash) home”
and press Enter.
To show the list of users in the home folder, “ls” command is used.
And here is our newly created user named “duck”.
Let me switch back to the slides.
Now, the next command is the “su”,
“su” stands for “Switch User”.
This command is useful for switching from the current user to another user.
Let us go to the Terminal now.
Enter the command:
“su space hyphen space duck” on the “Terminal” and press Enter.
You will be prompted for a password.
I shall type the user “duck's” password here. Please recall that it was “duck” itself.
Please notice that, the Terminal switches from the previous user to the new user which is “duck” in our case.
To logout from this user, type
“logout” and hit Enter.
Now the terminal logs out from the current user “duck” and comes back to the previous user account which is “vinhai” in our case.
Let us learn about the “usermod” command.
The “usermod” command
enables a super user or root user to modify the settings of other user accounts such as:
Change the password to no password or empty password.
Show the date on which the user account will be disabled.
Let us try this command and see.
Let me switch to the terminal now.
Let me show you how to set a date of expiry for the user account "duck".
Here, at the command prompt, type:
sudo space usermod space -(hyphen)e space 2012-(hyphen)12-(hyphen)27 space duck
and press Enter.
The user account expiry date is set as mentioned in the command here with the help of the option “-e”.
Now you have set an expiry date for the user account “duck”.
Let us now talk about the “uid” and “gid” commands.
“id – command” is used to check the identities of all the users and groups.
To know about the identity of the user, we use “id space -(hyphen)u”.
To know about the identity of the group users, it is “id space -(hyphen)g”
Now lets work on this.
At the terminal, let us type
“id” and press Enter.
Now we can see the User IDs and Group IDs on the system that we are using.
To get only the user id, we use “-(hyphen)u” option.
Let us type the command, “id space -(hyphen)u”
and press Enter. Now we can see only the 'ids' of the users.
But what if we need to know the names of the users?
To find that out, we will type
“id space -(hyphen)n space -(hyphen)u” on the terminal here and press Enter.
Now we can see the names of the users instead of their ids.
Let us now learn the commands for Group IDs.
Lets type “ id space -(hyphen)g”.
Here we can see the group ids.
If we want to view all the current user's group IDs, type:
“id space -(hyphen) (capital)G” and press Enter.
Please notice that I have typed G in capital letter.
See the result for yourself.
Now let us learn how to delete a user account.
For this we use “userdel” command.
We can delete an user account permanently with the help of the “userdel” command.
Let's try this on the terminal.
Here, type: “sudo space userdel space -(hyphen)r space duck”.
I have used the "-(hyphen)r" option.
This is to remove the user along with his home directory.
Let us press Enter and see what happens.
Now the user “duck” has been deleted.
Check this by typing:
“ls space /(slash)home” and press Enter.
We will find that the user account “duck” has been deleted.
Let me go back to the slides now.
Some of the useful commands in Linux System Administration are “df” and “du”.
The “df” command gives a report on the free space available on the disk.
And the “du” command gives a report on how much space a file has occupied.
Please try these two commands and find the output for yourself as an assignment.
Let us shift to the terminal. I shall show you a few useful options used with the “df” command.
Please type: df space -(hyphen)h and press Enter.
Here, it shows the size of the Filesystem, and the space used.
It also shows the space mounted on in a human readable format.
Let us now try some options with the “du” command.
At this point I assume that you have created some text files in your home folder.
If not, please refer to the tutorial on “General Purpose Utilities in Linux”.
I have already created some text files in my home directory to execute the commands.
Go to “home folder” on the terminal by typing
“cd space /(slash) home” and press Enter.
Then type: du space -(hyphen)s space *. (asterisk dot) txt and press enter.
This command will give you a report on the 'txt files' available in the directory along with its file sizes.
As an assignment, at the command prompt please type:
“du space -(hyphen)ch space *.(asterisk dot)txt” and see what happens.
Let me go back to the slides.
To summarize, we have learnt:
“adduser” command to create a new user.
“su” command to switch from one user to another user.
“usermod” command to change the user account settings.
“userdel” command to delete the user account.
"id" command to know the information about user ids and group ids.
“df” command to check the file system size and its availability.
“du” command to check the space occupied by a file.
This brings us to the end of this tutorial on “Basics of system administration”.
The video available at this url,
Summarizes the Spoken Tutorial project.
If you do not have good bandwidth, you can download and watch it.
We conduct workshops using spoken tutorials. We also give certificates to those who pass an online test. Please contact us for more details.
Spoken Tutorial is a part of the “Talk to a Teacher” project Supported by the National Mission on Education through ICT (NMEICT), MHRD, Government of India.
More information is available on this url.
This script has been contributed by ----------------------(name of the translator)
and this is -----------------------(name of the recorder) from --------------------------(name of the place)signing off. Thanks for watching.