Вы находитесь на странице: 1из 29

3101 SUSE Linux Enterprise

11 Fundamental

Managing Linux File System,


Objectives:
In this topics we will see about .
Understand the File System Hierarchy Standard (FHS)
Manage Directories with CLI
Create and View Files
Work with Files and Directories
Use whereis command
Search File Content using GUI
Understand the File System
Hierarchy Standard (FHS)
Filename in Linux can be up to 255 character long
Certain characters (the dollar sign $, the
semicolon ;, or the space, for example) have a
special meaning
Linux differentiates between upper-case and
lower-case letters.
For example, the file names file, FILE and File
refer to three different files
The Hierarchical Structure of the File
System
It begins at the root directory (/)
FHS (File System Hierarchy
Standard)
Device Files (/dev)
Each hardware component in the system
(such as hard drive partitions, CD drives,
printer, and mouse) is represented as a
file in the /dev directory.

You can view them via YaST or command


line.
ls l /dev/sda*
Or you can get into the /dev/ directory and
display them with ls -l
Configuration file
Located at /etc/ directory
ls l /etc/

You can see all the directory that are


located underneath /root
Manage Directories with CLI
Change Directories and List Directory
Contents Using the CLI
cd :- change directory
A command used to change between
directories
ls (list short)
List specified files
Pwd command
Stands for print working directory
Create and View Files
Creating a new file with touch
You can use the touch command to change the
time stamp of a file or to create a new
file with a size of 0 bytes. The following are
the most important options:
-a changes only the time stamp
-m changes the only the last modification
Additional Note
touch [option] file_name(s)
to modify both the access and modification
time you can use both am option
To change the date and time files being
accessed
Use touch d [[CC]YY]MMDDhhmm[.ss]
View a file with cat
You can use the cat command
(concatenate) to view the contents of a
file.
For example to view the content of the
permissions.local file in the root
directory /etc, you would enter
cat/etc/permissions.local
Work with Files and Directories

Move files using , mv command


syntax: mv[filename] [destinationDirectory]
Use full path to destination directory
NB:Check if the file is found in the old
directory
Copy files and directories with cp
Syntax: cp [filename] [destination]
NB: If source is left , it assumes the current
users home as source.
Check if the file is found in both directory
Copy files ,directory &
subdirecory
To copy with all its subdirectories use R
option.
Create a folder called Cisco under your
home directory
Under cisco create a subdirectory of
CCNA
CCNP
CCIE

NB: to see the list of files in directory use ls -a


Copy Cisco and its subdirectory on EEP
Double check if Cisco directory is available in
both Home and EEP directory
Move Cisco and its Subdirectory to your
Desktop.
Now check if the directory called Cisco is in
your Desktop and removed from your home
directory
Rename using mv
You have copied the FinalBudget.txt to
EEP directory, now rename it
2017_Budget.txt in the same folder
Mv [old_FileName][New_FileName]
Make and delete directory
Mkdir [option]
ex. Mkdir p budget/July will create a full
path for the directory budge
..delete dirctories
Rmdir [dirctoryName], if the directory is
empty
If the directory is not empty it will not allow
you to remove it unless
you remove the inside directory
Syntax: rmdir[option][directoryName]
..deleting files
Since file will not have subdirectories,
removing or deleting the file didnt require
to use force removal mechanism
Syntax: rm [filename]
NB: Dont forget to include the file extension
To Delete Directory use rmdir [option]
Find files on Linux
If the name of the file is not completely
known, you can use the two wildcards ?
(for any character) and * (for none, one, or
several characters).
File names are case sensitive. As a result,
the file name file1,File1 and FILE1 are
refer to 3 different files
Due to its complexity more on module 3
Use the whereis command
The whereis command returns the binaries
(option -b), manual pages (option -m), and the
source code (option -s) of the specified command.
If no option is used, all this information is returned,
provided the information is
available. This command is faster than find, but it
is less thorough.

Whereis b grep
To know more about whereis command use
Man whereis

Exam oriented command:


To find the full path of the command, use switch
command
Use the switch command
The which command searches all paths
listed in the variable PATH for the
specified command and returns the full
path of the command.
In the variable PATH, the most important
directories are listed where the shell looks
for executable files.
To find the exact path of command find,
Which find
Search file content
Suppose you have dozens of text files and
you need to find all files that include a
particular word, phrase, or item.
To scan these files without opening them
in an editor, you need to know how to do
the following:
Thank you !

Вам также может понравиться