Press enter to see results or esc to cancel.

Fix WordPress file permissions on Ubuntu

I am sitting here in the darkness of my room at 3 AM and trying to fix WordPress file permissions on Ubuntu. Even as an experienced developer, it’s a challenge to remember command line commands to solve it.

To fix file permissions, we don’t need any unique tool for this, but only one we already have built-in in Ubuntu. The only two commands we need are chown and chgrp.

Where to execute the commands?

Execute all the commands from this article from the root folder of your WordPress installation. Eg. If you use Apache you will probably put your WordPress into /var/www/<project-name> folder.

To navigate to this folder in your command line type: cd /var/www/<project-name>

Which tools do we need?

Here are two “tools/commands” you need to fix your file and directory permissions:

chownThis command is an abbreviation of change owner; I use it to change the owner of file system files, directories.
chgrpThis command is an abbreviation of change group; I use it to improve the group associated with a file system object to one of which they are a member.

What do we want to do?

We want to set proper file and folder permissions for our WordPress website. Generally speaking, we want to protect our files and folders by limiting access and setting permission rules.


sudo chown -R <username>:<username> *Changes ownership of all files and folders to your user account and user group.
sudo chown www-data:www-data -R wp-content/Changes ownership of all files and folders in wp-content folder to www-data user and group. Www-data is default Apache user and group.
find . -type d -exec chmod 755 {} \;Set all directories permissions to 755
find . -type f -exec chmod 644 {} \;Set all files permissions to 644

File and folder permissions

You are probably asking what the hell are those numbers “755” and “644” 🙂

It’s a straightforward model. There are three kinds of actions users, groups and what everybody else can do with our files:

  • Read
  • Write
  • Execute

File permissions are organized as three numbers:

  1. User permission
  2. Group permission
  3. Everybody’s permission

And the last thing is levels of the permission we can grant:

  • 0 – No access at all
  • 1 – Execute
  • 2 – Write
  • 3 – Write, and execute
  • 4 – Read
  • 5 – Read, and execute
  • 6 – Read, and write
  • 7 – Read, write and execute

Let’s translate numbers we gave to files and folders in our WordPress file structure.

We set 755 to all folders, which implies that the user (first number) can read, write and execute (7) whatsoever in that folder, user group (second number) can read and execute and everybody else (third number) also read and execute in this folders. The same pattern applies for files, you get the point. Right?

I hope I will never again forget those commands now when I wrote them and explain them in detail. Also, I hope you learn how to Fix WordPress file permissions on Ubuntu from this article or at least add it in the bookmarks as a resource for copy/paste magic when is needed 🙂

After you fix the file permissions on your WordPress website maybe you want to increase the speed of your WordPress website? I wrote an article on how to increase WordPress website speed without plugins with just simple four steps you have to implement.