LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Remove Permission Help needed. (https://www.linuxquestions.org/questions/linux-newbie-8/remove-permission-help-needed-847136/)

pinga123 11-29-2010 12:27 AM

Remove Permission Help needed.
 
How would i remove rwx permission for group and other users for all hidden files (except . and ..) inside /root using a one line command.

I have tried below command.
Code:

# chmod og-rwx /root/.*
but this has removed rwx permission for . and .. files .

As a result
Code:

# ls -ld /root
drwx------ 3 root root 4096 Nov 26 14:03 /root


jrtayloriv 11-29-2010 12:45 AM

<redacted -- please delete>

pinga123 11-29-2010 02:25 AM

Quote:

Originally Posted by pinga123 (Post 4174243)
How would i remove rwx permission for group and other users for all hidden files (except . and ..) inside /root using a one line command.

I have tried below command.
Code:

# chmod og-rwx /root/.*
but this has removed rwx permission for . and .. files .

As a result
Code:

# ls -ld /root
drwx------ 3 root root 4096 Nov 26 14:03 /root


following command worked for me.
Code:

cd /root; ls -A | grep '^\.' | xargs chmod og-rwx

honeybadger 11-29-2010 02:53 AM

Sorry, did not read the post properly :(. I apologize.

unSpawn 11-29-2010 04:44 PM

Quote:

Originally Posted by pinga123 (Post 4174243)
Code:

# chmod og-rwx /root/.*

What you should have done instead is run 'chmod og-rwx -R /root' (recursive, no wildcards).

Next time you think globbing is a Good Thing try running 'eval' (as in 'eval echo /root/.*') on the target or 'for ITEM in `eval echo /root/.*`; do readlink -f "${ITEM}"; done'. Else just remember "/." stands for the current directory ("/root" in your example) and "/.." for its parent directory (which would be "/"). I hope you see that using wildcards may well result in Something Completely Different than what you think you may expect...


All times are GMT -5. The time now is 08:17 AM.