• Contact
  • About Me
  • Privacy Policy
  • Disclaimer
DefenceDev
  • Home
  • Blog
  • Linux Tutorials
    • Bash Scripting Lessons
    • Commands
    • Networking
    • Bash Scripts
  • Solutions
    • Docker
  • Network Tutorials
    • FortiGate
    • MikroTik
  • Projects
    • AdGuard
    • Immich
    • Nextcloud
    • WordPress
  • Cloud
  • Video Tutorials
    • YouTube Channel
    • MikroTik Videos
  • Web Tools
No Result
View All Result
  • Home
  • Blog
  • Linux Tutorials
    • Bash Scripting Lessons
    • Commands
    • Networking
    • Bash Scripts
  • Solutions
    • Docker
  • Network Tutorials
    • FortiGate
    • MikroTik
  • Projects
    • AdGuard
    • Immich
    • Nextcloud
    • WordPress
  • Cloud
  • Video Tutorials
    • YouTube Channel
    • MikroTik Videos
  • Web Tools
No Result
View All Result
DefenceDev
No Result
View All Result
Home Linux Tutorials Commands

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

by neo
November 28, 2025
in Commands
0
Linux Files Operation: chwon (Change Ownership of The Files)

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

0
SHARES
42
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

Previous Post

Linux Files Operation: grep, Efficient Text Search

Next Post

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

neo

Related Posts

10+ Useful Linux find Command Examples You Should Know
Commands

10+ Useful Linux find Command Examples You Should Know

Check Disk Usage on the Linux with du Command
Commands

Check Disk Usage on the Linux with du Command

Linux Process, List all Running Services with ps Command
Commands

Check Running Processes and Services in Linux via ps

Descripton for kill command on Ubuntu
Commands

Linux Process Management, kill Command

Linux Files Operation: grep, Efficient Text Search
Commands

Linux Files Operation: grep, Efficient Text Search

Linux Files Operation: find Temp Files and Execute Commands on Found Files
Commands

How to Find Temporary Files in Linux and Execute Commands on Them

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

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

Recommended

Linux Files Operation: touch, cat, less - Read Content of Files

Create and Read Files in Linux with touch, cat, and less

Linux Real-Time Performance (CPU, Memory Usage) Metrics with htop, atop, nload, and iostat

Linux Real-Time Performance (CPU, Memory Usage) Metrics with htop, atop, nload, and iostat

Maximizing Network Efficiency with AdGuard: My 7-Day Results

Maximizing Network Efficiency with AdGuard: My 7-Day Results

FortiGate Brute Force Protection: Ban IPs After Failed Admin Login

FortiGate Brute Force Protection: Ban IPs After Failed Admin Login

Install Portainer on Ubuntu 24.04 Using Docker Compose

Install Portainer on Ubuntu 24.04 Using Docker Compose

Categories

  • Blog
  • Cloud
    • Private
  • Linux Tutorials
    • Bash Scripting Tutorials
    • Commands
    • Networking
  • Network Tutorials
    • FortiGate
    • MikroTik
  • Projects
    • AdGuard
    • Immich
    • Nextcloud
    • WordPress
  • Solutions
    • Docker
  • Video Tutorials
    • MikroTik Videos
  • 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

Maximizing Network Efficiency with AdGuard: My 7-Day Results

Maximizing Network Efficiency with AdGuard: My 7-Day Results

FortiGate Brute Force Protection: Ban IPs After Failed Admin Login

FortiGate Brute Force Protection: Ban IPs After Failed Admin Login

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

© 2025 defencedev.com - All rights reserved.

No Result
View All Result
  • Home
  • Blog
  • Linux Tutorials
    • Bash Scripting Lessons
    • Commands
    • Networking
    • Bash Scripts
  • Solutions
    • Docker
  • Network Tutorials
    • FortiGate
    • MikroTik
  • Projects
    • AdGuard
    • Immich
    • Nextcloud
    • WordPress
  • Cloud
  • Video Tutorials
    • YouTube Channel
    • MikroTik Videos
  • Web Tools

© 2025 defencedev.com - All rights reserved.