You have seen the strange characters that accompany a filename when it is listed. You would like to know what they all mean.
To see the permissions and ownership information relating to files and directories, use the ls command with the option -l.
Discussion
Run the command ls -l, and you will see a result like this:
$ ls -l total 16 -rw-r–r– 1 pi pi 5 Apr 23 15:23 file1.txt -rw-r–r– 1 pi pi 5 Apr 23 15:23 file2.txt -rw-r–r– 1 pi pi 5 Apr 23 15:23 file3.txt drwxr-xr-x 2 pi pi 4096 Apr 23 15:23 mydir |
Figure 3-6 shows the different sections of the listing information. The first section contains the permissions. In the second column, the number 1 (labeled “Files”) indicates how many files are involved. This field only makes sense if the listing entry is for a directory; if it is a file, it will mostly be just 1. The next two entries (both pi) are the owner and group of the file. The size entry (the fifth column) indicates the size of the file in bytes. The modified date will change every time the file is edited or changed and the final entry is the actual name of the file or directory.
The permissions string is split into four sections (Type, Owner, Group, and Other). The first section is the type of the file. If this is a directory, it will be the character d; if it is just a file, the entry will be just a -.
The next section of three characters specifies the owner permissions for that file. Each character is a flag that is either on or off. So if the owner has read permissions, there will be a r in the first character position. If he has write permissions, there will be a w in the second slot. The third position, which is – in this example, can be x if the file is executable (a program or script) for the owner.
The third section has the same three flags but for any users in the group. Users can be organized into groups. So, in this case, the file has a user pi and a group ownership of pi. So, if there were any other users in the group pi, they would have the permissions specified here.
The final section specifies the permissions for any other users who are neither pi nor in the group pi.
Since most people will only ever use the Raspberry Pi as the user pi, the permissions of most interest are in the first section.
See Also
To change file permissions, see Recipe 3.13.