When archiving big files (for example a big database) rsync feeds uselessly the disk cache. Thanks to the posix_fadvise linux system call we can tell the operating system that keeping archived data in cache is useless, leaving the disk cache for other applications (ie: the database).
Tobi Oetiker explains this on his blog and made a patch for rsync. The patch does not work out of the box and needed little modifications.
To colorize the output of less, use the GNU Source-highlight tool.
Install Debian package:
$ sudo apt-get install source-highlight Add this to your shell configuration file:
export LESSOPEN="| /usr/share/source-highlight/src-hilite-lesspipe.sh %s" export LESS=' -R '
Create a self-signed Certificate authority Create an RSA key Use the genrsa command to create the server private key with the following properties:
The key is protected with the symetric AES256 algorithm. (protecting the key is not mandatory) The key is 2048 bits long. Here is the command:
$ openssl genrsa -aes256 -out private/server.key 2048 Generating RSA private key, 2048 bit long modulus ...............................................................................................+++ ..+++ unable to write 'random state' e is 65537 (0x10001) Enter pass phrase for test.
Newbie guide to R
CDN: Content delivery network A CDN act as a cache for static ressources of your web server. One famous CDN is Akamai but is quite expensive.
CDN architecture is quite complex with a set of multiple proxies located in multiple datacenters around the world. The goal is to reduce the distance to the minimum between the served ressource and the user asking for the ressource.
A CDN not only saves the bandwith and load of your server but also global Internet peers involved between the client and the server.
Let’s take an example of installing Django without using Debian apt command. We will use virtualenv to make a self-contained python directory.
First create your installation directory:
$ mkdir -p project/django $ cd project/django Get the virtualenv tool:
$ wget --no-check-certificate 'https://raw.github.com/pypa/virtualenv/develop/virtualenv.py' Create the virtual environment:
$ python virtualenv.py --no-site-packages --distribute python_django_env Note interesting parameters::
--no-site-packages Don't give access to the global site-packages dir to the virtual environment --distribute Use Distribute instead of Setuptools.
Usefull command reminders
C pointers & Ksplice challenge The Ksplice Pointer Challenge.
#include <stdio.h> int main() { int x[5]; printf("%p\n", x); printf("%p\n", x+1); printf("%p\n", &x); printf("%p\n", &x+1); return 0; } On a 64bits architecture:
0x7fffe4a594d0 0x7fffe4a594d4 0x7fffe4a594d0 0x7fffe4a594e4
Route packets based on destination port
Pipe Viewer To visualize data throughput through a pipe use Pipe Viewer tool.
$ sudo apt-get install pv For example just replace every pipe with | pv |:
$ cat bigfile.txt | gzip -9 > /tmp/test.gz $ ```shell $ cat bigfile.txt | pv | gzip -9 > /tmp/test.gz 14MB 0:00:00 [22.6MB/s] [ <=> ] $
Playing with systemtap
What “Trickle is a portable lightweight userspace bandwidth shaper. It can run in collaborative mode (together with trickled) or in stand alone mode.”
Before, no limitation:
$ wget 'http://wwww.example.org/somefile' --2012-07-10 14:46:13-- http://wwww.example.org/somefile [ ... ] 2012-07-10 14:46:13 (866 KB/s) - `somefile' saved [12485] After, limited to 40 kbit/s:
$ trickle -v -s -d 40 wget 'http://www.example.org/somefile' --2012-07-10 14:50:27-- http://wwww.example.org/somefile [ ... ] wget: [trickle] avg: 20.8 KB/s; win: 20.8 KB/s wget: [trickle] avg: 40.
When an application crashes, with a segfault for example it can be usefull have debugging help like a stacktrace of function calls
ioctl(2) is a special system call used when no other system call can handle a specific I/O operation. For exemple, the generic write(2) syscall is used for writing to a specified file descriptor but there is neither syscall to open the CD-tray nor syscall to manage routing tables: ioctl is here as a fit-all syscall.
From the man page:
NAME ioctl - control device SYNOPSIS #include <sys/ioctl.h> int ioctl(int d, int request, void *args); DESCRIPTION The ioctl() function manipulates the underlying device parameters of special files.
Playing with the framebuffer on Linux
Introduction Rust is a system programming Language developed by Mozilla. For a C-like language, it features interesting paradigms:
functional style, actors, object oriented, safe memory allocation and free In this article we will link a Rust library with a C program.
Tools used:
rustc 0.13.0-nightly (5484d6f6d 2014-12-02) gcc (Debian 4.9.1-19) 4.9.1 docker Installation Compiling the Rust compiler takes quite some time, so I decided to use a nightly built container of the compiler:
Introduction Linc is a software switch in Erlang, which support Openflow 1.4.
Here we will try to install it and make it run in a simple scenario. Later we will try to use it with an openflow compatible Controller (maybe Opendaylight or FlowER).
Installation $ git clone https://github.com/FlowForwarding/LINC-Switch.git $ sudo apt-get install libpcap0.8-dev $ cd LINC-Switch $ cp rel/files/sys.config.orig rel/files/sys.config $ make Note that at some point during installation, root privileges are required to use the setcap utility.
Let’s play with eBPF in order to find what is slowing down my computer
Introduction Heimdal Build Heimdal git clone https://gitlab.com/BenjaminDobell/Heimdall.git sudo dnf install libusb-devel.x86_64 cd Heimdall mkdir build; cd build cmake -DCMAKE_BUILD_TYPE=Release -DDISABLE_FRONTEND .. make Check installation Put your device in download mode, on the A3 it’s:
1 Switch OFF device 2 Volume Down + Home button + Power button. 3 Choose Download mode: Volume Up $ sudo ./heimdal detect Download PIT file $ sudo ./heimdall download-pit --output 'a3-2020-02-20.pit' --verbose Heimdall v1.
Create a ed25519 SSH key ECC: Elliptic Curve Cryptography is a family of algorithms (ECDSA, ed25519) Curve25519: name of the elliptic curve Ed25519: Name of the signature algorithm $ ssh-keygen -a 100 -t ed25519 -b 521 -f ~/.ssh/id_ed25519.barbot.org -C "julien@barbot.org" You can look at explainshell.com to understand each parameters.
Use this key for specific hosts:
$ cat .ssh/config Host github.com IdentityFile ~/.
Introduction P4 is a domain-specific compiled programming language for network data forwarding. It does not know anything about already existing protocols: it doesn’t know IP, nor TCP.
A P4 program is compiled to something that is understandable by the P4 aware device. Such device can be a really hardware switch, a software switch, a FPGA.
In this article we will try to use a software switch. More precisely, the uBPF backend.
Introduction uBPF is a user-land implementation of the eBPF VM.
Installation $ git clone https://github.com/iovisor/ubpf.git $ cd ubpf $ make -C vm This compiles the ubpf library (libubpf.a) and a test program to use this library.
Run a simple eBPF program with uBPF static int idouble(int a) { return (a * 2); } int bpf_prog(void *ctx) { int a = 1; a = idouble(a); return (a); } Compile to a BPF binary, which is executable by the kernel eBPF VM, or, in our specific case, the user-land uBFP VM.