LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
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-23-2008, 06:22 AM   #1
babu198649
Member
 
Registered: Oct 2007
Posts: 160

Rep: Reputation: 30
find files that has write permission


Hi
i want to find the files which have write permission.To use the -perm switch of the find command i should know all the modes of the file.

But i want to list files that have write permission(other modes are not considered). How to write this command.

Thank you
 
Old 11-23-2008, 08:48 AM   #2
BlueC
Member
 
Registered: Aug 2007
Posts: 122

Rep: Reputation: 17
How about...

Code:
find . -perm /200
AFAIK that should return all files that have write permissions by the owner.

These are two different ways to achieve the same thing:

Code:
find . -perm /u+w
find . -perm /u=w
 
Old 11-23-2008, 11:42 PM   #3
babu198649
Member
 
Registered: Oct 2007
Posts: 160

Original Poster
Rep: Reputation: 30
I get error
/home/mrpg:$ find . -perm /200
find: invalid mode `/200'

/home/mrpg:$ find . -perm /u=w
find: invalid mode `/u=w'
 
Old 11-23-2008, 11:51 PM   #4
billymayday
LQ Guru
 
Registered: Mar 2006
Location: Sydney, Australia
Distribution: Fedora, CentOS, OpenSuse, Slack, Gentoo, Debian, Arch, PCBSD
Posts: 6,678

Rep: Reputation: 122Reputation: 122
That works for me. What distro are you using? What version of find? What is the filesystem?
 
Old 11-24-2008, 12:10 AM   #5
babu198649
Member
 
Registered: Oct 2007
Posts: 160

Original Poster
Rep: Reputation: 30
What distro are you using?
RHEL4

What version of find?
/home/mrpg:$ find -version
GNU find version 4.1.20



What is the filesystem?
/home/mrpg:$ df -Th
Filesystem Type Size Used Avail Use% Mounted on
/dev/mapper/VolGroup00-LogVol00
ext3 27G 21G 4.1G 84% /
/dev/sda3 ext3 99M 13M 82M 14% /boot
none tmpfs 502M 0 502M 0% /dev/shm
 
Old 11-24-2008, 12:20 AM   #6
billymayday
LQ Guru
 
Registered: Mar 2006
Location: Sydney, Australia
Distribution: Fedora, CentOS, OpenSuse, Slack, Gentoo, Debian, Arch, PCBSD
Posts: 6,678

Rep: Reputation: 122Reputation: 122
That is strange. I can copy and paste those usages and they work.

My find is only 4.2.27, so not that much later.

Just check you man page that yours supports that syntax.
 
Old 11-24-2008, 12:23 AM   #7
linuxlover.chaitanya
Senior Member
 
Registered: Apr 2008
Location: Gurgaon, India
Distribution: Cent OS 6/7
Posts: 4,631

Rep: Reputation: Disabled
With the same version of RHEL and find the following works for me:

find . -perm 200
 
Old 11-24-2008, 12:26 AM   #8
linuxlover.chaitanya
Senior Member
 
Registered: Apr 2008
Location: Gurgaon, India
Distribution: Cent OS 6/7
Posts: 4,631

Rep: Reputation: Disabled
But the ubuntu desktop supports the command 'as it is'.
This could be due the old find. The new find supports -perm using / but the older does not.
 
Old 11-24-2008, 12:28 AM   #9
billymayday
LQ Guru
 
Registered: Mar 2006
Location: Sydney, Australia
Distribution: Fedora, CentOS, OpenSuse, Slack, Gentoo, Debian, Arch, PCBSD
Posts: 6,678

Rep: Reputation: 122Reputation: 122
I thought that could be the case - hence my man page suggestion. But try

Code:
find . -perm +u=w
Code:
       -perm +mode
              Deprecated,  old  way of searching for files with any of the permission bits in mode set.  You
              should use -perm /mode instead. Trying to use the '+' syntax with symbolic  modes  will  yield
              surprising  results.   For example, '+u+x' is a valid symbolic mode (equivalent to +u,+x, i.e.
              0111) and will therefore not be evaluated as -perm +mode but instead as the exact mode  speci-
              fier  -perm mode and so it matches files with exact permissions 0111 instead of files with any
              execute bit set.  If you found this paragraph confusing, you're not alone  -  just  use  -perm
              /mode.  This form of the -perm test is deprecated because the POSIX specification requires the
              interpretation of a leading '+' as being part of a symbolic mode, and so we switched to  using
              '/' instead.

Last edited by billymayday; 11-24-2008 at 12:30 AM.
 
Old 11-24-2008, 12:30 AM   #10
babu198649
Member
 
Registered: Oct 2007
Posts: 160

Original Poster
Rep: Reputation: 30
hi
The man page of find says

-perm mode
File’s permission bits are exactly mode (octal or symbolic).
Symbolic modes use mode 0 as a point of departure.


There is no information about the "/" .Is it possible for me to list the files with write permissions.
 
Old 11-24-2008, 12:32 AM   #11
billymayday
LQ Guru
 
Registered: Mar 2006
Location: Sydney, Australia
Distribution: Fedora, CentOS, OpenSuse, Slack, Gentoo, Debian, Arch, PCBSD
Posts: 6,678

Rep: Reputation: 122Reputation: 122
Sorry - was adding to my post above while you posted. See above.
 
Old 11-24-2008, 12:43 AM   #12
babu198649
Member
 
Registered: Oct 2007
Posts: 160

Original Poster
Rep: Reputation: 30
Thanks billymayday,

I get the following output when my pwd is /tmp folder

/home/mrpg:$ find . -perm +u=w
.
./keyring-1fRJXf
find: ./keyring-1fRJXf: Permission denied
./hci.active.proc.6775


I dont want to list the files that i dont have Permission.But still i get Permission denied message .How to list only files which i have write Permission.
 
Old 11-24-2008, 01:15 AM   #13
billymayday
LQ Guru
 
Registered: Mar 2006
Location: Sydney, Australia
Distribution: Fedora, CentOS, OpenSuse, Slack, Gentoo, Debian, Arch, PCBSD
Posts: 6,678

Rep: Reputation: 122Reputation: 122
That's an error message, so you could use

Code:
find . -perm +u=w 2>&1
 
Old 11-24-2008, 01:38 AM   #14
babu198649
Member
 
Registered: Oct 2007
Posts: 160

Original Poster
Rep: Reputation: 30
I get error messages

/home/mrpg:$ find . -perm +u=w 2>&1
.
./keyring-1fRJXf
find: ./keyring-1fRJXf: Permission denied
./hci.active.proc.6775
 
Old 11-24-2008, 01:44 AM   #15
billymayday
LQ Guru
 
Registered: Mar 2006
Location: Sydney, Australia
Distribution: Fedora, CentOS, OpenSuse, Slack, Gentoo, Debian, Arch, PCBSD
Posts: 6,678

Rep: Reputation: 122Reputation: 122
Changed

Try

find . -perm +u=w 2>/dev/null

Last edited by billymayday; 11-24-2008 at 02:02 AM.
 
  


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
cdrom files: no write permission foodhater Linux - Hardware 4 11-17-2005 05:59 AM
Python CGI script can't write files, permission denied The_Nerd Programming 4 03-17-2005 12:19 PM
no write permission? santasballz Linux - Newbie 1 02-12-2004 11:26 PM
Keep getting "Permission Denied" when trying to write files dunnd40 Debian 2 02-01-2004 10:29 AM
No Write Permission... cabrone Linux - Newbie 4 09-15-2003 02:44 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 08:30 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
Open Source Consulting | Domain Registration