0% found this document useful (0 votes)
11 views

lunix 3

The document provides a comprehensive guide on installing a Linux system, covering both virtual and direct installation methods. It details the steps for setting up a virtual machine using VirtualBox, as well as the process for direct installation on physical hardware, including creating bootable media and configuring BIOS settings. Additionally, it highlights the advantages of using a Linux shell for efficient system interaction and automation.

Uploaded by

chado 26
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views

lunix 3

The document provides a comprehensive guide on installing a Linux system, covering both virtual and direct installation methods. It details the steps for setting up a virtual machine using VirtualBox, as well as the process for direct installation on physical hardware, including creating bootable media and configuring BIOS settings. Additionally, it highlights the advantages of using a Linux shell for efficient system interaction and automation.

Uploaded by

chado 26
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 122

Installing a Linux System

Computer Science Department


University of Batna 2

Licence
Plan
• Linux Installation Methods
• Virtual Installation
– Virtualization
– VirtualBox
– Installing VirtualBox
• Direct Installation of Linux
– What is Direct Installation?
– When to Use Direct Installation?
– Requirements
– Installing Ubuntu : Steps

Chapter : Installing Linux System 2


Linux Installation Methods
• Setting up a Linux OS on a device or virtual environment
to enable its use.
• Three Methods can be used for Installing and using
Linux
– Virtual Machine (VM): Runs Linux within another OS.
– Direct Installation: Installs Linux directly on physical
hardware.
• Full Installation: Linux as the only OS.
• Dual-Boot: Linux + Another OS (e.g., Windows).
– Direct booting from a bootable device : Requires bootable
media (USB/DVD)

Chapter : Installing Linux System 3


Virtual Installation
• Virtualization : is a fundamental aspect of modern computing,
enabling multiple OS (Host and Guest) to coexist on a single
physical machine.
– Host is the OS of the physical computer.
– Guest is the OS that is running inside the VM.
• Advantages of Virtualization
– Running multiple OS simultaneously.
– Allowing the test of a new OS, like Windows 11, without
affecting the Host OS.
– Save the VM state at any point and revert when needed.
– Enable seamless file sharing between host OS and guest OS
with shared folders and support for bidirectional clipboard
functionality.
• Oracle VM VirtualBox seems a leading free virtualization
tool.
Chapter : Installing Linux System 4
Virtual installation
• VirtualBox : is an open-source software developed by
Oracle.
– It allows users to create and manage VMs on a host OS.
– It runs on various host OS, including Windows, macOS,
Linux, and Solaris.

Chapter : Installing Linux System 5


Virtual installation
• Installing VirtualBox
– Hardware Configuration

Chapter : Installing Linux System 6


Virtual installation
• Installing VirtualBox
– Installation Steps
• Step 1 (Downloading) : Select the appropriate installer
for your host OS (e.g. Windows10, MacOS, Linux, etc.).
– Visiting the official website:
» https://www.virtualbox.org/

Chapter : Installing Linux System 7


Virtual installation
• Installing VirtualBox
– Installation Steps
• Step 1 (Downloading) : Two packages are available
– Base package: consists of all open source components, it is
licensed under the GNU GPL V3.
– Extension packs: can be downloaded to extend the
functionality of the base package.

Chapter : Installing Linux System 8


Virtual installation
• Installing VirtualBox
– Installation Steps
• Step 2 (Installing) : Locate and double-click the
downloaded .exe file.

Chapter : Installing Linux System 9


Virtual installation
• Installing VirtualBox
– Installation Steps
• Step 2 (Installing): Customization
 VirtualBox will be installed in the C
directory (It can be changed).
 A shortcut icon will be created for
VirtualBox on desktop.
 An entry is created in your Start
menu.
 Network adapter allows the guest
OS (inside VM) to use the host's
network resources.
 USB option allows you to configure
USB device access for VM.
Chapter : Installing Linux System 10
Virtual installation
• Installing VirtualBox
– Installation Steps
• Step 2 (Installing) : Proceed with the installation
– By clicking “Next” on the customization window, a Warning
Network interface option appears. Thus, click “Yes” to
proceed with the installation.

Chapter : Installing Linux System 11


Virtual installation
• Installing VirtualBox
– Installation Steps
• Step 2 (Installing) : Python core/win32api
– VirtualBox requires Python Core and win32api packages on
the Host OS.

Chapter : Installing Linux System 12


Virtual installation
• Installing VirtualBox
– Installation Steps
• Step 2 (Installing): Starting Installation
– Ready to Install wizard appears,
– Click “Install” to begin the installation.

Chapter : Installing Linux System 13


Virtual installation
• Installing VirtualBox
– Installation Steps
• Step 2 (Installing): Installation finished
– After the installation is complete, click “Finish” to
complete the installation process.

Chapter : Installing Linux System 14


Virtual installation
• Installing VirtualBox
– Installation Steps
• Step 3 (Creating the 1st VM):
– Download the Ubuntu ISO file from its official website.
https://ubuntu.com/

