Hello guys! We are going to create some quick and simple knowledge articles (so as not to get bored) of things that we often already know, but at some point in an interview or selection exam, we forget, and these simple articles usually exercise our mind to fix and avoid forgetfulness. And always with more intelligent commands that will make us memorize better and better. So let’s go to 5 Useful Commands for your Linux !!!
01. Find out if your user is in a group
02. Insert user in a group
03. Check if your user can use sudo
04. Getting information about a file
This command displays creation data, modification date. change and other information.
05. Working with permissions
- If we were to give zero permission to everyone, we could use chmod or chown:
chmod 0 file.txt
- If we want to return the initial permissions, we would use the same as it was:
chmod 644 file.txt
- And to change the owner:
sudo chown root file.txtthat way we change the owner and not the group, if we wanted to change the group we would also use:
sudo chown root:root file.txt
Viewing again with
stat we notice that the owner and/or the group have been changed, but we realize that the group is only allowed to read (r, read), if we wanted to get that permission, we can also use either
- with chmod:
sudo chmod g-r, for group (g) get (-) read permission (r, read), if we check the file again we will see that instead of
-rw-r–r–and now that is:
0604/-rw—-r–, others can still read (
r–), but if he is only part of the marcos group, his permission corresponding to the 3rd octet is ZERO 0 or -.
We soon realized that
Tip with image for each number the corresponding output for the octet: