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:
- Log in to DSM (DiskStation Manager) via your web browser.
- Navigate to Control Panel → Terminal & SNMP.
- Check the box Enable SSH service and click Apply.
- Note your NAS IP address (found under Control Panel → Network).
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:
- Open a terminal (Linux/macOS, Windows) or tools like PuTTY, Termius as example.
- Connect to your Synology NAS using SSH:
- Enter your password when prompted.
- Run the
id
command to display UID and GID:
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:
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¶
- Log in to DSM.
- Open Control Panel → Task Scheduler.
- Click Create → User-defined script.
- Under General, name the task (e.g., "Retrieve_UID_GID").
- Set User to the account whose UID and GID you want to retrieve.
- Go to the Task Settings tab and enter the following script:
- Click OK and then Run the task.
- An email containing your UID and GID information will be sent to you.
Image-based manual
Open Control Panel → Task Scheduler.
Click Create → User-defined script.
Under General, name the task (e.g., "Retrieve_UID_GID").
Under Schedule, set the task to "Run on the following date" and select "Do not repeat" under Repeat.
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.
Under Task Scheduler, select the task "Retrieve_UID_GID", click "Run", and confirm by clicking "OK" in the dialog to execute the script immediately.
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¶
- Log in to DSM.
- Open Control Panel → Task Scheduler.
- Click Create → User-defined script.
- Under General, name the task (e.g., "Retrieve_UID_GID").
- 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.
- Go to the Task Settings tab and enter the following script:
- Click OK and then Run the task.
- Navigate to
/volume1/<Shared Folder>/UID_GID_Info.txt
using File Station or SSH to view the results.
Image-based manual
Open Control Panel → Task Scheduler.
Under General, name the task (e.g., "Retrieve_UID_GID").
Under Schedule, set the task to "Run on the following date" and select "Do not repeat" under Repeat.
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.
Under Task Scheduler, select the task "Retrieve_UID_GID", click "Run", and confirm by clicking "OK" in the dialog to execute the script immediately.
The UID_GID_Info.txt file is stored in the
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 Panel → Terminal & SNMP and uncheck Enable SSH service.