Chapter 1
Chapter 1
Chapter 1
Cont’d
limited. Some hardware could not have available.
drivers built-in.
File System It uses the Unix File System (UFS), which It makes use of the New
includes the STD.ERR and STD.IO file Technology File System (NTFS)
systems. and the File Allocation System
(FAT32).
Reliability Unix and its distributions are well known for Although Windows has become
their high level of stability. more stable in recent years, it still
falls short of the reliability offered
by Unix systems.
Data Backup Creating a backup and recovery system in It contains a built-in backup and
and UNIX is time-consuming, but it is becoming recovery system that makes it
Recovery easier with the release of new Unix more user-friendly.
Linux Distributions and UIs
Linux distro, is an operating system compiled from
components developed by various open source project and
programmers.
Each distribution includes
● The Linux kernel (the foundation of the operating system),
● The GNU shell utilities (the terminal interface and commands),
●
The X server (for a graphical desktop),
●
The desktop environment,
●
a package management system,
● an installer and other
services.
Cont’d
There are commercially backed distributions, such as
◆
Fedora (Red Hat),
◆ openSUSE (SUSE) and
◆
Ubuntu (Canonical Ltd.),
And entirely community-driven distributions, such as
◆
Debian,
◆ Slackware,
◆
Gentoo and Arch Linux.
Cont’d
Linux GUI (Graphical User Interface) is defined as a
utility or feature which supports an interface for users and
allows users to interact with the system and takes help
from windows, icons, graphics, etc., and responds to the
●
The term file system takes its name from the
old paper-based data management systems,
where we kept documents as files and put them
into directories.
File system Hierarchy and Standard
Why do we need a file system in the first place?
File system Hierarchy and Standard
● is a method and data structure that the operating system uses to
control how data is stored and retrieved.
● A file system defines how files are named, stored, and retrieved
from a storage device.
● each group of data is called a file.
● The structure and logic rules used to name the groups of data and
their names is called a file system.
● FHS defines the directory structure and directory contents in Linux
distributions.
● the files on a Linux system are arranged in a hierarchical directory
structure.
Cont’d
●
they are organized in a tree-like pattern of directories (called
folders in other systems), which may contain files and
subdirectories.
●
The first directory in the file system is called the root directory.
●
The root directory contains files and subdirectories, which contain
more files and subdirectories and so on.
●
In Linux and many other operating systems, directories can be
structured in a tree-like hierarchy.
●
In the FHS, all files and directories appear under the root directory
“/”, even if they are stored on different physical or virtual devices.
Linux File system Hierarchy
/
(root)
bin sbin home etc boot root usr var dev lib
/boot Contains the static bootloader and kernel executable and configuration files required to boot
a Linux computer.
/dev This directory contains the device files for every hardware device attached to the system.
/etc Contains the local system configuration files for the host computer.
Home directory storage for user files. Each user has a subdirectory in /home.
/home
/lib Contains shared library files that are required to boot the system.
/media A place to mount external removable media devices such as USB thumb drives that may be
connected to the host.
/mnt A temporary mount-point for regular filesystems (as in not removable media) that can be
used while the administrator is repairing or working on a filesystem.
/root This is not the root (/) filesystem. It is the home directory for the root user.
Architecture of file
systems
A file system installed on an operating system
consists of three layers:
●
Physical file system
●
Virtual file system
●
Logical file system
Cont’d
Physical file system -
●
It's responsible for data storage and retrieval and space management on
the storage device (or precisely: partitions).
●
The physical file system interacts with the storage hardware via device
drivers.
The virtual file system -
●
provides a consistent view of various file systems mounted on the
same operating system.
●
It's common for a removable storage medium to have a different file
system than that of a computer.
●
A VFS defines a contract that all physical file systems must implement to
be supported by that operating system.
Cont’d
●
The logical file system is the user-facing part of
a file system, which provides an API to enable
user programs to perform various file operations,
such as OPEN, READ, and WRITE, without
having to deal with any storage hardware.
● On the other hand, VFS provides a bridge
between the logical layer (which programs
interact with) and a set of the physical layer of
various file systems.
Cont’d
Single-rooted hierarchy
◆
Files are organized by storing related files in the same
directory.
◆
In a hierarchical file system a directory contained inside
another directory is called a subdirectory.
◆
The top-most directory in such a file system, which does
not have a parent of its own, is called the root directory.
◆
Linux uses single rooted, inverted tree like File System
Hierarchy.
Mounting File System
◆
The Linux root filesystem is mounted on the root directory
(/) very early in the boot sequence.
◆ The act of assigning a directory to a storage device
(under the root directory tree) is called mounting, and the
assigned directory is called a mount point.
◆ For instance, on Linux, the mounting points for a
removable device (such as a memory card), are usually
under the /media directory.
◆
Use mount command
Files metadata
File metadata is a data structure that contains data about a file,
such as:
➔
File size
➔
Timestamps, like creation date, last accessed date, and
modification date
➔ The file's owner
➔ The file's mode (who can do what with the file)
➔ What blocks on the partition are allocated to the file
➔ and a lot more
Cont’d
●
Metadata isn’t stored with the file content, though. Instead, it’s
stored in a different place on the disk - but associated with the
file.
●
In Unix-like systems, the metadata is in the form of data
structures, called inode.
●
An inode is a data structure that keeps track of all the files and
directories within a Linux or UNIX-based filesystem.
●
Inodes are identified by a unique number called the inode
number.
●
Inodes are associated with files in a table called inode tables.
Unix File and Directory Permissions
●
Most file systems include attributes of files and directories that
control the ability of users to
– read
– Change
– navigate and
– execute the contents of the file system.
● Two types of permissions are widely available: traditional Unix file
system permissions and access control lists (ACLs) which are
capable of more specific control.
Cont’d
Unix-like systems implement three specific
permissions that apply to each class:
– The read permission grants the ability to read a file.
– The write permission grants the ability to modify a file.
– The execute permission grants the ability to execute a
file. This permission must be set for executable
programs, in order to allow the operating system to run
them.
Essential Shell Commands
The shell is a program that takes commands from the keyboard
and gives them to the operating system to perform.
– On most Linux systems a program called bash acts as the shell
program.
– Besides bash, there are other shell programs available for Linux
systems. ksh, tcsh and zsh.
What's a Terminal?
– It's a program called a terminal emulator.
– This is a program that opens a window and lets you interact with the
shell.
– There are a bunch of different terminal emulators we can use.
– These might include gnome-terminal, konsole, xterm, rxvt, kvt, nxterm,
and eterm.
Basic File Manipulation Commands
Manipulating Files:
– cp - copy files and directories
– mv - move or rename files and directories
– rm - remove files and directories
– mkdir - create directories
●
They are the basic commands for manipulating both
files and directories.
Cont’d
Wildcards
– is a shell feature that makes these commands so
powerful.
– Since the shell uses filenames so much, it provides
special characters to help you rapidly specify groups
of filenames.
– These special characters are called wildcards.
– Wildcards allow you to select filenames based on
patterns of characters.
e.g ls -l # to display all the contents in the
system.
Navigation
● We will introduce our first three commands:
● pwd (print working directory),
● cd (change directory) and
●
ls (list files and directories).
Cont’d
pwd
– Since the command line interface cannot provide graphic
pictures of the file system structure, we must have a
different way of representing it.
– The directory we are standing in is called the working
directory.
– To see the name of the working directory, we use the pwd
command.
Cont’d
● When we first log on to our Linux
system, the working directory is set to
our home directory.
●
This is where we put our files.
● On most systems, the home directory
will be called
/home/user_name.
● To list the files in the working directory,
we use the ls
command.
Cont’d
cd
●
To change the working directory we use the cd
command.
●
To do this, we type cd followed by the pathname of the
desired working directory.
●
A pathname is the route we take along the branches of
the tree to get to the directory we want.
●
Pathnames can be specified two different ways;
absolute pathnames or relative pathnames.
Advanced File Manipulation
Commands
Init
●
init is parent of all Linux processes with PID.
●
It is the first process to start when a computer boots
up and runs until the system shuts down.
● In simple words the role of init is to create processes
from script stored in the file /etc/inittab which is a
configuration file to be used by initialization system.
● It is the last step of the kernel boot sequence.
Cont’d
Processes
●
A process in Linux a program in execution.
●
It’s a running instance of a program.
●
Any command that you execute starts a process.
●
In Linux processes can be of two types:
➔ Foreground Processes - depend on the user for input. Also
referred to as interactive processes.
➔
Background Processes - run independently of the user.
Referred to as non-interactive or automatic processes.
●
There are two commands available in Linux to track running
processes.
➔
Top and Ps.
Cont’d
Cont’d
ps command
●
ps command is short for Process Status
●
It displays the currently-running processes.
●
However, unlike the top command, the output
generated is not in real time.
cont’d
Stop a process
● To stop a process in Linux, use the kill command.
● kill command sends a signal to the process.
●
There are different types of signals that you can send.
However, the most common one is ‘kill -9’ which is
SIGKILL.
● You can list all the signals using kill -L command.
Count’d
Threads
●
In the modern operating systems, threads serve as a popular
programming abstraction.
●
These threads share resources like open files, space, and memory
addresses
●
It avoids the inter-process communication channels and reduces forking
overhead.
●
As a result, threads perform a concurrent execution mechanism.
●
A thread provides everything needed for code execution, including
CPU flags, timers, counters, a stack, and more.
● In Linux, threads are also known as LWP or Lightweight Processes.
●
Show Threads Using PS Command (ps -eLf) in Linux
End