Asked
Updated
Viewed
174.8k times

If I were the root user, how would I give a user access to all files and folders in a certain directory? I tried:

# chmod 777 folderName

but even with using 777, it only changes the top-level directory permissions and not the files and folders within it. Do I have to manually change permissions on every file? Is there a way to mass change all permissions on folders and files under the parent directory?

add a comment
1

1 Answer

  • Votes
  • Oldest
  • Latest
Answered
Updated

The quickest way to change all directories and files under a parent directory is by executing the following command:

chmod -R 777 parent_dir_name/

Although, arbitrarily doing that is bad. The permission 777 is giving everyone permission to read, write and execute and that is NOT a good thing.

However, you did ask which was the quickest method, not the most appropriate.

BTW, should you have this sort of question regarding Unix commands, try man <unix_command> as in:

man chmod

It will provide you with the manual page for that particular command.

  • 0
    Daemonguy is correct the -R flag makes it recursive and will affect all the files and folders in the directory. — Uncensored-Hosting
  • 0
    If you want to just get directories try chmod -R 777 */ — mindcry
  • 0
    Hey guys. I'm a newbie with this Linux stuff but our Novell webserver crashed (hard drive) and thought to put Novells version (SUSE 10.0) instead. We have the root folder for our website at /etc/apache2/htdocs. We chmodded that folder and all sub-directories with all the commands that you posted on here and seemed to work. I go in there, create a new folder in the root directory, and when I try to access that new directory purch on the site it says FORBIDDEN PERMISSION ERROR. I then have to chmod THAT new folder as well to view it. Why do I have to chmod ALL folders one by one as I create them when I chmodded the root and all files and directories in there? Any ideas guys? — RGVsDigitalPimp
  • 0
    It's called the umask. Type man umask for more information. — Daemonguy
  • 0
    Thanks for the quick reply but I think I got even more confused, ha ha. Inversed numbers and all that with the umask command. I read the man umask and searched the net for umask explanations and found some but confused the heck out of me. We tried some umask commands that seemed to work but still getting permission denied forbidden errors. Hmmmm. — RGVsDigitalPimp
  • 0
    I'm really not certain where the disconnect is regarding umask operations. It's merely an exclusive OR operation. In Unix all base permissions begin as the following: Directories [ Octal 777 / Binary 111111111 ], and Files [ Octal 666 / Binary 110110110 ]. Apply your umask as exclusive OR to any file created. Umask = 022 (let's just say), create a new file named new.txt (touch new.txt). It should be set with the following perms (barring the use of acl's and the like): 666 ^ 022 = 644, or 110110110 ^ 000010010 = 110100100. Net result: rw-r--r--. — Daemonguy
  • 0
    110110110 ^ 000010010 = 110100100 — PsyckBoy
  • 0
    Good catch. Must have been a typo on my part. How embarrassing. — Daemonguy
  • 0
    All those ones and zeros can start to run together — PsyckBoy
  • 0
    Yeah but I am usually quite anal about that sort of thing. Sigh. — Daemonguy
add a comment
1