Skip to content

SettingPriorityUnderLinux

Here are the step-by-step instructions to set up the goxpyriment group with those high-priority privileges.


Step 1: Create the Group

First, you need to create the group in the system database.

sudo groupadd goxpyriment

Step 2: Create the Limits Configuration

Linux stores these specific "privilege" rules in /etc/security/limits.d/. You should create a new file specifically for your group so it doesn't mess with other system settings.

  1. Open a new config file:
    sudo nano /etc/security/limits.d/99-goxpyriment.conf
    
  2. Paste the following lines into the file:
    @goxpyriment - nice -20
    @goxpyriment - rtprio 50
    @goxpyriment - memlock unlimited
    
  3. Save and Exit: Press Ctrl + O, then Enter to save, and Ctrl + X to exit.

Step 3: Add Yourself (and others) to the Group

Simply creating the group isn't enough; you have to tell Linux which users belong to it. Replace $USER with a specific username if you are adding someone else.

sudo usermod -aG goxpyriment $USER

Step 4: Apply the Changes

Important: Linux only checks group memberships and limits when a user logs in.

  • You must log out of your Linux session and log back in.
  • Alternatively, you can run su - $USER in your terminal to start a sub-shell with the new permissions for testing.

How to Verify it Worked

Once you’ve logged back in, you can verify that your Go program (or any process) will have these rights.

1. Check Group Membership: Run the command groups. You should see goxpyriment in the list.

2. Check the Memory Lock Limit: Run this command to see your current "Max locked memory" limit:

ulimit -l
If it says unlimited, you are good to go!

3. Check Real-Time Priority: Run:

ulimit -r
It should return 50.


⚠️ A Friendly "Warning"

Since you are giving your code the ability to run at -20 niceness (the highest possible priority), a "busy loop" in your Go code (like for { } without a sleep) could potentially freeze your entire desktop.

Because your code is now more "important" than the mouse driver or the window manager, the OS won't interrupt your code to let you click "Stop." Always keep a terminal open with a top or htop window ready, or test your logic with lower priority first!