Skip to content

Instantly share code, notes, and snippets.

@mencargo
Last active September 12, 2024 16:56
Show Gist options
  • Save mencargo/c5e8c296a4e5492cdfb8c08774aed798 to your computer and use it in GitHub Desktop.
Save mencargo/c5e8c296a4e5492cdfb8c08774aed798 to your computer and use it in GitHub Desktop.
Linux commands

Some useful Linux commands

Disk usage

df -h

Folder size

du -sh folder

Files created last week / past 12 hrs

find /home/user -ctime -7 -o -mtime -7
find /home/user -cmin -720 -o -mmin -720

Find duplicated files

$ find . ! -empty -type f -exec md5sum {} + | sort | uniq -w32 -dD

Remove duplicated files

$ fdupes -rdN .

Number of files in folder

find DIR_NAME -type f | wc -l

Inodes usage

df -i

Current connections

ss -ano

Process Bulk images

for file in *.jpg; do convert $file -quality 85 -resize 1920x1280 $file; done

Simple Web VPN with SSH Tunnel

ssh -4ND 1080 user@server
chromium --proxy-server="socks5://localhost:1080"

.SSH permissions

chmod 700 ~/.ssh
chmod 600 ~/.ssh/id_rsa
chmod 644 ~/.ssh/authorized_keys
chmod 644 ~/.ssh/known_hosts
chmod 644 ~/.ssh/config
chmod 644 ~/.ssh/id_rsa.pub

Remote copy via SSH

scp -P 22 backup.zip root@server.net:/home/user/

Download link with redirect

curl -LJO https://github.com/pocketbase/pocketbase/releases/download/v0.16.5/pocketbase_0.16.5_linux_amd64.zip

Git - completely remove last commit

git reset --hard HEAD^
git push origin -f
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment