Linux Command to Fix Permissions for Files and Directories
- Friday, December 10, 2010, 15:15
- How To?
- Views: 148
- Add a comment
If you migrate your WordPress blog or another CMS driven website to another location, you might have to face issues with file permissions. For WordPress, the default directory permissions are 755 and the default file permissions are 644. This post focuses on setting these permission using command line (given that you have ssh access to your webserver). If your CMS or webserver want you to have different permissions, then you can change the numbers in the commands below to suit your needs.
Beware of 777 permissions though, as it can be a big security threat! If you are told to use 777, first try it with 755 and 644, if that doesn’t work, then carefully add 777 permissions only as a last resort. Here are the terminal commands to fix your permissions recursively for a directory and its content:
find /var/www -type d -exec chmod 755 {} \;
find /var/www -type f -exec chmod 644 {} \;
The command above finds, or looks for files and folders in the directory specified above by /var/www (If you want to look in a different directory, you can specify a different path like this. e.g. ~/public_html/myblog) and then it looks for the document type, be it directory (d) or file (f), and executes the chmod (change mode) command to change the permissions on all results.
Be very careful with these commands, specially if you are not sure what you are doing, it might break things for you!
Possibly related posts (generated automatically):
- View and Delete Recent Terminal Command (s) History in Ubuntu
- Search or Recall Commands Typed in Linux Terminal
- Adblock for Opera (Blocking ads in Opera on Windows/Linux)
- Some Useful Linux Terminal Commands
- Can’t Run .exe Files On Windows 7 Machine
- Command to Find Kernel Version for Ubuntu 9.10
- Find RAM Type and Speed From Commandline in Ubuntu 9.10 (Linux)
- How to Extract 7-Zip Files on Ubuntu 11.04, 10.10
You might also like
| WordPress Blog Post by Post Redirection! You recently... | Must Have Free Windows 7 Software Open source/free... | TurnKey: Ready to Use Specialized Virtual Appliances If you are... | Replace URL in WordPress Posts, Images and Links If you migrate... |





