Week - 3 1 Finding and Processing files 2 locate Queries a pre-built database of paths to files on the system Database must be updated by administrator.

Презентация:



Advertisements
Похожие презентации
Unit 2 Users Management. Users Every user is assigned a unique User ID number (UID) UID 0 identifies root User accounts normally start at UID 500 Users'
Advertisements

Browsing the Filesystem. Linux File Hierarchy Concepts Files and directories are organized into a single- rooted inverted tree structure Filesystem begins.
Running Commands & Getting Help. Running Commands Commands have the following syntax: command options arguments Each item is separated by a space Options.
Using Bash Shell. Command Line Shortcuts File Globbing Globbing is wildcard expansion: * - matches zero or more characters ? - matches any single character.
© 2005 Cisco Systems, Inc. All rights reserved.INTRO v Managing Your Network Environment Managing Cisco Devices.
Operators and Arithmetic Operations. Operators An operator is a symbol that instructs the code to perform some operations or actions on one or more operands.
USB Download Manual (v1.3) (GP2 Year 2010) LG Electronics/ LCD TV Division Feb. 17 th, Applied Models & Notice - File Copy - User Download Mode.
© 2009 Avaya Inc. All rights reserved.1 Chapter Two, Voic Pro Components Module Two – Actions, Variables & Conditions.
Unit 3 Text Processing and System Configuration tools.
PAT312, Section 21, December 2006 S21-1 Copyright 2007 MSC.Software Corporation SECTION 21 GROUPS.
A Bill is a proposal for a new law, or a proposal to change an existing law that is presented for debate before Parliament. Bills are introduced in either.
SPLAY TREE The basic idea of the splay tree is that every time a node is accessed, it is pushed to the root by a series of tree rotations. This series.
© 2005 Cisco Systems, Inc. All rights reserved. BGP v Route Selection Using Policy Controls Applying Route-Maps as BGP Filters.
HPC Pipelining Parallelism is achieved by starting to execute one instruction before the previous one is finished. The simplest kind overlaps the execution.
© 2006 Cisco Systems, Inc. All rights reserved. HIPS v Configuring Rules Rule Basics.
Inner Classes. 2 Simple Uses of Inner Classes Inner classes are classes defined within other classes The class that includes the inner class is called.
S5-1 PAT328, Section 5, September 2004 Copyright 2004 MSC.Software Corporation SECTION 5 RESULTS TITLE EDITOR.
Computers are a necessary part of modern life. Computers play an important role in the lives of most of us today, whether we realize it or not. Some people,
Copyright ® 2000 MSC.Software Results S17-1 PAT301, Section 17, October 2003 SECTION 17 FILE MANAGEMENT.
A new interface model for the Jazyki Mira typological database Oleg Belyaev The research is supported by RFBR grant ( а.
Транксрипт:

Week - 3 1

Finding and Processing files 2

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

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

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

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

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

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

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

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

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

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

The Gnome Search Tool Places -> Search for Files… Graphical tool for searching by Name Content Owner/group Size Modification time 13