SlideShare a Scribd company logo
* 1
Linux Basic Commands
* 2
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
* 3
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
* 4
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.
* 5
Typical Directory Structure
• Linux Filesystem is laid out in a hierarchical tree
structure.
• Top level directory is called root “/”
* 6
* 7
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
* 8
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
* 9
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
* 10
Basic Linux Commands
• ls, listing files and directories
– ls –a
– ls –l
– ls -la
• clear, clears the screen
• 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>
* 11
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
* 12
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
* 13
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
* 14
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>
* 15
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>
* 16
Basic Linux Commands
• whoami, print user id
• locate, finds files using a pre-built database.
• find, Finds files and directories in real-time.
– locate is faster but relies on an updated index; find
is slower but always accurate.
• whereis, Shows locations of executables,
source code, and manual pages
* 17
File Permissions in Linux
* 18
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
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>
* 20
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"
echo "Enter the first number:"
read X
echo "Enter the second number:"
read Y
PRODUCT=$((X * Y))
echo "The product is: $PRODUCT"
echo "Bye Bye..."
* 21

More Related Content

Similar to Linux Commands - Basic commands for Beginners (20)

PPT
PowerPoint_merge.ppt on unix programming
Priyadarshini648418
 
PPT
Linuxppt
AvinashSahu76
 
PPT
unixkkkkmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmkkk.ppt
sufiankedir156
 
PPTX
UNIX.pptx
P S Rani
 
PPTX
Basic Linux Administration - 3.pptxon server
RekeshPatel
 
PPTX
LINUX_admin_commands.pptx
GuhanSenthil2
 
PPTX
Linux week 2
Vinoth Sn
 
PPTX
KMSUnix and Linux.pptx
Ganesh Bhosale
 
PPT
4. Centos Administration
Mohd yasin Karim
 
PPT
Online Training in Unix Linux Shell Scripting in Hyderabad
Ravikumar Nandigam
 
PPTX
Linux Fundamentals
DianaWhitney4
 
PPT
Linux commandsppowershel1-LHC_School.ppt
pouriyamaleki1994
 
PPTX
Introduction_to_Linux_Opeparating system (1).pptx
ssuserf9c7f4
 
PPTX
Introduction_to_Linux operating system for naive(1).pptx
ssuserf9c7f4
 
PPTX
2. UNIX OS System Architecture easy.pptx
Priyadarshini648418
 
PPTX
UNIX/Linux training
Michael Olafusi
 
PDF
beginner.en.print
aniruddh Tyagi
 
PDF
beginner.en.print
Aniruddh Tyagi
 
PDF
beginner.en.print
aniruddh Tyagi
 
PPTX
INTRODUCTION TO LINUX
hafees4
 
PowerPoint_merge.ppt on unix programming
Priyadarshini648418
 
Linuxppt
AvinashSahu76
 
unixkkkkmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmkkk.ppt
sufiankedir156
 
UNIX.pptx
P S Rani
 
Basic Linux Administration - 3.pptxon server
RekeshPatel
 
LINUX_admin_commands.pptx
GuhanSenthil2
 
Linux week 2
Vinoth Sn
 
KMSUnix and Linux.pptx
Ganesh Bhosale
 
4. Centos Administration
Mohd yasin Karim
 
Online Training in Unix Linux Shell Scripting in Hyderabad
Ravikumar Nandigam
 
Linux Fundamentals
DianaWhitney4
 
Linux commandsppowershel1-LHC_School.ppt
pouriyamaleki1994
 
Introduction_to_Linux_Opeparating system (1).pptx
ssuserf9c7f4
 
Introduction_to_Linux operating system for naive(1).pptx
ssuserf9c7f4
 
2. UNIX OS System Architecture easy.pptx
Priyadarshini648418
 
UNIX/Linux training
Michael Olafusi
 
beginner.en.print
aniruddh Tyagi
 
beginner.en.print
Aniruddh Tyagi
 
beginner.en.print
aniruddh Tyagi
 
INTRODUCTION TO LINUX
hafees4
 

Recently uploaded (20)

PPTX
ENGlish 8 lesson presentation PowerPoint.pptx
marawehsvinetshe
 
PPTX
How to Create a Customer From Website in Odoo 18.pptx
Celine George
 
PDF
Biological Bilingual Glossary Hindi and English Medium
World of Wisdom
 
PPTX
ENG8_Q1_WEEK2_LESSON1. Presentation pptx
marawehsvinetshe
 
PPTX
Introduction to Biochemistry & Cellular Foundations.pptx
marvinnbustamante1
 
PDF
epi editorial commitee meeting presentation
MIPLM
 
PDF
Workbook de Inglés Completo - English Path.pdf
shityouenglishpath
 
