LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 10-11-2011, 08:38 AM   #1
trintukaz
Member
 
Registered: Sep 2011
Posts: 82

Rep: Reputation: Disabled
Read only files


Hello. I want to ask which command finds Read Only files I found information only about writable files.
 
Old 10-11-2011, 09:24 AM   #2
tshikose
Member
 
Registered: Apr 2010
Location: Kinshasa, Democratic Republic of Congo
Distribution: RHEL, Fedora, CentOS
Posts: 525

Rep: Reputation: 95
Hi,

Generally the find command is your friend. So man find to be familiarized.
That said, to find all the read-only (in reality readable and not writable) files on a folder launch
find /path/to/folder -perm 444 -a ! -perm 222

Regards,

Tshimanga
 
Old 10-11-2011, 09:41 AM   #3
tronayne
Senior Member
 
Registered: Oct 2003
Location: Northeastern Michigan, where Carhartt is a Designer Label
Distribution: Slackware 32- & 64-bit Stable
Posts: 3,541

Rep: Reputation: 1065Reputation: 1065Reputation: 1065Reputation: 1065Reputation: 1065Reputation: 1065Reputation: 1065Reputation: 1065
You may want to use the find utility with the -perm option; e.g.,
Code:
find / -type f -perm 444
The 444 means read only for owner, group and public.

You use the octal values that you would use with chmod; e.g.,
Code:
chmod 755 file                   (rwx for owner, rx for group, rx for public)
chmod 644 file                   (rw  for owner, r  for group, r  for public)
and so on.

Hope this helps some.
 
Old 10-11-2011, 10:16 AM   #4
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 10,007

Rep: Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191
You may need to think about exactly what you want a little more, ie what if the file is readable and executable but not writable (something like 544 for perms).
 
Old 10-11-2011, 12:22 PM   #5
trintukaz
Member
 
Registered: Sep 2011
Posts: 82

Original Poster
Rep: Reputation: Disabled
Quote:
find / -type f -perm 444
This command shows files which have permission read only for user,group or others but i need find files which have permission read only by all of them.
 
Old 10-11-2011, 02:39 PM   #6
bgeddy
Senior Member
 
Registered: Sep 2006
Location: Liverpool - England
Distribution: slackware64 13.37 and -current, Dragonfly BSD
Posts: 1,810

Rep: Reputation: 232Reputation: 232Reputation: 232
How about this:-
Code:
find / -type f -perm /444 -a -not -perm /222
The / in front of the perm means find stuff with any of the bits set so this finds type file with any read bit set and no write bits set. So file that are readable by someone and writeable by no one.
 
Old 10-11-2011, 11:34 PM   #7
trintukaz
Member
 
Registered: Sep 2011
Posts: 82

Original Poster
Rep: Reputation: Disabled
Thank you.
 
  


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



Similar Threads
Thread Thread Starter Forum Replies Last Post
samba does not keep windows attributes (read only files as read only for example) golden_boy615 Linux - General 3 07-17-2011 06:44 PM
Trouble with making a bash script to read in different files and rename output files. rystke Linux - Software 1 05-07-2009 08:00 AM
Shell programming: Question about source files and read data from the files ccwq Programming 3 08-05-2007 12:13 AM
mozzla problems-can not read files online, can not read attachments sarajevo Linux - Software 1 09-20-2005 06:58 PM
How program to read files with extension .dat y .cfg files COMTRADE in fedora 1? ivonne Linux - Software 0 11-22-2004 11:42 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 12:59 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