1

In an almalinux9.5 machine, I am sudo user. I am using a vnc session to access the machine. I've added myself from this vnc machine to linux groups using :

sudo usermod -aG <group-name> <user-name>

However when checking my groups, I am not able to see the new groups added except in two cases:

Logging again from my existing terminal : su -l $USER . Opening a new ssh session. Note that: In the vnc session, when opening another terminal, and checking the groups, I can't see the new groups added, expect "as mentioned above" by re-logging. So as workaround I need to re-login everytime I open a new terminal or work from ssh which is not practical in my case.

Do I miss something?

2 Answers 2

1

The process group membership is assigned at login time and a few other times (like su, sudo) and existing processes (like your vnc session) do not get the new groups.

If you close your vnc session and start a new one, the issue will go away, the new session will have the group memberships that existed at its start.

There are exactly two solutions to this:

  • Do what you are doing, elevate to the new groups each time you need them.
  • Restart your session so the the new permissions can propagate to the new processes.
2
  • Restarting vnc does not work, I am using vncserver as a service What I done and didn't work: 1- sudo systemctl restart vncserver@:1 2- sudo systemctl stop vncserver@:1 sudo systemctl start vncserver@:1 3- sudo systemctl disable vncserver@:1 sudo systemctl enable vncserver@:1 sudo systemctl start vncserver@:1 What I done and worked as mentioned: su -l $USER but worked only for the existing shell Commented Apr 25 at 0:02
  • You have to do the equivalent of logging out of the session and logging back in. If restarting vncserver doesn't reset your session, you have to do something else. Commented Apr 25 at 4:59
0

Solved by killing all the user processes:

sudo pkill -9 -u $USER

In my case, vnc will be restarted automatically as I am having in the service file:

[Service]
Restart=on-success
RestartSec=10

However, restarting vnc only did not solve the issue.

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.