In today’s episode of Linux Commands Explained, we’ll look at how to make soft and hard links, as well as how to list, set, and change file permissions in Kali Linux.
To get the previous episodes of Linux Commands Explained click the link below:
Creating Soft and Hard links in Kali Linux.
To begin with, let’s define what a “soft link” and a “hard link” are. A soft link, also known as a symbolic link, serves as an actual link to a file, whereas a hard link serves as a mirror copy. When we remove the original file, the soft link is rendered worthless since it will be connecting to a non-existent file, however with a hard link, the file will still exist because it is a mirror copy and will not be affected if the original file is deleted.
A soft link has the following characteristics:
- It allows the linking of files and folders.
- The path to the original file is included, but not the contents.
- The inode number and file permissions are different from the original.
A hard link has the following characteristics:
- It confines one to only linking files.
- The inode number and file permissions are the same as the original file.
- If the file permissions on the original file change, the linked file will be updated as well.
- It has the same contents as the original file, and the contents are preserved even if the original file is moved or deleted.
Here’s an example of how to make a soft link:



Here’s an example of how to make a hard link:

When we make modifications to the contents of the hard linked file, the changes are reflected in the original file as well. The image below is a good example of this.

You’re probably wondering what the point of a hard link since it functions similarly to the copy command. The difference between a hard link and a copy command is whenever we copy a file, we duplicate it, and if we edit the duplicated file, the change only affects that one file, however when we alter a hard link, the change affects all the files that share that hard link.

File Permissions in Kali Linux.
When it comes to permissions, Kali Linux files and folders have three sections:
- User –> u
- Group –> g
- Others –> o
This is shown clearly in the picture below:

Types of permissions abbreviations and their meaning;
- r -> read
- w -> write
- x -> execute
- l -> soft link
- d -> directory
- S or s -> SUID or SGID permission
- T or t -> sticky bit permission
We use the ls -l command to show the file permissions and also show the user and group owners of a particular file and directory.

To view the available users we use the users command whereas to see the available groups we use the groups command.

To change the ownership of a file or directory we use the chown command. It takes two arguments that is., sudo chown [user]:[group] <file or directory>.

Let’s restore the file ownership.

To add or remove permission to a file or q we user the chmod command which mean change mode. It takes two arguments that is., sudo chmod [option] <file or directory>.

Below are examples of chmod usage:
- sudo chmod o+r <file> –> gives write permission to others.
- sudo chmod g+rw <file> –> gives read and write permission to the group.
- sudo chmod o-rwx <file> –> removes read, write and execute permissions from the others.
- sudo chmod u-w <file> –> removes write permissions to the user.
- sudo chmod g+rx,u+rwx,o+r <file> –> this command gives read and execute permissions to the group, gives read, write and execute permissions to the user and gives read permission to the others.
- chmod u+w or u+rw or u+rwx <file> –> adding permissions to user.
- chmod g+w or g+rw or g+rwx <file> –> adding permissions to groups.
- chmod o+w or o+rw or o+rwx <file> –> adding permissions to others.
- chmod u-w or u-rw or u-rwx <file> –> removes permissions to user.
- chmod g-w or g-rw or g-rwx <file> –> removes permissions to groups.
- chmod o-w or o-rw or o-rwx <file> –> removes permissions to others.
Numbers can also be used to change the permissions of files and directories. Here are some numbers and what they represent when they’re used with chmod:
- 0 : no permission.
- 1 : execute (x)
- 2 : write (w)
- 3 : execute + write (wx)
- 4 : read (r)
- 5 : read +execute (rx)
- 6 : read + write (rw)
- 7 : read + write + execute (rwx)
Below is an example of the above:

Below are some more examples of chmod usage:
- sudo chmod 777 <file>
- sudo chmod 666 <file>
- sudo chmod 222 <file>
- sudo chmod 544 <file>
Hope this articles was helpful.
Happy hacking !!
Discover more from TechED Africa
Subscribe to get the latest posts sent to your email.