---
title: How to change group of a file on Linux?
date: '2023-01-29T00:00:00+00:00'
url: https://www.abhinav.co/how-to-change-group-of-a-file
summary: How to use chown and chgrp to change the owner and group of a file
tags:
- Ubuntu
- User
- Permissions
author: Abhinav Saxena
---

# How to change group of a file on Linux?

On Linux and other Unix like systems, if you want to check the user who owns a file, you can use `ls -l` comand:

```sh
# /tmp/test1 is the name of the file
$ ls -l /tmp/test1
-rw-r--r--  1 abhinav  staff  1369 Jan 29 10:28 /tmp/test1
```

### Change file owner using chown
If you want to change the owner of the file to say a user named `deploy`, do the following: 

```sh
# /tmp/test1 is the name of the file
$ chown deploy /tmp/test1
$ ls -l /tmp/test1
-rw-r--r--  1 deploy  staff  1369 Jan 29 10:28 /tmp/test1
```

### Change the group of the file using chgrp
If you want to change the group the file belongs to, you can do the following: 

```sh
# /tmp/test1 is the name of the file
$ chgrp deploy /tmp/test1
$ ls -l /tmp/test1
-rw-r--r--  1 deploy  deploy  1369 Jan 29 10:28 /tmp/test1
```

BTW, there's another shortcut. You can use `chown` command to change the group too.

```sh
# /tmp/test1 is the name of the file
$ chown deploy:deploy /tmp/test1
$ ls -l /tmp/test1
-rw-r--r--  1 deploy  staff  1369 Jan 29 10:28 /tmp/test1
```


There's another helpful command `chmod` that can you manage read, write and execute permissions at a much granular level. I will write more on `chmod` in a later post. Meanwhile, you can read more about `chown`, `chgrp` and `chmod` by using `man` command.

```sh
$ man chmod
```
