Mapa mental
103.3 Perform basic file management
Contenido del mapa
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
- consists of content and meta data
- types of files
- Regular files
- Directories
- Special files
- Everything in Linux is a file,
Manipulating Files
- Using ls to List Files
- ls
- -l
- -,:Regular file d,: directory file l: lnk file
- -lh
- human
- -a
- hidden files
- -l
- ls
- 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.
- Create File
- 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
- mv myfile.txt /home/frank/Documents
- Deleting Files with rm
- rm file1
- rm -i file1
- rm -f file1
- rm file1 file2 file3
- rm -f file1
- rm -i file1
- rm file1
- Using ls to List Files
Creating and Deleting Directories
- Creating Directory
- mkdir dir1
- mkdir dir1 dir2 dir3
- mkdir -p parents/children
- mkdir dir1 dir2 dir3
- mkdir dir1
- Creating Directory
Removing Directories
- rmdir dir1
- rmdir dir1 dir2
- rmdir -p parents/children
- rmdir dir1 dir2
- rmdir dir1
Recursive Manipulation of Files and Directories
- ls -R mydirectory
- ls -R animal
- ls -R animal/
- ls -R animal
- ls -R mydirectory
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
- rm -ri mydir/
- rm newcopy/
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.
- ls l?st
- []
- rmdir [a-z]*
- Remove all directories whose name starts with a letter.
- rmdir [a-z]*
- *
- are essentially symbols which may be used to substitute for one or more characters
- 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
- file globing
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
- cp -r animal ~/Documents/backup
- mkdir backup
- ls db-[1-3].tar.gz
- rm cne*.pdf
Información
- Descripción
- 103.3 Perform basic file management
- Creado por
- Rolando Martinez
- Visitas
- 15
- Etiquetas
- Valoración