Category Archives: Linux

Python Socket IPv6 (AF_INET6) Listen

Listen on an IPv6 address and port in Python with socket(): ADDR = (HOST, PORT) serversock = socket.socket(family=socket.AF_INET6) serversock.bind(ADDR) serversock.listen(0)ADDR = (HOST, PORT) serversock = socket.socket(family=socket.AF_INET6) serversock.bind(ADDR) serversock.listen(0) Change HOST and PORT as needed.

DEB.SURY.ORG Updated the Signing Key (March 2019)

On 18 March 2019 OndÅ™ej announced that he changed the signing key: I was informed that the current DPA signing key DF3D585DB8F0EB658690A554AC0E47584A7A714D was present on the server maintained by an other user of the repositories that got compromised. I do not believe that the users of the repositories are at any risk because […]

Bash Script to Dump a MySQL Table into a CSV File

Simple bash script to dump a MySQL table into a CSV file: mysql dbname -u’user’ -p’password’ <<QUERY_INPUT SELECT field1, field2, field3, field4 FROM table_name INTO OUTFILE ‘/path/file.csv’ FIELDS ENCLOSED BY ‘"’ TERMINATED BY ‘,’ ESCAPED BY ‘"’ LINES TERMINATED BY ‘\r\n’; QUERY_INPUTmysql dbname -u’user’ -p’password’ <<QUERY_INPUT SELECT field1, field2, field3, field4 FROM table_name INTO OUTFILE […]

Lost connection during Debian apt-get upgrade

If you lost the SSH connection on Debian while apt-get upgrade: 1) Re-login to your SSH server 2) Find the running instance of apt-get upgrade: ps aux | grep -E ‘release|upgrade|apt’ps aux | grep -E ‘release|upgrade|apt’ 3) Then kill it with kill PID 4) Type “dpkg –configure -a” to recover the apt-get upgrade 5) Done!


Today I tested HMGET, HGETALL, HSET, HGET performance. Here are my tests, see the “requests per second” value for comparisons: TESTING GET COMMAND     root@server:~# redis-benchmark -h -p 6379 –dbnum 1 get MYKEY ====== get MYKEY ====== 100000 requests completed in 3.27 seconds 50 parallel clients 3 bytes payload keep alive: 1   […]

Keep current version of config files when apt-get install on Debian

To automatically keep current config files when doing apt-get install on Debian: apt-get install nginx -y -o Dpkg::Options::="–force-confdef" -o Dpkg::Options::="–force-confold"apt-get install nginx -y -o Dpkg::Options::="–force-confdef" -o Dpkg::Options::="–force-confold" You can find more info on Raphael Hertzog’s Blog. Here are more info about –force-confold and –force-confdef: confold: If a conffile has been modified and the version in […]

How to Extract Links from a Web Page in Linux

In Linux you can extract links from a web page easily: Using Lynx Extract links and save them to links.txt file: lynx -dump | awk ‘/http/{print $2}’ > links.txtlynx -dump | awk ‘/http/{print $2}’ > links.txt If you need to add numbers to lines, use nl command: lynx -dump | awk ‘/http/{print […]

Should I reboot Debian server after apt-get upgrade?

If you ran “apt-get upgrade” you don’t always need to reboot the Debian server. To know if you need to reboot the server after “apt-get upgrade”, check if this file is present (it is generally of 0 bytes, so it is an empty file): /var/run/reboot-required/var/run/reboot-required Here is an example on my Debian server: -rw-r–r– 1 […]

Debian Install GCC Compiler and Development Environment

Install essential applications for building Debian packages: apt-get update apt-get install build-essentialapt-get update apt-get install build-essential The package build-essential will install libc6-dev, gcc, g++, make, etc. That’s all!

How to build ImageMagick so that it’s statically built

First install gcc and other needed packages to build ImageMagick: apt-get install build-essentialapt-get install build-essential Then install important ImageMagick libraries (i.e libpng, libjpeg, etc): apt-get install libpng-dev apt-get install libexif-dev apt-get install zlib1g-dev apt-get install libwebp-dev apt-get install libtiff5-dev apt-get install libjpeg-dev apt-get install libbz2-dev apt-get install liblzma-dev apt-get install libdjvulibre-dev apt-get install libopenjp2-7-dev apt-get […]