Each file or directory in Linux has an owner, group, and permissions that allow who can read, write, and execute the file.
If you wish to change the owner for a file or directory, you can make use of the chown command. Using the chown command you can change both the owner user and the owner group for a file or directory.
Note: Superuser (root) privileges are required to change ownership of files that you don't own.
sudo chown <new-user-name>:<new-user-group> file/directory
Example 1 : Change owner only
sudo chown code2care /Users/c2ctech/data/data.csv
sudo chown code2care /Users/c2ctech/data
Example 2: Change owner group only
sudo chown :devs /Users/c2ctech/data/data.csv
sudo chown :devs /Users/c2ctech/data
Example 3: Change both owner and group
sudo chown code2care:devs /Users/c2ctech/data/data.csv
sudo chown code2care:devs /Users/c2ctech/data
Facing issues? Have Questions? Post them here! I am happy to answer!
- Rename a directory using Linux/Unix command
- ls command to list only directories
- How to Restart or Reload Nginx Server Service on Linux
- 3 ways to clear screen on Linux Terminal
- ls command: sort files by name alphabetically A-Z or Z-A [Linux/Unix/macOS/Bash]
- Copy entire directory using Terminal Command [Linux, Mac, Bash]
- Fix: sudo: unable to open Read-only file system
- Create Hidden File or Directory using Shell Command
- Command to know the installed Debian version?
- The Date Command and its usage [Linux - Unix - macOS]
- Fix - bash: man: command not found
- How to tar.gz a directory or folder Command
- How to Display content of a file in Terminal Screen?
- How to change bash terminal prompt string and color
- Sort ls command by last modified date and time
- Execute .bin and .run file Ubuntu Linux
- zsh hello world example
- How to check uptime of Linux/Unix/macOS system/server using console command?
- [Fix] Linux - bash: useradd: command not found
- Command to check Last Login or Reboot History of Users and TTYs
- How to install and Configure sar sysstat tools in Ubuntu Linux
- How to use SCP Command to Copy Directory
- Linux Remove or Delete Files and Directories using Terminal Commands
- How to connect to SSH port other than default 22
- Install OpenSSL on Linux/Ubuntu
- Mac: How to Change Terminal Background Color - MacOS
- PowerShell iterate and get all SharePoint sites and sub sites - SharePoint
- Get Button Text onClick Android App - Android
- Python - Convert float to String - Python
- cURL -d Option with Examples - cURL
- Open Large File in Notepad++ (Fix: File is too big to be opened by Notepad++) - NotepadPlusPlus
- Change Mac Default Browser [updated for macOS Ventura] - MacOS
- Enable and reduce background noise in Microsoft Teams with AI-based noise suppression - Teams