Useful Linux Commands

commands that i use often, but hard to remember lol

Back to guides…

Adding swap to Linux

sudo fallocate -l 1G /swapfile
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile
echo '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstab

Replace 1G with whatever big you want.

Find files containing string

grep -rnw './' -e '<string>'

Find files with certain extension

find . -type f -name "*.<ext>"

Quick Reverse SSH

Local Machine

ssh -R 9000:localhost:22 user@remote

Remote Machine

ssh -p 9000 user@localhost

Start screen with certain command

screen -d -m -S <name> "<command>"

Docker Compose Pull-Down-Up

docker compose pull && docker compose down && docker compose up -d

Opening archives

Tarballs

tar -xvf file.tar
tar -xzvf file.tar.gz
tar -xjvf file.tar.bz2

Zips

Needs unzip to be installed.

unzip file.zip -d <destination>

Run .jar

java -Xmx1024M -Xms1024M -jar <jar> nogui