PDF
IMPORTANT GUIDELINES FOR M.Sc.ZOOLOGY DISSERTATION
raviralanaresh2
 
PPTX
PPT-Q1-WK-3-ENGLISH Revised Matatag Grade 3.pptx
reijhongidayawan02
 
PPTX
How to Send Email From Odoo 18 Website - Odoo Slides
Celine George
 
PPTX
CATEGORIES OF NURSING PERSONNEL: HOSPITAL & COLLEGE
PRADEEP ABOTHU
 
PDF
Chapter-V-DED-Entrepreneurship: Institutions Facilitating Entrepreneurship
Dayanand Huded
 
PPTX
EDUCATIONAL MEDIA/ TEACHING AUDIO VISUAL AIDS
Sonali Gupta
 
PDF
Vani - The Voice of Excellence - Jul 2025 issue
Savipriya Raghavendra
 
PDF
Women's Health: Essential Tips for Every Stage.pdf
Iftikhar Ahmed
 
PDF
Exploring the Different Types of Experimental Research
Thelma Villaflores
 
PDF
Android Programming - Basics of Mobile App, App tools and Android Basics
Kavitha P.V
 
PPTX
How to Create Odoo JS Dialog_Popup in Odoo 18
Celine George
 
PDF
STATEMENT-BY-THE-HON.-MINISTER-FOR-HEALTH-ON-THE-COVID-19-OUTBREAK-AT-UG_revi...
nservice241
 
PPTX
Nitrogen rule, ring rule, mc lafferty.pptx
nbisen2001
 
ENGlish 8 lesson presentation PowerPoint.pptx
marawehsvinetshe
 
How to Create a Customer From Website in Odoo 18.pptx
Celine George
 
Biological Bilingual Glossary Hindi and English Medium
World of Wisdom
 
ENG8_Q1_WEEK2_LESSON1. Presentation pptx
marawehsvinetshe
 
Introduction to Biochemistry & Cellular Foundations.pptx
marvinnbustamante1
 
epi editorial commitee meeting presentation
MIPLM
 
Workbook de Inglés Completo - English Path.pdf
shityouenglishpath
 
IMPORTANT GUIDELINES FOR M.Sc.ZOOLOGY DISSERTATION
raviralanaresh2
 
PPT-Q1-WK-3-ENGLISH Revised Matatag Grade 3.pptx
reijhongidayawan02
 
How to Send Email From Odoo 18 Website - Odoo Slides
Celine George
 
CATEGORIES OF NURSING PERSONNEL: HOSPITAL & COLLEGE
PRADEEP ABOTHU
 
Chapter-V-DED-Entrepreneurship: Institutions Facilitating Entrepreneurship
Dayanand Huded
 
EDUCATIONAL MEDIA/ TEACHING AUDIO VISUAL AIDS
Sonali Gupta
 
Vani - The Voice of Excellence - Jul 2025 issue
Savipriya Raghavendra
 
Women's Health: Essential Tips for Every Stage.pdf
Iftikhar Ahmed
 
Exploring the Different Types of Experimental Research
Thelma Villaflores
 
Android Programming - Basics of Mobile App, App tools and Android Basics
Kavitha P.V
 
How to Create Odoo JS Dialog_Popup in Odoo 18
Celine George
 
STATEMENT-BY-THE-HON.-MINISTER-FOR-HEALTH-ON-THE-COVID-19-OUTBREAK-AT-UG_revi...
nservice241
 
Nitrogen rule, ring rule, mc lafferty.pptx
nbisen2001
 
Ad

Linux Commands - Basic commands for Beginners

  • 1. * 1 Linux Basic Commands
  • 2. * 2 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
  • 3. * 3 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
  • 4. * 4 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.
  • 5. * 5 Typical Directory Structure • Linux Filesystem is laid out in a hierarchical tree structure. • Top level directory is called root “/”
  • 6. * 6
  • 7. * 7 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
  • 8. * 8 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
  • 9. * 9 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
  • 10. * 10 Basic Linux Commands • ls, listing files and directories – ls –a – ls –l – ls -la • clear, clears the screen • 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>
  • 11. * 11 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
  • 12. * 12 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
  • 13. * 13 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
  • 14. * 14 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>
  • 15. * 15 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>
  • 16. * 16 Basic Linux Commands • whoami, print user id • locate, finds files using a pre-built database. • find, Finds files and directories in real-time. – locate is faster but relies on an updated index; find is slower but always accurate. • whereis, Shows locations of executables, source code, and manual pages
  • 18. * 18 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. * 19 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>
  • 20. * 20 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" echo "Enter the first number:" read X echo "Enter the second number:" read Y PRODUCT=$((X * Y)) echo "The product is: $PRODUCT" echo "Bye Bye..."
  • 21. * 21