< Day Day Up > |
Recipe 9.6. Doing Batch Operations with chown9.6.1 ProblemYou want to change ownership of directories and their contents, or just the contents of directories, a list of files, or change ownership of files from one UID to another. 9.6.2 Solutionchown supports some batch operations, or you can use find, or you can use shell wildcards. To change several files at once with chown, use a space-delimited list: # chown carlas file.txt file2.txt file3.txt Alternatively, you can use shell wildcards: # chown carlas *.txt To give all of a user's files to another user, use: # chown -R -v —from valh piglet /shared/scripts You can do the same thing with find: # find / -user valh -exec chown -v piglet { } \; find can also search by UID, which chown cannot: # find / -uid 1050 -exec chown -v 1200 { } \; To change the ownership of a directory, including subdirectories and files, with verbose output, use: # chown -R -v piglet /shared/scripts
changed ownership of `scripts' to piglet
changed ownership of `scripts/backups.tgz' to piglet
changed ownership of `scripts/fake-spec-rpm' to piglet Either the user's login name or UID can be used. If you've deleted a user and the user has left behind orphan files, you'll need the UID. 9.6.3 See Also
|
< Day Day Up > |