SlideShare a Scribd company logo
BASH
Learn BASH Basics With Simple Examples
By: Mohamed Alaa El-Din.
What Is BASH
 Bash is a Unix Shell and Command Line Language.
 It typically runs in a Text Window where the user types commands that cause
actions.
 It Can Execute Command From The Files.
 To Get Help To Any Command Run
 man command => show the full manual.
 whatis command => show one line summary.
 command –help => show the summary and The flags of the command.
What Is Next
 Manipulate Directories And Files.
 Link Files (HardLink And SymLink),
 Export And Use Exported Variables.
 Navigate And Inspects The File System.
 Aliases
 Dot Bash Files
Manipulate With The Directories
 Manipulate Meaning Here Is To Create, Copy, Cut, Rename And Delete Files.
 To Manipulate Directories
 mkdir Test => Create New Directory With Name Of Test.
 rm –rf Test [files…] / * => Remove The Directory With name Of Test.
 cp /path/to/file /new/path/[optional rename the file] => copy the file to new
destination.
 mv /path/to/file /new/path/[optional rename the file] => Move Or Rename the file
to new destination.
Manipulate With The Files
To Manipulate Files
 touch test.txt => Create New File With Name Of Test.
 rm -f text.txt [files…] / * => Remove The File With name Of Test.
 cp /path/to/file /new/path/[optional rename the file] => copy the file / Directory to
new destination.
 mv /path/to/file /new/path/[optional rename the file] => Move Or Rename the file /
Directory to new destination.
Links: What Is Links
 Links Are Uses To Make A Copy From Targeted File Or Directory.
 In The Unix / Linux System There Are Two Different Type Of Links.
 Hard Link.
 Symbolic Link.
 By The Way When You List The Files And Directories with ls It Shows List Of
References That Map To It is Inodes.
 Inode is a data structure in a Unix-style file system that describes a file-system
object such as a file or a directory.
 Inodes are unique to each file system.
Links: Links Type: Hard Link
 Hard Link
 It Create Another Reference For The Selected Inode.
 Any Change Applied To The Link Will Change The Original File Because It Map To The
Original Indoe By The Its New Reference.
 in most (but not all) Unix/Linux distributions hard links cannot be created for directories
like the Unique file system.
 Hard links are also not allowed to cross file systems.
 How To Create
 ln <source> <linkname>
Links: Links Type: Symbolic Links
 Symbolic Link
 It Not Create Any Reference For Any inode At All Rather Than That It Create A Pointer For
An Original Directory Or File.
 Can Use To Point For Another File System Or Directory.
 How To Create
 ln –s <source> <linkname>
Links: How To Detect The Links Path And
The Original Path
 In Links There Are Two Deferent Links Will Be Present When After Creating The Links.
 Original Path.
 Link Path.
Links: How To Detect The Links Path And
The Original Path
 Original Path
 The Original Path Is Where The Original Directory Or File is Located.
 If You Know Where Is The Path This May Be Good But Some Times You Need To Know The
Original File Path From A Link.
 To Can Run Just Type readlink $(which link / alias / command).
 readlink => Will Read The Link Real Path But It Required A Full Path To the Link / command.
 $(command) => Here We Can Return A Command Value And Use It For The Previous Command.
 which => Get The Link Path Or The Alias Or Command Info.
 link / alias / command => The Wanted Value.
Links: How To Detect The Links Path And
The Original Path
 Link Path
 The Symbolic / hard Link Path Where The Link Is Located.
 Some Times You Want To Know Where Is The Is Located To Add It To Environment Variables.
 To Read The Link Path Just Type which link / alias / command
Links: Which VS Where
 Which
 Simply Is A Command Show The Info About The Target command Like:
 Alias => Will Print What It’s Aliased For.
 Command => Will Print The Command Info.
 Link => Will Print The Path Of The Link Only That Is Active And Work.
 Where
 Simply Is A Command Show The Info About The Target command Like:
 Alias => Will Print What It’s Aliased For.
 Command => Will Print The Command Info And It’s Path.
 Link => Will Print The Path Of The Link Not Only That Is Active And Work But All The Links Available.
Export Environment Variables: Custom
Path First Approach
 In Some Situation You Need To Add A Custom Path To The <$PATH> Variable, So
You Can Perform Some Actions With It.
 The Safest Way To Do It Is By Exporting The Path variable Concatenated With The
Custom Path
 export PATH=“$PATH:/custom/path”
 export => Define New Variable And Export It To The Shell
 PATH Is The Global Variable Name In Many Unix / Linux Distributions.
 $PATH => Here We Echo The <$PATH> Variable Data.
 : => Concatenate Operator.
 /custom/path => The New Path The Will Add To The <$PATH> Variable.
Export Environment Variables : Custom
Path Second Approach
 Another Way Is To Define A New Environment Variable
 export NEW_VAR=“/path/to/new_var”
Environment Variables: What Is Environment
Variables And The Most Important Ones.
 Environment Variables Are Variables That Exported From The Bash And The User
Defined As Well.
 To Show All Variables Just Run printenv.
 Now You Will See All The Environment Variables.
 How To Get The Environment Variables Value.
 Just Run echo $ENVIRONMENT_VARIABLE_NAME.
 echo Will Print The Value And Notice The $ Before The Variable Name.
 Most Important Variables Are:
 $HOME
 $PATH
 $USER
Navigate And Inspects The File System
 To Navigate You Can Use cd To Can Change The Current Directory.
 cd <FILE_NAME> => go to <FILE_NAME>
 cd .. => Back One Step / Go Out / Return Back.
 Inspects The File System Mean To View The Directories / Files List And Files
Contents.
 ls => Will List All The Directories And The Files.
 cat => Will Print The File Content.
 less => Will Print The File Content Within Full Page.
 | => Will Convert The Output From Its Previous Command And Put It Like A Virual File
To Pass It To The Command After it Like printenv | less / more / cat / grep
Aliases
 Aliases As From Its Name You Give A Command An Alias To Easy Usage.
 To Make Alias.
 alias <ALIAS_NAME> = content
 NOTE When Define An Alias Don’t Define It In The Bash It Will Stay For One Session
After Reopen The Terminal It Will Gone So Define It in One Of The bash files.
Dot BASH Files
 Files That Loaded When The Terminal Is Open To Start The BASH And Load All the
Environment Variables.
 There Is Many bash files like .bashrc and .zshrc.
 Note All Files Or Directories With . In it’s First Name That Mean It’s Hidden So You
can Show It By type ls –a.
 In The Bash Files You Can Define As Many Environment Variables, Aliases and
Functions And It Will Loaded When You Start Every Session For You.

More Related Content

PDF
Basics of UNIX Commands
PPT
intro unix/linux 07
PPT
intro unix/linux 11
PPT
intro unix/linux 09
ODP
intro unix/linux 02
PPT
03 browsing the filesystem
PPTX
File upload php
PPT
intro unix/linux 10
Basics of UNIX Commands
intro unix/linux 07
intro unix/linux 11
intro unix/linux 09
intro unix/linux 02
03 browsing the filesystem
File upload php
intro unix/linux 10

What's hot (20)

PPTX
File Uploading in PHP
PPTX
Basics of Unix Adminisration
PPTX
Basics of unix
PPTX
Basic unix commands
PPT
Linker scripts
PPTX
Unix training session 2
PPTX
Uploading a file with php
PDF
Unix commands in etl testing
PPTX
Files in php
PDF
Basic shell programs assignment 1_solution_manual
PPT
Basic Linux day 2
PPTX
Directory Commands - R.D.Sivakumar
ODP
Php File Upload
PPTX
Linux - Directory commands
PPTX
Introduction to linux day1
PDF
Course 102: Lecture 12: Basic Text Handling
PPT
PDF
File handling in qbasic
PPT
Csphtp1 17
File Uploading in PHP
Basics of Unix Adminisration
Basics of unix
Basic unix commands
Linker scripts
Unix training session 2
Uploading a file with php
Unix commands in etl testing
Files in php
Basic shell programs assignment 1_solution_manual
Basic Linux day 2
Directory Commands - R.D.Sivakumar
Php File Upload
Linux - Directory commands
Introduction to linux day1
Course 102: Lecture 12: Basic Text Handling
File handling in qbasic
Csphtp1 17
Ad

Similar to Learning Bash For linux Command Line (20)

PPTX
linux chapter 5.pptx lesson About introduction to linux
PDF
Command Line Tools
PPT
Using Unix
PDF
Mastering the command line for developers by Etietop Demas
PPTX
An Introduction to Linux
PPT
04 using and_configuring_bash
PDF
Linux intro 2 basic terminal
PPTX
DOCX
Directories description
PDF
The Shell Game Part 3: Introduction to Bash
PPT
8.1.intro unix
PPTX
Chapter 2 Linux File System and net.pptx
ODP
Nguyễn Vũ Hưng: Basic Linux Power Tools
ODP
Class 2
PDF
Shell intro
PPTX
Code tacoma command_line
PDF
Linux Basics
PDF
The structure of Linux - Introduction to Linux for bioinformatics
PDF
Shell scripting
PDF
basic-unix.pdf
linux chapter 5.pptx lesson About introduction to linux
Command Line Tools
Using Unix
Mastering the command line for developers by Etietop Demas
An Introduction to Linux
04 using and_configuring_bash
Linux intro 2 basic terminal
Directories description
The Shell Game Part 3: Introduction to Bash
8.1.intro unix
Chapter 2 Linux File System and net.pptx
Nguyễn Vũ Hưng: Basic Linux Power Tools
Class 2
Shell intro
Code tacoma command_line
Linux Basics
The structure of Linux - Introduction to Linux for bioinformatics
Shell scripting
basic-unix.pdf
Ad

Recently uploaded (20)

PDF
COLEAD A2F approach and Theory of Change
PPTX
water for all cao bang - a charity project
DOCX
"Project Management: Ultimate Guide to Tools, Techniques, and Strategies (2025)"
PPTX
The Effect of Human Resource Management Practice on Organizational Performanc...
PPTX
nose tajweed for the arabic alphabets for the responsive
PPTX
_ISO_Presentation_ISO 9001 and 45001.pptx
PPTX
ART-APP-REPORT-FINctrwxsg f fuy L-na.pptx
PDF
Instagram's Product Secrets Unveiled with this PPT
PPTX
fundraisepro pitch deck elegant and modern
PPTX
Tour Presentation Educational Activity.pptx
PPTX
BIOLOGY TISSUE PPT CLASS 9 PROJECT PUBLIC
DOC
LSTM毕业证学历认证,利物浦大学毕业证学历认证怎么认证
PPTX
Human Mind & its character Characteristics
PPTX
chapter8-180915055454bycuufucdghrwtrt.pptx
PPTX
Effective_Handling_Information_Presentation.pptx
PDF
oil_refinery_presentation_v1 sllfmfls.pdf
PDF
Nykaa-Strategy-Case-Fixing-Retention-UX-and-D2C-Engagement (1).pdf
PPTX
2025-08-10 Joseph 02 (shared slides).pptx
PPTX
Self management and self evaluation presentation
PDF
Microsoft-365-Administrator-s-Guide_.pdf
COLEAD A2F approach and Theory of Change
water for all cao bang - a charity project
"Project Management: Ultimate Guide to Tools, Techniques, and Strategies (2025)"
The Effect of Human Resource Management Practice on Organizational Performanc...
nose tajweed for the arabic alphabets for the responsive
_ISO_Presentation_ISO 9001 and 45001.pptx
ART-APP-REPORT-FINctrwxsg f fuy L-na.pptx
Instagram's Product Secrets Unveiled with this PPT
fundraisepro pitch deck elegant and modern
Tour Presentation Educational Activity.pptx
BIOLOGY TISSUE PPT CLASS 9 PROJECT PUBLIC
LSTM毕业证学历认证,利物浦大学毕业证学历认证怎么认证
Human Mind & its character Characteristics
chapter8-180915055454bycuufucdghrwtrt.pptx
Effective_Handling_Information_Presentation.pptx
oil_refinery_presentation_v1 sllfmfls.pdf
Nykaa-Strategy-Case-Fixing-Retention-UX-and-D2C-Engagement (1).pdf
2025-08-10 Joseph 02 (shared slides).pptx
Self management and self evaluation presentation
Microsoft-365-Administrator-s-Guide_.pdf

Learning Bash For linux Command Line

  • 1. BASH Learn BASH Basics With Simple Examples By: Mohamed Alaa El-Din.
  • 2. What Is BASH  Bash is a Unix Shell and Command Line Language.  It typically runs in a Text Window where the user types commands that cause actions.  It Can Execute Command From The Files.  To Get Help To Any Command Run  man command => show the full manual.  whatis command => show one line summary.  command –help => show the summary and The flags of the command.
  • 3. What Is Next  Manipulate Directories And Files.  Link Files (HardLink And SymLink),  Export And Use Exported Variables.  Navigate And Inspects The File System.  Aliases  Dot Bash Files
  • 4. Manipulate With The Directories  Manipulate Meaning Here Is To Create, Copy, Cut, Rename And Delete Files.  To Manipulate Directories  mkdir Test => Create New Directory With Name Of Test.  rm –rf Test [files…] / * => Remove The Directory With name Of Test.  cp /path/to/file /new/path/[optional rename the file] => copy the file to new destination.  mv /path/to/file /new/path/[optional rename the file] => Move Or Rename the file to new destination.
  • 5. Manipulate With The Files To Manipulate Files  touch test.txt => Create New File With Name Of Test.  rm -f text.txt [files…] / * => Remove The File With name Of Test.  cp /path/to/file /new/path/[optional rename the file] => copy the file / Directory to new destination.  mv /path/to/file /new/path/[optional rename the file] => Move Or Rename the file / Directory to new destination.
  • 6. Links: What Is Links  Links Are Uses To Make A Copy From Targeted File Or Directory.  In The Unix / Linux System There Are Two Different Type Of Links.  Hard Link.  Symbolic Link.  By The Way When You List The Files And Directories with ls It Shows List Of References That Map To It is Inodes.  Inode is a data structure in a Unix-style file system that describes a file-system object such as a file or a directory.  Inodes are unique to each file system.
  • 7. Links: Links Type: Hard Link  Hard Link  It Create Another Reference For The Selected Inode.  Any Change Applied To The Link Will Change The Original File Because It Map To The Original Indoe By The Its New Reference.  in most (but not all) Unix/Linux distributions hard links cannot be created for directories like the Unique file system.  Hard links are also not allowed to cross file systems.  How To Create  ln <source> <linkname>
  • 8. Links: Links Type: Symbolic Links  Symbolic Link  It Not Create Any Reference For Any inode At All Rather Than That It Create A Pointer For An Original Directory Or File.  Can Use To Point For Another File System Or Directory.  How To Create  ln –s <source> <linkname>
  • 9. Links: How To Detect The Links Path And The Original Path  In Links There Are Two Deferent Links Will Be Present When After Creating The Links.  Original Path.  Link Path.
  • 10. Links: How To Detect The Links Path And The Original Path  Original Path  The Original Path Is Where The Original Directory Or File is Located.  If You Know Where Is The Path This May Be Good But Some Times You Need To Know The Original File Path From A Link.  To Can Run Just Type readlink $(which link / alias / command).  readlink => Will Read The Link Real Path But It Required A Full Path To the Link / command.  $(command) => Here We Can Return A Command Value And Use It For The Previous Command.  which => Get The Link Path Or The Alias Or Command Info.  link / alias / command => The Wanted Value.
  • 11. Links: How To Detect The Links Path And The Original Path  Link Path  The Symbolic / hard Link Path Where The Link Is Located.  Some Times You Want To Know Where Is The Is Located To Add It To Environment Variables.  To Read The Link Path Just Type which link / alias / command
  • 12. Links: Which VS Where  Which  Simply Is A Command Show The Info About The Target command Like:  Alias => Will Print What It’s Aliased For.  Command => Will Print The Command Info.  Link => Will Print The Path Of The Link Only That Is Active And Work.  Where  Simply Is A Command Show The Info About The Target command Like:  Alias => Will Print What It’s Aliased For.  Command => Will Print The Command Info And It’s Path.  Link => Will Print The Path Of The Link Not Only That Is Active And Work But All The Links Available.
  • 13. Export Environment Variables: Custom Path First Approach  In Some Situation You Need To Add A Custom Path To The <$PATH> Variable, So You Can Perform Some Actions With It.  The Safest Way To Do It Is By Exporting The Path variable Concatenated With The Custom Path  export PATH=“$PATH:/custom/path”  export => Define New Variable And Export It To The Shell  PATH Is The Global Variable Name In Many Unix / Linux Distributions.  $PATH => Here We Echo The <$PATH> Variable Data.  : => Concatenate Operator.  /custom/path => The New Path The Will Add To The <$PATH> Variable.
  • 14. Export Environment Variables : Custom Path Second Approach  Another Way Is To Define A New Environment Variable  export NEW_VAR=“/path/to/new_var”
  • 15. Environment Variables: What Is Environment Variables And The Most Important Ones.  Environment Variables Are Variables That Exported From The Bash And The User Defined As Well.  To Show All Variables Just Run printenv.  Now You Will See All The Environment Variables.  How To Get The Environment Variables Value.  Just Run echo $ENVIRONMENT_VARIABLE_NAME.  echo Will Print The Value And Notice The $ Before The Variable Name.  Most Important Variables Are:  $HOME  $PATH  $USER
  • 16. Navigate And Inspects The File System  To Navigate You Can Use cd To Can Change The Current Directory.  cd <FILE_NAME> => go to <FILE_NAME>  cd .. => Back One Step / Go Out / Return Back.  Inspects The File System Mean To View The Directories / Files List And Files Contents.  ls => Will List All The Directories And The Files.  cat => Will Print The File Content.  less => Will Print The File Content Within Full Page.  | => Will Convert The Output From Its Previous Command And Put It Like A Virual File To Pass It To The Command After it Like printenv | less / more / cat / grep
  • 17. Aliases  Aliases As From Its Name You Give A Command An Alias To Easy Usage.  To Make Alias.  alias <ALIAS_NAME> = content  NOTE When Define An Alias Don’t Define It In The Bash It Will Stay For One Session After Reopen The Terminal It Will Gone So Define It in One Of The bash files.
  • 18. Dot BASH Files  Files That Loaded When The Terminal Is Open To Start The BASH And Load All the Environment Variables.  There Is Many bash files like .bashrc and .zshrc.  Note All Files Or Directories With . In it’s First Name That Mean It’s Hidden So You can Show It By type ls –a.  In The Bash Files You Can Define As Many Environment Variables, Aliases and Functions And It Will Loaded When You Start Every Session For You.