Useful Linux commands

File Transfer

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
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

1
2
3
4
5
6
7
8
9
10
11
12
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

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
# 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