LinuxQuestions.org
Review your favorite Linux distribution.
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 05-15-2011, 09:19 AM   #1
dannin
LQ Newbie
 
Registered: May 2011
Posts: 11

Rep: Reputation: 0
chmod doesn't change permissions on files in subdirs


I have a Qnap 219p NAS to which I have connected a USB external harddrive. I can access the external harddrive from my windows box using the network share, but at first i couldn't access the folders. The permissions set in the NAS GUI for the external drive is correct and are identical to the permissions set to the 2 internal drives.

I ssh'ed to the nas and used 'chmod -R 770 /share/external/sds1' - this granted me access to the folders, and some files. I can open all files in the root, but if I go just 2 folders 'deeper', i can't open the files in this folder, and in the folders after that.

In ssh, if i navigate to the folder wher I cannot open the files and use 'ls -l', i can see that the permissions (770) hasn't been applied to these files.

How can I get chmod to apply the 770 permission to all files, folders, subfolders and files in subfolders etc., without having to chmod every folder one by one?
 
Old 05-15-2011, 10:28 AM   #2
EricTRA
LQ Guru
 
Registered: May 2009
Location: Gibraltar, Gibraltar
Distribution: Fedora 20 with Awesome WM
Posts: 6,805
Blog Entries: 1

Rep: Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295
Hello and Welcome to LinuxQuestions,

Must be something typical (limit) on the NAS operating system I think because in my Bash session I can use chmod -R like you did and it applies all changes correctly (checked on a SVN tree that has more then 10 levels of subdirs). You could use find with -exec to get what you want:
Code:
find /your/base/dir -type d -exec chmod 770 {} \;
Try that and see if it works. You could check without the exec part to see if all subdirectories get listed before changing them.

Kind regards,

Eric

Last edited by EricTRA; 05-19-2011 at 03:39 PM.
 
2 members found this post helpful.
Old 05-15-2011, 04:19 PM   #3
dannin
LQ Newbie
 
Registered: May 2011
Posts: 11

Original Poster
Rep: Reputation: 0
..

Thank you.

What does the -exec cmd do?
 
Old 05-15-2011, 04:23 PM   #4
dannin
LQ Newbie
 
Registered: May 2011
Posts: 11

Original Poster
Rep: Reputation: 0
I just tried the command you wrote and got the following:


Code:
[~] # find /share/external/sds1 -type d -exec 770 {} \;
BusyBox v1.01 (2011.03.30-11:06+0000) multi-call binary

Usage: find [PATH...] [EXPRESSION]

Search for files in a directory hierarchy.  The default PATH is
the current directory; default EXPRESSION is '-print'
I'm not sure what to change to get it to work
 
Old 05-16-2011, 12:32 AM   #5
EricTRA
LQ Guru
 
Registered: May 2009
Location: Gibraltar, Gibraltar
Distribution: Fedora 20 with Awesome WM
Posts: 6,805
Blog Entries: 1

Rep: Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295
Hello,

You forgot the command itself after the -exec. From the man page for find
Quote:
-exec command {} +
This variant of the -exec action runs the specified command on the selected files, but the command line is built by appending each selected file name at the end; the total number of invocations of the command will be much less than the number of matched files. The command line is built in much the same way that xargs builds its command lines. Only one instance of `{}' is allowed within the command. The command is executed in the starting directory.
That explains what the -exec part does. So your command should be:
Code:
find /share/external/sds1 -type d -exec chmod 770 {} \;
Kind regards,

Eric
 
1 members found this post helpful.
Old 05-17-2011, 03:39 PM   #6
dannin
LQ Newbie
 
Registered: May 2011
Posts: 11

Original Poster
Rep: Reputation: 0
I don't think it recognizes the -exec command. When using the command you posted it outputs:

Quote:
[~] # find /share/external/sds1 -type d -exec chmod 770 {} \;
BusyBox v1.01 (2011.03.30-11:06+0000) multi-call binary

Usage: find [PATH...] [EXPRESSION]

Search for files in a directory hierarchy. The default PATH is
the current directory; default EXPRESSION is '-print'

EXPRESSION may consist of:
-follow Dereference symbolic links.
-name PATTERN File name (leading directories removed) matches PATTERN.
-print Print (default and assumed).

-type X Filetype matches X (where X is one of: f,d,l,b,c,...)
-perm PERMS Permissions match any of (+NNN); all of (-NNN);
or exactly (NNN)
-mtime TIME Modified time is greater than (+N); less than (-N);
or exactly (N) days

[~] #
Could it be that the linux OS on the NAS just isn't equipped with the -exec 'tool'?
 
Old 05-18-2011, 01:13 AM   #7
EricTRA
LQ Guru
 
Registered: May 2009
Location: Gibraltar, Gibraltar
Distribution: Fedora 20 with Awesome WM
Posts: 6,805
Blog Entries: 1

Rep: Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295
Hello,

It might be a limited version of the findutils. Do you know what OS and version is running on that NAS? Might show in the man page, have you checked that? Logically if they used a 'limited' version of findutils they would have adapted the man page too. So check the man page to see if you have the -exec option listed there and maybe try to find out OS with version and version of find(findutils).

Kind regards,

Eric
 
Old 05-19-2011, 02:33 PM   #8
dannin
LQ Newbie
 
Registered: May 2011
Posts: 11

Original Poster
Rep: Reputation: 0
Actually.. It looks like they completely removed the whole man page for chmod. Am i crazy, or is the command 'man chmod' ?


Quote:
[~] # man chmod
-sh: man: command not found
[~] #
 
Old 05-19-2011, 02:41 PM   #9
EricTRA
LQ Guru
 
Registered: May 2009
Location: Gibraltar, Gibraltar
Distribution: Fedora 20 with Awesome WM
Posts: 6,805
Blog Entries: 1

Rep: Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295
Hi,

Can you find out what OS the NAS is running? That might come in handy when troubleshooting this issue. I've got a strong feeling that it's a customized Linux, maybe based on FreeBSD.

Kind regards,

Eric
 
  


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
How do I change my windows partition permissions. chmod won't work. brandonloserkid Slackware 2 12-03-2004 05:39 PM
chmod won't change the file permissions midtown266 Linux - Newbie 12 11-28-2004 07:46 PM
How can I change the permissions of /dev/ptyp* (chmod does not work) gderou Mandriva 0 08-24-2004 10:37 AM
Why doesn't a wildcard chmod change "dot" files/directories? jht2k Linux - General 1 08-09-2004 02:31 PM
chmod shows change to permissions, but ls-l doesn't vdemuth Slackware 6 07-03-2004 04:29 AM


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