-rw-r--r-- 1 root root 1502 May 14 23:06 file1.css
-rw------- 1 www-data root 894 Mar 28 01:10 file2.html
What is the permission difference between these two files?
In Linux and Unix, everything is a file. Directories are files, files are files and devices are files. Devices are usually referred to as a node; however, they are still files. All of the files on a system have permissions that allow or prevent others from viewing, modifying or executing.
In first one
-rw-r--r--
the permissions are as follows for user, group and others
owner = Read & Write (rw-)
group = Read (r--)
other = Read (r--)
while in second one
-rw-------
only user have read, write permission,i.e
owner = Read & Write (rw-)
group = None (---)
other = None (---)
For more details read File Permissions Here
The first file:
-rw-r--r-- 1 root root 1502 May 14 23:06 file1.css
This file root root
is owned by the user root
which as you can see is specified by being in the file owner column of the listing. The second reference to root
is in the 4th column of the listing. That is the column that is showing the group owner of the file. The group owner is root.
The second file:
-rw------- 1 www-data root 894 Mar 28 01:10 file2.html
As specified by what's shown in the 3rd column, this file is owned by the username www-data
. as you can see, the group owner of the second file is root
.
You have usernames (user id) and group names (group id) for who owns files in Unix/Linux. The names of the user and group can be the same, or they can be different. Using the Long Listing
of ls
(ls -l
), you can see this type of detail about the file.
In short, the difference is the specific userid owner
and group id owner
. They are different in the two files.
Below is more details about the listing. A significant characteristic of the files is specified in column one of the listing. It is showing the type of permission given to the file, such as read, write, and execution.