Managing File Ownership
Shell·3 min read·Jan 1, 2025
In Unix-like operating systems, file ownership refers to the user and group that have control over a particular file or directory through the use of file permissions.
Together, ownership and permissions allow to improve the overall security of the system by enabling administrators and users to control who can access and modify each file and directory.
Checking file ownership
To display detailed information about a file, including its ownership, you can use the ls command with the -l flag as follows:
$ ls -l [file ...]Where file ... is an optional list of paths to the files you want to check.
Note: For directories, you'll have to specify the path to the parent directory, as the
lscommand will otherwise list the content of the target directory.
Example
This command will display extended information about all the files and directories located in the current working directory:
$ ls -l-rw-r--r-- 1 john developers 0 Apr 22 16:18 script.shWhere:
-
johnis the name of the user the files belong to.
Unlock the CLI & Scripting with Bash module
Learn how to gain advanced control over the OS and automate complex routine tasks prone to manual errors with the CLI and Bash scripting.
You get immediate access to:
- 34 focused lessons across the CLI and Bash
- 4 real-world projects with commented solutions
- Ongoing updates to this bundle
- Lifetime access to this bundle