User Management

Add Users

Create A User (Called "ashley")

useradd --create-home ashley

Create A User In Groups "users" And "dev"

useradd --create-home --groups users dev ashley

Create A User With The Uid 1337

useradd --create-home --uid 1337 ashley

Create Or Change A User Password

passwd ashley

Add User To A Group ("coder")

usermod --append --groups coder ashley

Permissions

Set Default Permission Of Files To 644

echo "masc 022" >> /etc/profile

Set Default Permission Of Files To 664

echo "umask 002" >> /etc/profile

Change Ownership Of A File ("example.txt") To User ("ashley")

chown ashley:users example.txt

Give Read Permission To User, Group, And Others

chmod ugo+r example.txt

Give Write Permission To User And Group

chmod ug+w example.txt

Remove Write Permission To A File For Group Members

chmod g-w example.txt

Make A File Executable

chmod +x example.txt

Log In As A Different User

su - ashley

Run A Command ("ls") As A Different User

su - ashley --command ls

Delete Users

Remove A User From A Group ("coder")

gpasswd --delete ashley coder

Delete A User From The System

userdel ashley

Delete A User And All User Data From The System

userdel --remove ashley

History

Show Which Users Are Currently Logged In

w

Show Login History

last