Skip to content

Instantly share code, notes, and snippets.

@user454322
Last active August 23, 2016 09:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save user454322/74936a9deb707483565c to your computer and use it in GitHub Desktop.
Save user454322/74936a9deb707483565c to your computer and use it in GitHub Desktop.
UNIX notes
grep -v “^$” filename > newfilename
#Remove special characters from a file
cat "$f" | tr -dc ' [:alnum:]\n\r' | tr '[:upper:]' '[:lower:]'
lsof -P -i -n
tcpdump -i eth0 host 192.168.1.1
netstat -t -u -c
hdparm -t /dev/sda
Test hard disk reading speed
echo “foo” > /dev/tcp/192.168.1.2/25
send echo to socket network
awk ‘length>72′ file
list of lines that are longer than 72 characters
sudo mknod /dev/ttyS4 c 4 68
Add another tty device using mknod command
find ~ -name ‘*.mp4′ | xargs mplayer
play all mp4 files on home directory
a2ps –line-number=5 message.rb
stop process using bash ^Z
[2]+ Stopped
you can view these processes with $jobs
then you can refer them to %2
e.g. $kill %2
$bg %2
$fg %2
find . -name '*.txt' | xargs perl -pi -e 's/old_str/new_str/g'
~/jruby/bin/jruby -J-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=4000 -J-Xdebug dioneas.rb ../sample/ruby/philosophers.rb
find ./ -type d -name .svn -exec rm -fr {} +
rm !(b)…..removes all file but b
#disable ipv6
net.ipv6.conf.all.disable_ipv6=1
#sysctl -w
echo 1 > /proc/sys/net/ipv6/conf/all/disable_ipv6
-Djava.net.preferIPv4Stack=true
Ghostscript
gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/screen -dNOPAUSE -dQUIET -dBATCH -dNumRenderingThreads=3 -sOutputFile=output.pdf input.pdf
-dNOGC — NO garbage collection
-c “30000000 setvmthreshold” –30MB of RAM
-dPDFSETTINGS=/screen (screen-view-only quality, 72 dpi images)
-dPDFSETTINGS=/ebook (low quality, 150 dpi images)
-dPDFSETTINGS=/printer (high quality, 300 dpi images)
-dPDFSETTINGS=/prepress (high quality, color preserving, 300 dpi imgs)
-dPDFSETTINGS=/default (almost identical to /screen)
pdftk sales_report.pdf output SalesReport.pdf user_pw PROMPT
echo “test” | ssh user@192.168.0.138 ‘cat > file’
CREATE DATABASE newdb WITH TEMPLATE originaldb OWNER dbuser;
patch -p0 -i ~/fix.diff
sed -n 5647,6239p app.log > relevant.log
python -m SimpleHTTPServer 8000
(server)$ cat file.zip | nc -l 8888
(client)$ nc <server> 8888 > file.zip
#test if example.com is listening on the port 80 with a timeout of 3s
nc -z -v -w3 example.com 80
dd if=/dev/dvd of=whatever.iso bs=2048 conv=sync,notrunc
# Run grep in parallel
find . -type f -name '*.log' -print0 | xargs -P4 grep -F "server"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment