Driver FixRecommendedSound, Wi-Fi or graphics acting up? Check drivers firstFind missing or outdated drivers fast.Check DriversOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsPC HealthRecommendedCrashes, freezes, slowdowns? Check your PC nowSpot repairable issues before they interrupt work.Check PC×
Skip to content
World desk8 min

Linux chown Command: Change File Ownership on Your VPS

A practical guide to Linux chown on VPS systems: inspect ownership, choose the narrowest command, handle recursive directories and symbolic links safely, and verify web-server access.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Use Linux chown to change the user owner, group owner, or both for a file or directory on your VPS. A typical deployment repair is sudo chown deploy:www-data /var/www/app/config.yml, followed by a separate permission check with ls -l or stat. Ownership and permission bits are different controls: chown changes who owns an object, but it does not automatically grant read, write, or execute access.

What chown changes

Unix-like systems record a user owner and a group owner for each file-system object. The chown utility changes one or both of those ownership fields. GNU Coreutils describes it as changing “the user and/or group ownership of each given file to new-owner or to the user and group of an existing reference file.”

As an Amazon Associate I earn from qualifying purchases.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Ownership is separate from the permission bits shown by ls -l. For example, making deploy the owner of a configuration file does not, by itself, add read permission for deploy, remove write permission from another account, or make a directory searchable. Use chmod when the mode bits also need to change.

The correct syntax

chown [OPTION]... [OWNER][:[GROUP]] FILE...
chown [OPTION]... --reference=RFILE FILE...

The owner/group operand has no embedded spaces. Quote a path that contains spaces, and put -- before a path that might otherwise be interpreted as an option.

#1 Best Overall
Sale
TOZO A1 Wireless Earbuds Bluetooth 5.3 Light Weight in Ear Headphones | IPX5 Waterproof,2 Mics for AI Calls,Immersive Premium Sound Bass Headset with Charging Case,32 EQ via App Black
  • [Ultra-Lightweight Ear Buds Designed for Small Ears] Each earbud weighs only 3.7g and features a compact, ergonomic in-ear design made especially for small ears. Secure, low-profile, and comfortable for workouts, all-day wear or overnight sleeping.The ultra-slim profile sits flush in your ear with no hard edges poking or rubbing, so you can even sleep on your side without discomfort.
  • [Immersive Stereo Sound with TOZO OrigX Technology] TOZO OrigX tuning delivers clear vocals, balanced mids, and natural stereo sound for music, podcasts, and videos.
  • [Long Battery Life for Daily Use] Get up to 7 hours of playtime on a single charge, with up to 32 hours total using the charging case—ideal for workdays, commuting, and extended listening sessions.
  • [Bluetooth 5.3 & Stable Connection] Bluetooth 5.3 provides fast pairing, stable wireless performance, and reduced dropouts as you move around home or office.
  • [Deep Bass with Clear Vocals] High-performance drivers produce punchy bass while keeping vocals clean and detailed for everyday listening.
Form Effect Example
USER Changes only the user owner. sudo chown deploy /srv/app/config.yml
USER:GROUP Changes both the user and group owners. sudo chown deploy:www-data /srv/app/config.yml
:GROUP Changes only the group owner. sudo chown :www-data /srv/app/config.yml
USER: Changes the user and sets the group to that user’s login group. sudo chown deploy: /srv/app/config.yml
--reference=RFILE Copies the user and group ownership from an existing reference file. sudo chown --reference=/srv/app/template.conf /srv/app/config.conf

Both symbolic names and numeric user or group IDs are accepted. Names are easier to review during routine administration. Numeric IDs are useful when two systems use different account names but must agree on the underlying IDs, such as some container or shared-storage deployments.

A safe VPS workflow

