Zusammenfassung der Ressource
103.3 Perform
basic file
management
- Introduction
- Everything in
Linux is a file,
- copy files
- delete files
- cover the
commands
associated with file
management.
- A file is an entity that
stores data and
programs.
- consists of content
and meta data
- file size, owner, creation
date, permissions
- types of files
- Regular files
- Directories
- Special files
- Manipulating Files
- Using ls to List Files
- ls
- -l
- -,:Regular file
d,: directory file
l: lnk file
- -lh
- human
- -a
- hidden files
- Creating, Copying,
Moving and
Deleting Files
- Create File
- touch file1
file2 file3
- touch -am file3
- -a option changes only the access
time, while the -m option changes
only the modification time.
- Copying Files
with cp
- cp file1 dir2
- Moving Files
with mv
- mv myfile.txt
/home/frank/Documents
- mv old_file_name
new_file_name
- -i: interactive
-f:forza
- Deleting Files
with rm
- rm file1
- rm -i file1
- rm -f file1
- rm file1 file2 file3
- Creating and Deleting
Directories
- Creating Directory
- mkdir dir1
- mkdir dir1 dir2 dir3
- mkdir -p parents/children
- Removing
Directories
- rmdir dir1
- rmdir dir1 dir2
- rmdir -p parents/children
- Recursive
Manipulation of
Files and
Directories
- ls -R mydirectory
- ls -R animal
- ls -R animal/
- Recursive
Copy with cp
-r
- tree mydir
- mkdir newcopy
- cp -r mydir
newcopy
- -r all the contents of mydir
including itself are copied into
newcopy.
- Recursive
Deletion with rm
-r
- rm
newcopy/
- rm -ri mydir/
- Recursive Interactive
- File Globbing and
Wildcards
- file globing
- File globbing is a feature provided by
the Unix/Linux shell to represent
multiple filenames by using special
characters called wildcards.
- Wildcards
- are essentially symbols which
may be used to substitute for
one or more characters
- *
- rm *: Delete all files in current working directory.
- ?
- ls l?st
- List all files with names
beginning with l followed
by any single character
and ending with st.
- []
- rmdir [a-z]*
- Remove all directories
whose name starts with a
letter.
- The
Asterisk
- find /home -name *.png
- ls lpic-*.txt
- cp -r animal/* forest
- rm *ate*
- The Question Mark
- ls l?st.txt
- ls ??st.txt
- Bracketed Characters
- ls l[aef]st.txt
- ls l[a-z]st.txt
- ls student-[0-9][A-Z].txt
- Combining Wildcards
- ls [plf]?st*
- ls f*[0-9]+.txt
- Guide Exercises
- touch dog cat
- mkdir animal
- mv dog cat -t animal/
- cd ~/Documents
- mkdir backup
- cp -r animal ~/Documents/backup
- mv animal/ animal.bkup
- ls db-[1-3].tar.gz
- rm cne*.pdf