LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 11-29-2010, 12:27 AM   #1
pinga123
Member
 
Registered: Sep 2009
Posts: 684
Blog Entries: 2

Rep: Reputation: 36
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
 
Old 11-29-2010, 12:45 AM   #2
jrtayloriv
Member
 
Registered: Jun 2004
Location: Inland NW, US
Distribution: Ubuntu
Posts: 365
Blog Entries: 1

Rep: Reputation: 44
<redacted -- please delete>

Last edited by jrtayloriv; 11-29-2010 at 12:47 AM. Reason: oops, n,
 
Old 11-29-2010, 02:25 AM   #3
pinga123
Member
 
Registered: Sep 2009
Posts: 684
Blog Entries: 2

Original Poster
Rep: Reputation: 36
Quote:
Originally Posted by pinga123 View Post
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
 
Old 11-29-2010, 02:53 AM   #4
honeybadger
Member
 
Registered: Aug 2007
Location: India
Distribution: Slackware (mainly) and then a lot of others...
Posts: 855

Rep: Reputation: Disabled
Sorry, did not read the post properly . I apologize.

Last edited by honeybadger; 11-29-2010 at 02:58 AM.
 
Old 11-29-2010, 04:44 PM   #5
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,335
Blog Entries: 55

Rep: Reputation: 3535Reputation: 3535Reputation: 3535Reputation: 3535Reputation: 3535Reputation: 3535Reputation: 3535Reputation: 3535Reputation: 3535Reputation: 3535Reputation: 3535
Quote:
Originally Posted by pinga123 View Post
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...
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Need to remove Group write permission . pinga123 Linux - Newbie 2 10-22-2010 04:59 AM
Remove execution permission for users sijeeshkt Linux - General 5 04-03-2010 06:45 AM
How To Remove 'Other' Folder Installed Without Permission taurusx5 Linux - Software 2 08-16-2008 11:41 AM
Lost permission on folder-how to remove it tritonw Fedora 3 01-21-2008 10:21 PM
file permission help needed arka Linux - Newbie 1 12-24-2002 06:44 AM


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

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration