This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
linux-commandline-tips [2018/12/11 05:07] serbizadmin [Differences] |
linux-commandline-tips [2020/08/29 23:47] serbizadmin [Find Stuff] |
||
---|---|---|---|
Line 1: | Line 1: | ||
~~NOTOC~~ | ~~NOTOC~~ | ||
====== Find Stuff====== | ====== Find Stuff====== | ||
- | * looking for duplicate filenames in 2 directories | + | * looking for **duplicate** filenames in 2 directories |
< | < | ||
fdupes --recurse dir1/ dir2/ </ | fdupes --recurse dir1/ dir2/ </ | ||
- | * find a word in a file | + | * find a **word** in a file |
< | < | ||
grep -rnw '/ | grep -rnw '/ | ||
- | * find all socket files your system runs | + | * find all **socket** files your system runs |
< | < | ||
find / -type s | find / -type s | ||
</ | </ | ||
+ | * find the latest file in a folder/ | ||
+ | < | ||
+ | find . -type f -printf '%T@ %P\n' | sort -n | awk ' | ||
+ | </ | ||
+ | * show files greater than 1G | ||
+ | < | ||
+ | du -h * | grep ' | ||
+ | </ | ||
+ | Change ' | ||
====== Differences====== | ====== Differences====== | ||
* between files, showing side by side | * between files, showing side by side | ||
< | < | ||
diff -y file1 file2 | less | diff -y file1 file2 | less | ||
+ | </ | ||
+ | * differences of files between directories | ||
+ | < | ||
+ | diff <(ls -a /dir1/) <(ls -a /dir 2/) | ||
+ | </ | ||
+ | or compare | ||
+ | < | ||
+ | comm <(ls -a /dir/) <(ls -a /dir2/) | ||
</ | </ | ||
\\ | \\ | ||
Line 25: | Line 42: | ||
cat /dev/null > modsec_audit.log</ | cat /dev/null > modsec_audit.log</ | ||
See also "log rotate" | See also "log rotate" | ||
+ | * remove everything else except... | ||
+ | < | ||
+ | rm -rf !(filename)</ | ||
+ | This works only if extglob is enabled. So | ||
+ | < | ||
+ | shopt -s extglob</ | ||
+ | \\ | ||
+ | ====== Compression====== | ||
+ | * lossless, multi-thread compression: | ||
+ | < | ||
+ | time xz -6ve -k --threads=0 < | ||
+ | </ | ||
+ | * compress multiple files | ||
+ | < | ||
+ | xz file1.txt file2.txt file3.txt | ||
+ | </ | ||
+ | * decompress | ||
+ | < | ||
+ | xz -d file.txt.xz | ||
+ | unxz file.txt.xz | ||
+ | </ | ||
+ | * test integrity | ||
+ | < | ||
+ | xz -tv < | ||
+ | </ | ||
+ | * concatenate multiple files | ||
+ | < | ||
+ | xzip -c file1.txt > files.xz | ||
+ | xzip -c file2.txt >> files.xz | ||
+ | </ | ||
+ | * concatenate, | ||
+ | < | ||
+ | xzcat test.txt.xz | ||
+ | test | ||
+ | | ||
+ | text | ||
+ | xzgrep exa test.txt.xz | ||
+ | | ||
+ | </ | ||
+ | |||
+ | ====== PHP====== | ||
+ | * View php config | ||
+ | < | ||
+ | php -r "print phpinfo();" | ||
+ | </ | ||
+ | or | ||
+ | < | ||
+ | php -i | grep in | ||
+ | </ | ||
+ | \\ | ||
+ | * reinstall all php packages | ||
+ | < | ||
+ | apt-get install --reinstall `dpkg -l | grep ' | ||
+ | </ | ||
+ | ====== Log Analysis====== | ||
+ | * limiting by date range | ||
+ | |||
+ | sed -n '/ |