Removing a File with a Strange Name

Files with strange characters in their names (like spaces, control characters, beginning hyphens, and so on) pose a problem when you want to remove them. There are a few solutions to this problem.




File Ownership

Every file belongs to both a user and a group−−usually to the user who created it and to the group the user was working in at the time (which is almost always the user's login group). File ownership determines the type of access users have to  particular files




Controlling Access to Files

Each file has permissions that specify what type of access to the file users have. There are three kinds of permissions: read, write, and execute. You need read permission for a file to read its contents, write permission to write changes to or remove it, and execute permission to run it as a program




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.




Write−Protecting a File

If you revoke users' write permissions for a file, they can no longer write to or remove the file. This effectively "write−protects" a file, preventing accidental changes to it. A write−protected file is sometimes called a "read only" file.




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.)




How to find files in a directory by modification Time

To find files last modified during a specified time, use find with the `−mtime' or `−mmin' options; the argument you give with `−mtime' specifies the number of 24−hour periods, and with `−mmin' it specifies the number of minutes.




prev [1] [2] [3] [4] [5] [6] [7] [8] next
Items 31 - 40 of 73 displayed.

Back to Home page