Chapter : Installing Linux System 15


Virtual installation
• Installing VirtualBox
– Installation Steps
• Step 3 (Creating the 1st VM):
– Execute VirtualBox from the Start Menu or the desktop
shortcut. Click the “New” button in the toolbar.
– The “Create Virtual Machine” wizard will guide user
through the setup process.

Chapter : Installing Linux System 16


Virtual installation
• Installing VirtualBox
– Installation Steps
• Step 3 (Creating the 1st VM): Introducing information
– Name for the VM (e.g., "Ubuntu VM").
– Set Type: Linux, and Version: Ubuntu (64-bit).
– ISO Image : attach the downloaded Ubuntu IOS image
file.
– Click "Next" to proceed.

Introduce the
required Info

Chapter : Installing Linux System 17


Virtual installation
• Installing VirtualBox
– Installation Steps
• Step 3 (Creating the 1st VM): Allocating Resources
– RAM Allocation
» Assign sufficient RAM for optimal performance of Ubuntu.
» Recommended:
• 2 GB (2048 MB) for basic use.
• 4 GB or more for better multitasking and performance.
» Ensure you leave enough RAM for the Host OS to avoid
slowdowns.

Chapter : Installing Linux System 18


Virtual installation
• Installing VirtualBox
– Installation Steps
• Step 3 (Creating the 1st VM): Allocating Resources
– CPU Allocation
» Assign the number of CPU cores for the VM:
• 1 Core: For basic tasks and lightweight use.
• 2 Cores or More: Recommended for better performance
and responsiveness.
» Do not allocate all CPU cores to the VM; keep some for the
Host OS.

Chapter : Installing Linux System 19


Virtual installation
• Installing VirtualBox
– Installation Steps
• Step 3 (Creating the 1st VM): Allocating Resources
– Create a Virtual Hard Disk

Chapter : Installing Linux System 20


Virtual installation
• Installing VirtualBox
– Installation Steps
• Step 3 (Creating the 1st VM): Allocating Resources
– Create a Virtual Hard Disk
» Select "Create a virtual hard disk now".
» Choose a disk format:
• VDI (VirtualBox Disk Image): The default choice, suitable for
most users.
• VHD or VMDK: Use these if you need compatibility with other
virtualization software (Hyper-V, VMware).
» Choose Storage Type:
• Dynamically Allocated: Expands as needed, saving disk space
initially.
• Fixed Size: Pre-allocates full disk space, improving
performance.
» Recommended Disk Size: At least 20 GB for Ubuntu.
• Use 30-50 GB for additional software and updates.

Chapter : Installing Linux System 21


Virtual installation
• Installing VirtualBox
– Installation Steps
• Step 3 (Starting the Installed OS on VM): Run the OS
– After completing the setup you can see the VirtualBox
interface shows the OS installed in vbox.
– Click “Start” to run the OS.

Chapter : Installing Linux System 22


Ubuntu

DIRECT INSTALLATION OF LINUX

Chapter : Installing Linux System 23


Direct Installation of Linux
• What is Direct Installation?
– Installing Linux as the primary OS directly on a physical
machine (laptop, desktop, or server).
– It replaces or coexists with other OS (e.g., Windows).
• When to Use Direct Installation?
– For users who want a dedicated Linux system for daily use
or development.
– Ideal for performance, as it utilizes the full hardware
resources.
• Requirements
– Compatible hardware and sufficient storage space.
– Linux ISO file and a bootable USB drive.

Chapter : Installing Linux System 24


Direct Installation of Linux
• Steps of installation
– Step 1 – Choosing a Linux distribution
– Step 2 – Downloading a Linux distribution (Ex. Ubuntu)
– Step 3 – Create the bootable media
– Step 4 – Perform the installation

Chapter : Installing Linux System 25


Direct Installation of Linux
• Steps of installation
– Step 1 : Choosing a Linux distribution

Chapter : Installing Linux System 26


Direct Installation of Linux
• Steps of installation
– Step 1 : Choosing a Linux distribution (Ex. Ubuntu)
• What is Ubuntu ?
– Free and open-source
– designed for ease of use, focusing on accessibility for
all user levels.
– It is freely available with both community and
professional support.
– It is suitable for both desktop and server use.
– It works on a wide range of hardware, including older
machines.

Chapter : Installing Linux System 27


Direct Installation of Linux
• Steps of installation
– Step 2 : Downloading the Ubuntu distribution
• From the official website : http://www.ubuntu.com/download
• We’ll need to download the ISO image of Ubuntu.
• The downloaded ISO file is a Bootable Linux image.

Chapter : Installing Linux System 28


Direct Installation of Linux
• Steps of installation
– Step 3 – Create the Bootable Media
• This step consists of writing the downloaded ISO file to an
USB device (to create the installation media).
• How do we create such a Media ?
– Required tools :
» A machine with an USB port.
» An USB flash drive with at least 16GB of space.
» A software tool to create the bootable drive.
• Choose a tool based on your OS
– Write the ISO File to the USB or DVD.
– Verify the Bootable Media

