Watch, Read, Listen

  • Configure VLan interface (with alias)

    If you want to isolate multiple networks, you can use VLAN (Virtual LAN). On most of the switches, you can configure VLAN to handle tagged packets and be able to send them to a specific port by isolating it. A VLAN is assigned a specific id that can be any number between 1 and 4096.…

  • Perform git commands with a specific ssh key

    It’s sometimes necessary to execute one git command with a special SSH key rather that the one you’re running with (for example on a remote console). This can be easily done by using such command: ssh-agent bash -c ‘ssh-add /home/myuser/.ssh/github.key; git pull [email protected]:MYPROJECT/myproject.git’

  • Aggregate results from command line on a specific field (e.g. netstat per IP)

    To aggregate results from a command line and count number of results for each field, you can combine multiple tools like awk, cut, uniq and sort to obtain the expected results. For example, if you want to retrieve count of connections opened per IP onto your server, just run: netstat -ntu | tail -n +3…

  • Generate SHA-512 hash on command-line with Python

    Need to generate the hash for a password? No need to use an online generator, totally insecure for your passwords … This simple command will ask you which string you want to hash and will return you the result after pressing “Enter” key! python -c “import crypt, getpass, pwd; print crypt.crypt(raw_input(), ‘\$6\ Besoin de générer…

  • Define the MTU size for current network

    To limit the fragmentation of packets and optimize your network, it can be necessary to find the best MTU size to set up on your interface. In order to find this best value, you can use a simple ping command. We’re first trying with a MTU size of 1500 bytes: $ ping -M do -s…

  • Set up RamFS or TmpFS on Linux

    In the most modern Linux systems, you will find memory-based file systems to make access to disk storage much faster by allocating some RAM space on a disk mount point. But this means that this disk area will be ephemeral and won’t exist anymore after a system reboot. You should never use it for storing…

  • Increase display limit for a find in Mongo Shell

    When doing a find request on a Shell Mongo, the display is automatically paginated and you’re getting this: Type “it” for more By default, the number of rows returned is 20. But this value can easily be changed by using this command: DBQuery.shellBatchSize = 200; You will now have 200 rows displayed per page.

  • Manage permissions on MySQL for remote users

    MySQL has always been one of the most used database engine for websites. Its security is really important, isolating and managing access must be taken in consideration. Hereafter are some commands to perform some checking and some updates. I will consider those variables for my examples, but you should customize them with your own: Show…

  • Gather/Aggregate results with MongoDB

    Need to gather or aggregate some results with MongoDB? Easy! You can use the group command over any collection to get a nice display of your results aggregated: db.collection.group( { key: { document: 1}, cond: { }, reduce: function( curr, result ) { result.total += 1; }, initial: { total : 0 } } )…

  • How to install NodeJS from sources in a specific directory

    First of all, you need to update repositories, and make sure you have all the needed packages ready and installed: sudo apt-get update sudo apt-get install build-essential openssl libssl-dev pkg-config Then, you can retrieve the sources from the official NodeJS website by downloading the “Source Code” (here, it’s version 5.0.0): sudo mkdir /opt/node/ cd /opt/node/…