SlideShare a Scribd company logo
1 of 24
www.quontrasolutions.com contact: 404-900-9988
Email :info@quontrasolutions.com
• The Linux file-system is hierarchical and is made of
directories, sub-directories and files.
• Directories can contain sub-directories and/or files; this is a
structure used by other file-systems, such as Microsoft-
based ones however the concept originated in UNIX.
• In Linux/Unix, everything is represented as a file; this
includes processes, devices, applications, I/O sockets, etc.
• Directories are a file as well, they contain the information of
any files directly under them, hierarchically.
• The Linux file-system structure is “tree” like.
• The file-system begins at a directory named “/”, which is
also referred to as the “root” directory.
• The “drives” representation is different than in Windows.
There are no C: or D: drives; each drive has a Mount Point,
which is a location under the root (/) directory in which it is
represented.
• Mount points can be created by the sys-admin that serve as
“connection” points of sort to physical devices and/or other
file-systems
Most Unix systems has the default /mnt directory for
arbitrary mounts. Linux systems, has the /media as an
additional default directory for removable storage devices
• Below is a visual representation of the basic Linux file-
system structure:
• Absolute: the root of Linux’s file-system is represented as
“/”; this slash mark will always be present when we use
absolute pathnames to navigate the file-system, for
example: /var/log/messages.log
• The first / in the example above represents the root dir,
“var” is a directory sitting directly under the root dir and
“log” is a directory under “var”. Finally, “messages.log” is
the name of a file which resides in /var/log/.
• Relative: relative pathnames refers to the current location
in the file-system as the point of origin and not the root
directory. Let’s assume we are in the /var/ directory right
now, in order to reach messages.log file we will use the
following path: log/messages.log
• Note that there is no / at the beginning of the pathname
and that it begins with the “log” directory, since we are
already inside /var/
 Every Linux user has a “home” directory; the home dirs
reside in /home/<username>
 The home dir has a few uses and advantages to its owner:
 It is the directory a user goes to after logging into the system.
 It becomes the current working directory after login.
 The owning user can freely create files and/or directories in it.
 Other users do not have permissions to access a home directory not
owned by themselves, with the exclusion of the user “root” which is
the administrative user of the system or other users that have been
granted special permissions by the admin.
 The home dir contains customization files which are loaded upon
login. (.bash_profile / .bashrc and others)
 Contains the history of the shell commands executed by the specific
user (.bash_history)
• There are two commands that aid us with navigating
through the file-system:
• PWD – Print Working Directory; displays the absolute pathname of
the current working directory:
•# pwd
•/home/nir
• CD – change directory; make the specified pathname our current
working directory. can be used with either absolute or relative
pathnames:
# cd /var/log
•# pwd
•/var/log
 CD with a relative pathname:
 # pwd
/var
# cd log
# pwd
/var/log
 CD without any pathname will make the user’s home dir the
current working directory:
 # pwd
/var/log
# cd
# pwd
/home/nir
• Pathname navigations has a few shortcuts to make things
simpler:
 . : represents the current working directory, for example: if the
current working dir is /var/log/ “ls .” will display the log files in this
dir.
 .. : represents the parent directory, one level above the current
working directory; following the above example, “ls ..” will display
the contents of /var/
 ~ : represents the home directory, each user and their own home.
example: “cd ~” will take the user “nir” into /home/nir/
 - : return to the previous working directory; “cd –” will return to the
working directory we were in before the last “cd” command we’ve
performed.
• The “ls” command is used to list the contents of
directories. It has numerous options that allow the
displaying and sorting of information in a few different ways.
• “ls” command syntax is as follows:
• ls [-option] [pathname[s]]
• If no options or arguments are given, “ls” by itself will list
the current working directory’s contents, for example:
• # ls
• file1 file2 file3
• “ls” has a few additional options to control the listing
results and sorting:
 -a : display hidden files
 -i : display inode numbers
 -R : list sub-directories’ contents recursively
 -d : list the directory details, not the files inside of it
 -l : display long list
 -t : sort by modification time
 -r : sort in reverse order
There are numerous additional options, run: ls --help to view them.
• To see detailed information about the contents of a
directory use the “ls -l” command.
• The various fields of this table contains most of the
information about a file, its permissions and times:
• # ls -l
• drwxrwxr-x 2 nir nir 4096 Jul 19 13:58 directory
• -rw-rw-r-- 1 nir nir 135 Jul 19 13:42 file1
• -rwxrwxr-- 1 nir nir 35 Jul 19 13:42 file2
• -rw-rw-r-- 1 nir nir 200 Jul 19 13:42 file3
• Metacharacters are characters which are interpreted by the
shell as more than just any regular character.
• These characters include: ! ; * | % $ ? <> []
• It is highly recommended to Avoid using metacharacters
when naming files and/or directories; it will work but is also
likely to cause trouble.
• When executing a command in the shell, the shell scans the
whole command for metacharacters; if any are found, the
shell “expands” these characters to their actual meaning
before the execution of the command, for example, when
running the command: “ls –la ~” the shell will first
interpret the ~ mark into its actual meaning, which is the
current user’s home dir and then execute: “ls –la
/home/<username>”.
 The Asterisk “*” character’s special meaning is: zero or
more characters; this character is also known as the
“Wildcard” character, example:
 # ls
dfile1 dfile2 directory file1 file2 file3 kfile9 mfile1
# ls k*
kfile9
 Filenames with a leading dot ( . ), such as “.bash_profile”
are categorized as “hidden” by the file-system
• The question mark’s “?” special meaning is: match any
single character (except a leading dot in hidden files).
example:
 # ls
afile1 afile2 afile123 afile directory file1 file2 file3
kfile9 mfile1
# ls afile?
afile1 afile2
• The square brackets “[]” special meaning is: match a set or
a range of characters in a single position.
example:
 # ls
dfile1 dfile2 directory file1 file2 file3 kfile9 mfile1
# ls [mk]*
kfile9 mfile1
• ‘cp’ copy a file to a new file or a list of files to a directory
• Syntax:
• cp [options] file(s) file|directory
• Options:
• -i run interactively, ask before overwriting files
• -f force copy, overwrite automatically
• -r recursively copy files and sub-directories
• $ cp file file_new
• $ ls -l file file_new
• -rw-r--r-- 1 root root 4 Jul 23 21:02 file
• -rw-r--r-- 1 root root 4 Jul 23 22:11 file_new
• ‘mv’ move or rename a file or move a list of files to a
directory
• Syntax:
• mv [options] file(s) file|directory
• Options:
• -i run interactively, ask before overwriting files
• -f force copy, overwrite automatically
• $ mv file file_new
• $ ls -l file file_new
• ls: file: No such file or directory
• -rw-r--r-- 1 root root 4 Jul 23 22:11 file_new
• ‘ln’ creates a new link for a file
• Syntax:
• ln [options] file link
• Options:
• -s create a symbolic link
• -f force linking, overwrite automatically
• $ ln -s file file_new
• $ ls -l file file_new
• -rw-r--r-- 1 root root 5 Jul 23 22:25 file
• lrwxrwxrwx 1 root root 4 Jul 23 22:26 file_new -> file
• ‘rm’ removes a file or files list
• Syntax:
• rm [options] file(s)
• Options:
• -r recursively remove files and sub-directories
• -f force copy, overwrite automatically
• $ rm file_new
• $ ls -l file file_new
• ls: file: No such file or directory
• ls: file_new: No such file or directory
• ‘mkdir’ create a new directory
• Syntax:
• mkdir [options] directory
• Options:
• -p create parent directories, if needed
• $ mkdir dir1
• $ ls -l
• drwxr-xr-x 2 root root 4096 Jul 23 22:20 dir1
• Note: ‘mkdir’ is the only command from the above that can create a
new directory. ‘cp’ and ‘mv’ will only copy existing directories with given
‘-r’
THANK YOU

More Related Content

More from QUONTRASOLUTIONS

Software Quality Assurance training by QuontraSolutions
Software Quality Assurance training by QuontraSolutionsSoftware Quality Assurance training by QuontraSolutions
Software Quality Assurance training by QuontraSolutionsQUONTRASOLUTIONS
 
Introduction to software quality assurance by QuontraSolutions
Introduction to software quality assurance by QuontraSolutionsIntroduction to software quality assurance by QuontraSolutions
Introduction to software quality assurance by QuontraSolutionsQUONTRASOLUTIONS
 
.Net introduction by Quontra Solutions
.Net introduction by Quontra Solutions.Net introduction by Quontra Solutions
.Net introduction by Quontra SolutionsQUONTRASOLUTIONS
 
Introduction to j2 ee patterns online training class
Introduction to j2 ee patterns online training classIntroduction to j2 ee patterns online training class
Introduction to j2 ee patterns online training classQUONTRASOLUTIONS
 
Saas overview by quontra solutions
Saas overview  by quontra solutionsSaas overview  by quontra solutions
Saas overview by quontra solutionsQUONTRASOLUTIONS
 
Sharepoint taxonomy introduction us
Sharepoint taxonomy introduction   usSharepoint taxonomy introduction   us
Sharepoint taxonomy introduction usQUONTRASOLUTIONS
 
Introduction to the sharepoint 2013 userprofile service By Quontra
Introduction to the sharepoint 2013 userprofile service By QuontraIntroduction to the sharepoint 2013 userprofile service By Quontra
Introduction to the sharepoint 2013 userprofile service By QuontraQUONTRASOLUTIONS
 
Introduction to SharePoint 2013 REST API
Introduction to SharePoint 2013 REST APIIntroduction to SharePoint 2013 REST API
Introduction to SharePoint 2013 REST APIQUONTRASOLUTIONS
 
Performance Testing and OBIEE by QuontraSolutions
Performance Testing and OBIEE by QuontraSolutionsPerformance Testing and OBIEE by QuontraSolutions
Performance Testing and OBIEE by QuontraSolutionsQUONTRASOLUTIONS
 
Obiee introduction building reports by QuontraSolutions
Obiee introduction building reports by QuontraSolutionsObiee introduction building reports by QuontraSolutions
Obiee introduction building reports by QuontraSolutionsQUONTRASOLUTIONS
 
Sharepoint designer workflow by quontra us
Sharepoint designer workflow by quontra usSharepoint designer workflow by quontra us
Sharepoint designer workflow by quontra usQUONTRASOLUTIONS
 
MSBI and Data WareHouse techniques by Quontra
MSBI and Data WareHouse techniques by Quontra MSBI and Data WareHouse techniques by Quontra
MSBI and Data WareHouse techniques by Quontra QUONTRASOLUTIONS
 
Introduction to .NET by QuontraSolutions
Introduction to .NET by QuontraSolutionsIntroduction to .NET by QuontraSolutions
Introduction to .NET by QuontraSolutionsQUONTRASOLUTIONS
 
Core java over view basics introduction by quontra solutions
Core java over view basics introduction by quontra solutionsCore java over view basics introduction by quontra solutions
Core java over view basics introduction by quontra solutionsQUONTRASOLUTIONS
 
Process and Threads in Linux - PPT
Process and Threads in Linux - PPTProcess and Threads in Linux - PPT
Process and Threads in Linux - PPTQUONTRASOLUTIONS
 

More from QUONTRASOLUTIONS (20)

Cognos Overview
Cognos Overview Cognos Overview
Cognos Overview
 
Hibernate online training
Hibernate online trainingHibernate online training
Hibernate online training
 
Java j2eeTutorial
Java j2eeTutorialJava j2eeTutorial
Java j2eeTutorial
 
Software Quality Assurance training by QuontraSolutions
Software Quality Assurance training by QuontraSolutionsSoftware Quality Assurance training by QuontraSolutions
Software Quality Assurance training by QuontraSolutions
 
Introduction to software quality assurance by QuontraSolutions
Introduction to software quality assurance by QuontraSolutionsIntroduction to software quality assurance by QuontraSolutions
Introduction to software quality assurance by QuontraSolutions
 
.Net introduction by Quontra Solutions
.Net introduction by Quontra Solutions.Net introduction by Quontra Solutions
.Net introduction by Quontra Solutions
 
Introduction to j2 ee patterns online training class
Introduction to j2 ee patterns online training classIntroduction to j2 ee patterns online training class
Introduction to j2 ee patterns online training class
 
Saas overview by quontra solutions
Saas overview  by quontra solutionsSaas overview  by quontra solutions
Saas overview by quontra solutions
 
Sharepoint taxonomy introduction us
Sharepoint taxonomy introduction   usSharepoint taxonomy introduction   us
Sharepoint taxonomy introduction us
 
Introduction to the sharepoint 2013 userprofile service By Quontra
Introduction to the sharepoint 2013 userprofile service By QuontraIntroduction to the sharepoint 2013 userprofile service By Quontra
Introduction to the sharepoint 2013 userprofile service By Quontra
 
Introduction to SharePoint 2013 REST API
Introduction to SharePoint 2013 REST APIIntroduction to SharePoint 2013 REST API
Introduction to SharePoint 2013 REST API
 
Performance Testing and OBIEE by QuontraSolutions
Performance Testing and OBIEE by QuontraSolutionsPerformance Testing and OBIEE by QuontraSolutions
Performance Testing and OBIEE by QuontraSolutions
 
Obiee introduction building reports by QuontraSolutions
Obiee introduction building reports by QuontraSolutionsObiee introduction building reports by QuontraSolutions
Obiee introduction building reports by QuontraSolutions
 
Sharepoint designer workflow by quontra us
Sharepoint designer workflow by quontra usSharepoint designer workflow by quontra us
Sharepoint designer workflow by quontra us
 
Qa by quontra us
Qa by quontra   usQa by quontra   us
Qa by quontra us
 
MSBI and Data WareHouse techniques by Quontra
MSBI and Data WareHouse techniques by Quontra MSBI and Data WareHouse techniques by Quontra
MSBI and Data WareHouse techniques by Quontra
 
Msbi by quontra us
Msbi by quontra usMsbi by quontra us
Msbi by quontra us
 
Introduction to .NET by QuontraSolutions
Introduction to .NET by QuontraSolutionsIntroduction to .NET by QuontraSolutions
Introduction to .NET by QuontraSolutions
 
Core java over view basics introduction by quontra solutions
Core java over view basics introduction by quontra solutionsCore java over view basics introduction by quontra solutions
Core java over view basics introduction by quontra solutions
 
Process and Threads in Linux - PPT
Process and Threads in Linux - PPTProcess and Threads in Linux - PPT
Process and Threads in Linux - PPT
 

Recently uploaded

URLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppURLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppCeline George
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docxPoojaSen20
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13Steve Thomason
 
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991RKavithamani
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3JemimahLaneBuaron
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Celine George
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationnomboosow
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfchloefrazer622
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxSayali Powar
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeThiyagu K
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Sapana Sha
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxmanuelaromero2013
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphThiyagu K
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdfSoniaTolstoy
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxpboyjonauth
 

Recently uploaded (20)

URLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppURLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website App
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docx
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3
 
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptxINDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communication
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdf
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptx
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot Graph
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptx
 

Browsing the file system linux by quontra solutions

  • 2.
  • 3. • The Linux file-system is hierarchical and is made of directories, sub-directories and files. • Directories can contain sub-directories and/or files; this is a structure used by other file-systems, such as Microsoft- based ones however the concept originated in UNIX. • In Linux/Unix, everything is represented as a file; this includes processes, devices, applications, I/O sockets, etc. • Directories are a file as well, they contain the information of any files directly under them, hierarchically.
  • 4. • The Linux file-system structure is “tree” like. • The file-system begins at a directory named “/”, which is also referred to as the “root” directory. • The “drives” representation is different than in Windows. There are no C: or D: drives; each drive has a Mount Point, which is a location under the root (/) directory in which it is represented. • Mount points can be created by the sys-admin that serve as “connection” points of sort to physical devices and/or other file-systems Most Unix systems has the default /mnt directory for arbitrary mounts. Linux systems, has the /media as an additional default directory for removable storage devices
  • 5. • Below is a visual representation of the basic Linux file- system structure:
  • 6. • Absolute: the root of Linux’s file-system is represented as “/”; this slash mark will always be present when we use absolute pathnames to navigate the file-system, for example: /var/log/messages.log • The first / in the example above represents the root dir, “var” is a directory sitting directly under the root dir and “log” is a directory under “var”. Finally, “messages.log” is the name of a file which resides in /var/log/.
  • 7. • Relative: relative pathnames refers to the current location in the file-system as the point of origin and not the root directory. Let’s assume we are in the /var/ directory right now, in order to reach messages.log file we will use the following path: log/messages.log • Note that there is no / at the beginning of the pathname and that it begins with the “log” directory, since we are already inside /var/
  • 8.  Every Linux user has a “home” directory; the home dirs reside in /home/<username>  The home dir has a few uses and advantages to its owner:  It is the directory a user goes to after logging into the system.  It becomes the current working directory after login.  The owning user can freely create files and/or directories in it.  Other users do not have permissions to access a home directory not owned by themselves, with the exclusion of the user “root” which is the administrative user of the system or other users that have been granted special permissions by the admin.  The home dir contains customization files which are loaded upon login. (.bash_profile / .bashrc and others)  Contains the history of the shell commands executed by the specific user (.bash_history)
  • 9. • There are two commands that aid us with navigating through the file-system: • PWD – Print Working Directory; displays the absolute pathname of the current working directory: •# pwd •/home/nir • CD – change directory; make the specified pathname our current working directory. can be used with either absolute or relative pathnames: # cd /var/log •# pwd •/var/log
  • 10.  CD with a relative pathname:  # pwd /var # cd log # pwd /var/log  CD without any pathname will make the user’s home dir the current working directory:  # pwd /var/log # cd # pwd /home/nir
  • 11. • Pathname navigations has a few shortcuts to make things simpler:  . : represents the current working directory, for example: if the current working dir is /var/log/ “ls .” will display the log files in this dir.  .. : represents the parent directory, one level above the current working directory; following the above example, “ls ..” will display the contents of /var/  ~ : represents the home directory, each user and their own home. example: “cd ~” will take the user “nir” into /home/nir/  - : return to the previous working directory; “cd –” will return to the working directory we were in before the last “cd” command we’ve performed.
  • 12. • The “ls” command is used to list the contents of directories. It has numerous options that allow the displaying and sorting of information in a few different ways. • “ls” command syntax is as follows: • ls [-option] [pathname[s]] • If no options or arguments are given, “ls” by itself will list the current working directory’s contents, for example: • # ls • file1 file2 file3
  • 13. • “ls” has a few additional options to control the listing results and sorting:  -a : display hidden files  -i : display inode numbers  -R : list sub-directories’ contents recursively  -d : list the directory details, not the files inside of it  -l : display long list  -t : sort by modification time  -r : sort in reverse order There are numerous additional options, run: ls --help to view them.
  • 14. • To see detailed information about the contents of a directory use the “ls -l” command. • The various fields of this table contains most of the information about a file, its permissions and times: • # ls -l • drwxrwxr-x 2 nir nir 4096 Jul 19 13:58 directory • -rw-rw-r-- 1 nir nir 135 Jul 19 13:42 file1 • -rwxrwxr-- 1 nir nir 35 Jul 19 13:42 file2 • -rw-rw-r-- 1 nir nir 200 Jul 19 13:42 file3
  • 15. • Metacharacters are characters which are interpreted by the shell as more than just any regular character. • These characters include: ! ; * | % $ ? <> [] • It is highly recommended to Avoid using metacharacters when naming files and/or directories; it will work but is also likely to cause trouble. • When executing a command in the shell, the shell scans the whole command for metacharacters; if any are found, the shell “expands” these characters to their actual meaning before the execution of the command, for example, when running the command: “ls –la ~” the shell will first interpret the ~ mark into its actual meaning, which is the current user’s home dir and then execute: “ls –la /home/<username>”.
  • 16.  The Asterisk “*” character’s special meaning is: zero or more characters; this character is also known as the “Wildcard” character, example:  # ls dfile1 dfile2 directory file1 file2 file3 kfile9 mfile1 # ls k* kfile9  Filenames with a leading dot ( . ), such as “.bash_profile” are categorized as “hidden” by the file-system
  • 17. • The question mark’s “?” special meaning is: match any single character (except a leading dot in hidden files). example:  # ls afile1 afile2 afile123 afile directory file1 file2 file3 kfile9 mfile1 # ls afile? afile1 afile2
  • 18. • The square brackets “[]” special meaning is: match a set or a range of characters in a single position. example:  # ls dfile1 dfile2 directory file1 file2 file3 kfile9 mfile1 # ls [mk]* kfile9 mfile1
  • 19. • ‘cp’ copy a file to a new file or a list of files to a directory • Syntax: • cp [options] file(s) file|directory • Options: • -i run interactively, ask before overwriting files • -f force copy, overwrite automatically • -r recursively copy files and sub-directories • $ cp file file_new • $ ls -l file file_new • -rw-r--r-- 1 root root 4 Jul 23 21:02 file • -rw-r--r-- 1 root root 4 Jul 23 22:11 file_new
  • 20. • ‘mv’ move or rename a file or move a list of files to a directory • Syntax: • mv [options] file(s) file|directory • Options: • -i run interactively, ask before overwriting files • -f force copy, overwrite automatically • $ mv file file_new • $ ls -l file file_new • ls: file: No such file or directory • -rw-r--r-- 1 root root 4 Jul 23 22:11 file_new
  • 21. • ‘ln’ creates a new link for a file • Syntax: • ln [options] file link • Options: • -s create a symbolic link • -f force linking, overwrite automatically • $ ln -s file file_new • $ ls -l file file_new • -rw-r--r-- 1 root root 5 Jul 23 22:25 file • lrwxrwxrwx 1 root root 4 Jul 23 22:26 file_new -> file
  • 22. • ‘rm’ removes a file or files list • Syntax: • rm [options] file(s) • Options: • -r recursively remove files and sub-directories • -f force copy, overwrite automatically • $ rm file_new • $ ls -l file file_new • ls: file: No such file or directory • ls: file_new: No such file or directory
  • 23. • ‘mkdir’ create a new directory • Syntax: • mkdir [options] directory • Options: • -p create parent directories, if needed • $ mkdir dir1 • $ ls -l • drwxr-xr-x 2 root root 4096 Jul 23 22:20 dir1 • Note: ‘mkdir’ is the only command from the above that can create a new directory. ‘cp’ and ‘mv’ will only copy existing directories with given ‘-r’

Editor's Notes

  1. Make sure everyone take notes (!)
  2. Explain about each one - (!)
  3. Discussion: Explain about hidden files
  4. Explain about MV and why it has no ‘-r’
  5. Explain briefly about non-symbolic links
  6. Explain about ‘rm -rf‘ls: file: No such file or directory
  7. try running ‘mkdir new_dir/new_subdir’