Chapter : Installing Linux System 29


Direct Installation of Linux
• Steps of installation
– Step 3 – Create the Bootable Media
• What is a Bootable Media ?
– It is a storage device used to start a computer's OS.
– Examples: USB drives, CDs, DVDs, or external hard
drives.
– Purpose:
» Installs or repairs OS and runs diagnostics.
» Recovering data from a non-booting OS.

Chapter : Installing Linux System 30


Direct Installation of Linux
• Steps of installation
– Step 3 – Create the Bootable Media
• Tools for creating a Bootable Media
– Lot of tools can be used such as Unetbootin, Ventoy,
Rufus, Etcher, dd, Fedora Media Writer, Popsicle, and
more.
– We can use Unetbootin, that is available for Linux,
MacOS, and Windows, by visiting :
https://unetbootin.github.io/
» It is easily to install UNetbootin by downloading the
executable file to your desktop and running it.

Chapter : Installing Linux System 31


Direct Installation of Linux
• Steps of installation
– Step 3 – Create the Bootable Media
• Writing the ISO File to the USB or DVD.
1. Insert the USB drive

2. Start UNetbootin

Chapter : Installing Linux System 32


Direct Installation of Linux
• Steps of installation
– Step 3 – Create the Bootable Media
• Writing the ISO File to the USB or DVD.
3. Select the distribution (ex. Ubuntu)

Chapter : Installing Linux System 33


Direct Installation of Linux
• Steps of installation
– Step 3 – Create the Bootable Media
• Writing the ISO File to the USB or DVD.
4. Specify the image file location

Chapter : Installing Linux System 34


Direct Installation of Linux
• Steps of installation
– Step 3 – Create the Bootable Media
• Writing the ISO File to the USB or DVD.
4. Specify the kind of the desired media and click OK

Chapter : Installing Linux System 35


Direct Installation of Linux
• Steps of installation
– Step 4 – Perform the installation
• Before starting installation, the following recommendations
are to be considered carefully :
– Familiarize Yourself with the installation Process
– As with any new OS installation, you should save any
important data before proceeding.
– The machine BIOS must be configured to boot with
UEFI.
– If dual-booting with Windows, understand disk
partitioning to prevent data loss.

Chapter : Installing Linux System 36


Direct Installation of Linux
• Steps of installation
– Step 4 – Perform the installation
• Changing the Boot Order of a Computers
– As your computer starts, press the DEL, ESC, F1, F2,
F8 or F10 during the initial startup screen.
– Depending on the BIOS manufacturer, a menu may
appear.
– Find the Boot option in the setup utility.
– Change the boot sequence setting so that the USB is
first.
– Save the changes and exit the BIOS/UEFI settings.

Chapter : Installing Linux System 37


Direct Installation of Linux
• Steps of installation
– Step 4 – Perform the installation
• insert the Ubuntu USB media in your machine and start it.
– Machine should boot from the USB device.

Chapter : Installing Linux System 38


Direct Installation of Linux
• Steps of installation
– Step 4 – Perform the installation
• To install Ubuntu alongside Windows, select the 1st
checkbox .

Chapter : Installing Linux System 39


Direct Installation of Linux
• Steps of installation
– Step 4 – Perform the installation
• Click Next until the accomplishment of the installation
Process.

Chapter : Installing Linux System 40


Thank You for Your Attention !
Any Questions or Comments?

Chapter : Installing Linux System 41


The Linux Shell

Computer Science Department


University of Batna 2

Licence
Plan
• Introduction
• Overview of a Linux Shell
• Shell Commands :
– File and Directory Management
– Linux Text Editors
– Process Management
– Installing/Uninstalling softwares

Chapter : The Linux Shell 2


Introduction
• The Linux OS has two main key components:
– Kernel – Core part that interacts with hardware.
• It manages system resources and facilitates
communication between software and hardware.
– Shell – Interface for users to interact with the system.
• It is an intermediary between the user and the
kernel.
• Focus of This Chapter
– This chapter focuses on the second component: The
Linux Shell.

Chapter : The Linux Shell 3


OVERVIEW OF A LINUX SHELL

Chapter : The Linux Shell 4


Overview of a Linux Shell
• Why it calls shell ?
– Because it is an outer layer (like a Walnut’s Shell) around
the kernel of Linux.

walnut’s shell

Chapter : The Linux Shell 5


Overview of a Linux Shell
• What is a Linux Shell ?
– A powerful tool for interacting with the Linux OS.
– This interaction is accomplished through Command-Line
Interface (CLI).
– CLI Acts as an intermediary between the user and the
kernel.
– It translates user commands from the Terminal into
instructions the kernel can understand.

Chapter : The Linux Shell 6


