I use the following command:
ls -l
As a result, I get the name of the files in the folder that I'm currently in, along with when they were last accessed, etc. On the left side, there are a string of characters and sometimes dashes. I was wondering if anyone can provide me a quick guide as to what each of the characters represent?
I can assume the first 'd' stands for directory, since that is the name of one of my folders. I'm assuming 'x' is for executable? Not sure, so can someone break it down for me?
This is what I'm referring to:
dr-xr-xr-x
Thanks for all of help.
From left to right every three letters together is a permission set designated for each kind of user. There are three kinds of permissions in every set
From left to right each set designate the permissions for
respectively on that file
So in your case the directory has read and execute permissions for owner, group and others('-' specifies that particular permission is not there). Permissions can be changed using the chmod command provided that you have the access privileges on that file/directory to do so.
From the
man
page ofchmod
:meaning
The first character is the type of file, usually you will see
d
for directory,-
for regular file, orl
for link.The next nine characters represent three different types of permissions for the file: user permissions, group permissions, and other permissions.
The first character will either be
r
or-
, indicating read permission.The second character will either be
w
or-
, indicating write permission.The last character will either be
x
or-
, or a number of different characters depending upon special properties of the file as described in the manual for ls (below).There may also be another character after these nine, specifying special access permissions, which are described manual for ls (below).
From the manual for ls
From the OpenBSD Manual Pages. Note that this also could be view in the command prompt using
man ls
. (Handy for future similar look-ups, eh!)The Long Format If the -g, -l, or -n options are given, the following information is displayed for each file: mode, number of links, owner (though not for -g), group, size in bytes, time of last modification (“mmm dd HH:MM”), and the pathname. In addition, for each directory whose contents are displayed, the first line displayed is the total number of blocks used by the files in the directory. Blocks are 512 bytes unless overridden by the -k option or BLOCKSIZE environment variable.
If the owner or group name is not a known user or group name, respectively, or the -n option is given, the numeric ID is displayed.
If the file is a character special or block special file, the major and minor device numbers for the file are displayed in the size field.
If the -T option is given, the time of last modification is displayed using the format “mmm dd HH:MM:SS ccyy”.
If the file is a symbolic link, the pathname of the linked-to file is preceded by “->”.
The file mode printed under the -g, -l, or -n options consists of the entry type, owner permissions, group permissions, and other permissions. The entry type character describes the type of file, as follows:
The next three fields are three characters each: owner permissions, group permissions, and other permissions. Each field has three character positions:
The first of the following that applies: - S - If in the owner permissions, the file is not executable and set-user-ID mode is set. If in the group permissions, the file is not executable and set-group-ID mode is set. - s - If in the owner permissions, the file is executable and set-user-ID mode is set. If in the group permissions, the file is executable and setgroup-ID mode is set. - x - The file is executable or the directory is searchable. - - The file is neither readable, writable, executable, nor set-user-ID, nor set-group-ID, nor sticky (see below).
These next two apply only to the third character in the last group (other permissions):
In addition, if the -o option is specified, the file flags (see chflags(1)) are displayed as comma-separated strings in front of the file size, abbreviated as follows: