Day 16 of my ALX Software Engineering Journey: File / User Management Commands

Today I was able to get a grasp of some commands that help with managing files and users in Linux . The linux commands we are being exposed to are getting much these days but I’m ready to take them all up to the best of my ability . Like Fred Swanicker said “The only way to justify privilege is by doing hard things “ so my mind is already conditioned to surmount any task brought to me no matter how difficult it gets .

Over to what I learnt today , I learnt a couple of commands and I learnt more about the context of file permissions.

Let’s get to it :

This image above explains the file permissions granted to different users . I’ve written about this file permission before you can look at it here

Now the first set of characters written as rwx depicts the changes the owner of the file can make (read , write and execute).

The second set of characters is written as rwx . It depicts the changes the group owner can make to the file (read , write and execute).

The third set of characters is written as rwx . It depicts the changes the other users that have access to the file can make to the file (read , write and execute).

Perhaps , we want to change the file permissions for any of these users we use the command chmod and it’s used in this context

chmod o+x (filename)

This command adds execution permissions to other users who have access to filename.

o stands for other users (others). You could interchange it with any other user of choice depending on the permissions you want to add or remove . If you would want to change the permissions for group you use

chmod g+x

same thing for the owner of the file chmod u+x . Easy pizzy!

How about if we want to remove permissions? Just substitute the + with minus -

Doing all this is stressful so there’s a shortcut to editing these file permissions.

Take note of these digits 4 2 1 0. With these digits you can edit file permissions. I’m not kidding , just follow me

4 = read permission(r)

2 = write permission(w)

1 = execute permission(x)

0 = no permission(-)

Using our regular rwx permission we can depict it using these numbers . if a user has all permissions rwx it is equal to 7

How?

Add 4 + 2 +1 = 7

Let’s try r-w this would be equal to 6

Now if we want to edit this permission for all three users , We type the command

chmod 666 (filename)

Now that’s easier than the first method!

I learnt some other commands that works on Linux:

su - this stands for switch user and it’s used to switch users in the linux environment

sudo- this stands for super script it’s used to give administrative privileges to a user .

whoami- this commands prints the current user.

adduser : this command adds a user to a file or directory .

addgroup : this command adds a group to a file or directory.

chown - this command is used to change ownership of a particular file.

chgrp - this command is used to change the group a file belongs to.

Did you find this article valuable?

Support Dillibe by becoming a sponsor. Any amount is appreciated!