Find the answer to your Linux question:
Page 1 of 2 1 2 LastLast
Results 1 to 10 of 13
Like Tree1Likes
Hi, I am the owner of a huge library of music placed under many directories. I am using chmod -R 755 * from the parent directory to give R +X ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Jul 2012
    Posts
    5

    Question Subdirectories and files are not affected by CHMOD


    Hi,
    I am the owner of a huge library of music placed under many directories. I am using chmod -R 755 * from the parent directory to give R +X permissions to users and others, but the permissions do not trickle down to the individual files under the sub directories. The directories seem to change but not the files.

    Another strange thing is, using FileZilla, I see the subdirs are still on 777, when I try to change it that way, it seems to carry on with the process but again, it doesn't actually change the permissions of neither the directories nor the files. What is happening?

    If this doesn't work, is there a way to restrict individual users to only read and execute in their home directory?

    Please don't spare description, I am not an expert (obviously).

    Thanks!

  2. #2
    Linux Newbie
    Join Date
    Jan 2012
    Location
    Ohio
    Posts
    175
    First things first, you don't want to set up execute permissions on something that isn't a script or binary. Read permissions for media files is sufficient for opening them. You only need to do 755 on the folders themselves. So far a restricting individual users to only read and execute in their home directory can be done (and typically is based on permissions set by default). If you want to limit them to not be able to move outside of their home directory you need to chroot them. What I would do for the media is chmod -R 644 *.mp3 (or whatever your file extension is) and then individually set the perms on the folders. You can also use the find command to change permissions conditionally. See this walk-through:
    Linux / UNIX: Change File Permissions Recursively ( conditional )

  3. #3
    Just Joined!
    Join Date
    Jul 2012
    Posts
    5
    Thanks for your reply, however as I wrote, the recursive chmod doesn't really trickle down, it won't change the files or the directories. What i've noticed that if I use chmod *.* it does change directories that have a . (dot) with some letters next to the dot. So those do change to 644.
    Problem is I have more than 200 directories/sub directories and go through each one of them is laborious and I can only do that through filezilla as the naming format does not allo me to enter the sub directories (see image attached). I've tried the suggestions in the link you've posted. All it does is it runs the command, everything scrolls through but again, nothing really changes. dirs.JPG

  4. #4
    Just Joined!
    Join Date
    Jan 2011
    Location
    Cambridge, Ontario, Canada
    Posts
    24
    chmod -R XXX /path/to/music/

    Are there any other unusual symptoms here? Do you own all of the files & subdirectories within the directory in question?

  5. #5
    Linux Newbie
    Join Date
    Jun 2012
    Location
    SF Bay area
    Posts
    166
    Quote Originally Posted by ktech11 View Post
    First things first, you don't want to set up execute permissions on something that isn't a script or binary. Read permissions for media files is sufficient for opening them. You only need to do 755 on the folders themselves. So far a restricting individual users to only read and execute in their home directory can be done (and typically is based on permissions set by default). If you want to limit them to not be able to move outside of their home directory you need to chroot them. What I would do for the media is chmod -R 644 *.mp3 (or whatever your file extension is) and then individually set the perms on the folders. You can also use the find command to change permissions conditionally. See this walk-through:
    Linux / UNIX: Change File Permissions Recursively ( conditional )
    That linked article is well worth a read, I second ktech11's suggestion that you check it out. Essentially you can run on "find" command to change all the directories to "755" then a second "find" to change all the regular files to "644". The nice thing about using find is that it will run a "chmod" command on each file individually, so you'll see any errors that happen. And as PairOfBlanks2 pointed out, it could be that you don't own all the directories and/or some of the music files.

    Check out the linked article, but something along these lines is what you'll probably end up using. Keep in mind that I'm just typing these into the forum and didn't test them, so please do read the article and/or the man page for "find" before cutting and pasting these.

    Code:
    $ find /path/to/music/dir -type d -print -exec chmod 755 {} \;
    
    $ find /path/to/music/dir -type f -print -exec chmod 644 {} \;
    You can remove the "-print" if you don't want to see all the file names scroll by while it's working. But it might be useful if there are errors.

  6. #6
    Just Joined!
    Join Date
    Jul 2012
    Posts
    5
    Hi,
    I did read the document referenced above yesterday and tried those "find" options with no success. Still it won't change the directories' or files' permissions. I don't see any errors while it's scrolling. The ownership is shown as root for all of them (and I am root). Is there a way I can log the actions into a file so I can search for errors and log the chown also for all files to analyze it deeply?

    Thank you.

  7. #7
    Linux Newbie
    Join Date
    Jun 2012
    Location
    SF Bay area
    Posts
    166
    OK, here's something that's worth checking... Are these actual files or symlinks to files? If they are symlink they would appear to have 777 permissions and when you "chmod" them nothing would seem to happen. In reality the chmod is working, but it's changing the permission on the files they link to, not the symlink itself. And while you can add flags to so it, you really don't need to change the settings for the symlink anyway.

    So you could try running a find command to print all symlinks in the directory structure, something like "find /path/to/music/dir -type l -print" should work.

    On an unrelated note, I general don't like to have things owned by "root" if it's not necessary. So if it were my system I'd pick a non-priv user and make all those files (and directories) owned by that user. That way you won't to be "root" to manage the media but everyone can still read them. if you want.

  8. #8
    Linux Newbie
    Join Date
    Jan 2012
    Location
    Ohio
    Posts
    175
    I second cnamejj's suggestions, also, after you have found whether or not they are symlinks, try one folder at a time and see what outputs. use chmod -v to get verbose output to help diagnose the problem

  9. #9
    Trusted Penguin
    Join Date
    May 2011
    Posts
    4,353
    piling on...

    what is the filesystem on which the files/dirs reside? check it in /proc/mounts for weirdness/unexpectedness.

  10. #10
    Just Joined!
    Join Date
    Jul 2012
    Posts
    5
    Quote Originally Posted by atreyu View Post
    piling on...

    what is the filesystem on which the files/dirs reside? check it in /proc/mounts for weirdness/unexpectedness.
    I used "mount" to get the info. Here is what I got for the particular drive (it's a USB drive):
    /dev/sda1 on /tmp/media/usb/USB2/62D8B378D8B34955 type ufsd (rw,noatime,nodiratime,nls=utf8,uid=0,gid=0,fmask= 0,dmask=0,sparse)


    Also, the folders are not symlinks, and I cannot go into each folder separately, because the names are too long with spaces and I can't cd into it...

    I have tried all the find commands suggested above, it runs the command on all files and directories, but to no avail. after that when I check permissions, all files have full read and write pems to all...

Page 1 of 2 1 2 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •