Some Useful Commands
Add firewall to startup (items) script
$ sudo update-rc.d firewall defaults
System startup links for /etc/init.d/firewall already exist.
and check:
$ find /etc/rc?.d | grep firewall
increase resolution
BEGIN
#!/bin/bash
xrandr –output VGA-0 –mode 1280×1024 &
xrandr –output LVDS –off &
END.
Intersection of unsorted files (-d) or Difference of (unsorted) files (-u)
cat(sort) file2 file1| uniq -d
uniq file1 – Removes duplicate lines
sort -u file1 – Sort uniq lines
Display a calendar: – cal -3
Only get diffs. Do multiple times for troublesome downloads
rsync -P rsync://rsync.server.com/path/to/file file
Locally copy with rate limit. It’s like nice for I/O
rsync –bwlimit=1000 fromfile tofile
Mirror web site (using compression and encryption)
rsync -az -e ssh –delete ~/fromfile/ remote_host:’~/tofile’
Synchronize current directory with remote one
rsync -auz -e ssh remote:/dir/ . && rsync -auz -e ssh . remote:/dir/
text manipulation (note sed uses stdin and stdout, so if you want to edit files, append <oldfile >newfile) | ||
sed ‘s/string1/string2/g’ | Replace string1 with string2 | |
sed ‘s/\(.*\)1/\12/g’ | Modify anystring1 to anystring2 | |
sed ‘/ *#/d; /^ *$/d’ | Remove comments and blank lines | |
sed ‘:a; /\\$/N; s/\\\n//; ta’ | Concatenate lines with trailing \ | |
sed ‘s/[ \t]*$//’ | Remove trailing spaces from lines | |
sed -n ‘1000p;1000q‘ | Print 1000th line | |
sed -n ‘10,20p;20q‘ | Print lines 10 to 20 | |
sort -t. -k1,1n -k2,2n -k3,3n -k4,4n | Sort IPV4 ip ddresses |
XMl:
locale -a xmllint --encode ISO-8859-1 filename.xml head -n 27 filename.xml
Leave a Reply