Overview of a Linux Shell
• Key Advantages of Using the Shell
– Efficiency
• It is faster than Graphical Interface (GUI)
– Scripting and Automation
• Shells automate repetitive tasks through scripts.
• Executing a sequence of commands.
– Optimized Resource Consumption
• Shells use fewer system resources compared to GUI.
– Enables remote administration
• Users can execute remote administration tasks through
the Secure Shell (SSH) tool.

Chapter : The Linux Shell 7


Overview of a Linux Shell
• Types of Linux Shell
– Bourne Shell (sh)
• was the first default shell on Unix systems
– Bourne-Again Shell (Bash)
• Default shell for most Linux distributions
– Z Shell (Zsh)
• extends Bash with additional features and improvements.
– C Shell (csh)
• Uses C programming like syntax
– TENEX C Shell (tcsh)
• Improved version of C Shell
– And Others

Chapter : The Linux Shell 8


Overview of a Linux Shell
• Accessing the shell
– Open Terminal using: Ctrl + Alt + T (Ubuntu, Debian)

Chapter : The Linux Shell 9


Overview of a Linux Shell
• Accessing the shell
– Open Terminal using : Active menu

Chapter : The Linux Shell 10


Overview of a Linux Shell
• Accessing the shell
– Go to the specific path where you want to open the Terminal
– Press the right key on a mouse, and it in the context menu
Click on "Open in Terminal"

Chapter : The Linux Shell 11


Shell Commands
• What are Shell Commands?
– Shell commands are instructions given to the shell to
perform various tasks.
– They allow users to interact with the Linux OS through the
CLI.
– Examples: ls, cd, mkdir, rm, cp, etc.

Chapter : The Linux Shell 12


Shell Commands Classification
• They can be classified based on their functions :

Chapter : The Linux Shell 13


SHELL COMMANDS: FILE AND
DIRECTORY MANAGEMENT

Chapter : The Linux Shell 14


Understanding Files, Folders and File System
• What is a File ?
– It is the smallest unit in which the information is stored.
– It is a collection of data stored on a disk with a name and
attributes.
– It can be text files, images, programs, or system data.
• What is a Folder ?
– Called Directory : is a special type of file that organizes and
stores other files and subdirectories within the filesystem.
– It helps in structuring and managing the file system.
• What is a File System ?
– Is the method used by an OS to store, retrieve, and manage
data on storage devices.
– It provides a structured way to organize files and directories.

Chapter : The Linux Shell 15


Linux File System
• Principle
– Linux organizes files in a hierarchical directory structure.
– Everything in Linux is treated as a file.
– File permissions and ownership help control access.
– Linux provides powerful commands to manage files and
directories efficiently.
– Linux supports multiple file systems (Ext4, FAT32, exFAT, XFS,
Btrfs, etc.).

Chapter : The Linux Shell 16


Linux File System
• Hierarchical Structure
– Files in Linux are organized into a multi-level hierarchy,
similar to a tree.
– Root Directory (/)
• The topmost directory in the Linux file system.
• All other files and directories branch out from /.
– Parent-Child Relationship
• Directories contain files or subdirectories.
• Every file is a descendant of the root directory.
• Special Directories in Linux
– . (dot) → Refers to the current directory.
– .. (double dot) → Refers to the parent directory.

Chapter : The Linux Shell 17


Linux File System
• Hierarchical Structure : Main Directories

Chapter : The Linux Shell 18


Linux File System
• Hierarchical Structure : Main Directories

Directory Description
/ Root directory, the top-level of the system.
/home/ User home directories (e.g. /home/user).
/bin/ Essential binaries (commands like ls, cp, mv).
/etc/ System configuration files (e.g. /etc/passwd).
/tmp/ Temporary files.
/dev/ Device files (USB, hard drives).
/proc/ Virtual filesystem for process management.
Boot-related files, including the Linux kernel and GRUB
/boot/
bootloader.

Chapter : The Linux Shell 19


Linux File System
• File Types
– 📄 Regular Files (-) – Documents, images, executables.
– 📂 Directories (d) – Folders that store files.
– 🔗 Symbolic Links (l) – Shortcuts to files or directories.
– ⚙ Special Files:
• Character Devices (c) – Interactive hardware (e.g.,
keyboard, printer).
• Block Devices (b) – Storage devices (e.g., SSD, USB).
• Sockets (s) – Used for network communication.
• Named Pipes (p) – Used for process communication.

Chapter : The Linux Shell 20


Linux File System
• File Permissions
– 🔑 Three Access Types:
• Read (r) – View file contents.
• Write (w) – Modify file contents.
• Execute (x) – Run executable files.
– 👥 User Categories:
• Owner (u) – The creator of the file.
• Group (g) – A set of users with shared access.
• Others (o) – Everyone else.
– Example : -rwxr-xr-- :
• Owner: rwx (read, write, execute)
• Group: r-x (read, execute)
• Others: r-- (read only)

Chapter : The Linux Shell 21


Linux File System
• File Permissions : Octal values
– Can be described in octal as :
Permissions Octal value
--- 0
--x 1
-w- 2
-wr 3
r-- 4
r-x 5
rw- 6
rwx 7
Chapter : The Linux Shell 22
Linux File System
• File Permissions : Octal values
– Examples
Octal Permission Meaning
777 rwxrwxrwx Full access to everyone
755 rwxr-xr-x Owner full, others read & execute
644 rw-r--r-- Owner read/write, others read only
600 rw------- Only owner can read/write
400 r-------- Owner read-only

Chapter : The Linux Shell 23


Linux File System
• Changing File Permissions : chmod
– Example: chmod 750 filename.sh
• Owner: rwx (7)
• Group: r-x (5)
• Others: --- (0)
– To Verify : ls -l filename.sh
• -rwxr-x--- 1 user group size date time filename.sh

Chapter : The Linux Shell 24


Basic File & Directory Mangement Commands

Command Description
ls List files and directories.
cd Change the current directory.
pwd Show the present working directory.
mkdir Create a new directory.
rmdir Remove an empty directory.
rm -r Remove a directory and its contents.
cp Copy files or directories.
mv Move or rename files and directories.
touch Create an empty file.
find Search for files and directories.

Chapter : The Linux Shell 25


Basic File & Directory Mangement Commands
• 💻 Navigating Directories
– ls # List files and directories
– cd dir # Change to directory 'dir'
– pwd # Show current directory
• 📂 Manging Files & Directories
– touch file.txt # Create a new file
– mkdir folder # Create a new directory
– rm file.txt # Delete a file
– rm -r folder # Delete a directory
• 📌 Managing File Permissions
– chmod # Set file permissions
– chmow # Change file ownership

Chapter : The Linux Shell 26


Basic File & Directory Mangement Commands
• Listing Files and Directories
– ls: Lists files in a directory

– ls -l: Shows detailed information


– ls -a: Displays hidden files
Basic File & Directory Mangement Commands
• Navigating Directories
– pwd: Shows current directory

– cd [dir]: Changes directory

– cd ..: Moves to the parent directory


Basic File & Directory Mangement Commands
• Creating and Removing Directories
– mkdir [option][dir]: Creates a directory

– rmdir [dir]: Removes an empty directory

– rm -r [dir]: Deletes a directory and its contents


Basic File & Directory Mangement Commands
• Creating and Removing Directories
– Examples
– mkdir /tmp/tutorial
– cd /tmp/tutorial
• Creating many directories at the same time in the current
location.
– mkdir dir1 dir2 dir3 # three D are created
• Create nested directories using -p (parent option)
– mkdir -p folder1/subfolderA/subfolderB

Chapter : The Linux Shell 30


Basic File & Directory Mangement Commands
• File Commands
– touch [file]: Creates an empty file

– rm [file] : Deletes a file


Basic File & Directory Mangement Commands
• File Commands
– cp [source] [dest]: Copies a file
– Examples
• cp file1.txt file2.txt projects/ # Copies file1.txt and file2.txt
into the projects directory.
• cp -r folder1/ folder2/ # Copies the entire folder1 directory
into folder2.
• cp file1.txt backup/file2.txt # Copies file1.txt into the
backup directory with a new name.
• cp *.txt documents/ # Copies all .txt files into the
documents directory.
• cp -i file1.txt file2.txt # Prompts before overwriting file2.txt.
i means interactive
Basic File & Directory Mangement Commands
• File Commands
– rm [file] : Deletes a file
– Examples
• rm file1.txt # Deletes file1.txt.
• rm -i file2.txt # Prompts before deleting file2.txt.
• rm -r folder1/ # Deletes folder1 and its contents
recursively.
• rm -f file3.txt # Forces deletion of file3.txt without
confirmation.
• rm *.log # Deletes all .log files in the current directory.
Basic File & Directory Mangement Commands
• File Commands
– mv [old] [new]: Moves or renames a file
– Examples
• mv file1.txt file2.txt file3.txt projects/ # transfer all three
files into the projects directory, retaining their original
names.
• mv projects/ backup/ # the entire projects directory, along
with its contents, will be inside the backup directory.
• mv file1.txt file2.txt # renames file1,txt to file2,txt
• mv dir1/ dir2/ # renames the directory dir1/ to dir2/
• mv file1.txt projects/file2.txt # moving and renaming
Basic File & Directory Mangement Commands
• Text File Commands
Command Description Example
cat Displays the contents of a file cat file.txt
grep Searches for a pattern in a file grep "error" log.txt
sort Sorts the contents of a file sort file.txt
head Displays the first few lines of a file head file.txt
tail Displays the last few lines of a file tail file.txt
wc Counts the lines, words, and characters wc file.txt
in a file
Basic File & Directory Mangement Commands
• Searching Files
– find [dir] -name '[pattern]': Searches for a file
– locate [file]: Finds file locations
– grep '[text]' [file]: Searches for text within a file
LINUX TEXT EDITORS

Chapter : The Linux Shell 37


Linux Text Editors
• What is a text editor ?
– Is a program (software application) used for editing text files.
– It is essential for programming, configuration file editing, and
scripting.
– Most configuration of Linux systems is done by editing text files.
– All Linux distributions include multiple text editors included.
• Two types of Editors
– Command-Line Editors
• vi – A traditional, lightweight, and widely available text editor
• nano – User-friendly and simple to use.
• vim – Advanced and powerful, supports modes.
• emacs – Feature-rich with extensive customization.
– Graphical Editors
• gedit – Default GUI editor in GNOME.
• KWrite – (for KDE).
• Kate – is a free text editor that is part of the KDE desktop
environment on Linux.
Chapter : The Linux Shell 38
Linux Text Editors
• vi Editor
– Default text editor in Unix/Linux.
– Powerful but has a steep learning curve.
• Modes:
– Command mode – for navigation & operations.
– Insert mode – for text input.
• Basic Commands
vi filename # Open file in vi
i # Switch to insert mode
ESC # Exit insert mode
:w # Save file
:q # Quit editor
:wq # Save & exit
:q! # Force quit without saving
Chapter : The Linux Shell 39
Linux Text Editors
• vi Editor : main interface

Chapter : The Linux Shell 40


Linux Text Editors
• nano Editor
– Simple & user-friendly command-line editor.
– Popular for beginners.
• Basic Commands
nano filename # Open a file in nano
CTRL + O # Save file
CTRL + X # Exit editor
CTRL + W # Search text
CTRL + K # Cut line
CTRL + U # Paste line

Chapter : The Linux Shell 41


Linux Text Editors
• nano Editor : main interface

Chapter : The Linux Shell 42


Linux Text Editors
• nano Editor : main interface

Chapter : The Linux Shell 43


Linux Text Editors
• gedit Editor
– is the default text editor for the GNOME desktop
environment.
– It is designed to be simple, efficient, and user-friendly.
• Key features
– Syntax highlighting for various programming languages.
– Find and replace with regular expressions.
– line numbering
– Undo/redo functionality for efficient editing.

Chapter : The Linux Shell 44


Linux Text Editors
• Main interface if gedit

Chapter : The Linux Shell 45


Linux Text Editors
• Basic Usage
– Open gedit:
• From terminal: gedit filename.txt
• From GUI: Click Applications → Accessories → gedit
– Create, edit, and save files.
– Use shortcuts:
• Ctrl + N → New file
• Ctrl + O → Open file
• Ctrl + S → Save file
• Ctrl + F → Find text

Chapter : The Linux Shell 46


Linux Text Editors
• Gedit vs some other Editors

Chapter : The Linux Shell 47


SHELL COMMANDS: PROCESS
MANAGEMENT

Chapter : The Linux Shell 48


Understanding Program and Process
• What is a Program ?
– a sequence of instructions that explains the task the CPU
should perform.
– When writing a program, a language should be use.
• High level languages that follow a syntax similar to the
natural language (as : c, c++, java, python, php, etc.)
• Medium level language (as Assembly language)
• Low-level languages that provides little or no abstraction
from a machine instructions (as : Binary machine code)

Chapter : The Linux Shell 49


Understanding Program and Process
• What is a Process?
– Is a fundamental concept in OS
– Is an instance of a program in execution : a sequence of actions
generated by execution a program.
– its execution requires resources as memory, files descriptors
and access rights, etc.

Chapter : The Linux Shell 50


Understanding Program and Process
• Process vs Program
Process Program
Definition Sequence of actions that A sequence of instructions
materializes a program in describing a task.
execution.
Nature Active (Dynamic entity) Passive (Static entity)
Lifecycle Managed by OS Managed by user
management OS
Lifespan Limited Longer
Required resources CPU, Memory, Disk, IO Stored in disk and doesn’t
devices, etc. require any other resources,
Synchronization Processes can be Do not have control over other
and control synchronized and controlled programs
using mechanisms
Understanding these distinctions between programs and processes is essential for
mastering the fundamentals of Concurrent Programming
Chapter : The Linux Shell 51
Linux Process Management
• Principle
– Each process has a unique PID : Process IDentifier.
– Processes have hierarchical relationships (parent-child).
– Multitasking and multiprocessing support.
– Each process has its own memory space.
– Controlled by the Linux kernel (scheduler, priority,
execution).

Chapter : The Linux Shell 52


Linux Process Management
• Parent-Child relationship
– Processes are created by forking off from an existing
process known as the parent process.
– Each process is either a parent or child of another process.
• A parent process is a process that creates one or more
child processes.
• A child process is a new process that is created by a
parent process.

Chapter : The Linux Shell 53


Linux Process Management
• Processes hierarchy
– Every process has a parent except the 'init' process
– The ‘init’ process is the very old process that is executed
when the system starts up and it is started by the kernel
itself.
• It is responsible for starting system services.
• It is the parent of all orphaned processes.

Chapter : The Linux Shell 54


