1

Is there any Way to Edit/Create a file in the method of File Permission ?

Suppose it is '7' means can we able to change it to '4' ?

i.e -rwx to -r ?

Is there any code or___ to do?

1 Answers1

2

I believe you are looking for chmod. This command allows you to change permissions for a file.

Say you want to change the permissions of ./foo.txt to '4' then it's chmod 4 ./foo.txt

If you want to do this to all the files in a directory it would be chmod 4 *.

If you wanted to do this recursively through all files and directories somewhere it would be chmod -R 4 *

If you wanted to revert the change back to '7' on a file, it would be chmod 7 ./foo.txt. You can also use * or -R this way to change permissions on more than one file.

Click here for the chmod man pages.

Occasionally you will need to run sudo chmod instead of just chmod. Originally I had it as sudo chmod everywhere, however it is a bad habit to get into to use sudo when you don't need to.

Eric Power
  • 391
  • 3
  • 15