Skip to main content

Linux Cheatsheet

Mencari file dengan ukuran tertentu

find . -size +100M -print0 | xargs -0 ls -lhS

atau mencari file berdasarkan nama/extension

find . -name '*.ear' -print0 | xargs -0 ls -lhS
rm symbolic symbolic-1

atau bisa juga menggunakkan unlink

unlink symbolic

Checkout branch dengan FZF

git checkout $(git for-each-ref refs/heads/ --format='%(refname:short)' | fzf)

Watch command

watch <command>

atau bisa menggabungkan dengan bash

watch bash -c "<command>"

perintah akan dijalankan sesuai dengan periode yang telah ditentukan

Encode dan decode text ke base64

encode

echo "plain text" | base64 -w 0

decode

echo "aGVsbG8K" | base64 -d

Copy output

copy output command

pwd | xclip -selection clipboard

Tree

tree dengan 1 tingkatan


tree -L 1

Echo

menambahkan baris baru di file

echo "new line" >> file.txt

replace dengan data baru

echo "replace text with this" > file.txt

copy file dari server ke local/host

scp -r -i private key.pem username@example.com:/path/server ./path/local/host

References: