Unit 11
Unit 11
System User
System User is created by default by the OS. This type of user is similar to normal
user but gets more privileges and access to secure programs which normal user
doesn’t have.
Normal User
These are the users which have been created by the Root and have limited access to
the resources and need permission from Root to access any secure resources and
services.
1.3. Logging In
Login:
Each user has user name, which has to be entered when, the login: prompt appears.
After you enter your login name, you are asked to enter your password. If the login
Operating System
name entered does not match any of the user names in the stored file, the login
message is displayed again. When a valid user name is entered at the terminal, the
[user_name@localhost current_directory_name] $ symbol is displayed on the
screen. This is the shell prompt, in which user_name is the user’s login name and
current_directory _name is the user's current working directory.
The administrator assigns each user a HOME directory when a new login account is
created. When you log in the terminal, you are taken directly into your HOME
directory. In Linux operating system, login names (user names) are usually the
names of users, and their HOME directory usually, although not necessarily, has
the same name. For instance, if your user name is Odroho and your HOME
directory name is also Odroho, when you logging in, you will see the following
prompt on the screen:
[Odroho@localhost Odroho]$
You can now start working on Linux.
User name and password are case-sensitive. The total login process appears like the
one shown below:
Red Hat Linux release 9 (Shrike)
Kernel 2.4.20-8 on an i686
Login: Odroho
Password: [user enters password here]
Last login: Fri Dec 13 12:18:02
[Odroho@localhost Odroho] $ _
Most system administration task requires that you login as root. To create a user
account you use the adduser command
Creating user account
[root@localhost root]# adduser Odroho
with password.
[root@localhost root]# passwd Odroho
New password:
BAD PASSWORD: it is based on a dictionary word
Retype new password:
passwd: all authentication tokens update successfully
You need to use the userdel command to delete a user account and related files
from user account. The userdel command must be run as root user. The syntax is as
follows:
Example
[root@localhost root]# userdel Odroho
[root@localhost root]# userdel –r Odroho
The second command will remove all files along with the home directory itself
and the user's mail spool. Please note that files located in other file systems will
have to be searched for and deleted manually.
208
Linux user and file management
Example
[Odroho@localhost Odroho]$ passwd
Changing password for Odroho
(current) UNIX password: [user enters old password here]
New UNIX password: [user enters new password here]
Retype new UNIX password [user re-enters new password here]
passwd: all authentication tokens updated successfully
[Odroho@localhost Odroho]$
The passwd command asks for the old password to ensure that only the
authorized user is trying to change the password. If Linux does not recognize the
old password, it displays a "passwd: Authentication failure" message, and the
Linux prompt appears on the screen.
Example
[Odroho@localhost Odroho]$ passwd
Changing password for Odroho
(current) UNIX password: [user enters the old password]
Passwd: Authentication failure
[Odroho@localhost Odroho]$
Example
[Odroho@localhost Odroho]$ passwd
Changing password for Odroho
(current) UNIX password: [user enters the old password]
New UNIX password: [user enter a new password]
Retype new UNIX password: [user enters the wrong password]
Sorry, passwords do not match
New UNIX password:
When you change a password, the new password should differ from the old
password by at least three positions. In Linux, a password should be at least six
characters long it cannot be the same as the user's login name. The new password
cannot be the same as the old password.
The root user has the authority to change the password of any user of the Linux
system. On executing the passwd command followed by a user name, the root
209
Operating System
Once you logged on to the system, your work session continues until your
instruction to the shell to terminate the session. Typing exit or logout at the
command prompt will end your current Linux session. The system then displays
the login: prompt on the screen.
In order to maintain the security of files, it is recommended to log out from the
terminal.
210
Linux user and file management
1.8. Exercises
(i) passwd
(ii) userdel
(iii) adduser
(iv) addusr
(i) Three
(ii) Four
(iii) Five
(iv) Six
211
Operating System
The UNIX file system has a hierarchical structure and files can be stored under
directories. The directories on the disk can be created to store files containing data
A file system is used
to control how
of similar nature. The user decides the directory name and the files in a directory.
information is stored Linux follows the UNIX file system convention.
and retrieved. A Sample Linux File Hierarchy
/
..(root)
212
Linux user and file management
All the files are stored on the disk under one main directory called the root
directory. The root directory has been further sub-divided into directories-bin, boot,
home, usr, etc, and dev. In each directory, files containing related data can be
stored. The administrator of the Linux system may place all the HOME directories
of the users under the /home directory. For example, the nazrul directory is the
HOME directory for the user, nazrul. He will store all his files in his HOME
directory, nazrul, or create new directories under it.
The directory nazrul contains two files, namely process1 and process2, and two
directories, Desktop and Templates. The Desktop directory contains two files,
namely, Default and start.
In the file system hierarchy, a file is referred to by its path name, which is made up
of the file name, preceded by the name of the directory containing the file. The path
name may have a set of directories, one directory containing another, until the '/'
directory is reached. The file name and the different directory names contained in
the path are separated by the `/ ' symbol.
For instance, in the previous figure, the full path of the file start can be given as:
/home/nazrul /Desktop/start. Similarly, the path for the file ls is /bin/ls. As you
notice, the '/' is a special character, therefore, it cannot be included in a file or
directory name.
The following are some of the directories under the / directory. Each of these
directories has been organized to store a specific type of file.
/bin : All the executable binary programs (file) required during booting, repairing,
files required to run into single-user-mode, and other important, basic
commands viz., cat, du,df, tar, rpm, wc, history, etc.
/dev : Contains device files for all the hardware devices on the machine
e.g., cdrom, cpu, etc
/etc : Contains Application’s configuration files, startup, shutdown, start,
stop script for every individual program.
/lib : The Lib directory contains kernel modules and shared library images
required to boot the system and run commands in root file system.
/home : Home directory of the users. Every time a new user is created, a directory
in the name of user is created within home directory which contains other
directories like Desktop, Downloads, Documents, etc.
/usr : Contains executable binaries, documentation, source code, libraries for
second level program.
/var : Stands for variable. The contents of this file are expected to grow. This
directory contains log, lock, spool, mail and temp files.
213
Operating System
The current working directory is the directory in which you are currently located.
Relative Path Names
You can refer to it as your current directory or your current working directory.
While referring to a file, instead of specifying the full path of the file, you can
specify the path in relation to your current directory.
Consider the following sample directory structure.
/home
Odroho is
Odroho currently
working
here.
Cricket
n
o
v
1
3
For instance, let's say that the user, Odroho, is working in the directory,
/home/Odroho. Odroho wants to access the file, nov13, under the
/home/Odroho/Cricket directory. If he accesses this file using the full path name,
Odroho would specify the path as /home/Odroho/Cricket/nov13. Alternatively,
Odroho can specify the relative path, Cricket/nov13. This is a much more
convenient way of specifying the path name.
Thus, notice that when you start the path name with a '/', Linux takes the path
name as an absolute path name or the full path name. Whenever the path name
starts with a character, it is taken as the relative path with respect to the current
working directory.
214
Linux user and file management
access the HOME directory in a convenient way. In Linux, you can specify the path
for your HOME directory with the tilde (~) sign. For instance, if Odroho wants to
access the nov13 file, he can specify the file name with the path as ~/Cricket/nov13
from anywhere in the file system.
In Linux, all information is treated as a file. So, besides a user's program files and
data files, there are also special files, such as those that contain information about
directory contents or the various input/output devices connected to the system. In
Linux, a device is also treated as a file and all the information going to, say, the
VDU (Visual Display Unit) is treated as if it were being sent to a file. In Linux, there
are three categories of files:
Ordinary files
Directory files
Special files
Ordinary files
All the files created by a user come under this category of files. These include all the
data files, program files, object files, and executable files. A user can make changes
to such files.
Directory files
Linux automatically creates a directory file when a directory is created. This file has
the same name as the directory, and contains information about the files under the
directory. For example, for the directory, /home/Odroho, there will be a directory
file called Odroho in the directory, /home, which contains information on all the
files and directories under the directory, Odroho. A directory file cannot be
modified by a user but is, instead, modified automatically by the system when a
new file or a sub-directory is added to the directory.
Special Files
Most of the system files in Linux are special files. Special files are typically
associated with input/output devices and are found in the standard Linux
directories, such as fdev and fetc. Users cannot alter special files.
215
Operating System
2.6. Exercises
a. All the files are stored on the disk under one main directory called the
(i) boot
(ii) bin
(iii) home
(iii) root
c. There are
216
Linux user and file management
File Access Permissions (FAPs) refer to the permissions associated with a file with
respect to the following:
Determining the The file owner
FAPs for a file The group owner
Other users
The following table summarizes the access permissions available for files and
directories.
Total 21
217
Operating System
The permissions are displayed in the first column from the second position
onwards.
The first three characters show the read, write, and execute permissions (in that
order) for the file owner, the next three are the permissions for the group owner,
and the last three are the permissions for other users.
If the permission is available, r, w, or x is displayed; else a hyphen is displayed.
The access permissions associated with a file or directory can be changed using the
chmod command. Only the owner of a file can change the permissions associated
with it.
Syntax
chmod mode file/s
You can specify the mode (permission for a type of user) in symbols or by using
numbers (the absolute way). The symbolic format uses letters to represent
permissions and the absolute way uses the numeric format.
Symbolic Mode
In the symbolic mode, the permission and the type of users for whom the
permission is to be granted are given in symbols.
The table below states the symbols for different permissions:
Symbol Meaning
r Read
w Write
x Execute
Symbols for Permissions
a All users
218
Linux user and file management
Here, ‘u’ indicates the file owner, ‘+’ indicates that the permission is to be given, ‘x’
indicates the execute permission, and x,c is the file name.
219
Operating System
3.4. Exercises
220