Ben Chuanlong Du's Blog

And let it direct your passion with reason.

Account Management in Linux

** Things on this page are fragmentary and immature notes/thoughts of the author. Please read with your own judgement! **

Create a User

Both adduser and useradd can be used to create a new user. adduser is interactive while useradd is non-interactive. It is suggested that you use useradd in batch …

Get Group Names on Linux/Unix

Linux

  1. Get information of the staff group.

    $ getent group staff
    staff:x:20:
    
  2. Get group ID of the staff group.

    $ getent group staff | cut -d: -f3
    20
    

Mac

  1. Get information of the staff group.

    $ dscl . -read /Groups/staff
    
  2. Get group ID of the staff group.

    $ dscl . -read /Groups/staff | awk …

List Running Jupyter Notebook Servers

You can list running Jupyter Notebook servers using the following command.

jupyter notebook list

It works well most of the time. However, if the servers are launched using the root account (e.g., in a Docker container), you might encounter issues. In this case, a better alternative is to list …

Run JAR Applications

If there is only 1 class with a main method or if there is a Main-Class defined for the JAR, you can use the following command to run the application.

java -jar app.jar

If you there are multiple classes with main methods in the JAR, you can execute any …

Add Users to a Group in Linux

There are several ways to add users to a group in Linux. The following uses the sudo group as illustration.

  1. gpasswd, usermod and adduser can all be used to add a user to a given group. However, it is suggested that you use gpasswd as it is more portable and …