To display a file's access attributes, use the
ls command with a
$ ls -l helloWorld.txt
-rwxr--r-- 1 JohnDoe staff Apr 01 10:45 helloWorld.txt
-rwxr--r-- are called the file attributes. They are made up of the file type, and file modes, as you can see in the figure below.
The first character represents the file type. Here are the options it can have.
rwxrwxrwx, which are just dummy variables.
You'll mainly be dealing with
- (regular files) and
The next nine characters represent the file modes for owner, group and all, respectively.
Let's see what values these modes can hold.
For a regular file, we have three simple attributes.
Thus, if the owner, group, or all has any of these attributes listed in their file mode, that means they are permitted to perform that command.
For example, let's look at file1.txt.
$ ls -l file1.txt
-rwxr----- 1 JohnDoe staff Apr 01 20:40 file1.txt
From the file type we can tell that this is a regular file (
-) The file modes tell us that the user can read, write and execute (
rwx), group members can only read (
r--), and the world has no access to anything (
To view the directory permission attributes, specify a
-d option - otherwise the shell will just list the files within that directory.
$ ls -dl dir1
drwxr-xr-x@ 6 JohnDoe JohnDoe 204 Mar 30 13:15 dir1
If the file is a directory (i.e. its first letter is
d), then its file attribute meanings are a little different.
w attributes to be valid, the
x attribute must also be set.
In this completely revised second edition of the perennial best seller How Linux Works, author Brian Ward makes the concepts behind Linux internals accessible to anyone curious about the inner workings of the operating system. Inside, you'll find the kind of knowledge that normally comes from years of experience doing things the hard way.$ Check price
Relieve your stress, back, neck and sciatic pain through 1,782 acupuncture points for immediate neck pain relief. Made for lower, upper and mid chronic back pain treatment, and improves circulation, sleep, digestion and quality of life.$$ Check price