Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Changing the file permissions of multiple files through Unix terminal

Hi I have about a 100 files in a folder and I want to change the file permissions to read write and execute for each file in this folder.

I know how to change the file permissions for a single file i.e. chmod a+rwx foo.txt but not for a group of files. Please help me out

Thank you!

GT

like image 437
smilingbuddha Avatar asked Jul 29 '11 14:07

smilingbuddha


People also ask

How do I change permissions on multiple files in Unix?

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.

How do I change multiple file permissions?

Chmod allows you to change the permission of multiple files and subdirectories within a directory using the –R option as follows: $ chmod –R [reference][operator][mode] file... Let's say the subdirectories under the downloads directory have the following permissions as shown in the following screenshot.

How do I give permission to all files in UNIX?

To change file and directory permissions, use the command chmod (change mode). The owner of a file can change the permissions for user ( u ), group ( g ), or others ( o ) by adding ( + ) or subtracting ( - ) the read, write, and execute permissions.

Can I chmod multiple files at once?

If you need to change a file permission, use the chmod command. It also allows to change the file permission recursively to configure multiple files and sub-directories using a single command.


1 Answers

you can use wildcards, like

chmod a+rwx *.txt

or

find <directory> -type f -exec chmod a+rwx {} \;

the last command will find all files and exec the chmod per each file.

however, having a+rwx is not recommended at all

like image 176
marcelog Avatar answered Sep 19 '22 07:09

marcelog