LinuxQuestions.org
Visit Jeremy's Blog.
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 10-05-2009, 02:15 AM   #1
grayFalcon
Member
 
Registered: Jan 2003
Distribution: Debian
Posts: 69

Rep: Reputation: 15
cp: cannot stat: Permission denied, even though file is 644?


Hello everybody!

I've got a funny problem: I have some files lying around in /root/bla/, all these files are 644 and /root/bla/ is 755. Still, when I try (as a different user) to cp /root/bla/file ., I get a "cp: cannot stat: Permission denied". I also cannot ls /root/bla/, I also get a Permission denied... what gives?

Thanks a lot in advance,
grayFalcon
 
Old 10-05-2009, 02:27 AM   #2
smeezekitty
Senior Member
 
Registered: Sep 2009
Location: Washington U.S.
Distribution: M$ Windows / Debian / Ubuntu / DSL / many others
Posts: 2,330

Rep: Reputation: 227Reputation: 227Reputation: 227
chmod +r <file>
chmod +w <file>
chmod +x <file>
try those
 
Old 10-05-2009, 02:47 AM   #3
lutusp
Member
 
Registered: Sep 2009
Distribution: Fedora
Posts: 835

Rep: Reputation: 102Reputation: 102
Quote:
Originally Posted by grayFalcon View Post
Hello everybody!

I've got a funny problem: I have some files lying around in /root/bla/, all these files are 644 and /root/bla/ is 755. Still, when I try (as a different user) to cp /root/bla/file ., I get a "cp: cannot stat: Permission denied". I also cannot ls /root/bla/, I also get a Permission denied... what gives?

Thanks a lot in advance,
grayFalcon
The explanation is easy -- you don't have the permissions set as you describe.

1. If the directory permissions are 755 (rwxr-xr-x) including all parent directories, anyone can list the directory contents. But you can't, so the full directory path doesn't have 755 permissions.

2. If the files are 644 (rw-r--r--), then you can read them. But you can't, so either the files don't have 644 permissions. or requirement (1) above is not met.

To clarify -- if the entire path isn't listable by your user, you will get the result you got. So any parent directory without the execute bit set for your user will make it and all subdirectories unlistable. And files in the subdirectories will be unreadable.

So to read any particular file in a path, and to get directory listing for the path, the entire path must be parseable by your user.

If as root you see that a particular subdirectory is set to 755, this isn't enough to assure that a user will be able to list or read files in that directory. For that, all the parent directories must be readable by your user as well.

Now. Think about the fact that you are in the /root directory. Why would the root user open his home directory for anyone to browse?

On my system, the /root directory has drwxr-x--- permissions. Meaning? Ordinary users cannot browse or read that directory or any subdirectories. Members of the root group can browse and read files, but ordinary users cannot.
 
Old 10-05-2009, 03:40 AM   #4
grayFalcon
Member
 
Registered: Jan 2003
Distribution: Debian
Posts: 69

Original Poster
Rep: Reputation: 15
Thanks! I did not realize that all parent directories have to be +x too... I was rather hoping to be able to expose only the one directory. Well, too bad.

Thanks again for the explanation,
-grayFalcon
 
  


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
permission denied to move a file? trnz$mr Slackware 3 06-05-2009 01:18 PM
.dmrc in ntfs (cannot change permission to 644) jiatong Linux - General 2 05-14-2009 02:45 AM
error: failed to stat /home/username/.gvfs: Permission denied ? Shadowmeph Linux - General 2 09-22-2008 06:07 PM
corrupt file Permission denied emetib Debian 4 04-20-2008 08:12 AM
cannot stat: Permission denied. Why? Mountain Linux - Software 5 04-03-2008 01:50 PM


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