Linux Operating System
Module 3
Linux Operating System
• Linux is a Unix-like, open source and community-developed operating
system (OS) for computers, servers, mainframes, mobile devices and
embedded devices.
• It is supported on almost every major computer platform, including
x86, ARM and SPARC, making it one of the most widely supported
operating systems.
Features of the Linux Operating System
• Open-source: Linux is free and its source code is available for anyone
to view, modify, and distribute.
• Multitasking: It can handle multiple processes at the same time
without affecting system performance.
• Security: Offers strong user-based authentication, data encryption,
and security policies.
• Portability: Runs on a variety of hardware, from PCs to servers and
mobile devices.
• Customizable: Users can modify the system according to their
requirements, from the kernel to the desktop environment.
Use of Linux Operating System
• Free and Open Source: No licensing fees and customizable to suit user
needs.
• Security: Linux is less vulnerable to malware and viruses compared to
other operating systems.
• Performance: Linux runs efficiently on both old and modern
hardware, offering faster performance and lower resource usage.
• Community Support: A large, active community of developers
provides support, documentation, and troubleshooting help.
• Stability: Known for its long-term reliability, Linux servers often run
without requiring a restart for months or years.
Directories in Linux
• /home: Stores personal files for each user.
• /bin: Contains essential user command binaries, like ls, cp, and mv.
• /etc: Holds configuration files and scripts for system-wide settings.
• /var: Stores variable data such as logs, databases, and email queues.
• /tmp: A temporary directory where programs store temporary files,
often cleaned at reboot.
Linux Kernel, Shell
• Linux Kernel: The core of the OS, responsible for managing hardware,
processes, and system resources.
• Shell: A command-line interpreter that allows users to interact with
the system by executing commands. The shell acts as a bridge
between the user and the kernel.
• Applications: User programs or software that run on top of the kernel,
such as web browsers, text editors, and office suites.
Types of Shells
• Bash (Bourne Again Shell): The most common and widely used shell
with scripting capabilities.
• Zsh (Z Shell): An extended shell with features like spell checking and
plugin support.
• Ksh (Korn Shell): Known for its scripting features, commonly used in
Unix environments.
• Tcsh (TENEX C Shell): An enhanced version of the C shell (csh), with
command-line editing and scripting features.
• Fish (Friendly Interactive Shell): A user-friendly shell with
autosuggestions and syntax highlighting.
Types of Files Used by the Linux File System
• Regular Files: These include text files, images, executable programs,
etc. Regular files can be either readable, writable, or executable.
• Directory Files: These are special files that store lists of other files and
subdirectories. They help organize the filesystem in a hierarchical
structure.
• Special Files: These include device files (located in /dev) and are used
to represent hardware like disk drives, printers, and terminals. Special
files include:
• Block devices (e.g., hard drives)
• Character devices (e.g., terminals)
Meta Characters
• Meta characters are special characters used in the shell to perform
tasks like wildcard matching, redirection, and controlling
output/input.
Meta Characters
• Examples:
• *: Matches any number of characters in a filename.
• ls *.txt lists all .txt files in the directory.
• ?: Matches exactly one character.
• ls file?.txt lists files like [Link], [Link], etc.
• |: Pipe operator, passes output of one command as input to another.
• ls | grep file lists files containing the word "file".
• >: Redirects output to a file.
• echo "Hello" > [Link] writes "Hello" to [Link].
• &: Runs a command in the background.
• firefox & runs Firefox in the background.
Directory-Related Commands in Linux
Standard Linux Streams
Changing File Permissions Using Octal
Notation in Linux
File Permissions in Linux System
• Read (r): Allows a user to view the contents of a file or directory.
• Write (w): Allows a user to modify or delete a file or create and delete
files within a directory.
• Execute (x): Allows a user to run an executable file or enter a
directory.
User, Group, and Others in Linux File
Permissions
• User (u): Refers to the owner of the file or directory. The owner has specific
permissions (read, write, execute) to access and modify the file or
directory.
• Example: A file owned by user alex might allow only Alex to edit it.
• Group (g): A group can include multiple users. Permissions assigned to a
group allow members of that group to access or modify the file or directory
according to the specified permissions.
• Example: A file can be shared among developers with group write access.
• Others (o): Refers to all other users who are neither the file's owner nor
part of the group. The "others" category determines what the rest of the
users on the system can do with the file.
• Example: A file may be read-only for everyone except the owner and group.
Redirection Operators in Linux
Parent, Child, and Daemon Processes in Linux
vi Editor
• vi is a powerful text editor in Linux, widely used for editing
configuration files and writing code. It operates in different modes:
vi Editor
Commands to Compress Files in Linux
• Tar - The tar command is not specifically a compression command. It’s generally
used to pull a number of files into a single file for easy transport to another system
or to back the files up as a related group.
• tar cfz bigfi[Link] bigfile
• Zip - The zip command creates a compressed file while leaving the
original file intact.
• zip ./bigfi[Link] bigfile
• Gzip - The gzip command is very simple to use. You just type “gzip” followed by
the name of the file you want to compress.
• gzip bigfile
• Bzip2 - As with the gzip command, bzip2 will compress the file that you select “in
place”, leaving only the original file.
• bzip bigfile
• Xz - A relative newcomer to the compression command team, xz is a front runner
in terms of how well it compresses files.
• xz bigfile
Viewing and Terminating Processes in Linux
Viewing and Terminating Processes in Linux
File-Related Commands in Linux
Commands for Managing Users and Groups
ls Command in Linux
history Command in Linux
Shell Program
• read is used to take input from the user.
• The result is printed using echo.
Shell Program
#!/bin/bash
# Shell program to add two numbers
echo "Enter first number:"
read num1
echo "Enter second number:"
read num2
sum=$((num1 + num2)) # Calculate sum
echo "The sum is: $sum"
Shell Program
#!/bin/bash
# Shell program to subtract two numbers
echo "Enter first number:"
read num1
echo "Enter second number:"
read num2
sub=$((num1 - num2)) # Calculate sub
echo "The subtraction is: $sub"
Head, Tail, Cat, and Tac Commands
Date, Uptime, and Whoami Commands
df, du, and free Commands
Absolute and Relative Path
Rename and Strings Commands
bg and fg Commands
grep Command
w, cal, and which Commands
Thank You!!