The Basics of Linux
The Basics of Linux
Zubair Sangi
Mehran University
Agenda
• What is Linux?
• History of Linux
• Linux Architecture
• File System Hierarchy
• Basic Linux Commands
• Users and Permissions
• Package Management
• Conclusion
What is Linux?
• Definition: Linux is an open-source, Unix-like operating system kernel
first created by Linus Torvalds in 1991.
• Key Features:
• Open Source
• Multiuser and Multitasking
• Security and Stability
Key features of Linux
1. Open Source:
• Definition: Linux is distributed under an open-source license, which
means that its source code is freely available to the public.
• Significance: Users can view, modify, and distribute the source code.
This fosters a collaborative development model, allowing a global
community of developers to contribute to its improvement.
Key features of Linux
Windows: Windows has improved its security measures over the years,
with features like User Account Control (UAC) and BitLocker encryption.
However, historically, Windows has been a more prominent target for
malware due to its widespread use. In terms of stability, Linux servers
are often praised for their uptime, while Windows has made strides in
this area with each new version.
Key features of Linux
Windows: Windows has improved its security measures over the years,
with features like User Account Control (UAC) and BitLocker encryption.
However, historically, Windows has been a more prominent target for
malware due to its widespread use. In terms of stability, Linux servers
are often praised for their uptime, while Windows has made strides in
this area with each new version.
History of Linux
• Timeline:
• 1991: Linus Torvalds releases the first Linux kernel.
• 1992: First official release of the Linux kernel.
• 1994: Formation of the Linux development community.
• Today: Linux is a dominant force in server environments, embedded
systems, and more.
History of Linux
Impact on computing:
• Server Environments:
• Linux is widely used in server environments due to its stability, security, and
performance.
• Many internet servers, including those powering major websites, run on
Linux-based systems (e.g., Google, Facebook, AWS, Netflix, Wordpress).
History of Linux
Impact on computing:
• Embedded Systems:
• Linux serves as the foundation for many embedded systems, including those
in smartphones, routers, smart TVs, and IoT devices (e.g., Android OS,
Rasberry Pi, Router Firmware, many IOT devices, etc).
• Its adaptability and scalability make it suitable for a wide range of
applications.
History of Linux
Impact on computing:
• Cloud Computing:
• Linux is a common choice for cloud computing infrastructure.
• Leading cloud service providers often use Linux-based systems to deliver
scalable and reliable services.
Linux Architecture
• Monolithic Kernel:
• The Linux kernel is monolithic, meaning it contains all core functions.
• Hardware Abstraction Layer:
• Provides a bridge between hardware and the kernel.
• System Libraries:
• Essential libraries for system functionality.
File System hierarchy
• /bin: Essential user command binaries
• /etc: Configuration files
• /home: User home directories
• /var: Variable files (logs, spool files, etc.)
• /usr: User programs and files
• /tmp: Temporary files
• /dev: Device files
• /proc: Process information
File System hierarchy
/bin (Binary):
The /home directory contains user home directories. Each user typically
has a subdirectory within /home where their personal files and settings
are stored.
File System hierarchy
/var (Variable):
The /usr directory houses user-related programs and data, including the
majority of the system's executables, libraries, documentation, and
source code. It is one of the largest directories in a Linux file system.
File System hierarchy
/tmp (Temporary):
The /dev directory contains device files, which represent and interface
with devices connected to the system. These files allow applications to
communicate with hardware devices.
File System hierarchy
/proc (Process):
1. To create a file
cat > filename
• Files created with cat command cannot be edited
• Files can be override
• (ctrl+d) getting out of edit mode
Basic Linux Commands
cat command:
tac f1
• It reverses the content from bottom to top.
• It works on multiple lines not on single line
Basic Linux Commands
cat command:
touch f1 f2 f3 f4 f5 f6
Basic Linux Commands
Vi/vim command:
vi f1
Basic Linux Commands
nano command:
nano f1
Basic Linux Commands
Nano Vs vi/vim:
history
Basic Linux Commands
Directories:
mkdir:
• To create a directory
mkdir mydir
Basic Linux Commands
Nested Directories:
mkdir -p mydir/dir1/dir2/dir3/dir4
cd ../../../../../..
Basic Linux Commands
Multiple Directories:
mkdir .dir1
Basic Linux Commands
Removing Directories:
1. Empty directory
rmdir dir1
2. Directory with content
rm –r dir1
Basic Linux Commands
Cut paste operation:
mv file1 dir1
• mv f1 f2 (when source and destination are files then shell will ask
permission for overwriting in destined file)
• mv f1 f2 (f2 is new file, work as a rename operation)
Basic Linux Commands
Rename operation:
mv file1 file2
mv dir1 dir2
Basic Linux Commands
Copy paste operation:
cp file1 file2
Basic Linux Commands
less, head, tail
less filelines50
head filelines50
tail filesline50
Basic Linux Commands
hostname:
hostname
o/p
ip-172-31-47-225.ap-south-1.compute.internal
Basic Linux Commands
ifconfig:
cat /etc/os-release
tree:
whoami:
o/p root
Basic Linux Commands
echo:
Group
Others
Symbolic
link
r=4
w=2
x=1
Access modes/permissions
Two methods to change the permissions:
Decimal method:
u = user/owner operators
g = group =+-
o = other
Access modes/permissions
Two methods to change the permissions:
r-- — u=r
rwx — g=wrx
-wx — o=wx
chmod u=r, g=rwx, o=wx file1
chmod u-wx, g+w, o=wx file1
Package Management
• Package Managers:
• Examples: apt, yum, pacman
• Installing Software:
• Use package manager commands to install, update, or remove software.
Conclusion
Recap of Key Points:
• Linux is open source, multiuser, and stable.
• Understanding the file system hierarchy is crucial.
• Basic commands are fundamental for navigating and managing files.
• Users, groups, and permissions control access.
• Package management simplifies software installation.
Q&A