The files permissions under Haiku let you choose if a file or a folder can be read, write or executed by you.
Even if Haiku operating system doesn't handle multiple users or any kind of "root" user, it's interesting to know how to change the access rights on a file.
Do you know the User Guide which is displayed by default on the Haiku desktop ?
Maybe not entirely, I will explain you why :)
You might know that the User Guide is opening the HTML page corresponding to the user guide.
However the link used behind is /bin/userguide Let's review this file from a permission point of view.
Type in a Terminal the below command to display the details of the access rights :
ls -l /bin/userguide
You might notice the strange characters displayed at the beginning of the line returned :
- r-x r-x r-x
The meaning of each character from 0 until 9 is as below : (0) The first symbol indicates the file type :
(0) (123) (456) (789)
(123) The symbols from 1 to 3 indicate the rights of the user on the file :
(456) The symbols from 4 to 6 indicate the rights of the group on the file :
(789) The symbols from 7 to 9 indicate the rights of others on the file :
In the case of the /bin/userguide, the meaning is that :
Now let's compare the "User Guide" on the Desktop which is just a link versus the /bin/userguide which is a command.
Copy the userguide command on the Desktop :
cp /bin/userguide /boot/home/Desktop
As you can see :
Now let's do some modifications on the "userguide" copied on the Desktop :
chmod u+r /boot/home/Desktop/userguide
Add (+) read right (r) to the user (u) on the file
chmod u-r /boot/home/Desktop/userguide
Remove (-) read right (r) on the user (u) on the file
chmod 700 /boot/home/Desktop/userguide
Give all accesses (7) to the user and no access to the group (0) or to others (0).
For the details : 7 is corresponding to 4(r)+2(w)+1(x) while 0 indicates no right.
chmod o-rwx /boot/home/Desktop/userguide
Remove (-) the read right (r) the write right ( w) and the execution right (x) to others (o)
chmod a+r /boot/home/Desktop/userguide
Add (+) the read right (r) to all (a).
All means : user (u) + group (g) + others (o).
chmod go+r /boot/home/Desktop/userguide
Add (+) read right (r) to the group (g) and to others (o).
Let's open the file "userguide" :
o
pen /boot/home/Desktop/userguide
As you can see it will open the "User Guide" HTML page corresponding to your language.
Now let's remove the "execution" right on this file :
chmod u-x /boot/home/Desktop/userguide
If you open the file again :
Tada !
It's now opened in Styled Edit.
Do you know the reason ?
Well, as you can see, the content of this file is a bash script.
Removing the execution right, means that now it will not be possible to execute that script, that's why it's opened in a text editor :)
There's another way to change the permissions on a file.
Right click on it and select "Get info" :
As you can see there's a "Permissions" tab allowing you to change the owner/group/other rights :
Nice ?
To finalize this article, let's compare the differences between a link to "User Guide" versus the bash file corresponding to "userguide".
On the "Information" tab :
The first indicates it's a "Symbolic link" while the second indicates it's a "Text file".
On the "Permissions" tab :
The link can be read / modified / executed while the file can be read / executed.
On the "Attributes" tab :
The attributes for the link do not contain much information, while the bash script file is including an icon.
Please note that depending on the folder or file location, you don't have all the rights to change the permissions on it.
For instance the "/boot/system" is a system directory and you will not be able to change it.
The opposite in the "/system/non-packaged" folder : it's not a system directory, so you will be able to change the access rights.
I hope you have found this article useful, if you would like to share some information on that topic you can put a comment below.