Listing the Permissions of a File

To list a file's access permissions, use ls with the `−l' option. File access permissions appear in the first column of the output, after the character for file type.

Changing the Permissions of a File

To change the access mode of any file you own, use the chmod ("change mode") tool. It takes two arguments: an operation, which specifies the permissions to grant or revoke for certain users, and the names of the files to work on.

Finding files by matching patterns

The simplest way to find files is with GNU locate. Use it when you want to list all files on the system whose full path name matches a particular pattern−−for example, all files with the text `audio' somewhere in their full path name, or all files ending with `ogg'; locate outputs a list of all files on the system that match the pattern, giving their full path name. When specifying a pattern, you can use any of the file name expansion characters

Finding Files in a Directory Tree by Name

Use find to find files in a directory tree by name. Give the name of the directory tree to search through, and use the `−name' option followed by the name you want to find. · To list all files on the system whose file name is `top', type:

$ find / −name top RET

Finding Files in a Directory Tree by Size

To find files of a certain size, use the `−size' option, following it with the file size to match. The file size takes one of three forms: when preceded with a plus sign (`+'), it matches all files greater than the given size; when preceded with a hyphen or minus sign (`−'), it matches all files less than the given size; with neither prefix, it matches all files whose size is exactly as specified. (The default unit is 512−byte blocks; follow the size with `k' to denote kilobytes or `b' to denote bytes.)

Running Commands on the Files You Find

You can also use find to execute a command you specify on each found file, by giving the command as an argument to the `−exec' option. If you use the string `'{}'' in the command, this string is replaced with the file name of the current found file when the command executes. Mark the end of the command with the string `';''.

Finding the smallest or the largest files and directories

To list the contents of a directory with the smallest files first, use ls with both the `−S' and `−r' options, which reverses the sorting order of the listing.

Finding Where a Command Is Located

Use which to find the full path name of a tool or application from its base file name; when you give the base file name as an option, which outputs the absolute file name of the command that would have run had you typed it. This is useful when you are not sure whether or not a particular command is installed on the system.

Changing File Modification Time

Use touch to change a file's timestamp without modifying its contents. Give the name of the file to be changed as an argument. The default action is to change the timestamp to the current time.

Splitting a File into Smaller Ones

It's sometimes necessary to split one file into a number of smaller ones. For example, suppose you have a very large sound file in the near−CD−quality MPEG2, level 3 ("MP3") format. Your file, `large.mp3', is 4,394,422 bytes in size, and you want to transfer it from your desktop to your laptop, but your laptop and desktop are not connected on a network−−the only way to transfer files between them is by floppy disk. Because this file is much too large to fit on one floppy, you use split.

prev [1] [2] [3] [4] next
Items 11 - 20 of 34 displayed.

Back to Home page