LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This 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


Reply
  Search this Thread
Old 01-17-2011, 11:50 PM   #1
Xeratul
Senior Member
 
Registered: Jun 2006
Location: UNIX
Distribution: FreeBSD
Posts: 2,658

Rep: Reputation: 255Reputation: 255Reputation: 255
How to check and fix the permissions to avoid writing (chmod o-rwx /home/*)


Hello,

I would like not check first, and if not ok, then to write the permssisions. Means no use to write endessly on disk if not needed.
How to check and fix the permissions to avoid writing (chmod o-rwx /home/*) ?

thanks is someone has any ideas for shortest linux solutions?


Thank you in advance!
Cheers
 
Old 01-18-2011, 01:30 AM   #2
cin_
Member
 
Registered: Dec 2010
Posts: 281

Rep: Reputation: 24
Code:
# stat /home/* --printf=%A"\n"
drwxr-xr-x
drwxr-xr-x
drwxr-xr-x
drwxr-xr-x
# stat /home/* --printf=%a"\n"
755
755
755
755
#
Seems the best way to get the information, check man stat for more formatting options...

From there I'd write a script that only calls the files necessary and chmod's them.

The 'o-rwx' argument suggests that you want to make the files wholly unavailable by groupid... what you could do is alter the umask() for each user, to avoid doing this again in the future.
 
Old 01-18-2011, 06:44 PM   #3
A.Thyssen
Member
 
Registered: May 2006
Location: Brisbane, Australia
Distribution: linux
Posts: 158

Rep: Reputation: 44
Another method is using perl...
Code:
  perl -e 'printf "%o\n", (stat(shift))[2];' ~
  40755
the '40000' means it is a directory. Note you need to print in Octal!


I wrote a script that reads a separate meta file to ensure my whole home has correct permissions depending on location (public or private), executable status, and allow me to say things like
bin/ -- all executable files
bin/admin/ -- private executable scripts
bin/admin/*.template -- non-executable data for a mailing script

Though the data in my permission file looks like...
Code:
#                           DIRS  EXEC  DATA
bin/                         755   755   644    R
bin/admin/                   700   700   700
bin/admin/*.template                     600
The columns are direction, executable, datafile permissions and 'R' mean recurse into deeper sub-directories (directory, which end in '/', specifications only).

My permissions script "do_perms" has works for me for years, though I am looking for a better program, or improvements that would allow me to specify specific what files I am refering to better, without me needing to specify EVERY file.

Last edited by A.Thyssen; 01-18-2011 at 07:03 PM. Reason: additional
 
  


Reply



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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
% chmod a+rwx HelloWorld! PersonaErazed LinuxQuestions.org Member Intro 1 07-17-2008 09:07 PM
Samba Permissions - RWX for all Users joshnya Linux - Newbie 2 05-17-2005 11:28 AM
RWX permissions w/ Knoppix? suprpenguin04 Linux - General 1 11-02-2004 11:41 AM
chmod a-rwx dinesh_p_v cat > dinesh_p_v I am a root user murugesan Linux - Software 0 04-07-2004 12:58 AM
WinXp and Redhat Sharing RWX permissions mickboda Linux - General 1 03-14-2004 04:41 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 09:25 PM.

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
Open Source Consulting | Domain Registration