[SOLVED] Change file permissions

Please post suggestions for improvement of Cinnamon here
https://github.com/linuxmint/Cinnamon
Post Reply
User avatar
JerryF
Level 11
Level 11
Posts: 3869
Joined: Mon Jun 08, 2015 1:23 pm
Location: Rhode Island, USA

[SOLVED] Change file permissions

Post by JerryF » Tue May 16, 2017 8:07 am

I looked on the forums for this, but couldn't find it.

I would like to change the file permissions of files that have a particular permission.

Example: Within the home folder 'jim' change file permissions that have only 777 to 644 using terminal.

Thanks.
Last edited by JerryF on Tue May 16, 2017 12:28 pm, edited 1 time in total.
IF your problem has been solved, please edit your ORIGINAL post and add [SOLVED] to the beginning of the Subject Line. It helps other members when browsing posts.

altair4
Level 19
Level 19
Posts: 9738
Joined: Tue Feb 03, 2009 10:27 am

Re: Change file permissions

Post by altair4 » Tue May 16, 2017 8:20 am

Code: Select all

chmod -R a-x+X /home/jim/Documents
change mode ( chmod ) recursively ( -R ) for all users ( a ) and all files and directories remove the execute bit ( -x ) then add it back to all directories ( +X ).

I wouldn't do it across the whole of the users home folder ( i.e., /home/jim ) because you may have a file or two that you want to be executable - some of them hidden. So I would do this subfolder by subfolder.

Sorry, I got sloppy. You wanted 644 not 666. THe corrected command would be:

Code: Select all

chmod -R a-x+X,go-w /home/jim/Documents
In addition, for group ( g ) and others ( o ) remove write ( -w )
Please add a [SOLVED] at the end of your original subject header if your question has been answered and solved.

User avatar
JerryF
Level 11
Level 11
Posts: 3869
Joined: Mon Jun 08, 2015 1:23 pm
Location: Rhode Island, USA

Re: Change file permissions

Post by JerryF » Tue May 16, 2017 11:52 am

Great! I'm still learning terminal commands. Will do them subfolder by subfolder.

I used to be pretty good at command prompt in Windows, but that's a horse of a different color! :lol:
IF your problem has been solved, please edit your ORIGINAL post and add [SOLVED] to the beginning of the Subject Line. It helps other members when browsing posts.

User avatar
Flemur
Level 17
Level 17
Posts: 7305
Joined: Mon Aug 20, 2012 9:41 pm
Location: Potemkin Village

Re: Change file permissions

Post by Flemur » Tue May 16, 2017 12:54 pm

JerryF wrote:Great! I'm still learning terminal commands. Will do them subfolder by subfolder.
I used to be pretty good at command prompt in Windows, but that's a horse of a different color! :lol:
This'll find 'em:

Code: Select all

find -type f -perm 0777
This'll change 'em:

Code: Select all

chmod 644 filename
You could stick those two together into a little script, but I'd do it the dumb way:

Code: Select all

find -type f -perm 0777 > file.txt
"vi file.txt" and stick "chmod 644 " at the front of each line, then "sh file.txt"
Please edit your original post title to include [SOLVED] if/when it is solved!
Your data and OS are backed up....right?

User avatar
JerryF
Level 11
Level 11
Posts: 3869
Joined: Mon Jun 08, 2015 1:23 pm
Location: Rhode Island, USA

Re: [SOLVED] Change file permissions

Post by JerryF » Tue May 16, 2017 2:09 pm

@Flemur:

This is great! I'll first do the files that I know need changing (document files, picture files, etc.)

And I just tested on a Live USB. The find command finds hidden files too (which I know YOU already knew). That way I can be careful and review each file and chmod the ones I know for sure.

Thanks!
IF your problem has been solved, please edit your ORIGINAL post and add [SOLVED] to the beginning of the Subject Line. It helps other members when browsing posts.

Post Reply

Return to “Cinnamon”