Linux Process Management
• Process Lifecycle
– New – A new process starts (forking from a parent).
– Running – Actively using CPU.
– Waiting – Suspended or waiting for I/O.
– Ready – Waiting to be assigned to a processor by the Linux
scheduler.
– Zombie (Terminated) – Process completes or is killed.
Zombie

Chapter : The Linux Shell 55


Linux Process Management
• Process Management Commands
– Linux provides various commands to monitor, control, and
terminate processes.
– Essential commands include ps, top, kill, and nice/renice.

Command Description
ps Displays the list of running processes
top Displays real-time system information (CPU, memory)
kill Terminates a process by its ID (send signal to processes)
nice sets the priority when starting a new process
renice changes the priority of an already running process.

Chapter : The Linux Shell 56


Linux Process Management
• Process Management Commands : ps - Process Status
– Shows information on running processes on Linux.
– Helps user see what’s happening inside Linux.
– If it is used without option, ps displays information about the processes
associated with the current terminal session.

– Result contains four columns of information. Where,


• PID – the unique process ID
• TTY – terminal type that the user is logged into
• TIME – amount of CPU in minutes and seconds that the process
has been running
• CMD – name of the command that launched the process.

Chapter : The Linux Shell 57


Linux Process Management
• Process Management Commands : ps - Process Status
– Syntax $ ps [option]
– To read more information about ps use man command
$ man ps

Chapter : The Linux Shell 58


Linux Process Management
• Process Management Commands : ps - Process Status
– $ ps aux : Views all running processes
– $ ps -u username : Displays processes for a specific user.
– $ ps -l : displays detailed information about running
processes.
– $ ps -ef : displays a detailed list of all running processes in
the system.
– $ ps -C firefox : Finds a process by name.
– $ ps –axjf : Views a hierarchical tree of processes.
– And others : to read more information on them execute
• $ man ps

Chapter : The Linux Shell 59


Linux Process Management
• Process Commands : Combining ps with grep
– grep allows filtering the output of ps to find specific
processes.
– Useful for locating a process by name or PID.
– Common Usage Examples:
• Find a process by name
– ps aux | grep firefox # Lists all processes and filters
only those containing "firefox."
• Find a process by user
– ps -u username | grep firefox # Shows processes run
by a specific user and filters for a specific one.

Chapter : The Linux Shell 60


Linux Process Management
• Process Management Commands : top
– Provides a live, updating view of your system’s resource
usage. It shows information about:
• Running processes
• CPU and memory usage
• System uptime and load
• Users and task states
• When should top be used ?
– Monitor System Performance : See how much CPU and
RAM is being used, Detect if OS is under heavy load.
– Identify Problematic Processes : Find processes using too
much CPU or memory.
– Track Server Activity : Helps system administrators avoid
server crashes by early detection
Chapter : The Linux Shell 61
Linux Process Management
• Process Management Commands : top
$ top

Chapter : The Linux Shell 62


Linux Process Management
• Process Management Commands : top

$– top
Key Columns in top:
– Key columns
• PID → Unique process ID.
• USER → The system user who owns the process.
• PR → Process priority (lower number = higher priority).
• NI → Niceness value (negative = higher priority, positive =
lower).
• %CPU → Percentage of CPU used by a process.
• %MEM → Percentage of memory used.
• VIRT → Total virtual memory used.
• RES → Resident memory (physical RAM used).
• SHR → Shared memory used (in KB).
• TIME+ → Total CPU time since the process started.
• COMMAND → The command that initiated the process.

Chapter : The Linux Shell 63


Linux Process Management
• Process Management Commands : top
$ top
– Key columns
• PID → Unique process ID.
• USER → The system user who owns the process.
• PR → Process priority (lower number = higher priority).
• NI → Niceness value (negative = higher priority, positive =
lower).
• %CPU → Percentage of CPU used by a process.
• %MEM → Percentage of memory used.
• VIRT → Total virtual memory used.
• RES → Resident memory (physical RAM used).
• SHR → Shared memory used (in KB).
• TIME+ → Total CPU time since the process started.
• COMMAND → The command that initiated the process.

Chapter : The Linux Shell 64


Linux Process Management
• Process Management Commands : kill
– sends a signal to a process as to terminate it.
– It should be used to forcefully stop unresponsive or
unwanted processes.
– To list all signals that can be send to processes use
$ kill -L

Chapter : The Linux Shell 65


Linux Process Management
• Process Management Commands : kill
– To gracefully kill a process (PID)
• Asking the process to terminate voluntary
$ kill <PID>
Or
$ kill -15 <PID>

– To forcefully kill a process


• Send it the signal 9 (SIGKILL)

$ kill -9 <PID>

Chapter : The Linux Shell 66


Linux Process Management
• Process Management Commands : kill
– gracefully vs forcefully
Feature Graceful Termination (SIGTERM) Forceful Kill (SIGKILL)
Signal SIGTERM (15) SIGKILL (9)
Immediately stops
Effect Requests process to exit normally
process
Chance for No cleanup, may cause
Yes, allows cleanup (e.g., save work)
Cleanup issues
Killing unresponsive
Used For Stopping processes safely
processes
Risk of Data
No, if handled properly Yes, possible corruption
Loss?