Make the smallest ownership change that solves the problem, and verify it immediately. This sequence keeps the intended scope visible before a command can affect production files.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  1. Inspect the current object. Run ls -l /path/to/file for a quick view, or stat /path/to/file when you need the numeric IDs and complete metadata. For a directory, inspect the directory itself before deciding whether its contents should also change.
  2. Confirm the accounts. Check the user with id deploy and the group with getent group www-data. Replace those names with the accounts your service actually uses. If either lookup fails, stop and correct the account configuration instead of guessing a name.
  3. Choose the narrowest scope. Use a single path when one file or directory is wrong. Add -R only when every descendant in a deliberately selected tree should receive the change.
  4. Run with the required privilege. A normal account commonly needs sudo to change ownership. Whether a non-root account may change a group is constrained by local policy and group membership.
  5. Check the result and status. Run ls -l or stat again. GNU tools use exit status zero for success and a nonzero status for failure; a diagnostic or nonzero status means the ownership problem is not resolved yet.
  6. Test the application separately. If this is a deployment repair, make a real application or web-server request after verification. A correct owner does not prove that permissions, parent-directory traversal, service configuration, or the file contents are correct.

Common ownership changes

Change only the user owner

sudo chown deploy /srv/app/config.yml

This leaves the existing group unchanged. It is appropriate when the service group is already correct and only the account that owns the file needs correction.

Rank #2
Sale
Smart Watch for Men Women Compatible with iPhone Samsung Android Phone 1.69 inch Full Touch Screen IP68 Waterproof Bluetooh Fitness Tracker Heart Rate/Sleep Monitor (Black)
  • 【IP68 Waterproof Multifunctinal Smart Watch】Torjalph fitness activity tracker smart watch is IP68 waterproof technology ,you can wear it when swimming,handwashing,it's rain-proof which means that you perform multiple exercise modes outside without worrying about sweat or rain corroding your fitness smart watch,and this watch equipped with a 230 mAh large capacity battery magnetic charging ,and this sports activity tracker watch can be used 5-7 days If fully charged.
  • 【Larger 1.83'' Full Screen Watch & Multi-dial Selection】1.83 inch full HD color touch screen smart watch for men / women provides excellent 240*284 resolution image quality ,This Bluetooth smart watch offers a better touch experience and remarkable immersion and ,more than 200 watch faces for you to choose from App"Da Fit ", you can change the dial style according to your mood to wear keeping the world on your wrist
  • 【Accurate Activity Tracker Smart Watch 】sports watch activity tracker uses sweat and dust resistant breathable silicone strap, our Fitness Tracker Smart Watch for Android iOS Phones supports 12 sports modes,walking,running,bicycle,swimming,badminton,basketball,football,rope skipping. This bluetooth calls smart watch for men women is lightweight and stylish, bringing more convenient and relaxing sports experience while also providing more protection.
  • 【Your 24 Hour Personal Daily Health Monitor】Fitness watch for women men full touch screen IP67 waterproof bluetooth smartwatch for Android iOS Phones with heart rate blood pressure monitor multifunction Andriod smart watch with steps counter sleep monitor sports fitness watch, monitoring blood oxygen saturation allows you to understand your physical condition in real time to track fitness progress ,to know your health status in time.
  • 【More Functions Bluetooth Call Smart Watch】This fitness activity smart watch full screen for iPhone and Android phones includes a bunch of new features including:The bluetooth smart watch can hang up the phone, receive and display WhatsAPP /Text /Facebook /Twitter /Messenger reminder.Support sedentary reminder, alarm clock, stopwatch, timer,weather information,music control, remote camera control compatible with Android 5.0 and above or iOS 9.0 and above smartphones.

Change user and group together

sudo chown deploy:www-data /srv/app/config.yml

This sets deploy as the user owner and www-data as the group owner in one operation. Confirm that both accounts exist first; a misspelled name produces a failure rather than a useful ownership change.

Change only the group

sudo chown :www-data /srv/app/config.yml

The leading colon means “leave the user owner as it is.” This is useful when a deployment account owns a file but a web-service group must be associated with it.

Set a user’s login group

sudo chown deploy: /srv/app/config.yml

