Skip to content

Linux runuser Guide

Mattscreative edited this page Dec 5, 2025 · 2 revisions

Linux runuser Guide

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.


Table of Contents

  1. runuser Basics
  2. Running as User
  3. User Switching
  4. Environment
  5. Troubleshooting

runuser Basics

Run as User

Basic usage:

# Run command as user
runuser -l username -c 'command'

# -l = login shell
# -c = command

Simple Usage

Basic command:

# Run as user
runuser -u username command

# -u = user (runs command as user)

Running as User

Execute Command

Run command:

# Execute command
runuser -u username -c 'ls -la'

# Runs ls as specified user

Login Shell

With login shell:

# Login shell
runuser -l username -c 'echo $HOME'

# -l = login (full login environment)

User Switching

Switch User

Change user:

# Switch to user
runuser -l username

# Opens shell as user

Without Login

No login shell:

# Without login
runuser -u username

# Runs shell without full login

Environment

Preserve Environment

Keep environment:

# Preserve environment
runuser -u username -c 'env'

# Shows user's environment

Custom Environment

Set environment:

# Custom environment
runuser -u username -c 'HOME=/custom command'

# Sets custom HOME

Troubleshooting

runuser Not Found

Check installation:

# runuser is part of util-linux
# Usually pre-installed

# Check runuser
which runuser

Summary

This guide covered runuser usage, user switching, and privilege management for Arch Linux, CachyOS, and other distributions.


Next Steps


This guide covers Arch Linux, CachyOS, and other Linux distributions. For distribution-specific details, refer to your distribution's documentation.

Clone this wiki locally