October 28, 2019 · Linux
Useful Linux commands
File Transfer
zip -r ./migrations/xxx.com-v1.0.zip . -x *.git* -x migrations/\* -x wp-content/uploads/\*
find ./wp-content/uploads -type f ! -name '*\.jpg' ! -name '*.jpeg' ! -name '*.png' ! -name '*.gif'
find ./ -type f ! -name '*\.jpg' ! -name '*.jpeg' ! -name '*.png' ! -name '*.gif' | grep -Ril "_0xaae8"
scp -P 10022 upload.zip [email protected]:~
find ./ -type f ! -name '*\.jpg' ! -name '*.jpeg' ! -name '*.png' ! -name '*.gif' | grep -Ril "jbzaokatanabeg"
git submodule update --init --recursive
rsync -avz -e 'ssh -p 10022' ./www.abc.com [email protected]:/var/www/
rsync -avz ./partner.a.net dev-b-server:/var/www
zip -r ./migrations/www.a.com-v1.0.6.zip . -x *.git* -x migrations/\* -x wp-content/uploads/\*
find ./wp-content/uploads -type f ! -name '*\.jpg' ! -name '*.jpeg' ! -name '*.png' ! -name '*.gif'
find ./ -type f ! -name '*\.jpg' ! -name '*.jpeg' ! -name '*.png' ! -name '*.gif' | grep -Ril "_0xaae8"
scp -P 10022 eilly.co.zip techbeast-staging:~
find ./ -type f ! -name '*\.jpg' ! -name '*.jpeg' ! -name '*.png' ! -name '*.gif' | grep -Ril "jbzaokatanabeg"
git submodule update --init --recursive
rsync -avz -e 'ssh -p 10022' ./.git [email protected]:/var/www/www.b.com/.git
Split log
awk 'BEGIN {
split("Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec ", months, " ")
for (a = 1; a <= 12; a++)
m[months[a]] = a
}
{
split($4,array,"[:/]");
year = array[3]
month = sprintf("%02d", m[array[2]])
print > FILENAME"-"year"_"month".txt"
}'
Server log operations
# check IP Access Time
cat serverLog | awk '{print $1}' | sort | uniq -c | sort -n | cat
cat ./www_a_com* | awk '{print $1}' | sort | uniq -c | sort -n | tee sum_count_ip_access_logs
# check Request Method
cat serverLog | awk '{print $5}' | sort | uniq -c | sort -n | cat
cat ./www_a_com* | awk '{print $5}' | sort | uniq -c | sort -n | cat
# check String Occurrances
find ./. -type f ! -name '*\.jpg' ! -name '*.jpeg' ! -name '*.png' ! -name '*.gif' | grep -Ril "_0xaae8"
find ./ -name '*' -exec grep -q '_0xaae8' {} \; -print
find ./ -name '*' -exec grep -q ’127.0.0.1’ {} \; -print
find ./ -name ‘*.php’ -exec grep -q ‘index.php’ {} \; -print