Книга: Fedora™ Unleashed, 2008 edition
Changing File Access Permissions with chmod
Changing File Access Permissions with chmod
What you learned about chmod
earlier can be greatly extended through one simple parameter: -c
. This instructs chmod
to print a list of all the changes it made as part of its operation, which means you can capture the output and use it for other purposes. For example:
[paul@caitlin tmp]$ chmod -c 600 *
mode of `1.txt' changed to 0600 (rw-------)
mode of `2.txt' changed to 0600 (rw-------)
mode of `3.txt' changed to 0600 (rw-------)
[paul@caitlin tmp]$ chmod -c 600 *
[paul@caitlin tmp]$
There the chmod
command is issued with -c
, and you can see it has output the result of the operation: Three files were changed to rw-------
(read and write by user only).
However, when the command is issued again, no output is returned. This is because -c
prints only the changes that it made. Files that already match the permissions you are setting are left unchanged and therefore are not printed.
There are two other parameters of interest: --reference
and -R
. The first enables you to specify a file to use as a template for permissions rather than specifying permissions yourself. For example, if you want all files in the current directory to have the same permissions as the file /home/paul/myfile.txt
, you would use this:
$ chmod --reference /home/paul/myfile.txt *
You can use -R
to enable recursive operation, which means you can use it to chmod
a directory and it changes the permissions of that directory and all files and subdirectories under that directory. You could use chmod -R 600 /home
to change every file and directory under /home
to become read/write to their owners.
- Printing the Contents of a File with cat
- Changing Directories with cd
- Changing File Access Permissions with chmod
- Copying Files with cp
- Printing Disk Use with du
- Finding Files by Searching with find
- Searches for a String in Input with grep
- Paging Through Output with less
- Creating Links Between Files with ln
- Finding Files from an Index with locate
- Listing Files in the Current Directory with ls
- Reading Manual Pages with man
- Making Directories with mkdir
- Moving Files with mv
- Listing Processes with ps
- Deleting Files and Directories with rm
- Printing the Last Lines of a File with tail
- Printing Resource Usage with top
- Printing the Location of a Command with which
- Printing the Contents of a File with cat
- Finding Files from an Index with locate
- Практическая работа 53. Запуск Access. Работа с объектами базы данных
- Shared Cache file
- Безопасность внешних таблиц. Параметр EXTERNAL FILE DIRECTORY
- Chapter 13. rc.firewall file
- Using Double Quotes to Resolve Variables in Strings with Embedded Spaces
- Drawbacks with restore
- 7. AGGREGATION WITH INDEPENDENT WORKS
- Configure Access Control
- 4.3.3. Makefile Targets
- Запуск Access. Открытие учебной базы данных Борей