Linux offers multi-user functions (more than 1 user can operate the computer at the same time).
In networks that require remote connection, users ssh into the machine.
Secure Shell(ssh): a network protocol that allows users to log into a remote machine and execute commands in an insecure network.
File permissions
Files and directories have different access rights and these rights can be assigned. These rights are privileges that users have to either read(r), write(w) and execute(x) a file.
Some commands used to change file permissions include:
chmod:
This command changes the permissions of a file or directory. When it is typed with an option and a file name it is used to change the permission of a file.
In the photo above, the file "file" never had read(r) write (w) and execute (x) permissions for the user and group but I modified the file permissions with the command chmod 777 file
Permissions can be changed systemically or absolutely.
Systemical Method:
uses letters to add permission to files.
Using the diagram above the user, group and other users have all read, write and execute permissions.
For further illustration, the first rwx are the file permissions for the user, the next one is for the group and the last is for other users.
When a systemical method of modifying permission is used, we use letters to modify.
Assuming I want to remove the read permission the user has, I simply type
chmod u-r [name of file]
This command removes the read permission from the current user as illustrated above.
In the systemic method,
u: user
g: group
o: other users
These letters can be used to modify the permissions a user, group or other users have.
Let’s try one more illustration
Let’s give the user read permission to the file using the systemic method
chmod u+r [name of file ]
Voila!!
Absolute Method
The absolute method modifies file permissions by the use of numbers in the octal notation (base 8)
In the systemic method, the read permission has a value of 4.
Write permission has the value of 2.
Execute permission has the value of 1.
To remove read permission from the user we simply type
chmod 377 [name of file]
What this command did was to add 2(write) and 1(execute) (2+1 =3) together while it excluded the read (4).
To change the file permissions using the absolute method you combine the numbers.
To add read, write and execute permissions to the user, group and other users.
The command is chmod 777 filename
To remove read, write and execute permissions to the user, group and other users.
The command is
chmod 000 [filename]
Directory permissions
Are somewhat different as read(r), write(w) and execute(x) mean different things.
r= allows the content of a directory to be listed.
w= allows files in a directory to be created, deleted or renamed.
x= allows entry into a directory (the change directory command can be used to switch to it (cd
)).
Superuser(su)
This command allows a user to become a super user and perform administrative tasks. To exit the su
program type exit
sudo:
this stands for super user do. It’s an alternative to su
. It’s used to execute a command that only admins such as the root user can execute.
It requires a password for authentication.
It can also be accessed with
sudo-i
.
chown
This command is used to change the ownership of a file. When the user is not an administrative user it’s combined with sudo to make it executable.
sudo chown [filename]
chgrp
This command is used to change the group of a file or directory.
adduser
Is used to add a user to Linux.
It must be done as a root user.
id
Is used to display the id of the current user.
groups
Displays the user the group a file or directory belongs to.
whoami
Displays the id of the current user.
Summary
Subscribe to my newsletter to get notified when I drop my next post.