To view the current ownership of a file, you use the ls (list) command with the -l (long format) option.
In your current environment, you can run:
ls -l example.txt
How to read the output:
When you run that command, you will see a line like this:
-rw-rw-r-- 1 labex labex 0 Dec 23 03:16 example.txt
The two names in the middle represent the ownership:
- The first
labex: This is the Owner (the user who owns the file). - The second
labex: This is the Group (the group that owns the file).
Pro Tip:
If you want to see the ownership of all files in your current directory, simply type:
ls -l
This is one of the most common commands you'll use in Linux to check permissions and ownership quickly! Give it a try in your terminal to see if the owner has changed to root after your last command.