'sudo id -G <username>' vs 'id -G' issue

Ralf Mardorf silver.bullet at zoho.com
Thu Nov 3 07:39:57 UTC 2016


On Thu, 03 Nov 2016 09:50:04 +1100, Karl Auer wrote:
>On Thu, 2016-11-03 at 09:07 +1100, Karl Auer wrote:
>> Or use newgrp?  
>
>I should point out that newgrp puts you in a subshell. It doesn't
>actually change the groups in the running shell.

Thank you Karl,

it should work for my purpose.

ubuntu-mate at ubuntu-mate:~$ touch fata_morgana
ubuntu-mate at ubuntu-mate:~$ echo "thieves' den opened" > open_sesame
ubuntu-mate at ubuntu-mate:~$ sudo chown 1001:1001 open_sesame
ubuntu-mate at ubuntu-mate:~$ sudo chmod o-rwx open_sesame
ubuntu-mate at ubuntu-mate:~$ cat open_sesame
cat: open_sesame: Permission denied
ubuntu-mate at ubuntu-mate:~$ sudo groupadd -g1001 alibaba
ubuntu-mate at ubuntu-mate:~$ sudo usermod -aG alibaba ubuntu-mate
ubuntu-mate at ubuntu-mate:~$ newgrp - alibaba
ubuntu-mate at ubuntu-mate:~$ cat open_sesame
thieves' den opened
ubuntu-mate at ubuntu-mate:~$ touch morgiana
ubuntu-mate at ubuntu-mate:~$ ls -l *org*
-rw-rw-r-- 1 ubuntu-mate ubuntu-mate 0 Nov  3 08:23 fata_morgana
-rw-rw-r-- 1 ubuntu-mate alibaba     0 Nov  3 08:25 morgiana
                         ^^^^^^^
                         ^^^^^^^ even this doesn't matter.
ubuntu-mate at ubuntu-mate:~$ id | cut -d\  -f2
gid=1001(alibaba)

Regards,
Ralf





More information about the ubuntu-users mailing list