Linux - GeneralThis Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I run a small network at a school consisting of a linux red hat 9 box running squid, samaba, dansguardian, etc.
We have a office management program that we use for attendance, grades, family info, etc. Updates for this program come out from time to time and must be installed. So... When I run the update it changes the permissions on all the files in the directory, say /123
What I want to know is how can i change all the files, directories, etc underneath /123 to read/write at the same time without having to go to each file/directory manually and change them?
I assume "find /123" will find the directory /123 and the "chmod u+rw" means to change it to read and write for everyone?
what does -print0 | xargs -0 chmod u+rw actaully mean?
Thanks again for the quick reply and the time saver!
The -type f (or d) only selects normal files (f) or directories (d). /123 is the starting point, all subdirs are checked too.
The -exec ... {} \; part makes it possible to execute a 'normal' command, chmod in this case.
Hope this is what you want, try it first on a non essential directory
find /123 will find the directory /123 and all subdirectories and files below
-print0 will print the files with a trailing [00] byte, that's important if you have spaces or strange characters in your filenames
| xargs -0 will pipe the file and directory names found, one at a time, to the command specified thereafter
chmod u+rw will add read and write the users permissions
so it boils down to
chmod u+rw /123
chmod u+rw /123/file 1
chmod u+rw /123/file 2
chmod u+rw /123/dir1
chmod u+rw /123/dir1/file 3
Thank you to both responders, the future just got easier for me! I did print off obth ways of doing it and will experiement with the one i didnt use at a later time.
You could also just use the -R (recursive) flag to chmod (though if you want to limit it to just regular files (or directories), then obviously 'find ... -type ...' is the way to go).
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.