SlideShare a Scribd company logo
19/05/2024 1
Linux Lecture – 01
Sharjeel Kashif
19/05/2024 Sharjeel Kashif, NCP 2
Today’s Lecture
• Operating System Concept
• Brief History of UNIX & Linux
• A Linux Distribution
• Architecture of Linux
• Basic Principals of Linux
• Linux File System
• Typical Linux Directory Structure
• How to login
• Basic Linux Commands
19/05/2024 Sharjeel Kashif, NCP 3
Operating System Concept
• An operating system (OS) is
a resource manager
• It is a set of software
routines:
– that allow users and
application programs to access
system resources
– in a safe, efficient and abstract
way
– CPU, memory, disks, modems,
printers network cards etc.
• A general operating system
architecture can be
understood by the figure
Users
Shell or GUI
Application
Programs
System Utilities
System Call Library
Operating System Kernel
Dual Processor with 2 GB RAM,
160 GB Hard Disk
19/05/2024 Sharjeel Kashif, NCP 4
Operating System Concept
• The kernel controls the hardware
• It provides functions like
– Handling of interrupts from the devices
– Allocation of memory to programs
– Sharing of CPU among the programs
• Basic kernel services are exposed to higher-level programs
through a library of system calls
• Application Programs and System Utility Programs
make use of system calls
– Launched using a shell/GUI
• The OS may differ from one another on the basis of:
– System calls
– System utilities
– User interface they provide
– Resource scheduling policies implemented by the kernel
19/05/2024 Sharjeel Kashif, NCP 5
History of UNIX & Linux
• In late 1960s, MULTICS was introduced for
mainframe computers
• Joint venture of GE, MIT and Bell Labs
• Inspired Ken Thompson – who wrote simpler
version called UNICS, which evolved into UNIX
• Ken Thompson with Dennis Ritchie in 1973 wrote
the UNIX kernel in C
• The Fifth edition of UNIX was released to
universities in 1974
• In 1978, UNIX development was split into two main
branches:
– SYSV
– BSD
19/05/2024 Sharjeel Kashif, NCP 6
• Linux – open source OS for PCs
• Developed by Linus Torvalds (a Finnish graduate student),
in 1991
• Neither pure SYSV nor BSD, mix of both
• Conforms to a set of standards called POSIX
• Code freely available, anyone can:
– Modify, add features, correct deficiencies
• Different Distributions:
– Caldera Systems Corel Debian Mandrake
– Red Hat Slackware Strom SUSE
– Turbo Gentoo Stampede Knoppix
– Fedora Ubuntu College Linux White Box Linux
History of UNIX & Linux
19/05/2024 Sharjeel Kashif, NCP 7
A Linux Distribution
• A distribution comprises of:
– Kernel
• 2.6.9-89.0.11.EL.cernsmp
– System Utilities
• File copy, hard disk repair/defragment etc.
– GUI
• GNOME, KDE
– Application Programs
• Open office, evolution, firefox, gedit, gftp. konqueror,
evince, kdevelop, kview, emace, vim etc.
19/05/2024 Sharjeel Kashif, NCP 8
Architecture of Linux
• Kernel
– Initializes the device drivers
– Processor & memory management functions
– Support for many different type of file systems
– A wide range of system calls (mix of SYS V, BSD and POSIX.1)
– Loaded into the memory at system startup
– Location /boot/vmlinuz
– Source files /usr/src/linux
• Shells & GUIs
– Textual command line shells
• bourne shell (sh), bourne again shell (bash)
• csh and tcsh
– GUI Environment
• GNOME and KDE
19/05/2024 Sharjeel Kashif, NCP 9
Architecture of Linux
• System Utilities
– ls, grep, sed, awk, less, bc, wc, more etc.
– Powerful tools that perform a single task
extremely well
– Can also chain programs together using pipes
– Server programs called daemons
• Application Programs
– emacs, vi, kdevelop, gcc, g++, open/star office
etc.
19/05/2024 Sharjeel Kashif, NCP 10
Basic Principals of Linux
• Everything is a file
• Small, single purpose programs
• Ability to chain programs to perform complex
tasks
• Avoid captive user interface
• Configuration data is stored in text
• Linux is case-sensitive
19/05/2024 Sharjeel Kashif, NCP 11
Linux File System
• Every file in Linux can be one of the
following four types:
– Ordinary File (contain data, info)
– Directories (hold files & other directories)
– Devices (for accessing the hardware)
– Links (Pointer to another file)
• Hard Link
• Soft Link
19/05/2024 Sharjeel Kashif, NCP 12
Typical Directory Structure
• Linux Filesystem is laid out in a hierarchical tree
structure.
• Top level directory is called root “/”
19/05/2024 Sharjeel Kashif, NCP 13
/bin: Binary files
• /bin contains commands that may be used by both
the system administrator and by users
19/05/2024 Sharjeel Kashif, NCP 14
/bin: Binary files
19/05/2024 Sharjeel Kashif, NCP 15
/sbin: Super-user Binaries
• This directory contains the binaries used by the
root user
/boot: Boot files
• This directory contains everything required for
the boot process except configuration files
19/05/2024 Sharjeel Kashif, NCP 16
/dev : Device files
• The /dev directory is the location of special
or device files
/proc : Virtual File System
• The /proc directory contains directories and
files that report system information and
status
19/05/2024 Sharjeel Kashif, NCP 17
/etc: Configuration files
• /etc contains configuration files and directories.
19/05/2024 Sharjeel Kashif, NCP 18
/home: User area
• /home contains user home directories
• Area writable by individual users
• Others users may be able to read depending
upon permissions
19/05/2024 Sharjeel Kashif, NCP 19
/lib: Library files
• /lib contains essential shared libraries and
kernel modules.
• The /lib directory contains those shared library
images needed to boot the system and run the
commands in the root filesystem, i.e., by
binaries in /bin and /sbin.
19/05/2024 Sharjeel Kashif, NCP 20
/mnt: Mount area
• Mount point for a temporarily mounted
filesystem.
• This directory is provided so that the system
administrator may temporarily mount a
filesystem as needed.
• The content of this directory is a local issue
and should not affect the manner in which
any program is run.
19/05/2024 Sharjeel Kashif, NCP 21
/root & /tmp
• The /root is a home directory for the root user
• The /tmp directory must be made available for
programs that require temporary files
• /tmp is writable by everyone i.e. world writable
19/05/2024 Sharjeel Kashif, NCP 22
/usr/lib: Library files
• Libraries for programming and packages.
• /usr/lib includes object files, libraries, and
internal binaries that are not intended to be
executed directly by users or shell scripts.
19/05/2024 Sharjeel Kashif, NCP 23
19/05/2024 Sharjeel Kashif, NCP 24
Summary: Directory Structure
• Home Directories: /root,/home/username
• User Executables: /bin, /usr/bin, /usr/local/bin
• System Executables: /sbin, /usr/sbin, /usr/local/sbin
• Other Mountpoints: /media, /mnt
• Configuration: /etc
• Temporary Files: /tmp
• Kernels and Bootloader: /boot
• Server Data: /var, /srv
• System Information: /proc, /sys
• Shared Libraries: /lib, /usr/lib, /usr/local/lib
19/05/2024 Sharjeel Kashif, NCP 25
Logging into a Linux System
• Two types of login screens
– virtual consoles (text-based)
– graphical logins (display managers)
• Login using login name and password
• Each user has a home directory for personal
file storage
19/05/2024 Sharjeel Kashif, NCP 26
Absolute & Relative Paths
• Absolute pathnames
– Begin with a forward slash
– Complete "road map" to file location
– Can be used anytime you wish to specify a file
name
• Relative pathnames
– Do not begin with a slash
– Specify location relative to your current working
directory
– Can be used as a shorter way to specify a file
name
19/05/2024 Sharjeel Kashif, NCP 27
Basic Linux Commands
• ls, listing files and directories
– ls –a
– ls –l
– ls –C
– ls –F
– ls --color
– ls –d
– ls –g
– ls –o
– ls –h
– ls –lh, ls –CaF
19/05/2024 Sharjeel Kashif, NCP 28
Basic Linux Commands
• cd, change directory
– cd ..
– cd –
– cd ~/mydir
– cd /home/usman
– cd
• su, switch user, su – (complete user
environment)
• id, print user and group ids
• passwd, change password
– yppasswd
19/05/2024 Sharjeel Kashif, NCP 29
Basic Linux Commands
• man, manual pages
– man <command>
• info, information pages
– info <command>
• command --help, basic help by author
– ls --help, man --help
• pwd, present working directory
19/05/2024 Sharjeel Kashif, NCP 30
Basic Linux Commands
• ps, process information
– ps aux
– pstree
– ps fax
– top
• free, memory information
– free –m
• cal, calendar information
– cal, cal 2009
• head, output the first part of files
– head [-n <lines>] <filename>
• tail, output the last part of files
– tail [-n <lines>] <filename>
19/05/2024 Sharjeel Kashif, NCP 31
Basic Linux Commands
• cat, concatenate/display files
– cat /home/usman/myfile
• clear, clears the screen
• date, see/modify system date & time
– date, date [MMDDhhmm[[CC]YY][.ss]]
• df, disk space usage
– df –h
• du, file space usage
– du –sh
• uname, print system info
– uname [-a, -s, -n, -r, -v, -m]
19/05/2024 Sharjeel Kashif, NCP 32
Basic Linux Commands
• echo, display a line or text
– echo “any text”, echo $HOSTNAME
• exit, exit the current session/shell
• file, determine file type
– file <file name/path>
• hostname, show or set the system hostname
– hostname [<new-name>]
• more, file perusal filter for CRT viewing
– more <file name/path>
• less, file perusal filter
– less <file name/path>
19/05/2024 Sharjeel Kashif, NCP 33
Basic Linux Commands
• cp, copy files and directories
– cp [options] file destination
• More than one file may be copied at a time if the
destination is a directory:
– cp [options] file1 file2 destination
• If the destination is a directory, the copy is placed
there
• If the destination is a file, the copy overwrites the
destination
• If the destination does not exist, the copy is renamed
19/05/2024 Sharjeel Kashif, NCP 34
Basic Linux Commands
• mv, move and/or rename files and directories
– mv [options] file destination
• More than one file may be moved at a time if
the destination is a directory:
– mv [options] file1 file2 destination
• In mv also, the destination works like cp
• mkdir, creates directories
– mkdir <directory name/path>
• rmdir, removes empty directories
– rmdir < directory name/path>
19/05/2024 Sharjeel Kashif, NCP 35
Basic Linux Commands
• touch, create empty files or update file
timestamps
– touch <file name/path>
• rm, remove files
– rm [options] <file name/path>
– rm -i file (interactive)
– rm -r directory (recursive)
– rm -f file (force)
• rm –r, recursively removes directory trees
– rm –rf <directory name/path>
19/05/2024 Sharjeel Kashif, NCP 36
Basic Linux Commands
• chsh, change your login shell
• alias, setting command aliases
– alias ll=‘ls –l’
• whoami, print user id
• find, finding files and directories
– find <path> –iname <file name>
– find <path> -size +100
– find <path> -user usman –o –group it
– find <path> -perm 755
19/05/2024 Sharjeel Kashif, NCP 37
File Permissions in Linux
Octal Binary Permissions
0 000 _ _ _
1 001 _ _ x
2 010 _ w _
3 011 _ w x
4 100 r _ _
5 101 r _ x
6 110 r w _
7 111 r w x
19/05/2024 Sharjeel Kashif, NCP 38
Basic Linux Commands
• chmod, changing permissions of files/directories
– Octal mode
• chmod 644 <file name/path>
• chmod 755 <file name/path>
• chmod 6 <file name/path>
– Symbolic mode
• chmod u+x, g-r, o+x <file name/path>
• chmod a+x <file name/path>
• chmod =x <file name/path>
• chown, changing ownership of files/directories
• chgrp, changing group ownership of files/directories
– chown usman <file name>
– chgrp it <file name>
– chown usman.it <file name>
19/05/2024 Sharjeel Kashif, NCP 39
Basic Linux Commands
• stat, display the file status
– stat <file name/path>
• ssh, Open SSH client for remote login
– ssh <username>@<hostname>
– ssh –l <username> <hostname>
– ssh <hostname>
• scp, secure copy (remote file copy)
– scp <file name>
<username>@<hostname>:<path>
– scp <username>@<hostname>:<path> <local
path>
19/05/2024 Sharjeel Kashif, NCP 40
Basic Linux Commands
• env/setenv, adding or changing a variable
• Setting variable values
– MYVAR=“something”
– echo $MYVAR
– bash shell
• export MYVAR=“something”
– tcsh shell
• setenv MYVAR “soemthing”
• Sourcing files
– source /home/env/my_env.csh
– . /home/env/my_env.sh
19/05/2024 Sharjeel Kashif, NCP 41
Basic Linux Commands
• ln, creating links
– ln <source file name/path> <link name>
– ln –s <source file name/path> <link name>
• .bashrc (bash shell)
– For setting local variables and aliases
• .tcshrc (tcsh shell)
– For setting local variables and aliases
• .chsrc (csh shell)
– For setting local variables and aliases
19/05/2024 Sharjeel Kashif, NCP 42
Shell Scripting Basics
#!/bin/sh
echo “Welcome to Linux -- ” $USER
echo “Today is : ” $(date)
echo “You are working in : ” `pwd`
echo “Enter your last name: ”
read LNAME
echo "Hello -- $LNAME”
read X
read Y
echo “The product is : $X*$Y “
echo “Bye Bye…”
19/05/2024 Sharjeel Kashif, NCP 43
Shell Scripting Basics
• #!/bin/sh
MSG=“Assignments due today…”
for i in $(cat ~/users) ; do
NAME=$i
EMAIL_ADD=$NAME@ncp.edu.pk
echo $MSG | mail –s “Warning” EMAIL_ADD
done
19/05/2024 Sharjeel Kashif, NCP 44
Thank you
Q & A

