Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make all files under a directory world readable on linux? [closed]

People also ask

How do I make all files readable in Linux?

chmod o-rwx foldername To change directory permissions for everyone, use “u” for users, “g” for group, “o” for others, and “ugo” or “a” (for all). chmod ugo+rwx foldername to give read, write, and execute to everyone. chmod a=r foldername to give only read permission for everyone.

What is the meaning of chmod 777?

Setting 777 permissions to a file or directory means that it will be readable, writable and executable by all users and may pose a huge security risk.

How do I chmod everything in a directory?

To modify the permission flags on existing files and directories, use the chmod command ("change mode"). It can be used for individual files or it can be run recursively with the -R option to change permissions for all of the subdirectories and files within a directory.

What does chmod 666 do?

chmod 666 file/folder means that all users can read and write but cannot execute the file/folder; chmod 777 file/folder allows all actions for all users; chmod 744 file/folder allows only user (owner) to do all actions; group and other users are allowed only to read.


man 3 chmod contains the information you are looking for.

chmod -R +r directory

the -R option tells chmod to operate recursively.


As a directory could contain links and/or bind mounts, the use of find could ensure a finest granularity in what to do and what to not do....

find directory \( -type f -o -type d \) -print0 |
    xargs -0 chmod ugo+r

To exclude paths under mount points:

find directory -mount \( -type f -o -type d \) -print0 |
    xargs -0 chmod ugo+r

To exclude some specific files (.htaccess for sample):

find directory \( -type f -o -type d \) ! -name '.htaccess' -print0 |
    xargs -0 chmod ugo+r

chmod -R 0444 ./folder_name

Apply the permission to all the files under a directory recursively