You are on page 1of 16

Creating Directory

#mkdir –p test01/test02
#mkdir –p /par/{son,daughter}
Creating file
Removing files
• The rm filename or rm –i filename command
is used to delete files with confirmation message, type “yes”
to accept delete files or “no” to cancel.
• File deletion is permanent!

By Msc. Khiev Sopheaktra Chapter 03: Module3-Working with Files and Directories 3
Removing files
• The rm –f filename command is used to force delete
files with no confirmation message.
• File deletion is permanent!

By Msc. Khiev Sopheaktra Chapter 03: Module3-Working with Files and Directories 4
Removing files
• Delete directories with the rm –r or -R parent
directory-name to descend delete directories with
confirmation.

By Msc. Khiev Sopheaktra Chapter 03: Module3-Working with Files and Directories 5
Removing files
• Delete directories with the rm –rf or rm -fr parent
directory-name to force delete directories with no
confirmation.

By Msc. Khiev Sopheaktra Chapter 03: Module3-Working with Files and Directories 6
Removing files
• rmdir directory-name is used to delete empty
directory.

By Msc. Khiev Sopheaktra Chapter 03: Module3-Working with Files and Directories 7
Coping File
Coping File
• Use –v option to display copy process
Coping File
• Use –i to prompt before overwrites. i: interactive
yes: Overwrite
no: Don’t overwrite (doesn’t copy)
Common ls options
• Many options to the ls command, including:
• -a – display all files, including hidden files

• -l – long display listing

By Msc. Khiev Sopheaktra Chapter 03: Module3-Working with Files and Directories 11
Common ls options
-rw-rw-r--
A regular file, readable and writeable by owner user and group,
but only readable by everybody else.
drwxr-xr-x
Note that the d above indicates that the permissions are for a
directory (i.e. the file's type is a directory).
This directory is readable, writeable, and executable (grants
permission to execute the file) by “user" whilst only readable and
executable by "group" and "other".

By Msc. Khiev Sopheaktra Chapter 03: Module3-Working with Files and Directories 12
Common ls options
• -R – Recursive: list subdirectories recursively

By Msc. Khiev Sopheaktra Chapter 03: Module3-Working with Files and Directories 13
Common ls options
• -S – Sort output based on file size (from bigger to smaller)

By Msc. Khiev Sopheaktra Chapter 03: Module3-Working with Files and Directories 14
Common ls options
• -Sr – Sort output based on file size (from smaller to bigger);
r: reverse
• Slh - Sort output based on file size with long listing format,
human readable; h: human readable

By Msc. Khiev Sopheaktra Chapter 03: Module3-Working with Files and Directories 15
Common ls options
• -t – Sort output based on modification time (Current
modify--before current)
• -tl- Sort output based on modification
time with long listing format

By Msc. Khiev Sopheaktra Chapter 03: Module3-Working with Files and Directories 16

You might also like