-
-
Notifications
You must be signed in to change notification settings - Fork 2
Linux runuser Guide
Mattscreative edited this page Dec 5, 2025
·
2 revisions
Complete beginner-friendly guide to runuser on Linux, covering Arch Linux, CachyOS, and other distributions including running commands as different users, user switching, and privilege management.
Basic usage:
# Run command as user
runuser -l username -c 'command'
# -l = login shell
# -c = commandBasic command:
# Run as user
runuser -u username command
# -u = user (runs command as user)Run command:
# Execute command
runuser -u username -c 'ls -la'
# Runs ls as specified userWith login shell:
# Login shell
runuser -l username -c 'echo $HOME'
# -l = login (full login environment)Change user:
# Switch to user
runuser -l username
# Opens shell as userNo login shell:
# Without login
runuser -u username
# Runs shell without full loginKeep environment:
# Preserve environment
runuser -u username -c 'env'
# Shows user's environmentSet environment:
# Custom environment
runuser -u username -c 'HOME=/custom command'
# Sets custom HOMECheck installation:
# runuser is part of util-linux
# Usually pre-installed
# Check runuser
which runuserThis guide covered runuser usage, user switching, and privilege management for Arch Linux, CachyOS, and other distributions.
- su Guide - Switch user
- sudo Guide - Execute as another user
- User and Groups - User management
-
runuser Documentation:
man runuser
This guide covers Arch Linux, CachyOS, and other Linux distributions. For distribution-specific details, refer to your distribution's documentation.