Operating System
By Umer Tanveer
Introduction to UNIX and Linux
Written by Dennis Ritchie and Ken Thomsom in at
Bell Labs in 1969
Initially written in assembly language and a high-
level language called B. Later converted from B to C
language.
Linux written by Linus Torvalds (an undergraduate
student at the Univ. of Helsinki, Finland) in 1991.
Most popular operating systems
Internet runs on UNIX and Linux
Why Choose Linux /Unix
Open Source and Free
Stability and Security:
Versatility and Customization
Powerful Command Line:
Large Developer Community:
/bin - Essential User Command Binaries
/bin is a crucial UNIX directory storing vital
command binaries necessary for system
functionality and repair.
Includes essential commands such as ls for listing
files, cp for copying, mv for moving, and rm for
removing files.
Practical application in everyday tasks; for example,
ls to view directory contents or cp to duplicate files.
Critical for system stability by housing a minimal set
of commands required even in emergency situations
or during system bootstrapping.
/boot - Boot Loader Files
/boot is a pivotal directory responsible for storing crucial
files essential for the successful initiation of the UNIX
system during startup.
Houses critical boot loader configuration files, such as
grub.cfg, and kernel images (e.g., vmlinuz), pivotal for
system bootstrapping.
The grub.cfg file contains bootloader configuration
settings, specifying how the system should boot,
including kernel selection and system parameters.
The vmlinuz kernel image is a core component, serving
as the initial executable that launches the operating
system during startup.
/dev - Device Files
/dev directory stores device files crucial for
communication between the operating system and
hardware components.
-Examples include /dev/sda for the first hard disk
and /dev/tty1 for the first virtual terminal.
- Users and applications interact with hardware
through /dev files, reading or writing data to these
device files.
Secure interaction is important at this step
/home - User Home Directories
The /home directory is dedicated to housing user
home directories, offering personalized spaces for
each user.
Each user's home directory within /home provides a
dedicated and private space, like /home/john,
ensuring personalization and confidentiality for their
files and settings.
Within the user's home directory in /home,
individual files and settings, such as documents,
preferences, and configurations, are stored, allowing
for a personalised computing experience.
/lib - System Libraries
The /lib directory is essential for storing system
libraries that support executable files and
applications.
The /lib directory in Linux holds critical system
libraries that provide essential support for
executable files, ensuring seamless functionality
across the operating system.
Common libraries in /lib, like libc, serve as shared
resources used by multiple programs, enhancing
efficiency by preventing redundancy, reducing
development effort, and ensuring consistent,
reliable functionality across the system.
/etc - System Configuration Files
The /etc directory is designated for storing system
configuration files in UNIX systems.
Examples of critical configuration files found in /etc
include /etc/passwd for user information and
/etc/network/interfaces for network configurations
The /etc directory in Linux is where system
administrators customize software behavior by
modifying configuration files; for instance, adjusting
network settings in /etc/network/interfaces.
/root - Root User's Home Directory
The /root directory is exclusively designated as the
home directory for the root user, the superuser with
administrative privileges.
The /root directory holds the home directory for the
root user, providing the superuser with a dedicated
space for system administration and configuration
files.
As the superuser's dedicated space, the /sbin
directory within /root holds vital binaries crucial for
executing administrative tasks, allowing root to
efficiently manage and maintain the system.
UNIX/Linux Directory Hierarchy
bin dev home … sbin usr
faculty … students
UNIX/Linux Directory Hierarchy..
students
ali … nadeem … munir
personal … courses
cs401 … cs604
What Is Shell?
How we denote home directory it varies from one shell to
another shell
Shell act as intermediator between user an kernel. It
takes user command as input then convert it into
machine or kernel readable form,
It is a text interpreter
Bash( Bourne Again Shell)
Sh (Bourne Shell)
Zsh( Z shell)
Ksh (Kom Shell)
Csh
The difference
Bash: The most popular and default shell on many Linux
distributions, known for its versatility, scripting capabilities,
and compatibility with older Bourne shell scripts.
Sh: The original Unix shell, simpler and faster than Bash, but
lacks some advanced features. Still included for compatibility
reasons.
Csh: Offers syntax similar to the C programming language,
making it easier for programmers to learn and use. Popular on
older BSD systems.
Zsh: An extension of Bash, offering advanced features like
autocompletion, plugins, and theming, popular among power
users and those seeking a more customizable experience.
Ksh: A superset of the Bourne shell, incorporating its features
and adding functionalities like built-in support for arithmetic
operations and improved scripting capabilities.
Some Common Commands
cd - Change Directory
The cd command is fundamental for navigating the
UNIX file system by changing the current working
directory.
Usage :Use cd followed by the target directory's
name or path to switch to that directory.
Example: cd Documents changes the current
directory to "Documents."
ls - List Directory Contents
The ls command is essential for inspecting the
contents of a directory within the UNIX file system.
Usage: Execute ls to list the files and directories in
the current working directory
Example: ls -l displays a detailed list, including
permissions, owner, size, and modification time.
pwd - Print Working Directory
The pwd command is used to reveal the current
working directory's full path in UNIX.
Usage: Type pwd in the command line to print the
complete path of the present working directory.-
Example: Running pwd might output something
like /home/user/Documents, indicating the current
location.
cp - Copy Files or Directories
The cp command is employed for duplicating files
or directories in UNIX
Usage - Use cp followed by the source
file/directory and destination path to create a
copy.
Example: - cp file.txt /backup copies the file.txt to
the /backup directory.
mv - Move Files or Directories
The mv command in UNIX serves the purpose of
both moving and renaming files or directories.
Usage: Execute mv followed by the source
file/directory and the destination path to relocate
or rename.
Example: - mv file.txt /documents/newfile.txt
moves and renames file.txt to newfile.txt in the
/documents directory.
Some Platforms for learning
Here are some of the best websites to learn Unix/Linux for
absolute beginners:
TryHackMe: This platform offers a free gamified learning
experience where you can learn Linux fundamentals through
hands-on practice in a safe, virtual environment.
Linux Journey: This website provides a comprehensive
beginner's guide to Linux, covering topics such as the
command line, file system, and basic administration tasks.
Codecademy: This website offers a free introductory course to
Linux that teaches you the basics of the command line and
how to navigate the Linux file system.