Skip to content

Retrieving UID and GID on Synology NAS

Introduction

Synology NAS devices run on a Linux-based operating system, which manages file and user permissions using User IDs (UIDs) and Group IDs (GIDs). Knowing these IDs is essential when configuring permissions for network shares, Docker containers, or custom scripts. This guide covers two methods to retrieve UID and GID on a Synology NAS: via SSH (command-line interface) and through a custom script on the Synology DSM web interface.


Enabling SSH Access

Before using the CLI method, SSH must be enabled on your Synology NAS:

  1. Log in to DSM (DiskStation Manager) via your web browser.
  2. Navigate to Control PanelTerminal & SNMP.
  3. Check the box Enable SSH service and click Apply.
  4. Note your NAS IP address (found under Control PanelNetwork).

Security Notice

Ensure that you disable SSH when not in use to prevent unauthorized access.


Method 1: Using SSH and the id Command

Once SSH is enabled, follow these steps to retrieve your UID and GID:

  1. Open a terminal (Linux/macOS, Windows) or tools like PuTTY, Termius as example.
  2. Connect to your Synology NAS using SSH:
    ssh username@your-nas-ip
    
  3. Enter your password when prompted.
  4. Run the id command to display UID and GID:
    id
    
Example output
uid=1026(user) gid=100(users) groups=100(users), 101(administrators)
  • uid=1026 → The UID of the logged-in user.
  • gid=100 → The primary group ID.
  • Additional groups indicate membership in multiple groups.

To check another user’s UID and GID, use:

id <username>


Method 2: Using a Custom Script in DSM Web (E-Mail)

For users who prefer a web-based solution, a simple script can be executed via Synology’s Task Scheduler:

Creating the Script

  1. Log in to DSM.
  2. Open Control PanelTask Scheduler.
  3. Click CreateUser-defined script.
  4. Under General, name the task (e.g., "Retrieve_UID_GID").
  5. Set User to the account whose UID and GID you want to retrieve.
  6. Go to the Task Settings tab and enter the following script:
     id
    
  7. Click OK and then Run the task.
  8. An email containing your UID and GID information will be sent to you.

Image-based manual

Image title

Open Control PanelTask Scheduler.

Click CreateUser-defined script.

Image title

Under General, name the task (e.g., "Retrieve_UID_GID").

Image title

Under Schedule, set the task to "Run on the following date" and select "Do not repeat" under Repeat.

Image title

Under Task Settings, enable "Send run details by email", enter the recipient email address, and add the id command under User-defined script to retrieve and send the UID and GID information.

Image title

Under Task Scheduler, select the task "Retrieve_UID_GID", click "Run", and confirm by clicking "OK" in the dialog to execute the script immediately.

Image title

After running the task, the Task Scheduler confirms completion. The Standard output displays the retrieved UID and GID information.


Method 3: Using a Custom Script in DSM Web (Shared Folder)

For users who prefer a web-based solution, a simple script can be executed via Synology’s Task Scheduler:

Creating the Script

  1. Log in to DSM.
  2. Open Control PanelTask Scheduler.
  3. Click CreateUser-defined script.
  4. Under General, name the task (e.g., "Retrieve_UID_GID").
  5. Set User to the account whose UID and GID you want to retrieve. This user must also have the necessary permissions to write to the specified shared folder.
  6. Go to the Task Settings tab and enter the following script:
    echo "Current User ID (UID): $(id -u)" > /volume1/<Shared Folder>/UID_GID_Info.txt
    echo "Current Group ID (GID): $(id -g)" >> /volume1/<Shared Folder>/UID_GID_Info.txt
    
  7. Click OK and then Run the task.
  8. Navigate to /volume1/<Shared Folder>/UID_GID_Info.txt using File Station or SSH to view the results.

Image-based manual

Image title

Open Control PanelTask Scheduler.

Image title

Under General, name the task (e.g., "Retrieve_UID_GID").

Image title

Under Schedule, set the task to "Run on the following date" and select "Do not repeat" under Repeat.

Image title

Under Task Settings, enter the script in User-defined script to save the UID and GID information in a shared folder:

The email notification option is disabled, making email delivery optional. The output will be saved in the specified shared folder instead.

Image title

Under Task Scheduler, select the task "Retrieve_UID_GID", click "Run", and confirm by clicking "OK" in the dialog to execute the script immediately.

Image title

The UID_GID_Info.txt file is stored in the , containing the retrieved UID (1035) and GID (100). The file was created and modified as expected, confirming that the script executed successfully.


Conclusion

Whether using SSH or a custom DSM script, retrieving UID and GID on a Synology NAS is straightforward. The command-line method provides instant results, while the script-based approach is useful for users who prefer a graphical interface. Understanding UID and GID is essential for advanced permission management and integration with other services like Docker, NFS, and SMB permissions.

Security Notice

To disable SSH after use, go to Control PanelTerminal & SNMP and uncheck Enable SSH service.