Skip to main content

Linux Permissions & Users

Understanding Linux permissions is crucial for security and system administration.

User Management

# View current user
whoami

# View all users
cat /etc/passwd

# Add user
sudo adduser username

# Delete user
sudo deluser username

# Switch user
su - username
sudo su  # Switch to root

File Permissions

# Permission format: rwxrwxrwx
# Owner | Group | Others
# r=read(4), w=write(2), x=execute(1)

# Change permissions
chmod 755 file.txt    # rwxr-xr-x
chmod u+x script.sh   # Add execute for owner
chmod g-w file.txt    # Remove write for group

# Change ownership
chown user:group file.txt
chown -R user:group directory/

# View permissions
ls -l

Sudo and Root Access

# Run command as root
sudo command

# Edit sudoers file
sudo visudo

# Become root
sudo su
sudo -i

Next: Linux Process Management →