Skip to main content
Articles

Using The Terminal To Bulk Edit Website File Permissions

42
0

Sometimes I inherit websites or web-apps from other people who think they can just hand me something and it will just work.

I’ve just unzipped a file with about 100 directories and 1,500 images, scripts, and css files, all with their permissions oddly set to 600. Obviously this will not work just uploaded to a server, and I’m not about to go change all the permissions by hand folder by folder.

600 permissions means that only the owner of the file has full read and write access to it. Once a file permission is set to 600, no one else can access the file. 644 grants the owner read and write access, while the group members and other system users only have read access. This is what we want for most public facing scripts and images that are rendered in a browser. Most directories are set to 755.

You can use this little hack in WHM/cPanel/macOS/Linux .. (and maybe Windows too but I don’t know how and couldn’t care less) to change them all at once.

  • Open the TERMINAL app in your applications.
  • Type ls (This will list your current directory)
  • Type cd Desktop (Change Directory -> Desktop) Thats where the I expanded the .ZIP file.
  • Type find foldername d -exec chmod 755 {} \;  (change foldername to whatever your folder is named. The D in d -exec stands for DIRECTORIES. So all directories are getting changed to 755)
  • Hit enter
  • Type find foldername f -exec chmod 644 {} \;  (change foldername to whatever your folder is named. The F in F -exec stands for FILES. So all directories are getting changed to 644)
  • Hit enter
Corner Icon Render
Corner Icon Render
Corner Icon Render
Corner Icon Render How Can I Help You?