Module 04 : Linux
Module 04 : Linux
Linux
Copyright © by Technovalley Software India Pvt Ltd. All Rights Reserved. Reproduction is Strictly Prohibited.
What is Linux?
Linux is an open-source, Unix-like operating system kernel that serves as the core
component of various Linux-based operating systems. It was created by Linus Torvalds in 1991
and has since become one of the most widely used operating systems worldwide, especially in
the server and embedded systems domains.
Copyright © by Technovalley Software India Pvt Ltd. All Rights Reserved. Reproduction is Strictly Prohibited.
What is Linux? (Cont’d)
Here are some key points to understand what Linux is:
Kernel: At its core, Linux is a kernel. A kernel is the central component of an operating system
that manages hardware resources, provides essential services, and allows applications to interact
with the hardware. Linux kernel is responsible for tasks like process management, memory
management, device management, and file system management.
Open Source: Linux is distributed under open-source licenses, typically the GNU General
Public License (GPL). This means that anyone can view, modify, and distribute the source code
of the Linux kernel. This open nature encourages collaboration and has led to the development
of many Linux distributions (or "distros") that use the Linux kernel.
Copyright © by Technovalley Software India Pvt Ltd. All Rights Reserved. Reproduction is Strictly Prohibited.
What is Linux? (Cont’d)
Here are some key points to understand what Linux is (Cont’d):
Distributions (Distros): Some popular Linux distributions include Ubuntu, Debian, Fedora,
CentOS, and Arch Linux. Each distribution may have its own focus, user interface, and package
management system.
Multiplatform: The Linux kernel supports a wide range of hardware architectures, making it
adaptable for use on various devices, from servers and desktop computers to smartphones,
embedded systems, and supercomputers.
Copyright © by Technovalley Software India Pvt Ltd. All Rights Reserved. Reproduction is Strictly Prohibited.
What is Linux? (Cont’d)
Here are some key points to understand what Linux is (Cont’d):
Security and Stability: Linux is known for its security and stability. Its robust user and
permission management, along with its strong multi-user support, makes it a popular choice for
server environments. Additionally, Linux systems are less prone to viruses and malware
compared to other operating systems, due in part to its open-source nature and user privileges
model.
Command-Line Interface (CLI): Linux offers a powerful command-line interface (CLI) that
allows users to interact with the system through text-based commands. This provides a high
level of control and automation for advanced users and system administrators. Linux also
supports various graphical user interfaces (GUIs) for those who prefer a more traditional desktop
experience.
Copyright © by Technovalley Software India Pvt Ltd. All Rights Reserved. Reproduction is Strictly Prohibited.
What is Linux? (Cont’d)
Here are some key points to understand what Linux is (Cont’d):
Community and Ecosystem: Linux has a large and active user and developer community. This
community-driven development model results in continuous improvement and support. There
are forums, online resources, and documentation available for troubleshooting, learning, and
expanding your knowledge of Linux.
Customization and Flexibility: Linux is highly customizable. Users can choose from a wide
variety of software packages and configure their systems to suit their specific needs. This
flexibility is one of the reasons Linux is used in a wide range of applications.
Copyright © by Technovalley Software India Pvt Ltd. All Rights Reserved. Reproduction is Strictly Prohibited.
Linux File System
Copyright © by Technovalley Software India Pvt Ltd. All Rights Reserved. Reproduction is Strictly Prohibited.
Understanding the Linux File System
The Linux file system, like any other operating system, is responsible for organizing and
managing files and directories on a storage device (usually a hard drive or solid-state drive).
Linux file systems follow a hierarchical structure and provide a unified way to access,
create, delete, and manipulate files and directories.
The most commonly used file system on Linux is the ext4 file system, but there are several
others as well.
Copyright © by Technovalley Software India Pvt Ltd. All Rights Reserved. Reproduction is Strictly Prohibited.
Fourth Extended File System (Ext4)
Ext4, short for Fourth Extended File System, is a widely used and robust file system in the
Linux ecosystem. It is an extension of its predecessor, Ext3, and brings significant improvements
in terms of performance, scalability, and features.
Ext4 supports larger file sizes and partitions, with a maximum file size of 16 terabytes and
a maximum volume size of one exabyte. It employs techniques like delayed allocation and
extents to enhance file system efficiency and reduce fragmentation.
Ext4 also includes journal checksums for improved data integrity, ensuring a higher level
of reliability.
With its backward compatibility with Ext2 and Ext3, Ext4 seamlessly integrates into
existing Linux systems, making it a popular choice for a variety of applications, from desktops
to servers.
Copyright © by Technovalley Software India Pvt Ltd. All Rights Reserved. Reproduction is Strictly Prohibited.
Understanding the Linux File System (Cont’d)
Here are some key aspects of the Linux file system:
Folders and Files: It stores all your files and folders in a tree-like structure, starting with the
main folder represented by "/". Everything is organized within this structure.
Inodes: Each file and folder has a special card (inode) that holds details about it, like who owns
it, when it was created, and where it's stored on the computer.
Permissions: It controls who can see or change files and folders. It uses a system of read, write,
and execute permissions for different users.
Connecting Drives: You can attach external drives or network folders, and they become part of
the file system at a certain location, like a new folder.
Copyright © by Technovalley Software India Pvt Ltd. All Rights Reserved. Reproduction is Strictly Prohibited.
Understanding the Linux File System (Cont’d)
Here are some key aspects of the Linux file system (Cont’d):
Shortcuts: There are special files called shortcuts that point to other files or folders. They're like
signposts that make it easy to find things.
Rules for Organization: Linux follows a set of rules to keep everything neat and organized in
the same way across different computers. This helps software and people find things easily.
Regular Checkups: Sometimes, the file system needs a checkup to fix problems, just like
cleaning up and rearranging files in your cabinet. There are tools for that, like fsck, smartctl etc.
Storage Limits: Linux can limit how much space each person or group can use on the computer,
so one person doesn't use up everything.
Copyright © by Technovalley Software India Pvt Ltd. All Rights Reserved. Reproduction is Strictly Prohibited.
Linux File Hierarchy Structure (FHS)
Copyright © by Technovalley Software India Pvt Ltd. All Rights Reserved. Reproduction is Strictly Prohibited.
Directories
A directory is a file the solo job of which is to store the file names and the related
information. All the files, whether ordinary, special, or directory, are contained in directories.
This structure is often referred to as a directory tree. The tree has a single root node, the
slash character (/), and all other directories are contained below it.
Copyright © by Technovalley Software India Pvt Ltd. All Rights Reserved. Reproduction is Strictly Prohibited.
“/” Directory
The "/" directory, known as the root directory, serves as the starting point for the entire file
system hierarchy. All other directories and files are organized beneath it in a tree-like structure.
The "/" directory contains essential system files, configuration files, and subdirectories, playing
a central role in the organization and navigation of the Linux file system.
Copyright © by Technovalley Software India Pvt Ltd. All Rights Reserved. Reproduction is Strictly Prohibited.
“/home” Directory
The “/home” is a directory for a particular user of the system and consists of individual files..
For example: /home/botnet
Copyright © by Technovalley Software India Pvt Ltd. All Rights Reserved. Reproduction is Strictly Prohibited.
“/usr” Directory
/usr, which contains user-related data such as executables and libraries.
Copyright © by Technovalley Software India Pvt Ltd. All Rights Reserved. Reproduction is Strictly Prohibited.
“/etc” Directory
/etc directory contains configuration files for the system.
Copyright © by Technovalley Software India Pvt Ltd. All Rights Reserved. Reproduction is Strictly Prohibited.
“/root” Directory
/root directory is the home directory for the root user.
Copyright © by Technovalley Software India Pvt Ltd. All Rights Reserved. Reproduction is Strictly Prohibited.
“/opt” Directory
/opt, which is often used for installed software packages.
Copyright © by Technovalley Software India Pvt Ltd. All Rights Reserved. Reproduction is Strictly Prohibited.
“/lib” Directory
Libraries essential for the binaries in /bin/ and /sbin/.
Copyright © by Technovalley Software India Pvt Ltd. All Rights Reserved. Reproduction is Strictly Prohibited.
“/boot” Directory
The '/boot' directory contains boot loader files which are essential to boot the system.
Copyright © by Technovalley Software India Pvt Ltd. All Rights Reserved. Reproduction is Strictly Prohibited.
“/bin” Directory
The "/bin" directory in Linux contains essential binary executables (commands) that are required
for system booting and repairing, allowing basic functionality even in single-user mode.
Copyright © by Technovalley Software India Pvt Ltd. All Rights Reserved. Reproduction is Strictly Prohibited.
“/sbin” Directory
The "/sbin" directory in Linux stores system binaries (executables) that are essential for system
administration tasks and are typically meant for use by the system administrator.
Copyright © by Technovalley Software India Pvt Ltd. All Rights Reserved. Reproduction is Strictly Prohibited.
“/var” Directory
The "/var" directory in Linux holds variable data such as logs, spool files, and temporary files
that may change during the course of system operation.
Copyright © by Technovalley Software India Pvt Ltd. All Rights Reserved. Reproduction is Strictly Prohibited.
“/mnt” Directory
The "/mnt" directory in Linux is commonly used as a mount point for temporarily mounting file
systems or devices.
Copyright © by Technovalley Software India Pvt Ltd. All Rights Reserved. Reproduction is Strictly Prohibited.
“/media” Directory
The "/media" directory in Linux is typically used as a mount point for removable media such as
USB drives and optical discs.
Copyright © by Technovalley Software India Pvt Ltd. All Rights Reserved. Reproduction is Strictly Prohibited.
“/tmp” Directory
The "/tmp" directory in Linux is used for storing temporary files, providing a common location
for programs to write data that is needed only during the current session.
Copyright © by Technovalley Software India Pvt Ltd. All Rights Reserved. Reproduction is Strictly Prohibited.
“/dev” Directory
The "/dev" directory in Linux contains special device files that represent and provide access to
physical and virtual devices, enabling communication between the kernel and hardware or
software components.
Copyright © by Technovalley Software India Pvt Ltd. All Rights Reserved. Reproduction is Strictly Prohibited.
Linux Command Line Interface (CLI)
Copyright © by Technovalley Software India Pvt Ltd. All Rights Reserved. Reproduction is Strictly Prohibited.
What is Linux Command Line Interface (CLI) ?
The Linux Command Line Interface (CLI) is a text-based interface that allows users to
interact with the operating system by entering commands.
Unlike graphical user interfaces (GUIs), which rely on visual elements and mouse
interactions, the CLI operates solely through text commands.
The power of the Linux CLI lies in its efficiency, flexibility, and scripting capabilities.
Users can perform a wide range of tasks, from navigating the file system and managing files to
configuring system settings and running complex scripts.
Copyright © by Technovalley Software India Pvt Ltd. All Rights Reserved. Reproduction is Strictly Prohibited.
Directory Commands
Directory commands in Linux facilitate tasks like creating, listing, navigating, moving, copying,
and removing directories using commands such as mkdir, ls, pwd, cd, mv, cp, and rmdir.
Command Description Example
Copyright © by Technovalley Software India Pvt Ltd. All Rights Reserved. Reproduction is Strictly Prohibited.
Directory Commands (Cont'd)
Copyright © by Technovalley Software India Pvt Ltd. All Rights Reserved. Reproduction is Strictly Prohibited.
File Commands
File commands in Linux, including touch, cat, cp, mv, rm, and more, enable tasks like creating,
viewing, copying, moving, and deleting files from the command line.
Command Description Example
Copyright © by Technovalley Software India Pvt Ltd. All Rights Reserved. Reproduction is Strictly Prohibited.
File Commands (Cont’d)
Copyright © by Technovalley Software India Pvt Ltd. All Rights Reserved. Reproduction is Strictly Prohibited.
Permission Management
Copyright © by Technovalley Software India Pvt Ltd. All Rights Reserved. Reproduction is Strictly Prohibited.
About Permission Management
In Linux, every file has an owner (a user) and a group, determining who can access or
modify it. Permissions are set for the owner, group, and others, controlling read, write, and
execute rights. This structure enhances security by regulating file access based on user roles and
permissions.
Users Description
Owner permissions Control access rights for the user who owns the
file.
Other (world) permissions Determine access privileges for users who are
neither the owner nor in the group of the file.
Copyright © by Technovalley Software India Pvt Ltd. All Rights Reserved. Reproduction is Strictly Prohibited.
Permission Indicators in Linux
While using ls -l command, it displays various information related to file permission as follows
┌──(botnet㉿shelter)-[~]
└─$ ls -l
drwxr-xr-x 2 botnet botnet 4096 Nov 10 15:56 technovalley
-rw-r--r-- 1 botnet botnet 0 Nov 10 15:55 technovalley.txt
● Read (r): Users can view the content of the file or directory.
● Write (w): Users can modify or delete the file, or create new files in a directory.
● Execute (x): For files, this allows users to run the file as a program. For directories, it
enables access and listing of contents.
Copyright © by Technovalley Software India Pvt Ltd. All Rights Reserved. Reproduction is Strictly Prohibited.
Size
Group Name
Group Permission
User Permission
Type
Copyright © by Technovalley Software India Pvt Ltd. All Rights Reserved. Reproduction is Strictly Prohibited.
Change file permissions in Linux
You can use chmod command for changing the permissions on a file in Linux.
Permissions used to be called mode of access and hence chmod was the short form of change the
mode of access.
Copyright © by Technovalley Software India Pvt Ltd. All Rights Reserved. Reproduction is Strictly Prohibited.
Absolute Mode
In the absolute mode, permissions are represented in numeric form (octal system to be precise).
In this system, each file permission is represented by a number.
r (read) = 4
w (write) = 2
x (execute) = 1
– (no permission) = 0
With these numeric values, you can combine them and thus one number can be used to represent
the entire permission set.
Copyright © by Technovalley Software India Pvt Ltd. All Rights Reserved. Reproduction is Strictly Prohibited.
Absolute Mode (Cont’d)
Number Permission
0 ---
1 --x
2 -w-
4 r--
Copyright © by Technovalley Software India Pvt Ltd. All Rights Reserved. Reproduction is Strictly Prohibited.
Absolute Mode (Cont’d)
For Example:
Suppose you want to change the file permission on technovalley.txt so that everyone can read
and write but no one can execute it?
┌──(botnet㉿shelter)-[~]
└─$ chmod 666 technovalley.txt
-rw-rw-rw- 1 botnet botnet 0 Nov 10 15:55 technovalley.txt
Copyright © by Technovalley Software India Pvt Ltd. All Rights Reserved. Reproduction is Strictly Prohibited.
Symbolic Mode
The problem with the absolute mode is that you should always provide three numbers for all the
three owners even if you want to change the permission set for just one owner.
This is where you can use the symbolic mode with chmod command.
In symbolic mode, owners are denoted with the following symbols:
u = User Owner
g = Group Owner
o = Other
a = All (User + Group + Other)
Copyright © by Technovalley Software India Pvt Ltd. All Rights Reserved. Reproduction is Strictly Prohibited.
Symbolic Mode (Cont’d)
The symbolic mode uses mathematical operators to perform the permission changes:
Operator Permission
Copyright © by Technovalley Software India Pvt Ltd. All Rights Reserved. Reproduction is Strictly Prohibited.
Symbolic Mode (Cont’d)
For Example:
If you want to add execute permission for group owner, you can use chmod command like this:
┌──(botnet㉿shelter)-[~]
└─$ chmod g+x technovalley.txt
-rw-rwx-rw- 1 botnet botnet 0 Nov 10 15:55 technovalley.txt
Copyright © by Technovalley Software India Pvt Ltd. All Rights Reserved. Reproduction is Strictly Prohibited.
User Management
Copyright © by Technovalley Software India Pvt Ltd. All Rights Reserved. Reproduction is Strictly Prohibited.
Create an Accounts
The most basic task is to create an account to represent the user who will be working on the
system.
Each user must authenticate to Linux with an identity that can be used to control their
resource access and consumption.
User accounts are stored in the /etc/passwd file. That file should not be edited directly by
tools such as nano, gedit, vim.
/etc/shadow is a text file that contains information about the system’s users’ passwords.
There is adduser command to create new user account.
Copyright © by Technovalley Software India Pvt Ltd. All Rights Reserved. Reproduction is Strictly Prohibited.
Create an Accounts (Cont’d)
Copyright © by Technovalley Software India Pvt Ltd. All Rights Reserved. Reproduction is Strictly Prohibited.
Update Password and Remove Account
Copyright © by Technovalley Software India Pvt Ltd. All Rights Reserved. Reproduction is Strictly Prohibited.
Modify User Account Settings
The usermod command in Linux is used to modify user account properties. It allows you to
change settings such as the user's username, home directory, shell, and more.
For Example: To grant sudo privileges to the user "technovalley" using the usermod command
Copyright © by Technovalley Software India Pvt Ltd. All Rights Reserved. Reproduction is Strictly Prohibited.
Package Management
Copyright © by Technovalley Software India Pvt Ltd. All Rights Reserved. Reproduction is Strictly Prohibited.
Linux Repository
A Linux repository, short for software repository, is a centralized storage location where
software packages are stored, managed, and made available for distribution to Linux-based
operating systems.
These repositories play a crucial role in the Linux ecosystem, providing a convenient and
secure way for users to discover, install, and update software applications.
They contain a vast array of packages, including system utilities, libraries, and applications,
ensuring users have access to a diverse and well-maintained selection of software.
Package managers, such as APT (Advanced Package Tool) for Debian-based systems and
YUM (Yellowdog Updater, Modified) for Red Hat-based systems, interact with these
repositories, simplifying the process of software installation and maintenance.
Copyright © by Technovalley Software India Pvt Ltd. All Rights Reserved. Reproduction is Strictly Prohibited.
Package Management Commands
apt-get : apt-get is a command-line package management tool in Debian and Ubuntu-based
Linux distributions, used for installing, updating, and removing software packages.
Copyright © by Technovalley Software India Pvt Ltd. All Rights Reserved. Reproduction is Strictly Prohibited.
Summary
In this module, we explored the history of Linux, its distinctive features, and the diverse
landscape of Linux distributions.
We delved into the file system hierarchy, unraveling the significance of various directories
in Linux.
The module comprehensively covered fundamental Linux commands, providing insights
into file manipulation, user management, and efficient package management.
From the evolution of Linux to its core functionalities, including an in-depth understanding
of file structures and essential commands, the module aimed to equip learners with a robust
foundation in Linux operating systems.
Copyright © by Technovalley Software India Pvt Ltd. All Rights Reserved. Reproduction is Strictly Prohibited.