Posts tagged "user"

Change default shell for new users

If you have a system with lots of new users, you probably want to set the default shell to the one that most users prefer.

If you're using the useradd command, you can set default options in the file /etc/default/useradd.

Editing this file can be done by using useradd -D ...:

# set default shell for new users to bash
useradd -D -s /bin/bash

Check here for more information.


Get granted roles with psql

With psql, there is an easy way to check which roles are granted to a role: \du

henk=> CREATE ROLE accounting;
CREATE ROLE
henk=> CREATE ROLE alex;
CREATE ROLE
henk=> GRANT accounting TO alex;
GRANT ROLE
henk=> \du accounting
             List of roles
 Role name  |  Attributes  | Member of
------------+--------------+-----------
 accounting | Cannot login | {}

henk=> \du alex
              List of roles
 Role name |  Attributes  |  Member of
-----------+--------------+--------------
 alex      |              | {accounting}

Specify docker exec user

With docker exec, you can execute commands inside of running Docker containers. The --user flag allows you to declare the user to use inside the container.

Example:

$ docker run -d
cf4bea1aa03eafc0a4adf49cc1f38e98de66ab586cbf026d369de2d51f83fbc3
$ docker exec -it --user postgres cf4bea1a /bin/bash
postgres@cf4bea1aa03e:/$