File Types#
Reviewing our output again:
1 2 3 4 5 6 7 8 9 10 11 12 |
|
We can breakdown the very first group: -rw-r--r--
. This group is in fact another series of groups:
- Type:
-
- User permissions:
rw-
- Group permissions:
r--
- Other permissions:
r--
Note
We'll discussed the permission groups shortly.
The very first column, a -
in our case, is the file type.
All you need to know is that -
means a file; d
means a directory; and l
means a (symbolic) link. Everything else is uncommon and can be looked up in a manual page.
Just learn to recognise files, directories, and links within a directory listing.
Symbolic Links#
A symbolic link (l
) is like a special file type that means the file you're seeing is actually an "address" to another file. If you open the file and edit it, you'll be editing the file to which the symbolic link points, not the symbolic link itself. If you delete the symbolic link, you may actually delete the file it points to and the link. Instead of using rm my_link
, you would instead use unlink my_link
to play it safe.
Here's an example of a symbolic link in a listing:
1 2 3 |
|
Note
This listing was generated on my macOS machine. I like to move between systems when demonstrating this kind of work because it shows not much changes between systems.
We have two things in the listing:
- A symbolic link:
l
- A directory
d
The link can be clearly seen in the listing: document -> myfiles/important_document.txt
. We can look inside the files:
1 2 3 4 5 |
|
And if we edit document
, we can see it affects the original file:
1 2 3 4 |
|
I edited document
, but it edited myfiles/important_document.txt
.
This is a simple concept to understand. Just have a play around and create your own symbolic links using the ln -s
command (and remember man ln
, of course.)