Ubuntu - manage User & groups security with low level commands

Published on: 22nd Apr 2014

Updated on: 16th Jul 2025

Overview

Here's the commands that you need to do the basic user and group management.

Managing users and groups

Switching to another user context

16.Jul.2025: sometimes, you want to execute a bash script with a dedicated user ID for the reason of any new files or directories to be created will be under this user ID without having to execute chown. Another advantage is that you are allowed to set the file modification time because the file owner is same as the user who is running the script.

For example, you need to upgrade an application while we want to allow the 'myftpuser' (or any other user ID) to access the new directory created by the script.

runuser -l myftpuser -c "./tools/util/upgrade-app.sh"

Where upgrade-app.sh is calling rsync to copy new files and set the file modification time.

More about security

Related posts

Back to #UBUNTU blog

Back to #blog listing

Author

Lau Hon Wan, software developer.