The trailing colon requests the login group associated with deploy. Use this form only when that account’s configured login group is the group you intend to apply; use an explicit USER:GROUP when the service group must be unambiguous.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #3
New Bee Guitar Cable 10ft Electric Instrument Bass AMP Cord
  • [Low Noise High Fidelity] New bee guitar cord with 22AWG oxygen-free-copper center conductors provides enhanced signal transfer, the PVC insulation material and the high-density stranded copper double shield provide noise rejection for quiet operation
  • [Ideal for Choice] New bee 1/4 straight and right angle metal connectors, ensures a secure connection in any instrument, pedal, or amp jack. L shape great fro on stage guitar stands
  • [Wide Compatible] Suitable for mixer, power amplifier, microphone, effector, decoder, equalizer, electoronic organ, electric guitar, electric bass and other electronic equipments. Widely used in the installation of smart home, karaoke speaker, professional stage audio, etc
  • [Easy Disassemble] Making incidental repairs quick and easy! Very nice, flexible cable
  • [Dont Hesite to Order] 24 hours customer services and professional technology team are standing by

Copy ownership from a known-good file

sudo chown --reference=/srv/app/template.conf /srv/app/config.conf

--reference copies both user and group ownership from the reference object. It does not copy permission bits, timestamps, contents, or extended attributes. Choose a reference in the same deployment context and inspect the result afterward.

Changing a directory tree with -R

sudo chown -R deploy:www-data /var/www/app

-R (also written --recursive) descends through the selected directory and applies the ownership operation to every descendant it processes. That can be exactly what a newly deployed tree requires, but it can also overwrite intentional ownership boundaries among uploads, private keys, caches, sockets, and mounted content.

  • Write the full intended path; do not run a recursive command from a broad location such as / or an entire home directory unless that scope is explicitly intended.
  • Inspect the tree before changing it. A command such as find /var/www/app -maxdepth 2 -ls can reveal unexpected mount points, links, or sensitive files; review the output rather than assuming every descendant belongs to the same service.
  • Prefer a one-file or one-subdirectory command when only one deployment artifact is wrong.
  • Afterward, inspect representative files and directories, including the top-level directory and any path the service must traverse.

Symbolic links and traversal safety

Recursive ownership changes need an explicit policy for symbolic links. GNU chown documents -H, -L, and -P for controlling link traversal during recursive operation. -P, which does not follow symbolic links, is the default when no traversal option is specified.

Rank #4
BSIMB 15.6" Digital Family Calendar & Chore Chart, No Subscription Fees
  • Digital Family Calendar: BSIMB digital calendar wall touch screen puts an end to your chaotic life. Designed for busy families, the digital calendar keeps you organised and in step with your family. Assign different colours and tasks to each family member to make family scheduling easier and more intuitive.
  • Easy Setup and Auto-Sync: Plug in, connect to WLAN and auto-syn your electric calendar in minutes. Digital wall calendar compatible with Google calendar, iCloud calendar, Outlook calendar, Cozi calendar and Yahoo calendar. Add events directly on the device or through the ecalendar app. Electronic calendar stays current whether you're at work or traveling—no manual updates needed.
  • All-In-One Home Assistant: Smart calendar builds habits and encourage independence with personalised chores. Display daily meal plan to reduce the daily ‘What's for dinner?’ stress. To-do lists keep track of everything you want. Turning chores into valuable achievements with stars and rewards, making life easier and more enjoyable.
  • Manage Anytime Anywhere: BSIMB electronic calendar for family stay connected with the powerful ecalendar app. Access and manage your digital wall calendar anytime, anywhere with free features like stars & rewards, photo screensaver, chore charts, meals plans, to-do lists etc. Electronic planner paid features like Magic Import tailor advanced tools for users with special needs.
  • Stay in Touch with Loved Ones: Share photos or videos from your phone to electronic wall calendar with app, instantly update your life moment, and keep in touch with your family, especially those who are far away; you can also surprise your smart calendar digital wall by sending him a wish card; it's also great for keeping tech-illiterate elders in touch with the youngsters.
Option Recursive behavior Operational implication
-P Do not follow symbolic links during traversal; this is the default. Limits the operation to the selected tree and avoids unexpectedly reaching a link target.
-H Controls handling of a command-line symlink while traversing recursively. Use only when the documented behavior for your platform and path is understood.
-L Follows symbolic links encountered during recursive traversal. GNU warns that combining -L with -R can create a security risk if an attacker introduces a link to an arbitrary target during traversal.

For a symlink itself, -h or --no-dereference requests changing the link’s ownership rather than the referent where supported. Edge-case behavior can vary, so check the target distribution’s chown manual before relying on it. If you need to change the destination file, resolve and name that destination deliberately instead of assuming a recursive command will do the right thing.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Why a web server still cannot read the file

A common deployment symptom is that deploy can create a file but the web service cannot read it after release. First determine whether the problem is ownership or permissions rather than changing both blindly.

  1. Inspect the file: ls -l /var/www/app/config.yml shows the owner, group, and mode; stat /var/www/app/config.yml provides a more complete view.
  2. Identify the service account and group actually used by the web server. Do not assume the account name from another distribution or an old deployment.
  3. If the owner or group is wrong, apply the narrow command, for example sudo chown deploy:www-data /var/www/app/config.yml.
  4. If ownership is correct but the mode bits do not permit the service’s access, use a separately reviewed chmod change. Do not treat chown as a substitute for permissions.
  5. Check every parent directory. A process needs execute (search) permission on each directory in the path, not merely read permission on the final file.
  6. Recheck the command status and make an actual request or service test. Ownership metadata alone cannot establish that the application can open the file.

Names, numeric IDs, and cross-system deployments

Use symbolic names when an administrator must quickly understand the result:

sudo chown deploy:www-data /srv/app/config.yml

Use numeric IDs when the receiving system’s names differ but the file must map to specific IDs:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
sudo chown 1001:33 /srv/app/config.yml

Verify the mapping with id and getent group before applying numeric values. An ID that represents a deployment account on one VPS may represent a different account on another, so copying numbers without checking local account databases can create a harder-to-diagnose security problem.

Handling failures and recovering safely

“Operation not permitted” or a similar error

Check whether the command was run with sufficient privilege and whether the file system permits ownership changes. Re-run with sudo only after confirming the target path and intended account. If the command still fails, preserve the diagnostic and nonzero exit status as evidence that the change did not complete; do not assume a partial-looking listing means the whole requested scope succeeded.

The wrong tree was changed

Stop further deployment actions, record the command that ran, and inspect the affected scope. There is no universal “undo” value: restoring ownership requires knowing the previous user and group for each object. Use a backup, package manifest, configuration-management record, or a known-good reference to reconstruct the intended ownership, then apply a narrowly scoped correction and verify it.

A symlink points outside the application

Do not respond by adding -L casually. The default non-following behavior is safer for an untrusted or changing tree. Inspect the link and its destination, decide whether the destination should be managed by this deployment, and name that destination explicitly only if changing it is authorized.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Choosing the least risky form

Situation Preferred form Why
One file has the wrong user owner. chown USER FILE Smallest scope and leaves the group untouched.
The service needs a specific user and group. chown USER:GROUP FILE Makes both ownership fields explicit.
Only group association is wrong. chown :GROUP FILE Avoids changing the user owner.
A complete application tree was created under the wrong account. chown -R USER:GROUP DIRECTORY Efficient, but every descendant is in scope and must be reviewed.
A target should match a trusted file’s ownership. chown --reference=RFILE FILE Copies both ownership fields without guessing names.
A tree contains links or may be influenced by another user. Keep recursive default -P; avoid -L. Reduces the chance of modifying an unintended link target.

Verification checklist

  • Did you inspect the original owner and group before changing them?
  • Do the requested user and group exist locally?
  • Is the path as narrow as possible, and is -R truly required?
  • Are symbolic links handled with the default non-following policy unless an exception is documented?
  • Did you check both the command’s exit status and the resulting metadata?
  • Did you review permission bits and parent-directory traversal separately?
  • Did you test the web server or application after the metadata change?

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Windows Errors? Fix Them Before They SpreadFree repair scan
Outdated Drivers Are Slowing You DownFree scan - exact matches

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.