Sunday, September 27, 2009

Ubuntu File Permissions and recursively changing file permissions:

To change file permissions of a particular folder and folders/files under it recursively to read write execute, the shell command is :

sudo chmod 777 -R /path/tothe/particularfile-folder/

The first 7 determines that it is intended for this "user"(current user)....
The second 7 determines that it is intended for this "group"(current user group or a particular group)....
The third 7 determines that it is intended for "others"....

Now what is the fuss about "7"?/ u guys might be wondering. This has significance.

All Unix like systems have the following standard to represent RWX(read-write-execute)for a user/groups/other users in the system:

4- Read(can only read).

2- Write(can only write).

1- Execute(can only execute).

so, if you want to give a current user only execute rights you say:
sudo chmod 177 blah/blah

but if you want to give read and execute you give (1 + 4 = 5):

sudo chmod 577 blah/blah/topath

if you want to give read and write to a user group and others but not execute you give (4 + 2 = 6):

sudo chmod 166 blah/blah/topath

so far i guess you must have figured out that

1+4= 5 (gives execute and read rights but not write rights)

1+2= 3 (gives execute and write rights but not read rights)

4+2= 6 (gives read and write rights but not execute rights)

4+2+1=7 (gives read write and execute rights).....

you can use the above commands for recursively or just changing folder permissions, file permissions......

just chill whenever you see a 7,3,6,5 in a chmod or in any other command.....its determining the UGO(User Group and Other) rights/or what so ever..........


Monday, September 7, 2009

to make a shell script executable

hi all..........

we all do face some probs now and then to make a shell script executable, especially when running in a text mode or while accessing linux through telnet remotely.........

to make a shell script executable, you are required to type the following code:

$chmod a+x executable_file

then you run/execute the script the way you want........


rahul kavi

recursively change file folder permissions

Hi again..........its been a while since ive written my last blog post..........

I have lost touch with Unix/Linux and its commands........ite been a while(about 6-9 months) since ive used linux...... Now im completely on linux for over a month.. :)

This blog post is about converting the files and its constituent folders and files into your own files(i.e, you are the owner), if you sufficient rights to convert

to do it..........
step 1) go to the particular folder using "$cd folder_path"
step 2( type the chmod command with -R parameter......... "$chmod -R 777 *"
step 3) if its alright you will get the prompt, otherwise you have some error message, you may not have sufficient rights to modify the permissions of that particualr folder..

"777" gives you rights to read write exacute and "-R" refers to "recursively" do it........

cheers........rahul kavi