• Contact
  • About Me
  • Privacy Policy
  • Disclaimer
DefenceDev
  • Home
  • Linux
    • Bash Scripting
      • Bash Scripting Lessons
    • Commands&Tips
    • Monitoring
  • Networking
    • FortiGate
    • MikroTik
  • Projects & Case Studies
  • Self-Hosted
    • AdGuard
    • Immich
    • Nextcloud
    • WordPress
  • Virtualization
    • Proxmox
    • VMware
  • Tools
No Result
View All Result
  • Home
  • Linux
    • Bash Scripting
      • Bash Scripting Lessons
    • Commands&Tips
    • Monitoring
  • Networking
    • FortiGate
    • MikroTik
  • Projects & Case Studies
  • Self-Hosted
    • AdGuard
    • Immich
    • Nextcloud
    • WordPress
  • Virtualization
    • Proxmox
    • VMware
  • Tools
No Result
View All Result
DefenceDev
No Result
View All Result
Home Linux Commands&Tips

Linux Files Operation: chown (Change Ownership of the Files)

by neo
September 3, 2026
in Commands&Tips
0
Linux Files Operation: chwon (Change Ownership of The Files)

Linux Files Operation: chwon (Change Ownership of The Files)

0
SHARES
59
VIEWS
Share on FacebookShare on LinkedIn
Table of Contents
  • Files Operation: Change Ownership of The Files
    • Using chown Command in Linux
    • Examples and Usage
  • Troubleshooting

Files Operation: Change Ownership of The Files

Linux Files Operation: chown (Change Ownership of The Files) plays a key role in security and system management. Each file is associated with a specific owner and group, dictating who has access and what permissions they have. At times, you may need to transfer ownership of files, whether for administrative tasks, collaboration, or system maintenance. This is where the chown command comes into play.

In this post, we’ll explore how to use chown to change the ownership of files and directories on a Linux system. We’ll cover basic and advanced usage, from changing ownership to managing user and group associations effectively. By the end, you’ll have a solid understanding of how to control file permissions and ownership, ensuring proper access management in your Linux environment.

Let’s dive in and master file ownership with chown!

Using chown Command in Linux

The chown command in Ubuntu is used to change the ownership of files and directories. It stands for “change owner.” This command allows you to modify the user and group ownership of a specified file or directory.

Examples and Usage

  • Change the owner of a file:
chown newowner filename
  • Change the owner and group of a file:
chown newowner:newgroup filename
  • Change the group of a file:
chown :newgroup filename
  • Recursively change ownership of a directory and its contents:
chown -R newowner:newgroup directory

Webserver Example

In case you need to adapt a file to be accesses by web server, you need to have the following permission:

chown -R www-data:www-data *
  • chown: Changes the ownership of files or directories.
  • -R: Recursively applies ownership changes to all files and subdirectories within the current directory.
  • www-data:www-data: Specifies the new owner (www-data) and group (www-data). This is often used for web server files to grant the server process the necessary access to manage those files.
  • *: The wildcard character selects all files and directories in the current directory to apply the ownership change.

Troubleshooting

To check the oownership,you can type:

ls -ltrh

Output:

root@webserver:/srv/www/wordpress# ls -ltrh
total 248K
-rw-r--r--  1 www-data www-data  351 Feb  6  2020 wp-blog-header.php
-rw-r--r--  1 www-data www-data  405 Feb  6  2020 index.php
-rw-r--r--  1 www-data www-data 2.5K Nov 26  2022 wp-links-opml.php
-rw-r--r--  1 www-data www-data 5.6K May 30  2023 wp-cron.php
-rw-r--r--  1 www-data www-data 2.3K Jun 14  2023 wp-comments-post.php
-rw-r--r--  1 www-data www-data  34K Jun 19  2023 wp-signup.php
-rw-r--r--  1 www-data www-data 4.8K Jun 22  2023 wp-trackback.php
-rw-r--r--  1 www-data www-data 3.9K Jul 16  2023 wp-load.php
-rw-r--r--  1 www-data www-data 8.4K Sep 16  2023 wp-mail.php
drwxr-xr-x  9 www-data www-data 4.0K Nov  9  2023 wp-admin
-rw-r--r--  1 www-data www-data  325 Jan 12 07:27 wordfence-waf.php
-rw-r--r--  1 root     root      325 Jan 12 07:40 wordfence-waf.php.bkp
-rw-r--r--  1 www-data www-data 3.2K Apr  2 20:01 xmlrpc.php
-rw-r--r--  1 www-data www-data  20K Apr  2 20:01 license.txt
drwxr-xr-x 30 www-data www-data  16K Apr  2 20:01 wp-includes
-rw-r--r--  1 www-data www-data  28K Apr  2 20:01 wp-settings.php
-rw-r--r--  1 www-data www-data 3.0K Apr  2 20:01 wp-config-sample.php
-rw-r--r--  1 www-data www-data 7.3K Apr  2 20:01 wp-activate.php
-rw-r--r--  1 www-data www-data  50K Apr  2 20:01 wp-login.php
-rw-r--r--  1 www-data www-data 7.3K Jun  6 08:18 readme.html
-rw-r--r--  1 www-data www-data 3.6K Jun 19 11:34 wp-config.php
drwxr-xr-x 11 www-data www-data 4.0K Jun 21 19:55 wp-content

