User Tools

Site Tools


wiki:linux_cheat_sheet

User Management

# create a user
USERNAME=foo
useradd $USERNAME

# reset password
USERNAME=foo
passwd $USERNAME

# add an existing user to a group
USERNAME=foo
GROUP=www
usermod -a -G $GROUP $USERNAME
cat /user/group

# remove user
USERNAME=foo
userdel $USERNAME

# add a user to a group
USERNAME=foo
GROUP=www-data
usermod -a -G $GROUP $USERNAME

Archive

# Create an archive
OUTPUT=archive.tar.gz
INPUT=folder
tar -zcvf $OUTPUT $INPUT

# Extract archive
OUTPUT=folder
INPUT=archive.tar.gz
tar -zxvf $INPUT -C $OUTPUT

Utilities

# disk usage
df -h

# find out who is taking too much place
du -hsx /* | sort -rh

network

IP_TO_CHECK=0.0.0.0
nmap -PN $IP_TO_CHECK

Files

# List all open files by a specific process
lsof -p 1753

# List all network connections
lsof -i

# List all network files in use by a specific process
lsof -i -a -p 234
lsof -i -a -c ssh

# List processes which are listening on a particular port
lsof -i :25
wiki/linux_cheat_sheet.txt · Last modified: 2019/08/04 01:20 by ctv_admin