Скачать презентацию
Идет загрузка презентации. Пожалуйста, подождите
Презентация была опубликована 9 лет назад пользователемАнастасия Пашкова
1 Week - 3 1
2 Finding and Processing files 2
3 locate Queries a pre-built database of paths to files on the system Database must be updated by administrator Full path is searched, not just file name May only search directories where the user has read and execute permission 3
4 Locate examples Locate passwd Search for files with passwd in the name or path Useful options -i performs a case-insensitive search -n x lists only the first x matches -e DIR1,DIR2,…. excludes the search from the directories DIR1,DIR2,etc. 4
5 find Find[dir1 dir2….][criteria….] Searches directory trees in real-time Slower but more accurate than locate CWD is used if no starting directory given All files are matched if no criteria given Can execute commands on found files May only search directories where the user has read and execute permission 5
6 Basic find Examples Find –name snow.png Search for files named snow.png in the current directory Find –iname snow.png Case-insensitive search for files named snow.png,snow.png,SNOW.PNG,etc. in the current directory Find/-name*.txt Search for files anywhere on the system that end in.txt Find/etc-name*pass* Search for files in /etc/that contain pass in their name Find/home-user joe –group joe Search for files owned by the user joe and group joe in /home/ 6
7 Find and Logical operators Criteria are ANDed together by default. Can be ORd or negated with –o or –not. Parentheses can be used to determine logic order, but must be escaped in bash Find –user joe –not –group joe Find –user joe –o-user jane Find –not \(-user joe –o-userjane\) 7
8 Find and permissions Can match ownership by name or id find/-user joe –o-uid 500 Can match octal or symbolic permissions Find –perm 755 Matches if mode is exactly 755 Find –perm +222 Matches if anyone can write Find –perm -222 Matches if everyone can write Find –perm -002 Matches if other can write 8
9 Find and Numeric criteria Many find criteria take numeric values Find –size 10M Files with a size of exactly 10 megabytes Find – size +10M Files with a size over 10 megabytes Find –size -10M Files with a size less than 10 megabytes Other modifiers are available such as k for KB, G for GB,etc. 9
10 Find and Access Times Find can match by inode timestamps -atime when file was last read -mtime when a file data last changed -ctime when file data or metadata last changed Value given is in days Find/tmp –ctime +10 Files changed more than 10 days ago Can use a value of minutes -amin -mmin -cmin Find/etc-amin
11 Executing commands with find Commands can be executed on found files Command must be preceded with –exec or –ok -ok prompts before acting on each file Commands must end with space\; Can use {} as a filename placeholder Find –size +100M –ok mv{} /tmp/largerfiles/ \; 11
12 Find and execution samples Find –name*.conf-exec cp{}.orig \; Backup configuration files from the current directory,adding a.orig extension Find /tmp –ctime +3 –user joe –ok rm {} \; Prompt to remove joes tmp files that are over 3 days old Find ~-perm -002 –exec chmod o –w {} \; Fix other writable files in your home directory Find /home –type d –ls Do an ls-l style listing of all directiories in /home/ Find /data –type f-perm 644 –name*.sh –ok chmod 755{} \; Find files that end in.sh found in the /data/directory with a current permission of 644, and ask to make them executable 12
13 The Gnome Search Tool Places -> Search for Files… Graphical tool for searching by Name Content Owner/group Size Modification time 13
Еще похожие презентации в нашем архиве:
© 2024 MyShared Inc.
All rights reserved.