Linux Files Operation: chwon (Change Ownership of The Files)

defencedev.com

Tags: linux
Previous Post

Linux Files Operation: grep, Efficient Text Search

Next Post

Fortigate and Ubuntu Bash Automation

neo

Related Posts

10+ Useful Linux find Command Examples You Should Know
Commands&Tips

10+ Useful Linux find Command Examples You Should Know

My Ultimate Linux/Ubuntu Commands Cheat Sheet (2025)
Commands&Tips

My Ultimate Linux/Ubuntu Commands Cheat Sheet (2025)

Timeshift on Linux: How to Create and Restore System Snapshots
Commands&Tips

Timeshift on Linux: How to Create and Restore System Snapshots

Remote Desktop Access to Ubuntu 24.04 from Windows
Commands&Tips

Remote Desktop Access to Ubuntu 24.04 from Windows

Fix "blk_update_request: critical target error" on Ubuntu Server (dev sdb, DISCARD Operation)
Commands&Tips

Fix “blk_update_request: critical target error” on Ubuntu Server with SSD (dev sdb, DISCARD Operation)

Passwordless SSH Login on Ubuntu: Secure Server Access
Commands&Tips

Passwordless SSH Login on Ubuntu: Secure Server Access

Next Post
Solution: Connect from Ubuntu to the FortiGate Firewall and Execute Command (Bash Script)

Fortigate and Ubuntu Bash Automation

Recommended

Lesson 11: Practical Linux Bash Examples and Projects

Lesson 11: Practical Linux Bash Examples and Projects

Nextcloud: Security Concept with FortiGate Firewall

Nextcloud: Security Concept with FortiGate Firewall

Briefly unavailable for scheduled maintenance. Check back in a minute.

WordPress Stuck in Maintenance Mode After Plugin Update

Promox Telegram Alert Example

Configure Telegram Notifications in Proxmox VE Using Webhooks

Fix Proxmox VM Snapshot “Out of Space” Errors

Fix Proxmox VM Snapshot “Out of Space” Errors

Categories

  • Linux
    • Bash Scripting
    • Commands&Tips
    • Monitoring
  • Networking
    • FortiGate
    • MikroTik
  • Projects & Case Studies
  • Self-Hosted
    • AdGuard
    • Immich
    • Nextcloud
    • WordPress
  • Virtualization
    • Proxmox
    • VMware
  • Web Tools

DefenceDev Tutorials

defencedev Logo

Whether you’re just starting or looking to expand your skills, I hope you find useful information and engaging discussions here. Let me take you through my journey and the goals behind this space!

Follow Us

Recent News

Briefly unavailable for scheduled maintenance. Check back in a minute.

WordPress Stuck in Maintenance Mode After Plugin Update

Promox Telegram Alert Example

Configure Telegram Notifications in Proxmox VE Using Webhooks

  • Site Map
  • Privacy Policy
  • Facebook Page
  • GitHub
  • Disclaimer
  • Contact
  • About Me

© 2025 defencedev.com - All rights reserved.

No Result
View All Result
  • Home
  • Linux
    • Bash Scripting
      • Bash Scripting Lessons
    • Commands&Tips
    • Monitoring
  • Networking
    • FortiGate
    • MikroTik
  • Projects & Case Studies
  • Self-Hosted
    • AdGuard
    • Immich
    • Nextcloud
    • WordPress
  • Virtualization
    • Proxmox
    • VMware
  • Tools

© 2025 defencedev.com - All rights reserved.