Linux
Linux
• Introduction to Linux
• File permissions
• VI editor
• Expression pattern
• Process Management
• Cron Jobs
• The Linux Kernel is like the brain of the operating system because it manages how the
computer interacts with its hardware and resources.
• The Linux Kernel is combined with a collection of software packages and utilities, which
are together called Linux distributions. ( Ubuntu,Debian,openSUSE etc)
• These distributions make the Linux Operating System ready for users to run their
applications and perform tasks on their computers securely and effectively.
Linux
Kernel : is the core of the Linux based
OS. Different types of the kernel are:
Monolithic Kernel, Hybrid Kernels ,
Exo Kernels , Micro Kernels.
Advantages of Linux
Linux is an open-source operating system.
Linux is more secure than any other OS.
It maintains the privacy of the user.
It is fast and easy to install from the web.
The software updates in Linux are easy and frequent.
Linux is a multi-programming, multi-user operating system, it means the same system
can be used by different users with different access rights and simultaneously many
applications can be run on it.
Linux can work on different types of hardware, so Linux is portable.
Differences between Linux and Windows
LINUX WI N D OWS
• Linux is an open source OS. • Windows are not open source OS.
• Linux provides more security than • It provides less security than Linux.
windows.
• Administrator user has all
• Root user is the super user and has all administrative privileges of computers.
the administrative privileges.
• While there is back slash is used for
• There is forward slash is used for Separating the directories.
Separating the directories.
Linux File System
• The Linux file system organizes data and files on a storage device, providing a
structured way to manage information.
• The Linux File Hierarchy Structure or the Filesystem Hierarchy Standard (FHS) defines
the directory structure and directory contents in Unix-like operating systems.
The /boot directory in a Linux file system contains the files needed to start the boot process of
the operating system.
Linux Directory Structure
In Linux/Unix operating system everything is a file even directories are files, files are files, and
devices like mouse, keyboard, printer, etc are also files.
We know that in a Windows-like operating system, files are stored in different folders on
different data drives like C: D: E: whereas in the Linux/Unix operating system files are stored
in a tree-like structure starting with the root directory.
Basic File Commands
• ls (lists the files and directories in the working directory)
• wc, word count ( prints the count of each word, lines etc )
Syntax : : wc filename
number_of_lines number_of_words number_of_characters filename
(wc -l fname ) (wc -w fname) (wc -c fname)
ls -l
1st character :: File type -- - (normal file),d (directory file),s (socket file), l (link file)
2nd character :: File permissions – read , write , execute for user(root), group ,
others
• Users (u) :: the user permissions apply only to the owner of the file or directory , they will
not impact the actions of other users.
• Group (g) :: the group permissions apply only to the group that has been assigned to the
file or directory , they will not affect the actions of other users.
• Others (o) :: the other permissions apply to all other users on the system.
• All (a) :: all three permissions ( owner , groups , others)
type :wq and hit enter ( w for saving the file , q to quit the file )
Command Mode
Insert Mode
Escape Mode
Regular Expressions
• Regular expressions are special characters or set of characters that help us to search
for data and match the complex pattern.
GREP ( Global Regular
Expression Print )
It is a powerful tool used for searching and manipulating text patterns
within files.
It’s a command-line utility in Unix and Unix-like operating systems used
for searching within files for lines that match a regular expression and
printing them to the standard output.
Though most common use of SED command in UNIX is for substitution or for find and
replace. Syntax :: sed options [script] [inputfile]
Listing running processes :: to check the running processes , run the command ps
( process status ) or ps –f ( displays detailed info )
UID : USER ID that this process belongs to ( the person who is running it )
PID : process ID
PPID : parent process ID
C : CPU utilization of process
STIME : process start time
TTY : terminal type associated with the process
TIME : CPU time taken by the process
CMD : the command that started this process
TTY : Teletypewriter originally and also means any terminal on Linux/Unix systems.
PTS : stands for the pseudo-terminal slave
PARENT AND CHILD PROCESSES ::
processes are organized in a hierarchical manner where each process, except for the very first
process called the "init" process, has a parent process.
When a process creates another process, the one that initiated the creation becomes the parent,
and the new process becomes its child.
For example, imagine you start a terminal session. The terminal process becomes the parent
process.
Now, if you run a command within that terminal, say, open a text editor, the text editor process
becomes a child process of the terminal.
If you then decide to run another command, say, a file compression tool from within the text
editor, that compression tool process becomes a child process of the text editor process and a grandchild
process of the terminal.
ZOMBIE AND ORPHAN PROCESSES :: A zombie process is a terminated process that has
completed its execution, but its entry still remains in the process table because its parent
process hasn't yet read its exit status.
Essentially, it's a dead process that is waiting for its parent process to
acknowledge its termination and retrieve its exit status.
An orphan process is a process whose parent has terminated or finished while
the child process is still running.
When the parent process ends before the child, the orphaned child process
gets re-parented to the init process (PID 1), which becomes its new parent.
DAEMON PROCESSES :: a daemon is a process that runs in the background, usually waiting
for something to happen that it is capable of working with.
For example, a printer daemon waiting for print commands.
Cron Jobs
A cron job is a task created using cron , a tool for scheduling and
automating future tasks on Unix-like operating systems.
With cron jobs, system administrators can automate maintenance
, disk space monitoring , and backups at regular intervals.
They are also useful for web developers as they can set up
simultaneous cron jobs at different intervals to back up a site ,
check for broken links , and clear its cache.
Each cron job is stored in a cron table or “crontab” . The files
themselves are usually stored in a directory like
/var/spool/cron/crontabs , with one file per user , named after
their username.
• Structure of a Cron expression
* * * * * command – to – execute
- - - - -
Day of the week (0-7) (Sunday =0 or 7)
Hour (0-23)
Minute (0-59)