Operating Systems in Practice: Linux Overview
Operating Systems in Practice: Linux Overview
Operating
Systems in
Practice
Karl O’Connell
Linux Overview
Logging On
Ordinary user: limited in what he / she can do. Usually has permission
to read (view files), write (create & save files) and execute (run
executables) in his /her home directory. Users usually have permission
to run certain commands but would not have access to parts of the
system.
home directory: where the user can store his / her files
passwd – has an entry for each user. It contains information about each
user such as user id, home directory, etc.
karl:x:1000:1000:Karl OConnell,,,:/home/karl:/bin/bash
joe:x:1001:1001:joe,,,:/home/joe:/bin/bash
tony:x:1002:1002:tony,,,:/home/tony:/bin/bash
kate:x:1003:1005::/home/kate:/bin/bash
The numbers represent the user & group ids (uid + gid)
The x indicates that the encrypted password is contained in the shadow file.
tony:$6$AS36G$VPhHTlmCN.S8LnP3z.ZWeegJUrFrIcCzQ7IFbfDGmYgxe1/5JnjNN7KB
WRAzS/9HYw/h697DC6XvdT14dctO1.:17423:0:99999:7:::
kate:!:17423:0:99999:7:::
The string (after the user name) is the encryption of the user’s password.
groupZ:x:1003:tony,joe
10
11
12
Linux Commands
ls lists files in current directory
su switches user
cp copy a file
Linux Documentation
There is a wealth of documentation available. Obviously one can
search the Internet using any search engine.
For example, if you require information about the ls command (lists files
in current directory), enter the following:
man ls
14
info ls
16
Linux Directories
Linux directories (or folders) are containers that
may contain sub-directories and files.
Alternatively
tree –L 1
21
tree –d | less
(space to scroll, q to exit)
Install tree
22
Absolute PATH
The absolute (or full) path is given using the / symbol
(which donates the top of the tree).
23
24
Home Directory
When a user logs on, he / she generally has a home directory.
Here the user can store his / her own files including sub-directories and
their contents.
It is usually the default login directory i.e. where a user goes after
logging in.
25
Files
A file is a collection of data items stored on disk. What ever you store in a
computer - it must be a file. Files are associated with devices like hard disk,
etc. Every file has a location i.e. an absolute path.
The command ls –l (long listing) displays the different properties of files in the
current directory. There are different types of files such as:
Regular (ordinary): this is the most common type of file. It’s identified by the –
at the beginning of the permission string.
Example:
-rw-r--r-- 1 joe joe 16 Jan 31 13:56 myFile
28
Types of File
Directory: in a typical system about 10% of files are directories. It’s
identified by the d at the beginning of the permission string.
Example:
drwxr-xr-x 2 joe groupX 4096 Jan 31 13:57 newDir
Symbolic (soft) link: this is a short cut to an other file. It’s identified by
the l at the beginning of the permission string.
29
File Attributes
Every file has a number of properties (attributes). Some of these can be seen when
entering ls –l
The first item is the permission string (-rw-r--r-- ). This is followed by the number of hard
links (1), owner (joe), the group (groupX), the size in bytes (16), date (Jan 31), time
(13:56) and file name (myFile).
More information can be displayed e.g. ls –i displays the information node (i-node)
number; ls –s displays the number of blocks required to store the file. Try man ls.
There are many commands used with files such as cat, rm, touch, cp, etc.
30
File Permissions
Consider the following.
• The permissions are read r, write w and execute x. The first three are user
permissions; the next three are for the group the final three are for others.
• The above file temp can be read and written to by the owner, read by
members of the group staff and read by all users. The above permissions
are the usual default permissions when a file is created. Permissions can be
changed by the owner or by the root user.
31
joe can read (view file contents), write (make & save changes) and myFile (if it’s a program or a script)
the file myFile
32
Directory Permissions
Directories also have permissions but have slightly different meanings.
Example
joe owns this directory and can change any of its nine permissions
joe can see directory contents and add or remove files to / from it.
Members of groupY can see directory contents (& copy them) but can not add
or remove contents.
Editors
Although strictly not part of the operating system, all Linux systems
come with at least one editor.
There are many types of editors available both GUI (gedit) or command
line (nano)
The vi editor used to be the standard UNIX editor and is still included in
all distributions.
34
Editors (cont.)
gedit runs in a GUI environment.
35
gedit Editor
36
Editors (cont.)
Nano has a command line interface.
37
nano Editor
38