User ID(UID), GID (Group ID) in Linux are numerical identifiers to set access to files, directories and system resources, just like rwx which in octal equivalent is r=4, w=2, x=1 and the desperate permission which will equal to 777.
777 is quite useful when nothing is working and an easy way out but yes use sparingly. UID and GID can be used also to restrict permissions or access.
Quite a few ways to get UID value for the current login user.
At terminal typing:
echo "$UID"
id -u
echo/run/user/$UID
All commands above are the same, get the user id of the currently logged in user.
To get the GID, or the group membership of the currently logged in user is quite straight forward, at terminal type:
id
The output will be the group-id(name of the group) and those are the group membership of the currently logged in user.
id -Gn will just list the groups without the GID.
id -G will just list the GIDs without name group
Another quite useful variable, if let's say someone is asking for help, how to add themselves to a specific group and you're not sure what is his or her username is just to pass this command:
sudo usermod -aG libvirt $USER
Change libvirt to any group name. In this example the currently logged in user will be added to libvirt group.
That's it, continue learning. Enjoy Linux.
When everything seems to be too hard, pause, relax and Pray.
Prayer is powerful, believe and you will be heard.
Be humble, you don't have to carry everything.
God loves you always.
Comments
Post a Comment