Posted in

How to use chown command in terminal?

If you’ve spent any time navigating Linux or macOS systems via the terminal, you’ve probably run into permissions issues—whether it’s a "permission denied" error when trying to edit a configuration file, install software, or move a file to a system directory. As a terminal hardware supplier, I get asked about these problems all the time; more than once, customers have picked up our terminals specifically to avoid the limitations of graphical user interfaces when they need deep system access. The chown command is one of the most useful tools in that process, so today I’m breaking down exactly how to use it, why it matters, and how it works for anyone using a physical terminal device in a server room, office, or field deployment. Terminal

Let’s start with the basics: chown stands for "change owner". It’s a terminal utility built into Unix-based systems that lets you modify two key pieces of file and directory metadata: the user owner and the group owner assigned to a given file or folder. On every Unix system, every file has three permission sets—user, group, and others—and every file is tied to one user account and one group account. If you don’t own a file, or aren’t in the group that owns it, you won’t be able to modify, delete, or even access it without using sudo, which comes with its own set of security rules. That’s where chown fills a gap: it’s the tool that lets you adjust those ownership settings directly, right from the terminal, which is why it’s a staple for anyone using a terminal for day-to-day admin, especially when you’re working remotely via a terminal device.

A lot of new users mix up chown with chmod, which is another common utility for changing permissions. Let me clear that up right away: chmod adjusts what users, groups, and others can do with a file (read, write, execute), while chown adjusts who that file belongs to. They work hand in hand, but they serve completely different purposes. For example, if you have a file that only you should edit, you’d use chown to set your user as the owner, then chmod to make sure you have write access. If you need that file accessible to a team, you’d use chown to set a shared group as the group owner, then adjust the group permissions with chmod. That separation makes chown critical for managing access on both single-user machines and multi-user servers, which is why it’s something all our customers ask about when setting up their terminal devices for server management.

Now, let’s get into the actual syntax. The basic structure of a chown command is simple: chown [options] new_owner:new_group file_or_directory. Let’s break that down with real examples, because examples stick way better than just rules.

First, changing just the user owner. If you have a file called project_notes.txt, and its current owner is a user named old_user, and you want to make a new user named jake the owner, you’d run:
chown jake project_notes.txt
That’s the simplest use case. If you want to change both the user and the group owner at the same time, you use a colon to separate them. So if you want jake to own the file, and assign it to a group called dev_team, you’d run:
chown jake:dev_team project_notes.txt
You can also change just the group owner without touching the user owner by omitting the user name before the colon. For example, if jake is already the owner, but you want to move the file to the dev_team group, you’d run:
chown :dev_team project_notes.txt
That’s a quick trick to adjust group access without altering the user ownership, which is useful when you’re managing shared resources on a server.

Once you’re comfortable with the basics, there are a few key options that make chown way more powerful, especially for managing entire directories and their contents. The most common one is -R, which stands for recursive. If you have a directory called website_files, and you want to change the ownership of that directory, all the files inside it, and all subdirectories, you add the -R flag:
chown -R jake:dev_team website_files
This is a command I use all the time when setting up terminal devices for web hosting or team file sharing. Instead of running chown on every single file in the directory, one by one, the recursive flag does it in a single line, which saves hours of tedious work.

Another useful option is –reference, which lets you copy the ownership settings from another file instead of typing them out manually. For example, if you have a template file called template.txt that has the exact user and group you need for a new file called new_report.pdf, you can run:
chown –reference=template.txt new_report.pdf
That’s perfect for standardizing ownership across multiple files in a project, especially when you’re managing a lot of similar files on a terminal.

Now, let’s talk about common mistakes and pitfalls that a lot of new terminal users run into with chown, especially when they’re using a physical terminal device to manage remote or local servers. The biggest one is trying to use chown without the right permissions. By default, only the root user—or a user with sudo privileges—can change the owner of a file. If you try to run a chown command for another user without sudo, you’ll get an error like Operation not permitted. For example, if you try to chown a file owned by root to your regular user account, you’ll need to add sudo before the command:
sudo chown jake project_notes.txt
That’s a critical rule to remember, because changing file ownership incorrectly can break your system. I’ve had customers reach out to me after misusing chown on their terminals and accidentally changing the ownership of a system file, which left them locked out of editing configuration files. If you run into a "permission denied" error with chown, the first thing to check is whether you need to use sudo.

Another common mistake is mixing up the order of the user and group. If you write chown dev_team:jake, that will try to set the user owner to dev_team (which is a group, not a valid user name) and the group owner to jake. That will throw an error, or if you have a group named jake, it will flip the settings incorrectly. Always remember: user comes first, then group, separated by a colon. For users who are new to working with terminals from a physical device, this mix-up is super common, so I always suggest testing chown on a test file first before running it on important directories.

Let’s put this all together with a real-world use case, because that’s how most people learn best. Let’s say you have a terminal device deployed in a small business’s server room, and you need to set up a shared project directory for your design team. The current owner of the directory is root, and you want to adjust it so three designers can access, edit, and save files to the directory. Here’s the step-by-step process:

  1. First, create a dedicated group for the design team. Run groupdesign in the terminal. That creates a new group called design_team.
  2. Next, add each of the three designer user accounts to the design_team group. For each user, run sudo usermod -aG design_team designer1, sudo usermod -aG design_team designer2, and sudo usermod -aG design_team designer3. The -aG flag adds the user to the group without removing them from any other groups they’re part of.
  3. Now, set the ownership of the project directory. Let’s say the directory is located at /srv/design_projects. You want the root user to still be the owner (so only root can manage access) but set the group owner to design_team. Run:
    sudo chown :design_team /srv/design_projects
  4. Finally, make sure the directory has the right permissions so members of the design group can write to it. Run chmod 775 /srv/design_projects. That gives the root user full access, the design group read and write access, and others only read access.
  5. To make sure any new files added to the directory automatically inherit the group ownership (instead of defaulting to the user’s primary group), set the setgid bit on the directory. Run sudo chmod g+s /srv/design_projects. That’s a little extra step that saves you from having to run chown again every time a new file is added, which is perfect for a shared team directory.

This exact workflow is something I walk customers through all the time when they’re setting up their terminals for team use. Physical terminals give you direct, low-level access to your server that a lot of people miss when they’re only using cloud-based or graphical tools, and chown is one of the commands that makes that access powerful and safe.

Another thing to note is how chown works on different operating systems. If you’re using a terminal on Linux, the syntax is identical to what I’ve covered here. If you’re using a macOS terminal, it works the same way too, but there’s a small difference: on macOS, the root user is disabled by default, so you’ll use sudo more often than you would on a Linux server. For Windows users who have the Windows Subsystem for Linux (WSL) installed, chown works the same way as it does on Linux too, which makes it easy to transfer skills between different terminal environments.

I also want to touch on security, because that’s a big reason why chown matters beyond just file access. When you run chown to change ownership of a file, you’re not just rearranging permissions—you’re defining who is accountable for that file. For example, if a sensitive customer data file is owned by an old employee who left, using chown to set it to a new employee’s user account ensures that you can track who accesses or modifies that file, which is critical for compliance with regulations like GDPR or HIPAA. Terminal devices, which are often the first point of access for server administrators, rely on tools like chown to maintain that accountability, which is why it’s such a key command for anyone managing critical data.

Now, let’s address some frequently asked questions I get from customers about chown, because these are the questions that come up when you’re actually using the command on a daily basis.

Question: Can I use chown to change ownership of system files?
Answer: You can, but it’s not recommended. System files are configured to be owned by root, and changing their ownership can break your operating system. For example, if you change the ownership of the /etc/passwd file to a regular user, you won’t be able to log in as other users. Only use chown on system files if you have a specific, documented reason and you know exactly what you’re doing.

Question: What if I have a lot of files that need the same ownership?
Answer: The -R recursive flag is perfect for this, as I mentioned earlier. If you have a directory with 100 files that all need to be owned by a new user, running sudo chown -R newuser directory_name will adjust all of them in one command. Just double-check the directory name before running it, because a typo here can lead to changing ownership of the wrong directory.

Question: Can I revert a chown change if I make a mistake?
Answer: You can, but only if you know what the original ownership was. If you’re working on a test file, you can use ls -l to check the current owner and group before you run chown, and save that information so you can revert if needed. For system files, it’s a good idea to make a backup before running chown, or use sudo to run it as a test command first to make sure you have the syntax right.

At this point, if you’re working with a terminal device, you’re probably already running into situations where you need to adjust file ownership, or you’ll run into them soon. Chown is one of those tools that seems simple at first, but mastering it saves you hours of frustration when permissions go wrong. It’s also a core part of what makes terminal access so powerful: unlike graphical tools that limit you to pre-built workflows, the terminal lets you use precise commands like chown to tailor access exactly to your needs.

For our customers, who run terminals in everything from small office server rooms to large industrial facilities, knowing how to use chown is non-negotiable. That’s why we include basic command tutorials with every terminal device we sell, and our support team is always available to help walk you through chown commands, permission settings, or any other terminal tool you need. If you’re setting up a terminal for your team or your business, and you’re ready to get started with chown and other system management tools, feel free to reach out to our procurement team to discuss your specific needs. We work with teams of all sizes, from individual developers to large enterprise operations, and we can help you pick the right terminal device to fit your workflow.

When you’re working with terminals, every command counts, and chown is one of the most fundamental. Whether you’re fixing a permission error on a config file, setting up a shared team directory, or managing access to sensitive data, getting comfortable with chown will make your time in the terminal way more efficient and less stressful.

Metering Blocks References

  1. "chown(1) — Linux manual page". The Linux Foundation.
  2. "chown — macOS Manual Page". Apple Inc.
  3. "Windows Subsystem for Linux Command Reference". Microsoft Corporation.
  4. "Understanding Unix File Permissions and Ownership". University of Cambridge Computing Service.

Hangzhou Lingcheng Technology Co., Ltd.
We are one of the most professional terminal manufacturers and suppliers in China. With a professional production team, we are able to meet the needs of the majority of our customers. Please feel free to wholesale bulk high quality terminal from our factory. Customized orders are welcome.
Address: Room 1613, 16th Floor, Building 3, No. 99 Wangzhou Road, Liangzhu Street, Yuhang District, Hangzhou City, Zhejiang Province
E-mail: LCKJ0408@163.com
WebSite: https://www.lingchengelectric.com/