More Related Content

PPT
Linuxppt
PPT
Linux HSC Taining for beginners administration.
PPT
linux-lecture1.ppt
PPT
Linux administration classes in mumbai
PPTX
KMSUnix and Linux.pptx
PPTX
UNIX.pptx
PPTX
Module1
PDF
Programming Embedded linux
Linuxppt
Linux HSC Taining for beginners administration.
linux-lecture1.ppt
Linux administration classes in mumbai
KMSUnix and Linux.pptx
UNIX.pptx
Module1
Programming Embedded linux

Similar to Linux commandsppowershel1-LHC_School.ppt (20)

PPT
Basic Unix
PPTX
Network and System Administration Power Point
PPTX
Linux powerpoint
PPT
Operating Systems 1
PPTX
Introduction to Unix
PDF
Unix - An Introduction
PPT
chapter 3 linux-lecture.ppt
PPTX
Linux Shell Basics
PDF
Unix Basics
PPTX
Unix_Introduction_BCA.pptx the very basi
PDF
Linux basic
PPT
linux-lecture1.ppt
PPTX
Linux Systems Programming: Ubuntu Installation and Configuration
PPTX
Cha-2- Software Maintenance Part-2.gghgpptx
PDF
AOS Lab 1: Hello, Linux!
PPT
Unix/Linux Basic Commands and Shell Script
PPTX
Rishav Mishra final presentation on UNIX Final.pptx
PPT
PowerPoint_merge.ppt on unix programming
PPSX
Linux: An Unbeaten Empire
PPT
Intro tounix (1)
Basic Unix
Network and System Administration Power Point
Linux powerpoint
Operating Systems 1
Introduction to Unix
Unix - An Introduction
chapter 3 linux-lecture.ppt
Linux Shell Basics
Unix Basics
Unix_Introduction_BCA.pptx the very basi
Linux basic
linux-lecture1.ppt
Linux Systems Programming: Ubuntu Installation and Configuration
Cha-2- Software Maintenance Part-2.gghgpptx
AOS Lab 1: Hello, Linux!
Unix/Linux Basic Commands and Shell Script
Rishav Mishra final presentation on UNIX Final.pptx
PowerPoint_merge.ppt on unix programming
Linux: An Unbeaten Empire
Intro tounix (1)
Ad

