This is just a catch-all for the many little useful Linux tricks I want to remember.
less /etc/passwd
-m
creates a home directory-c
adds a comment-G
adds the user to one or more secondary groups (customize this one)sudo useradd -m \
-c "Firstname Lastname" \
-G wheel,docker \
fLastname
sudo deluser --remove-home fLastname
df
is good for finding how much space is used on all your disks: df -h
du
is the Disk Usage command. Here's an easy way to find the biggest directories in your installation: du -hs * | sort -rh | head -5
Quick replace line in file (absolute value): sed -i 's/User=.*/User=root/' install/audit.service
Quick replace line in file (variable): sed -i "s|WorkingDirectory=.*|WorkingDirectory=$thisDirectory|" install/audit.service
Find all your open/listening ports: sudo netstat -tulpn
Screen is a command to help you run sessions while gone. It's real easy to set up:
sudo [yum/apt] install -y screen
Enter a screen session: screen
Leave a screen session: ctrl + a, d
Rejoin screen session: screen -r
So, instead of using screen, you can also just ignore the terminal disconnect signal:
nohup {yourCommand} > p.out 2> p.err < /dev/null &
Say you want /docker
to be totally open to everybody in the docker group--read, write, create new files, etc.
sudo mkdir /docker
sudo chgrp -R docker /docker;
sudo chmod -R g+rws /docker