Your upload finished, the site loads, then WordPress refuses to update a plugin. Usually the files belong to the wrong user. Learning how to change file owner in Linux takes one command, chown, plus a minute of thinking about who should actually own what.
Quick Answer: Run
sudo chown newuser filenameto change a file's owner, orsudo chown newuser:newgroup filenameto set the owner and group together. Add-Rto cover a folder and everything inside it, for examplesudo chown -R deploy:www-data /var/www/example.com. Confirm the result withls -l. As of October 2026, type the group name in full on Ubuntu 26.04.
Last verified: October 2026, against Ubuntu 26.04 LTS (uutils coreutils 0.8.0), Ubuntu 24.04 LTS (GNU coreutils 9.4) and the GNU chown manual.
Our team fixes 20 to 30 client server problems every day, and broken ownership after a manual upload or restore is one of the regulars. This guide is the routine we follow on those tickets, written so you can run it yourself in about 5 minutes.
How Linux File Ownership Works (chown vs chmod)
Every file on a Linux server has exactly two owners: one user and one group. Run ls -l and you'll see both:
bash-rw-r--r-- 1 deploy www-data 4120 Oct 28 09:14 wp-config.php
The third column, deploy, is the user owner. The fourth, www-data, is the group.
The difference between chown and chmod is simple: chown decides who owns a file, and chmod decides what that owner, the group and everyone else may do with it. A file set to 644 is still useless to WordPress if the wrong user owns it, which is why chmod 777 seems to "fix" so many problems while opening a security hole. Fix ownership first.
Only root can hand a file to a different user; a regular user may only switch a file's group to one they already belong to, as the GNU chown manual spells out. Lost root or sudo access? Reset it with a safe root password change first.
How to Change File Owner in Linux, Step by Step
Check the current owner, run chown with the new user and group, then verify. Four steps cover nearly every real case.
Step 1: See who owns it now
bashls -l report.pdf ls -ld /var/www/example.com # -d shows the folder itself stat -c '%U:%G %n' report.pdf # owner:group only
Step 2: Change the owner, the group, or both
bashsudo chown deploy report.pdf # owner only sudo chown deploy:www-data report.pdf # owner and group sudo chown :www-data report.pdf # group only sudo chown 1001:33 report.pdf # numeric UID:GID
As of October 2026, sudo chown user:group file is the one form that behaves the same on every major distribution, including Ubuntu 26.04 LTS and its new Rust tools. Typing both names costs about 2 extra seconds and removes any doubt about which group the file lands in.
Insider Insight: Ubuntu 26.04 LTS swapped GNU chown for the Rust rewrite from uutils. One difference catches admins out:
chown deploy: file(trailing colon, no group) should also set the group to deploy's login group, but on 26.04 it leaves the group untouched. It was reported on Launchpad in May 2026, and the upstream fix was still an open pull request in late October. Runchown --versionto see which build you have.
Step 3: Run a recursive chown for a user and group
bashsudo chown -R -c deploy:www-data /var/www/example.com
-R walks every subfolder and -c prints only what changed. Add -h to change a symlink itself rather than its target.
Step 4: Verify nothing was missed
bashsudo find /var/www/example.com ! -user deploy -ls | head
Empty output means every file now belongs to deploy. Don't trust a quiet exit alone: uutils builds before 0.6.0 could report success even when earlier files failed (CVE-2026-35340).
Still seeing the WordPress problem?
Share the error, affected page, and the checks you completed. Your WordPress site can stay with its current hosting provider.
Set the Right Web-Server Owner and Fix Ownership After Upload
Files a site only reads should belong to the account that deploys them, with the web server as the group. Only folders the site writes to need web-server write access.
The Who-Writes Test
We ask three questions before any chown on a site folder:
- Who edits these files? That's the owner, usually your SFTP or deploy user.
- Which process runs them? That's the group:
www-dataon Ubuntu,apacheornginxon AlmaLinux, or the site's own PHP-FPM pool user. - Who writes here at runtime? Only those folders, such as uploads and cache, get group write.
For a shared folder where new files inherit the web group automatically, see the setgid setup in our guide to adding Linux users, groups and permissions.
Should www-data own my whole WordPress site?
WordPress shows its FTP "Connection Information" prompt when the PHP process doesn't own the files it needs to change. Running chown www-data on WordPress files with sudo chown -R www-data:www-data /var/www/example.com clears that prompt in about 5 seconds, but it also lets any vulnerable plugin rewrite your entire site. Do it only if you want one-click dashboard updates.
In our experience, the middle path works best: deploy user as owner, www-data as group, and only wp-content/uploads group-writable. The official WordPress documentation covers the trade-offs.
Fix ownership after upload or restore
Across the 4,000+ sites Hostaccent has migrated, the step people most often skip is re-owning files after unpacking a backup. Extract a tar archive as root and it keeps the old server's numeric IDs, so ls -l shows a bare number like 1003, or a stranger who happens to hold that ID here. To find and fix it:
bashsudo find /var/www/example.com -nouser -o -nogroup | head sudo chown -R deploy:www-data /var/www/example.com
On cPanel servers, site files belong to the cPanel account user and public_html sits in the nobody group, as a proper cPanel server setup keeps it. If ownership is right and FTP still can't write, check the causes of FTP 530 login authentication failed.
Pro Tip:
sudo chown --reference=index.php broken.phpcopies the owner and group from a file you know is right. It's the fastest repair when a single file was uploaded as root.
Common chown Mistakes That Break a Server
Most chown disasters come from running -R on the wrong path, rarely from the command itself. Hostaccent's engineers resolve 20 to 30 client issues a day, and our most expensive ownership cases follow a recursive chown aimed at a system folder: sudo stops working because /etc/sudoers no longer belongs to root.
- A stray space.
sudo chown -R deploy /var/www /hands the entire disk to deploy. Read the path twice, and add--preserve-rootso chown refuses to touch/. - "Operation not permitted." You're not root, the file carries the immutable flag (check
lsattr, clear it withsudo chattr -i file), or the mount doesn't store Linux ownership, such as FAT or NTFS drives. - Recursive changes under /etc. Certificate keys under
/etc/letsencryptmust stay owned by root, and a careless chown there is one way a Certbot renewal fails.
Your Next Step: A Server Where Ownership Stays Sorted
Now you know how to change file owner in Linux, and why the deploy-user and web-group split decides whether uploads work. You can manage that on any bare box, or start where help is a ticket away. The Standard plan at $12.00/mo (renewing at the same $12.00/mo) gives you full root access, free 30 Gbps DDoS protection and 24/7 support from Hostaccent's own engineers, backed by a 99.99% uptime guarantee and a 30-day money-back guarantee. One honest caveat: no control panel licence is included, so budget separately if you want cPanel. When you're ready, start on the Standard plan.
Frequently Asked Questions
How to change file owner in Linux without sudo?
You can't give a file you own to another user without root, and that's deliberate: otherwise users could dodge disk quotas or plant files under someone else's name. You can still change the group to one you belong to, with chown :teamgroup file or chgrp teamgroup file. To truly transfer a file, ask the other user to copy it, since a copy always belongs to whoever creates it.
What is the difference between chown and chgrp?
chgrp changes only the group, while chown can change the user, the group, or both in a single command. So chown :www-data file and chgrp www-data file produce exactly the same result. Most admins simply use chown for everything, because one tool with one syntax means fewer mistakes in scripts. The chgrp command survives mainly for compatibility with older shell scripts and traditional Unix habits.
How do I change ownership of a directory but not the files inside?
Run chown on the folder without -R, for example sudo chown deploy /var/www/example.com. That changes the directory entry alone and leaves every file inside exactly as it was. To change only the subfolders and skip regular files, combine it with find: sudo find /var/www/example.com -type d -exec chown deploy {} +. Swap -type d for -type f to change only the files.
Does chown change file permissions?
Normally no, because the permission bits stay as they were. The one exception surprises people: changing the owner of an executable clears its setuid and setgid bits, even when root runs the command, as the chown(2) system call manual explains. If a helper program stops working after a chown, check ls -l for a missing s in its permissions and restore it with chmod once ownership is final.
Why does chown say "invalid user"?
The name you typed doesn't exist on this server, so run getent passwd deploy to check. Typos are the usual cause, followed by commands copied from another distribution: the web user is www-data on Ubuntu but apache or nginx on AlmaLinux and Rocky. Also check the separator. Modern chown expects user:group, and the old dotted user.group form is deprecated and breaks on usernames containing dots.












Discussion
Have a question or tip about this topic? Share it below — your comment will appear after review.