Recently uploaded (20)

PPTX
Digestion and Absorption of Carbohydrates, Proteina and Fats
PDF
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
PPTX
Final Presentation General Medicine 03-08-2024.pptx
PPTX
Orientation - ARALprogram of Deped to the Parents.pptx
PDF
IGGE1 Understanding the Self1234567891011
PDF
GENETICS IN BIOLOGY IN SECONDARY LEVEL FORM 3
DOC
Soft-furnishing-By-Architect-A.F.M.Mohiuddin-Akhand.doc
PDF
Computing-Curriculum for Schools in Ghana
PPTX
Chinmaya Tiranga Azadi Quiz (Class 7-8 )
PDF
RMMM.pdf make it easy to upload and study
PDF
A GUIDE TO GENETICS FOR UNDERGRADUATE MEDICAL STUDENTS
PPTX
Lesson notes of climatology university.
PDF
Paper A Mock Exam 9_ Attempt review.pdf.
PDF
ChatGPT for Dummies - Pam Baker Ccesa007.pdf
PPTX
UV-Visible spectroscopy..pptx UV-Visible Spectroscopy – Electronic Transition...
PDF
Weekly quiz Compilation Jan -July 25.pdf
PDF
advance database management system book.pdf
PPTX
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
PPTX
Unit 4 Skeletal System.ppt.pptxopresentatiom
PPTX
Cell Types and Its function , kingdom of life
Digestion and Absorption of Carbohydrates, Proteina and Fats
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
Final Presentation General Medicine 03-08-2024.pptx
Orientation - ARALprogram of Deped to the Parents.pptx
IGGE1 Understanding the Self1234567891011
GENETICS IN BIOLOGY IN SECONDARY LEVEL FORM 3
Soft-furnishing-By-Architect-A.F.M.Mohiuddin-Akhand.doc
Computing-Curriculum for Schools in Ghana
Chinmaya Tiranga Azadi Quiz (Class 7-8 )
RMMM.pdf make it easy to upload and study
A GUIDE TO GENETICS FOR UNDERGRADUATE MEDICAL STUDENTS
Lesson notes of climatology university.
Paper A Mock Exam 9_ Attempt review.pdf.
ChatGPT for Dummies - Pam Baker Ccesa007.pdf
UV-Visible spectroscopy..pptx UV-Visible Spectroscopy – Electronic Transition...
Weekly quiz Compilation Jan -July 25.pdf
advance database management system book.pdf
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
Unit 4 Skeletal System.ppt.pptxopresentatiom
Cell Types and Its function , kingdom of life
Ad

