10

My folder is /images/. There are .png, .gif and .jpg images in this folder. How do I change permissions of specific file extension .jpg to 644 under the folder via SSH?

Scott Berrevoets
  • 16,921
  • 6
  • 59
  • 80
richard
  • 1,456
  • 4
  • 15
  • 22

1 Answers1

18

Connect to the remote computer with ssh and then execute this command may work:

find /images/. -name "*.jpg" | xargs chmod 644

Guillaume
  • 8,741
  • 11
  • 49
  • 62
  • 6
    This won't work in a number of cases, for example if there are any spaces in any of the filenames. Use the `-exec` flag of `find` instead: `find /images/. -name "*.jpg" -exec chmod 0644 {} \;` – Markus Amalthea Magnuson Jun 07 '17 at 13:16
  • 1
    How can we add sudo to this command? I have to execute this with root privilege. – rineez Mar 26 '20 at 10:32