:::: MENU ::::

Posts Categorized / Linux

  • Sep 27 / 2016
  • 0

Escape sequences for SSH (when you’re stuck)

You can get stuck with your ssh session when your network is changing or when there’s a network disruption. You will face a lock leading to the unability to stop your session, even by doing a CTRL-C.

That’s why there’s some escape sequences you can use in that case (especially the first one when you’re stuck):

  ~.  - terminate connection (and any multiplexed sessions)
  ~B  - send a BREAK to the remote system
  ~C  - open a command line
  ~R  - Request rekey (SSH protocol 2 only)
  ~^Z - suspend ssh
  ~#  - list forwarded connections
  ~&  - background ssh (when waiting for connections to terminate)
  ~?  - this message
  ~~  - send the escape character by typing it twice

Note that escapes are only recognized immediately after newline.

  • Sep 16 / 2016
  • 0

Renew a GPG key when you get “GPG error – KEYEXPIRED”

Getting this error when trying to update packages on your linux distro using apt?

$apt-get update
W: An error occurred during the signature verification. The repository is not updated and the previous index files will be used. GPG error: http://apt.puppetlabs.com jessie Release: The following signatures were invalid: KEYEXPIRED 1468001658

This just means that the GPG key is expired and that you need to renew it.

You can list expired keys and get the ID by using this command:

$apt-key list | grep expired
pub   4096R/4BD6EC30 2010-07-10 [expired: 2016-07-08]

Here, we can see that ID “4BD6EC30” is expired and is leading to the issue.

Let’s now update this key:

$apt-key adv --recv-keys --keyserver keys.gnupg.net 4BD6EC30

And you can now perform the update properly, you won’t get error anymore.

  • Sep 07 / 2016
  • 0

Send an UDP packet with NetCat

It can be needed to test an UDP connection with a server to ensure that connectivity is working and double check the data received.

Let’s take a simple example with a remote logstash server:
– Server mylogstash.mydomain.local
– Listening on port 5000

On emitter side, we are sending an UDP packet simulating a log line coming from an application:

echo -e '{"version": "1.1","host":"myapp.org","message":"My message","backtrace":"Backtrace of my app\n\nmore stuff"}\0' | nc -u -w 1 mylogstash.mydomain.local 5000

On receiving server side, we are executing a tcpdump to check that packet is correctly coming with good content:

# tcpdump -i any udp port 5000 -A
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on any, link-type LINUX_SLL (Linux cooked), capture size 262144 bytes
10:43:47.621172 IP mylogstash.mydomain.local.49435 > localhost.5000: UDP, length 108
[email protected]@............./..t..{"version": "1.1","host":"myapp.org","message":"My message","backtrace":"Backtrace of my app

more stuff"}.

Here we are! It’s very simple to control UDP flows or simply check connection between 2 servers.

  • Aug 22 / 2016
  • 0

Find and identify where inodes are used

Your monitoring system is claiming that your server is running out of free inodes but your disks are not full at all? Maybe you just need to check your filesystem usage and how many files are being used at the same time… Here are some tips to check and identify the inodes being used.

First of all, you can check percentage of inodes used with this simple command:

df -ih

You will see inode usage for your partitions and mouting points:

#dh -ih
Filesystem                                    Inodes IUsed IFree IUse% Mounted on
rootfs                                          120K  7.1K  112K    6% /
udev                                            495K   356  495K    1% /dev
tmpfs                                           497K   299  496K    1% /run
/dev/mapper/vg-root                             120K  7.1K  112K    6% /
tmpfs                                           497K     6  497K    1% /run/lock
tmpfs                                           497K     2  497K    1% /run/shm
/dev/sda1                                       122K   241  122K    1% /boot
/dev/mapper/vg-usr                              179K   51K  129K   29% /usr
/dev/mapper/vg-var                              242K  199K   43K   83% /var

Here, we can easily see that /var is using 83% of inodes, which is quite high.

Let’s now identify how those inodes are used with a compound command using find:

find /var -xdev -printf '%h\n' | sort | uniq -c | sort -k 1 -n

You will get a sorted result like this (I truncated to display only the last lines which are the most important):

#find /var -xdev -printf '%h\n' | sort | uniq -c | sort -k 1 -n
     52 /var/lib/ucf/cache
    106 /var/spool/exim4/input
    153 /var/log
    184 /var/log/apache2
    301 /var/lib/mibs/ietf
    319 /var/cache/apt/archives
   2289 /var/lib/dpkg/info
  10893 /var/spool/postfix/maildrop

We can clearly see that inodes are mostly used by /var/spool/postfix/maildrop. You just have to go in that folder and check if files are useful and/or if you can do some cleaning there.
Then, once files are removed and directory clean, your inodes will be freed and everything will be back to normal!

  • Aug 02 / 2016
  • 0

Skype group chat not working on linux

With Linux version for Skype, it can happen that group conversation are not working as expected (conversations do not start, or updates are not working, or group members do not appear, …).

You can check MSNP version you are using by typing this command in any conversation chat:


If you are getting this message (“LoggedOut”), this means that you have the MSNP issue:

System: MSNP: Connection Data:
 * Status: LoggedOut

You can so enter in the chat:


Then, restart Skype.

Once restarted, you can check again the MSNP version:


You should now get “LoggedIn”:

System: MSNP: Connection Data (MSNP24):
 * Status: LoggedIn

Et voila, Skype will now work correctly 🙂Avec la version Linux de Skype, il arrive parfois que les conversations de groupe rencontrent des soucis (elles ne dĂ©marrent pas, ou les mises Ă  jour ne se font pas, ou les participants n’apparaissent pas, …).

Vous pouvez vĂ©rifier la version de MSNP utilisĂ©e en tapant cette commande dans n’importe quelle conversation :


Si vous obtenez ce message (“LoggedOut”), c’est que vous avez le problème de MSNP :

System: MSNP: Connection Data:
 * Status: LoggedOut

Vous pouvez alors taper :


Puis redémarrez votre Skype.

Une fois redémarré, vous pouvez vérifier à nouveau la version de MSNP :


Et vous devriez maintenant avoir “LoggedIn” :

System: MSNP: Connection Data (MSNP24):
 * Status: LoggedIn

Et voilà, Skype fonctionnera désormais correctement 🙂

  • Jul 21 / 2016
  • 0

Open bash session into a docker container

Once a docker container is started, it’s always hard to get access into and see what’s happening inside. As a workaround, the easiest way to understand what’s happening in a container is to get a CLI on it and investigate.

Since version 1.3, you can easily open a bash session into a running container by using:

  • The ID of the container:
    sudo docker exec -i -t 43f10328e4e9 /bin/bash
  • Or the name of the container:
    sudo docker exec -i -t super_docker /bin/bash

You will get access with a bash session to your container:

$ [email protected]:/#

Question ? Contact