Linux commandsppowershel1-LHC_School.ppt

  • 1. 19/05/2024 1 Linux Lecture – 01 Sharjeel Kashif
  • 2. 19/05/2024 Sharjeel Kashif, NCP 2 Today’s Lecture • Operating System Concept • Brief History of UNIX & Linux • A Linux Distribution • Architecture of Linux • Basic Principals of Linux • Linux File System • Typical Linux Directory Structure • How to login • Basic Linux Commands
  • 3. 19/05/2024 Sharjeel Kashif, NCP 3 Operating System Concept • An operating system (OS) is a resource manager • It is a set of software routines: – that allow users and application programs to access system resources – in a safe, efficient and abstract way – CPU, memory, disks, modems, printers network cards etc. • A general operating system architecture can be understood by the figure Users Shell or GUI Application Programs System Utilities System Call Library Operating System Kernel Dual Processor with 2 GB RAM, 160 GB Hard Disk
  • 4. 19/05/2024 Sharjeel Kashif, NCP 4 Operating System Concept • The kernel controls the hardware • It provides functions like – Handling of interrupts from the devices – Allocation of memory to programs – Sharing of CPU among the programs • Basic kernel services are exposed to higher-level programs through a library of system calls • Application Programs and System Utility Programs make use of system calls – Launched using a shell/GUI • The OS may differ from one another on the basis of: – System calls – System utilities – User interface they provide – Resource scheduling policies implemented by the kernel
  • 5. 19/05/2024 Sharjeel Kashif, NCP 5 History of UNIX & Linux • In late 1960s, MULTICS was introduced for mainframe computers • Joint venture of GE, MIT and Bell Labs • Inspired Ken Thompson – who wrote simpler version called UNICS, which evolved into UNIX • Ken Thompson with Dennis Ritchie in 1973 wrote the UNIX kernel in C • The Fifth edition of UNIX was released to universities in 1974 • In 1978, UNIX development was split into two main branches: – SYSV – BSD
  • 6. 19/05/2024 Sharjeel Kashif, NCP 6 • Linux – open source OS for PCs • Developed by Linus Torvalds (a Finnish graduate student), in 1991 • Neither pure SYSV nor BSD, mix of both • Conforms to a set of standards called POSIX • Code freely available, anyone can: – Modify, add features, correct deficiencies • Different Distributions: – Caldera Systems Corel Debian Mandrake – Red Hat Slackware Strom SUSE – Turbo Gentoo Stampede Knoppix – Fedora Ubuntu College Linux White Box Linux History of UNIX & Linux
  • 7. 19/05/2024 Sharjeel Kashif, NCP 7 A Linux Distribution • A distribution comprises of: – Kernel • 2.6.9-89.0.11.EL.cernsmp – System Utilities • File copy, hard disk repair/defragment etc. – GUI • GNOME, KDE – Application Programs • Open office, evolution, firefox, gedit, gftp. konqueror, evince, kdevelop, kview, emace, vim etc.
  • 8. 19/05/2024 Sharjeel Kashif, NCP 8 Architecture of Linux • Kernel – Initializes the device drivers – Processor & memory management functions – Support for many different type of file systems – A wide range of system calls (mix of SYS V, BSD and POSIX.1) – Loaded into the memory at system startup – Location /boot/vmlinuz – Source files /usr/src/linux • Shells & GUIs – Textual command line shells • bourne shell (sh), bourne again shell (bash) • csh and tcsh – GUI Environment • GNOME and KDE
  • 9. 19/05/2024 Sharjeel Kashif, NCP 9 Architecture of Linux • System Utilities – ls, grep, sed, awk, less, bc, wc, more etc. – Powerful tools that perform a single task extremely well – Can also chain programs together using pipes – Server programs called daemons • Application Programs – emacs, vi, kdevelop, gcc, g++, open/star office etc.
  • 10. 19/05/2024 Sharjeel Kashif, NCP 10 Basic Principals of Linux • Everything is a file • Small, single purpose programs • Ability to chain programs to perform complex tasks • Avoid captive user interface • Configuration data is stored in text • Linux is case-sensitive
  • 11. 19/05/2024 Sharjeel Kashif, NCP 11 Linux File System • Every file in Linux can be one of the following four types: – Ordinary File (contain data, info) – Directories (hold files & other directories) – Devices (for accessing the hardware) – Links (Pointer to another file) • Hard Link • Soft Link
  • 12. 19/05/2024 Sharjeel Kashif, NCP 12 Typical Directory Structure • Linux Filesystem is laid out in a hierarchical tree structure. • Top level directory is called root “/”
  • 13. 19/05/2024 Sharjeel Kashif, NCP 13 /bin: Binary files • /bin contains commands that may be used by both the system administrator and by users
  • 14. 19/05/2024 Sharjeel Kashif, NCP 14 /bin: Binary files
  • 15. 19/05/2024 Sharjeel Kashif, NCP 15 /sbin: Super-user Binaries • This directory contains the binaries used by the root user /boot: Boot files • This directory contains everything required for the boot process except configuration files
  • 16. 19/05/2024 Sharjeel Kashif, NCP 16 /dev : Device files • The /dev directory is the location of special or device files /proc : Virtual File System • The /proc directory contains directories and files that report system information and status
  • 17. 19/05/2024 Sharjeel Kashif, NCP 17 /etc: Configuration files • /etc contains configuration files and directories.
  • 18. 19/05/2024 Sharjeel Kashif, NCP 18 /home: User area • /home contains user home directories • Area writable by individual users • Others users may be able to read depending upon permissions
  • 19. 19/05/2024 Sharjeel Kashif, NCP 19 /lib: Library files • /lib contains essential shared libraries and kernel modules. • The /lib directory contains those shared library images needed to boot the system and run the commands in the root filesystem, i.e., by binaries in /bin and /sbin.
  • 20. 19/05/2024 Sharjeel Kashif, NCP 20 /mnt: Mount area • Mount point for a temporarily mounted filesystem. • This directory is provided so that the system administrator may temporarily mount a filesystem as needed. • The content of this directory is a local issue and should not affect the manner in which any program is run.
  • 21. 19/05/2024 Sharjeel Kashif, NCP 21 /root & /tmp • The /root is a home directory for the root user • The /tmp directory must be made available for programs that require temporary files • /tmp is writable by everyone i.e. world writable
  • 22. 19/05/2024 Sharjeel Kashif, NCP 22 /usr/lib: Library files • Libraries for programming and packages. • /usr/lib includes object files, libraries, and internal binaries that are not intended to be executed directly by users or shell scripts.
  • 24. 19/05/2024 Sharjeel Kashif, NCP 24 Summary: Directory Structure • Home Directories: /root,/home/username • User Executables: /bin, /usr/bin, /usr/local/bin • System Executables: /sbin, /usr/sbin, /usr/local/sbin • Other Mountpoints: /media, /mnt • Configuration: /etc • Temporary Files: /tmp • Kernels and Bootloader: /boot • Server Data: /var, /srv • System Information: /proc, /sys • Shared Libraries: /lib, /usr/lib, /usr/local/lib
  • 25. 19/05/2024 Sharjeel Kashif, NCP 25 Logging into a Linux System • Two types of login screens – virtual consoles (text-based) – graphical logins (display managers) • Login using login name and password • Each user has a home directory for personal file storage
  • 26. 19/05/2024 Sharjeel Kashif, NCP 26 Absolute & Relative Paths • Absolute pathnames – Begin with a forward slash – Complete "road map" to file location – Can be used anytime you wish to specify a file name • Relative pathnames – Do not begin with a slash – Specify location relative to your current working directory – Can be used as a shorter way to specify a file name
  • 27. 19/05/2024 Sharjeel Kashif, NCP 27 Basic Linux Commands • ls, listing files and directories – ls –a – ls –l – ls –C – ls –F – ls --color – ls –d – ls –g – ls –o – ls –h – ls –lh, ls –CaF
  • 28. 19/05/2024 Sharjeel Kashif, NCP 28 Basic Linux Commands • cd, change directory – cd .. – cd – – cd ~/mydir – cd /home/usman – cd • su, switch user, su – (complete user environment) • id, print user and group ids • passwd, change password – yppasswd
  • 29. 19/05/2024 Sharjeel Kashif, NCP 29 Basic Linux Commands • man, manual pages – man <command> • info, information pages – info <command> • command --help, basic help by author – ls --help, man --help • pwd, present working directory
  • 30. 19/05/2024 Sharjeel Kashif, NCP 30 Basic Linux Commands • ps, process information – ps aux – pstree – ps fax – top • free, memory information – free –m • cal, calendar information – cal, cal 2009 • head, output the first part of files – head [-n <lines>] <filename> • tail, output the last part of files – tail [-n <lines>] <filename>
  • 31. 19/05/2024 Sharjeel Kashif, NCP 31 Basic Linux Commands • cat, concatenate/display files – cat /home/usman/myfile • clear, clears the screen • date, see/modify system date & time – date, date [MMDDhhmm[[CC]YY][.ss]] • df, disk space usage – df –h • du, file space usage – du –sh • uname, print system info – uname [-a, -s, -n, -r, -v, -m]
  • 32. 19/05/2024 Sharjeel Kashif, NCP 32 Basic Linux Commands • echo, display a line or text – echo “any text”, echo $HOSTNAME • exit, exit the current session/shell • file, determine file type – file <file name/path> • hostname, show or set the system hostname – hostname [<new-name>] • more, file perusal filter for CRT viewing – more <file name/path> • less, file perusal filter – less <file name/path>
  • 33. 19/05/2024 Sharjeel Kashif, NCP 33 Basic Linux Commands • cp, copy files and directories – cp [options] file destination • More than one file may be copied at a time if the destination is a directory: – cp [options] file1 file2 destination • If the destination is a directory, the copy is placed there • If the destination is a file, the copy overwrites the destination • If the destination does not exist, the copy is renamed
  • 34. 19/05/2024 Sharjeel Kashif, NCP 34 Basic Linux Commands • mv, move and/or rename files and directories – mv [options] file destination • More than one file may be moved at a time if the destination is a directory: – mv [options] file1 file2 destination • In mv also, the destination works like cp • mkdir, creates directories – mkdir <directory name/path> • rmdir, removes empty directories – rmdir < directory name/path>
  • 35. 19/05/2024 Sharjeel Kashif, NCP 35 Basic Linux Commands • touch, create empty files or update file timestamps – touch <file name/path> • rm, remove files – rm [options] <file name/path> – rm -i file (interactive) – rm -r directory (recursive) – rm -f file (force) • rm –r, recursively removes directory trees – rm –rf <directory name/path>
  • 36. 19/05/2024 Sharjeel Kashif, NCP 36 Basic Linux Commands • chsh, change your login shell • alias, setting command aliases – alias ll=‘ls –l’ • whoami, print user id • find, finding files and directories – find <path> –iname <file name> – find <path> -size +100 – find <path> -user usman –o –group it – find <path> -perm 755
  • 37. 19/05/2024 Sharjeel Kashif, NCP 37 File Permissions in Linux Octal Binary Permissions 0 000 _ _ _ 1 001 _ _ x 2 010 _ w _ 3 011 _ w x 4 100 r _ _ 5 101 r _ x 6 110 r w _ 7 111 r w x
  • 38. 19/05/2024 Sharjeel Kashif, NCP 38 Basic Linux Commands • chmod, changing permissions of files/directories – Octal mode • chmod 644 <file name/path> • chmod 755 <file name/path> • chmod 6 <file name/path> – Symbolic mode • chmod u+x, g-r, o+x <file name/path> • chmod a+x <file name/path> • chmod =x <file name/path> • chown, changing ownership of files/directories • chgrp, changing group ownership of files/directories – chown usman <file name> – chgrp it <file name> – chown usman.it <file name>
  • 39. 19/05/2024 Sharjeel Kashif, NCP 39 Basic Linux Commands • stat, display the file status – stat <file name/path> • ssh, Open SSH client for remote login – ssh <username>@<hostname> – ssh –l <username> <hostname> – ssh <hostname> • scp, secure copy (remote file copy) – scp <file name> <username>@<hostname>:<path> – scp <username>@<hostname>:<path> <local path>
  • 40. 19/05/2024 Sharjeel Kashif, NCP 40 Basic Linux Commands • env/setenv, adding or changing a variable • Setting variable values – MYVAR=“something” – echo $MYVAR – bash shell • export MYVAR=“something” – tcsh shell • setenv MYVAR “soemthing” • Sourcing files – source /home/env/my_env.csh – . /home/env/my_env.sh
  • 41. 19/05/2024 Sharjeel Kashif, NCP 41 Basic Linux Commands • ln, creating links – ln <source file name/path> <link name> – ln –s <source file name/path> <link name> • .bashrc (bash shell) – For setting local variables and aliases • .tcshrc (tcsh shell) – For setting local variables and aliases • .chsrc (csh shell) – For setting local variables and aliases
  • 42. 19/05/2024 Sharjeel Kashif, NCP 42 Shell Scripting Basics #!/bin/sh echo “Welcome to Linux -- ” $USER echo “Today is : ” $(date) echo “You are working in : ” `pwd` echo “Enter your last name: ” read LNAME echo "Hello -- $LNAME” read X read Y echo “The product is : $X*$Y “ echo “Bye Bye…”
  • 43. 19/05/2024 Sharjeel Kashif, NCP 43 Shell Scripting Basics • #!/bin/sh MSG=“Assignments due today…” for i in $(cat ~/users) ; do NAME=$i EMAIL_ADD=$NAME@ncp.edu.pk echo $MSG | mail –s “Warning” EMAIL_ADD done
  • 44. 19/05/2024 Sharjeel Kashif, NCP 44 Thank you Q & A