Chapter : The Linux Shell 67


Linux Process Management
• Process Management Commands : kill
– When to use each one ? gracefully / forcefully
✔️ Use graceful termination (SIGTERM) when:
– Stopping applications like databases, servers, or text
editors.
❌ Use forceful kill (SIGKILL) only when:
– A process is frozen and does not respond to SIGTERM.
– You need to immediately stop a problematic process
consuming too many resources.

Chapter : The Linux Shell 68


Linux Process Management
• Process Management Commands : nice/renice – Priority
– nice sets the priority when starting a new process.
– renice changes the priority of an already running process.
• Lower values = higher priority
• higher values = lower priority.
• Range: -20 (highest priority) to 19 (lowest priority).

Chapter : The Linux Shell 69


Linux Process Management
• Process Management Commands : nice/renice – Priority
– For processes launched by an ordinary user, the niceness
value by default is 0.
– In fact, by running the nice command without any inputs, you
can quickly get the nice value for your terminal or shell.

Chapter : The Linux Shell 70


Linux Process Management
• Process Management Commands : nice/renice – Priority

$ nice –n <nice_value> <command/process>


$ renice <nice_value> -p <PID>

– to decrease the priority of all processes associated with


group "staff" and user "john" to 15, you would run:

$ renice 15 -g staff -u john

Chapter : The Linux Shell 71


Linux Process Management
• Exercise : Solving a Slow OS Problem.
– Scenario
• You are working on a Linux computer, and you notice
that your system is slowing significantly. Programs
respond slowly, and the CPU’s fan is running loudly.
• Your job is to identify the problem and take the
appropriate action to restore system performance.

Chapter : The Linux Shell 72


Linux Process Management
• Exercise : Solving a Slow OS Problem.
– Questions
1. What do you think might be causing this system
slowdown ?
2. Which command would you use to investigate this
situation ?
3. How would you identify the process that is causing
the problem ?
4. Suppose you found a background process using too
much CPU. How can you resolve the problem without
killing it ?
5. If necessary, how could you terminate a problematic
process ?

Chapter : The Linux Shell 73


Installing and Uninstalling softwares
PACKAGE MANAGEMENT

Chapter : The Linux Shell 79


Installing and Uninstalling Softwares
• What is a Package?
– Is a file that includes all the components needed to install
software on a Linux system, such as :
• Program binaries : The actual compiled software files.
• Metadata: Information about the package (version,
dependencies, description)
• Configuration files: Default settings and setup details.
• Why is it useful ?
– Packages make software easy to install, update, and
manage.

Chapter : The Linux Shell 80


Installing and Uninstalling Softwares
• Common Package Formats
Format Used By Description
Used by Debian-based
.deb Debian, Ubuntu, Linux Mint
systems. Managed using apt.
Used by Red Hat-based
.rpm Red Hat, Fedora, CentOS systems. Managed with yum
or dnf.
A compressed archive. May
.tar.xz Arch Linux and others not include dependency info.
Requires manual steps.

Chapter : The Linux Shell 81


Installing and Uninstalling Softwares
• Package Management
– Refers to the system of tools used to install, update, and
remove software on a Linux system.
– It automates:
• Downloading packages
• Installing packages
• Updating software
• Resolving and installing dependencies
• Removing software cleanly
– Each Linux distribution has its own package manager.
• Installing and uninstalling applications in Linux is
handled through the package management system.

Chapter : The Linux Shell 82


Installing and Uninstalling Softwares
• Package Management System
– When installing software
• The package manager downloads the required package.
• It reads the metadata to understand dependencies and
configurations.
• It installs the software and ensures everything works
properly.

Chapter : The Linux Shell 83


Installing and Uninstalling Softwares
• Package Management System
– When Uninstalling Software
• The package manager removes the software files.
• Optionally removes configuration files and unused
dependencies.

Chapter : The Linux Shell 84


Installing and Uninstalling Softwares
• Popular Package Management System

Package Manager Used In Format


APT Debian, Ubuntu .deb

YUM/DNF Fedora, CentOS, RHEL .rpm

Pacman Arch Linux .tar.xz

Others

Chapter : The Linux Shell 85


Installing and Uninstalling Softwares
• APT (Advanced Package Tool)
– Common Commands
• $ sudo apt update – Updates the package list.
• $ sudo apt install <package> – Installs a new package.
– Ex. $ sudo apt install firefox
• $ sudo apt upgrade – Upgrades installed packages.
– Ex. $ sudo apt upgrade firefox
• $ sudo apt remove <package> – Removes a package.
– Ex. $ sudo apt remove firefox
• $ apt-cache search <term> – Searches for packages.
– Ex. $ sudo apt search apache2
• $ sudo apt show firefox – Shows inf on a package

Chapter : The Linux Shell 86

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy