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

14.1 MasteringLinuxCommandLine-02-LinuxFileSystem - Handouts

The document discusses the Linux file system, including its organization, key directories like /bin, /usr, and /home, and different types of files. It explains that the root of the file system is represented by / and everything falls under it. Key directories are used for storing binaries, user files, configuration files, and each user's home directory. File types covered include regular files, directories, and special files like block/character devices, pipes, and symlinks.

Uploaded by

amit_post2000
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views

14.1 MasteringLinuxCommandLine-02-LinuxFileSystem - Handouts

The document discusses the Linux file system, including its organization, key directories like /bin, /usr, and /home, and different types of files. It explains that the root of the file system is represented by / and everything falls under it. Key directories are used for storing binaries, user files, configuration files, and each user's home directory. File types covered include regular files, directories, and special files like block/character devices, pipes, and symlinks.

Uploaded by

amit_post2000
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 9

11/19/2019

Mastering Linux Command-line

GlobalETraining.com
Mastering Linux Command Line GlobaleTraining.com

Linux File System


 File System Layout
 Unix Files
 File Names
 File Categories
 File Organization
 Pathnames
 Working with directories
 Working with files
 Comparing files
 etc.

GlobalETraining.com
Mastering Linux Command Line GlobaleTraining.com

Linux File System

GlobalETraining.com
Mastering Linux Command Line GlobaleTraining.com

1
11/19/2019

Analogy - House
 Living Room  Living Room
 Kitchen  Kitchen
 Master Bedroom  Bedroom
 Guest Bedroom  Bathroom
 Game Room
 Bathroom

GlobalETraining.com
Mastering Linux Command Line GlobaleTraining.com

Linux File System Organization


/ (root)

directory1 directory2 directory3 file1

sub-directory1
file2

sub-directory2 sub-directory3

file2

GlobalETraining.com
Mastering Linux Command Line GlobaleTraining.com

Linux File System Organization - Sample


/ (root)

tmp bin etc sbin dev opt usr home var ……….

cat cd who john mary

GlobalETraining.com
Mastering Linux Command Line GlobaleTraining.com

2
11/19/2019

Directories
Directory Purpose
/ Represents the root of the file system. Everything else falls under root.

/bin Contains binaries


/sbin Contains system binaries
/var A place for files that may change often. Example of usage: User Emails
/usr The "user file system”. Contains executables, libraries, man files and other types of documention
/opt Contains locally installed software.
/home User’s home directories are located under this directory

/etc Contains system-wide configuration files and system databases i.e system administration related files.

/dev Contains files that represent hardware like hard drives etc.

/lib Stores the needed libraries and data files for programs stored within /usr or elsewhere.

/tmp, /var/tmp Location for temporary files.

GlobalETraining.com
Mastering Linux Command Line GlobaleTraining.com

System Administration Related Info


Hard Disk – Partitions & Mount-points
 Hard disk is partitioned into multiple partitions at the time of OS installation.

 These PARTITIONS are mounted (or mapped or linked) to desired spot.

 A partition with the mount-point “/” (called as root) is MUST!


 A partition is configured as “swap partition” which us used by the OS. This is also MUST!
 Optionally, more partitions can be created and mount at:
 /opt (/opt is referred as the mount-point for the partition mounted)
 /var (/var is referred as the mount-point for the partition mounted)
 etc.
 If /opt partition is not created, /opt is still created and becomes part of “/” partition.
GlobalETraining.com
Mastering Linux Command Line GlobaleTraining.com

System Administration Related Info


“lost+found”
 Each partition has a “lost+found” directory.
 If a partition is mounted at /opt, then you will see /opt/lost+found.

 It is used by the “fsck” command or similar functionality commands.


 File System Check.

 Used by Linux System Administrators for filesystem management.

GlobalETraining.com
Mastering Linux Command Line GlobaleTraining.com

3
11/19/2019

Home Directory

GlobalETraining.com
Mastering Linux Command Line GlobaleTraining.com

10

Home Directory
 Every user has a home directory
/ (root)
 User Login  home directory.
 $HOME holds user’s home directory path.

tmp bin etc sbin usr home var

john’s home directory


cat cd who john mary

GlobalETraining.com
Mastering Linux Command Line GlobaleTraining.com

11

File Types

GlobalETraining.com
Mastering Linux Command Line GlobaleTraining.com

12

4
11/19/2019

File Types
 Regular Files (-)
 Directory Files (d)
 Special Files
 Block Device Files (b)
 Character Device Files (c)
 Named pipe files (p)
 Symbolic link files (l)
 Socket files (s)

GlobalETraining.com
Mastering Linux Command Line GlobaleTraining.com

13

Regular Files
 Readable file
 A binary file
 Image file
 Compressed file

GlobalETraining.com
Mastering Linux Command Line GlobaleTraining.com

14

Directory Files
 This type of file contains other files and sub-directories.

GlobalETraining.com
Mastering Linux Command Line GlobaleTraining.com

15

5
11/19/2019

Special Files
Block Device File Character Device File
These files are hardware files Provides a serial stream of input or
most of them are present in /dev. output. Your terminals are classic
example for this type of files.

Pipe File Symbolic Link File


Pipes allow separate processes to These are links to other files.
communicate without having
been designed explicitly to work Socket Files
together. A socket file is used to pass
information between applications
Example: | for communication purpose

GlobalETraining.com
Mastering Linux Command Line GlobaleTraining.com

16

Everything is a file
 Everything is a file in Linux.
 Hard Disk
 CD-ROM
 Memory
 Printer

GlobalETraining.com
Mastering Linux Command Line GlobaleTraining.com

17

File Naming Restrictions

GlobalETraining.com
Mastering Linux Command Line GlobaleTraining.com

18

6
11/19/2019

File Names
 Case-sensitive  myfile
 You can use:  Myfile
 Alphabets – Upper & Lower
 Numbers
 . (dot)
 _ (underscore)
 - (hyphen)
 Etc

GlobalETraining.com
Mastering Linux Command Line GlobaleTraining.com

19

File Names – Avoid these

 /  :  >  (
 )
 *  &  <
 {
 ?  }

GlobalETraining.com
Mastering Linux Command Line GlobaleTraining.com

20

File Names – File Extension


 File extension has no significance
 It only adds visual value.
 Example:
 myfile
 myfile.txt

GlobalETraining.com
Mastering Linux Command Line GlobaleTraining.com

21

7
11/19/2019

Understanding Linux Paths

GlobalETraining.com
Mastering Linux Command Line GlobaleTraining.com

22

Paths
 Parent Directory / (root)

 Sub-directory or Child-directory
 Absolute Paths
 Relative Paths
 ./ tmp bin etc sbin usr home var

 .
 ..
cat cd who john mary
 Home Directory
 ~
Myfile.txt dir2

GlobalETraining.com
Mastering Linux Command Line GlobaleTraining.com

23

Paths
/ (root)
Absolute Path Example
/home/john/Myfile.txt

Relative Path Example


tmp bin etc sbin usr home var ./Myfile.txt

~/Myfile.txt
cat cd who john mary
.  Current Directory
..  Parent Directory
Myfile.txt dir2
~  Home Directory
GlobalETraining.com
Mastering Linux Command Line GlobaleTraining.com

24

8
11/19/2019

DOTS
Hidden Files/Folders

 Filenames or directory names that start with a dot (.)

Command Purpose
 System/User level dot files
ls List contents of a folder
 .profile
ls –l Long list
 .exrc ls –a List hidden files also
 .bashrc
 DOT (.)

 Two DOTS (..)


GlobalETraining.com
Mastering Linux Command Line GlobaleTraining.com

25

Wild Cards
Special Character Purpose
* Match all character
? Match any one character
[] Match specified between [ and ]

GlobalETraining.com
Mastering Linux Command Line GlobaleTraining.com

26

You might also like