Re: chmod equivalent to find commands
On Sat, Mar 12, 2005 at 06:53:59AM -0500, Fafa Diliha Romanova wrote: hello. i know there's an equivalent to these two find commands that can be summed up in one chmod command: find . -type d -exec chmod 755 {} \; find . -type f -exec chmod 644 {} \; The EXACT equivalent would be: find . -type d -exec chmod u=rwx,go=rx {} \; find . -type f -exec chmod u=rw,go=r {} \; But I take it that that isn't exactly what your looking for. Your probably looking for something like chmod -R u=rwX,go=rX . it fixes my permissions ... i haven't tested this yet but i think it's wrong: chmod -R u+rwX,a+rX This may work it depends on exactly what you need to do and how bad your permissions are messed up. Instead of a+rX, it might be better to do go+rX since you already have u covered, but I don't think it will make a big difference. Also, this adds to the existing permissions, it won't take away any permissions like my example earlier does. Lastly, the big difference between this and the find version is that the find version, both mine and yours, will set the execute bit on all directories and not on any normal files where the recursive chmod with the X permission with set the x permission on any file/directory that already has at least one type of execute permission already set and not on any other files or directories. So if your permissions are messed so badly that you have directories without any execute permission, this won't fix that. The find version on the other hand will ignore everything that is not a normal file or directory (i.e. fifos, sockets, device files), but this probably won't be a big deal either. The single recursive chmod I gave you will most likely be what you need. what would be the best solution here? thanks, -- fafa -- ___ Sign-up for Ads Free at Mail.com http://promo.mail.com/adsfreejump.htm ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to [EMAIL PROTECTED] -- I sense much NT in you. NT leads to Bluescreen. Bluescreen leads to downtime. Downtime leads to suffering. NT is the path to the darkside. Powerful Unix is. Public Key: ftp://ftp.tallye.com/pub/lorenl_pubkey.asc Fingerprint: CEE1 AAE2 F66C 59B5 34CA C415 6D35 E847 0118 A3D2 pgpeTFjDB1JLg.pgp Description: PGP signature
Re: chmod equivalent to find commands
On Sat, Mar 12, 2005 at 09:53:02PM +0200, Giorgos Keramidas wrote: On 2005-03-12 10:30, Eric McCoy [EMAIL PROTECTED] wrote: Fafa Diliha Romanova wrote: hello. i know there's an equivalent to these two find commands that can be summed up in one chmod command: find . -type d -exec chmod 755 {} \; find . -type f -exec chmod 644 {} \; Uhm, why? Even if that were possible, isn't clarity more important that stuffing as many actions as possible in one line? What you list above is similar to the way I use for changing the permissions of files/dirs and it works all the time. There's no reason to try to write one, long, complicated command just for the sake of making it one command instead of two. Otherwise, you may as well do more complex stuff like: Summing it up into one command does not neccessarily mean it's longer or more complicated. I use the following command all the time to fix permissions similar to what he seems to be doing. Though it's not technically equivalent, it's probably all he needs. chmod -R u=rwX,go=rX . My umask of 022 simplifies the command to the following: chmod -R =rwX . find . | while read line; do mode='' [ -d ${line} ] mode=0755 [ -f ${line} ] mode=0644 [ -n ${mode} ] echo chmod ${mode} \${line}\ done | sh But this is getting quickly very difficult to remember easily and repeat consistently every time you want to do something similar :) what would be the best solution here? I would do it the same way you do, but with xargs instead: find . -type X -print0 | xargs -0 chmod XXX This is an excellent way to do this, IMHO. If you were feeling crazy and use sh: find . | while read path; do \ if [ -d $path ]; then chmod 755; else chmod 644; fi; \ done I guess you meant to write: find . | while read path; do \ if [ -d $path ]; then chmod 755 ${path}; else chmod 644 ${path}; fi; \ done Otherwise, many chmod failures are the only result. But this has a minor buglet. It will change everything that is not a directory to mode 0644. This mode is ok for files, but it may not be ok (or it may even fail) for other stuff (symbolic links, for instance). - Giorgos ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to [EMAIL PROTECTED] -- I sense much NT in you. NT leads to Bluescreen. Bluescreen leads to downtime. Downtime leads to suffering. NT is the path to the darkside. Powerful Unix is. Public Key: ftp://ftp.tallye.com/pub/lorenl_pubkey.asc Fingerprint: CEE1 AAE2 F66C 59B5 34CA C415 6D35 E847 0118 A3D2 pgppl3wPpj89X.pgp Description: PGP signature
Re: chmod equivalent to find commands
On Sun, Mar 13, 2005 at 02:09:12AM -0800, Loren M. Lang wrote: On Sat, Mar 12, 2005 at 06:53:59AM -0500, Fafa Diliha Romanova wrote: hello. i know there's an equivalent to these two find commands that can be summed up in one chmod command: find . -type d -exec chmod 755 {} \; find . -type f -exec chmod 644 {} \; The EXACT equivalent would be: find . -type d -exec chmod u=rwx,go=rx {} \; find . -type f -exec chmod u=rw,go=r {} \; But I take it that that isn't exactly what your looking for. Your probably looking for something like chmod -R u=rwX,go=rX . And one last thing, I'm assuming your umask is probably 022. When chmod doesn't have the u, g, o, or a qualifies, then it uses the umask to mask the permission bits as appropriate so the command can be simplified to the following: chmod -R =rwX . it fixes my permissions ... i haven't tested this yet but i think it's wrong: chmod -R u+rwX,a+rX This may work it depends on exactly what you need to do and how bad your permissions are messed up. Instead of a+rX, it might be better to do go+rX since you already have u covered, but I don't think it will make a big difference. Also, this adds to the existing permissions, it won't take away any permissions like my example earlier does. Lastly, the big difference between this and the find version is that the find version, both mine and yours, will set the execute bit on all directories and not on any normal files where the recursive chmod with the X permission with set the x permission on any file/directory that already has at least one type of execute permission already set and not on any other files or directories. So if your permissions are messed so badly that you have directories without any execute permission, this won't fix that. The find version on the other hand will ignore everything that is not a normal file or directory (i.e. fifos, sockets, device files), but this probably won't be a big deal either. The single recursive chmod I gave you will most likely be what you need. what would be the best solution here? thanks, -- fafa -- ___ Sign-up for Ads Free at Mail.com http://promo.mail.com/adsfreejump.htm ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to [EMAIL PROTECTED] -- I sense much NT in you. NT leads to Bluescreen. Bluescreen leads to downtime. Downtime leads to suffering. NT is the path to the darkside. Powerful Unix is. Public Key: ftp://ftp.tallye.com/pub/lorenl_pubkey.asc Fingerprint: CEE1 AAE2 F66C 59B5 34CA C415 6D35 E847 0118 A3D2 -- I sense much NT in you. NT leads to Bluescreen. Bluescreen leads to downtime. Downtime leads to suffering. NT is the path to the darkside. Powerful Unix is. Public Key: ftp://ftp.tallye.com/pub/lorenl_pubkey.asc Fingerprint: CEE1 AAE2 F66C 59B5 34CA C415 6D35 E847 0118 A3D2 pgp8S8gtJsQUs.pgp Description: PGP signature
Re: chmod equivalent to find commands
Thank you for your kind assistance! That was exactly what I was looking for. But after the constructive response from many other kind souls on this list, I have decided to stick with my find command for now and keep your recursive chmod as an alternate. I keep a local mirror of all my modified configuration files (gives me easy backup and a great deal control over my system). I needed this command to quickly change permissions and ownership of the homedir I store them in. Thanks again! -- Fafa - Original Message - From: Loren M. Lang [EMAIL PROTECTED] To: Fafa Diliha Romanova [EMAIL PROTECTED] Subject: Re: chmod equivalent to find commands Date: Sun, 13 Mar 2005 02:09:12 -0800 On Sat, Mar 12, 2005 at 06:53:59AM -0500, Fafa Diliha Romanova wrote: hello. i know there's an equivalent to these two find commands that can be summed up in one chmod command: find . -type d -exec chmod 755 {} \; find . -type f -exec chmod 644 {} \; The EXACT equivalent would be: find . -type d -exec chmod u=rwx,go=rx {} \; find . -type f -exec chmod u=rw,go=r {} \; But I take it that that isn't exactly what your looking for. Your probably looking for something like chmod -R u=rwX,go=rX . it fixes my permissions ... i haven't tested this yet but i think it's wrong: chmod -R u+rwX,a+rX This may work it depends on exactly what you need to do and how bad your permissions are messed up. Instead of a+rX, it might be better to do go+rX since you already have u covered, but I don't think it will make a big difference. Also, this adds to the existing permissions, it won't take away any permissions like my example earlier does. Lastly, the big difference between this and the find version is that the find version, both mine and yours, will set the execute bit on all directories and not on any normal files where the recursive chmod with the X permission with set the x permission on any file/directory that already has at least one type of execute permission already set and not on any other files or directories. So if your permissions are messed so badly that you have directories without any execute permission, this won't fix that. The find version on the other hand will ignore everything that is not a normal file or directory (i.e. fifos, sockets, device files), but this probably won't be a big deal either. The single recursive chmod I gave you will most likely be what you need. what would be the best solution here? thanks, -- fafa -- ___ Sign-up for Ads Free at Mail.com http://promo.mail.com/adsfreejump.htm ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to [EMAIL PROTECTED] -- I sense much NT in you. NT leads to Bluescreen. Bluescreen leads to downtime. Downtime leads to suffering. NT is the path to the darkside. Powerful Unix is. Public Key: ftp://ftp.tallye.com/pub/lorenl_pubkey.asc Fingerprint: CEE1 AAE2 F66C 59B5 34CA C415 6D35 E847 0118 A3D2 2.dat -- ___ Sign-up for Ads Free at Mail.com http://promo.mail.com/adsfreejump.htm ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to [EMAIL PROTECTED]
Re: chmod equivalent to find commands
I think it's really best that I stick to my find commands. chmod -R u=rwX,go=rX . worked really fast but it also made all my files executable. Bad idea, asking for such a command. By the way, umask 022? What is meant by that? - Original Message - From: Loren M. Lang [EMAIL PROTECTED] To: Giorgos Keramidas [EMAIL PROTECTED] Subject: Re: chmod equivalent to find commands Date: Sun, 13 Mar 2005 02:15:00 -0800 On Sat, Mar 12, 2005 at 09:53:02PM +0200, Giorgos Keramidas wrote: On 2005-03-12 10:30, Eric McCoy [EMAIL PROTECTED] wrote: Fafa Diliha Romanova wrote: hello. i know there's an equivalent to these two find commands that can be summed up in one chmod command: find . -type d -exec chmod 755 {} \; find . -type f -exec chmod 644 {} \; Uhm, why? Even if that were possible, isn't clarity more important that stuffing as many actions as possible in one line? What you list above is similar to the way I use for changing the permissions of files/dirs and it works all the time. There's no reason to try to write one, long, complicated command just for the sake of making it one command instead of two. Otherwise, you may as well do more complex stuff like: Summing it up into one command does not neccessarily mean it's longer or more complicated. I use the following command all the time to fix permissions similar to what he seems to be doing. Though it's not technically equivalent, it's probably all he needs. chmod -R u=rwX,go=rX . My umask of 022 simplifies the command to the following: chmod -R =rwX . find . | while read line; do mode='' [ -d ${line} ] mode=0755 [ -f ${line} ] mode=0644 [ -n ${mode} ] echo chmod ${mode} \${line}\ done | sh But this is getting quickly very difficult to remember easily and repeat consistently every time you want to do something similar :) what would be the best solution here? I would do it the same way you do, but with xargs instead: find . -type X -print0 | xargs -0 chmod XXX This is an excellent way to do this, IMHO. If you were feeling crazy and use sh: find . | while read path; do \ if [ -d $path ]; then chmod 755; else chmod 644; fi; \ done I guess you meant to write: find . | while read path; do \ if [ -d $path ]; then chmod 755 ${path}; else chmod 644 ${path}; fi; \ done Otherwise, many chmod failures are the only result. But this has a minor buglet. It will change everything that is not a directory to mode 0644. This mode is ok for files, but it may not be ok (or it may even fail) for other stuff (symbolic links, for instance). - Giorgos ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to [EMAIL PROTECTED] -- I sense much NT in you. NT leads to Bluescreen. Bluescreen leads to downtime. Downtime leads to suffering. NT is the path to the darkside. Powerful Unix is. Public Key: ftp://ftp.tallye.com/pub/lorenl_pubkey.asc Fingerprint: CEE1 AAE2 F66C 59B5 34CA C415 6D35 E847 0118 A3D2 2.dat -- ___ Sign-up for Ads Free at Mail.com http://promo.mail.com/adsfreejump.htm ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to [EMAIL PROTECTED]
Re: chmod equivalent to find commands
On Sun, Mar 13, 2005 at 05:33:12AM -0500, Fafa Diliha Romanova wrote: I think it's really best that I stick to my find commands. chmod -R u=rwX,go=rX . worked really fast but it also made all my files executable. That should only of happened if they already had at least one execute bit set. Now if you mistyped it as a lower-case x, then it's garenteed to set the execute bit. Bad idea, asking for such a command. By the way, umask 022? What is meant by that? umask is used to mask off certain permission bits from being set when a file is created. Most files are created with permissions 666, but a umask of 022 will mask it to 644. For directories it would mask 777 to 755. Other common umask are 002, 027, and 077. Umask: 022 002 027 077 022 002 027 077 Start: 666 666 666 666 777 777 777 777 Finish: 644 664 640 600 755 775 750 700 The techninal operation is mode ~umask Now when you use the string =rwX instead of something like u=rwX, no qualifier in front of the =, +, or - sign, then it sets all bits minus what is masked off so a umask of 022 will prevent it from setting the write bit on group or other permissions. - Original Message - From: Loren M. Lang [EMAIL PROTECTED] To: Giorgos Keramidas [EMAIL PROTECTED] Subject: Re: chmod equivalent to find commands Date: Sun, 13 Mar 2005 02:15:00 -0800 On Sat, Mar 12, 2005 at 09:53:02PM +0200, Giorgos Keramidas wrote: On 2005-03-12 10:30, Eric McCoy [EMAIL PROTECTED] wrote: Fafa Diliha Romanova wrote: hello. i know there's an equivalent to these two find commands that can be summed up in one chmod command: find . -type d -exec chmod 755 {} \; find . -type f -exec chmod 644 {} \; Uhm, why? Even if that were possible, isn't clarity more important that stuffing as many actions as possible in one line? What you list above is similar to the way I use for changing the permissions of files/dirs and it works all the time. There's no reason to try to write one, long, complicated command just for the sake of making it one command instead of two. Otherwise, you may as well do more complex stuff like: Summing it up into one command does not neccessarily mean it's longer or more complicated. I use the following command all the time to fix permissions similar to what he seems to be doing. Though it's not technically equivalent, it's probably all he needs. chmod -R u=rwX,go=rX . My umask of 022 simplifies the command to the following: chmod -R =rwX . find . | while read line; do mode='' [ -d ${line} ] mode=0755 [ -f ${line} ] mode=0644 [ -n ${mode} ] echo chmod ${mode} \${line}\ done | sh But this is getting quickly very difficult to remember easily and repeat consistently every time you want to do something similar :) what would be the best solution here? I would do it the same way you do, but with xargs instead: find . -type X -print0 | xargs -0 chmod XXX This is an excellent way to do this, IMHO. If you were feeling crazy and use sh: find . | while read path; do \ if [ -d $path ]; then chmod 755; else chmod 644; fi; \ done I guess you meant to write: find . | while read path; do \ if [ -d $path ]; then chmod 755 ${path}; else chmod 644 ${path}; fi; \ done Otherwise, many chmod failures are the only result. But this has a minor buglet. It will change everything that is not a directory to mode 0644. This mode is ok for files, but it may not be ok (or it may even fail) for other stuff (symbolic links, for instance). - Giorgos ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to [EMAIL PROTECTED] -- I sense much NT in you. NT leads to Bluescreen. Bluescreen leads to downtime. Downtime leads to suffering. NT is the path to the darkside. Powerful Unix is. Public Key: ftp://ftp.tallye.com/pub/lorenl_pubkey.asc Fingerprint: CEE1 AAE2 F66C 59B5 34CA C415 6D35 E847 0118 A3D2 2.dat -- ___ Sign-up for Ads Free at Mail.com http://promo.mail.com/adsfreejump.htm -- I sense much NT in you. NT leads to Bluescreen. Bluescreen leads to downtime. Downtime leads to suffering. NT is the path to the darkside. Powerful Unix is. Public Key: ftp://ftp.tallye.com/pub/lorenl_pubkey.asc Fingerprint: CEE1 AAE2 F66C 59B5 34CA C415 6D35 E847 0118 A3D2 pgpL1VDKoE3jR.pgp Description: PGP signature
chmod equivalent to find commands
hello. i know there's an equivalent to these two find commands that can be summed up in one chmod command: find . -type d -exec chmod 755 {} \; find . -type f -exec chmod 644 {} \; it fixes my permissions ... i haven't tested this yet but i think it's wrong: chmod -R u+rwX,a+rX what would be the best solution here? thanks, -- fafa -- ___ Sign-up for Ads Free at Mail.com http://promo.mail.com/adsfreejump.htm ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to [EMAIL PROTECTED]
Re: chmod equivalent to find commands
Fafa Diliha Romanova wrote: hello. i know there's an equivalent to these two find commands that can be summed up in one chmod command: find . -type d -exec chmod 755 {} \; find . -type f -exec chmod 644 {} \; it fixes my permissions ... i haven't tested this yet but i think it's wrong: chmod -R u+rwX,a+rX what would be the best solution here? I would do it the same way you do, but with xargs instead: find . -type X -print0 | xargs -0 chmod XXX If you were feeling crazy and use sh: find . | while read path; do \ if [ -d $path ]; then chmod 755; else chmod 644; fi; \ done The latter is overkill, but the approach can be useful for nontrivial operations on systems that don't support -print0. It also has the benefit that you can do it over ssh without having to copy over a script, e.g. ssh [EMAIL PROTECTED] sh -s script.sh (No nightmares from having to double- or triple-escape special characters, either.) Sorry, I don't know how to do it all with chmod. I assume you've consulted the excellent FreeBSD man pages? ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to [EMAIL PROTECTED]
Re: chmod equivalent to find commands
In the last episode (Mar 12), Fafa Diliha Romanova said: i know there's an equivalent to these two find commands that can be summed up in one chmod command: find . -type d -exec chmod 755 {} \; find . -type f -exec chmod 644 {} \; it fixes my permissions ... i haven't tested this yet but i think it's wrong: chmod -R u+rwX,a+rX That chmod command should work just fine. -- Dan Nelson [EMAIL PROTECTED] ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to [EMAIL PROTECTED]
Re: chmod equivalent to find commands
On 2005-03-12 10:30, Eric McCoy [EMAIL PROTECTED] wrote: Fafa Diliha Romanova wrote: hello. i know there's an equivalent to these two find commands that can be summed up in one chmod command: find . -type d -exec chmod 755 {} \; find . -type f -exec chmod 644 {} \; Uhm, why? Even if that were possible, isn't clarity more important that stuffing as many actions as possible in one line? What you list above is similar to the way I use for changing the permissions of files/dirs and it works all the time. There's no reason to try to write one, long, complicated command just for the sake of making it one command instead of two. Otherwise, you may as well do more complex stuff like: find . | while read line; do mode='' [ -d ${line} ] mode=0755 [ -f ${line} ] mode=0644 [ -n ${mode} ] echo chmod ${mode} \${line}\ done | sh But this is getting quickly very difficult to remember easily and repeat consistently every time you want to do something similar :) what would be the best solution here? I would do it the same way you do, but with xargs instead: find . -type X -print0 | xargs -0 chmod XXX This is an excellent way to do this, IMHO. If you were feeling crazy and use sh: find . | while read path; do \ if [ -d $path ]; then chmod 755; else chmod 644; fi; \ done I guess you meant to write: find . | while read path; do \ if [ -d $path ]; then chmod 755 ${path}; else chmod 644 ${path}; fi; \ done Otherwise, many chmod failures are the only result. But this has a minor buglet. It will change everything that is not a directory to mode 0644. This mode is ok for files, but it may not be ok (or it may even fail) for other stuff (symbolic links, for instance). - Giorgos ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to [EMAIL PROTECTED]