change directory permissions code example

Example 1: change the permissions of a folder in linux

sudo chmod -R 757 <file>

Example 2: bash how to change the permissions on all directories and subdirectories

# Basic syntax:
find /path/to/directory -type d -exec chmod 775 {} \;
# This changes the permissions on the "directory" directory and all 
# subdirectories within it. 

# Note, this is usually better than "chmod -R 775 /path/to/directory"
# 	which changes the permissions on the subdirectories and *all files*

# Note, here's how permissions work. You specify three decimal digits
#	which specify the read, write, and execute permissions for yourself,
#	the group, and others respectively. The way this works is that each
#	decimal you specify is converted to a three digit binary equivalent
#	where 1 = true (permission granted) and 0 = false. The 

Decimal		Binary		Permission		Permission meaning
7			111			rwx				read, write, and execute
6			110			rw-				read and write
5			101			r-x				read and execute
4			100			r--				read only
3			011			-wx				write and execute
2			010			-w-				write only
1			001			--x				execute only
0			000			---				none

Example 3: changing folder permission in linux

chown {user:group} {directory} -R

Example 4: linux chmod permissions

The three rightmost digits define permissions for the:
file user, the group, and others. 

#	Permission				rwx	Binary
7	read, write and execute	rwx	111
6	read and write			rw-	110
5	read and execute		r-x	101
4	read only				r--	100
3	write and execute		-wx	011
2	write only				-w-	010
1	execute only			--x	001
0	none					---	000