LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
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, 07: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, 09: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-24-2008, 12:42 AM   #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-24-2008, 12:51 AM   #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, 01: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, 01: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, 01:23 AM   #7
linuxlover.chaitanya
Senior Member
 
Registered: Apr 2008
Location: Nagpur, India
Distribution: Cent OS 5/6, Ubuntu Server 10.04
Posts: 4,629

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

find . -perm 200
 
Old 11-24-2008, 01:26 AM   #8
linuxlover.chaitanya
Senior Member
 
Registered: Apr 2008
Location: Nagpur, India
Distribution: Cent OS 5/6, Ubuntu Server 10.04
Posts: 4,629

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, 01: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 01:30 AM.
 
Old 11-24-2008, 01: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, 01: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, 01: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, 02: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, 02: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, 02: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 03:02 AM.
 
  


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


All times are GMT -5. The time now is 10:34 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration