Tmux
, à l’instar de Screen, est un multiplexeur de terminaux, outil permettant d’exploiter plusieurs terminaux au sein d’un seul et même affichage.
Installation
Tmux n’est pas installé par défaut. Pour l’installer à l’aide d’un utilitaire graphique il suffit d’Installer le paquets tmux.
Par l’installer avec apt-get depuis un terminal, il suffit de saisir la commande suivante :
sudo apt-get install tmux
Utilisation de tmux
Les principaux raccourcis
Tmux fait appel à l’ensemble de touches <Ctrl> <b> là ou screen fait appel à <Ctrl> <a>.
Les raccourcis et fonctions étant proches voire identiques à ceux de Screen, pour mieux les comprendre, reportez-vous à la page
Screen.
Raccourcis de base
- <Ctrl> <b> suivi de <c> : Créer un nouveau terminal dans la session tmux active
- <Ctrl> <b> suivi de <n> : Switcher entre les différents terminaux de la session
- <Ctrl> <b> suivi de <X> : Choisir un terminal spécifique (ou X est le numéro du terminal)
- <Ctrl> <b> suivi de <d> : Se détacher de la session tmux (lancer ‘tmux a’ pour s’y rattacher)
- <Ctrl> <b> suivi de <,> : Permet de renommer un terminal
- <Ctrl> <b> suivi de <w> : Affiche la liste des terminaux disponibles
- <Ctrl> <b> suivi de <t> : Afficher l’heure dans un terminal
Commandes dans un Split
- <Ctrl> <b> suivi de <« > : Split vertical du terminal courant en deux ouverture d’un terminal dans le nouveau panel
- <Ctrl> <b> suivi de <%> : Split horizontal du terminal courant en deux ouverture d’un terminal dans le nouveau panel
- <Ctrl> <b> suivi de <o> : Switcher entre les terminaux splittés
- <Ctrl> <b> suivi de <espace> : Changer l’organisation visuelle des terminaux splittés
- <Ctrl> <b> suivi de <Alt> (flèches directionnelles) : Reduire, agrandir fenêtre du split
- <Ctrl> <b> suivi de <!> : Convertir un split en terminal seul
- <Ctrl> <b> suivi de <q> : Afficher les numéros des terminaux splittés
- <Ctrl> <b> puis saisissez :join : permet de joindre un terminal seul dans un split
Par exemple, après avoir tapé le combo <Ctrl> <b> si vous saisissez
:join -v -s 3.0 -p 50
Où :
-h ou -v : pour horizontalement ou verticalement
-s 3.0 : terminal 3 et volet 0 (volet si écran splitté)
-p 50 : occupation à 50% de la fenêtre
Ici donc vous ajouterez verticalement, un terminal numéroté 3 et qui prendra 50% de l’espace total.
Lire la suite…
Many system administrators seem to have problems with the concepts of pipes and redirection in a shell. A coworker recently asked me how to deal with log files. How to find the information he was looking for. This article tries to shed some light on it.
Input / Output of shell commands
Many of the basic Linux/UNIX shell commands work in a similar way. Every command that you start from the shell gets three channels assigned:
- STDIN (channel 0):
Where your command draws the input from. If you don’t specify anything special this will be your keyboard input.
- STDOUT (channel 1):
Where your command’s output is sent to. If you don’t specify anything special the output is displayed in your shell.
- STDERR (channel 2):
If anything wrong happens the command will send error message here. By default the output is also displayed in your shell.
Try it yourself. The most basic command that just passes everything through from STDIN to STDOUT is the ‘cat’ command. Just open a shell and type ‘cat’ and press Enter. Nothing seems to happen. But actually ‘cat’ is waiting for input. Type something like “hello world”. Every time you press ‘Enter’ after a line ‘cat’ will output your input. So you will get an echo of everything you type. To let ‘cat’ know that you are done with the input send it an ‘end-of-file’ (EOF) signal by pressing Ctrl-D on an empty line.
The pipe(line)
A more interesting application of the STDIN/STDOUT is to chain commands together. The output of the first command becomes the input of the second command. Imagine the following chain:

The contents of the file /var/log/syslog are sent (as input) to the grep command. grep will filter the stream for lines containing the word ‘postfix’ and output that. Now the next grep picks up what was filtered and filter it further for the word ‘removed’. So now we have only lines containing both ‘postfix’ and ‘removed’. And finally these lines are sent to ‘wc -l’ which is a shell command counting the lines of some input. In my case it found 27 of such lines and printed that number to my shell. In shell syntax this reads:
cat /var/log/syslog | grep 'postfix' | grep 'removed' | wc -l
The ‘|’ character is called pipe. A sequence of such commands joined together with pipes are called pipeline.
Useless use of ‘cat’
Actually ‘cat’ is supposed to be used for concatenating files. Like “cat file1 file2”. But some administrators abuse the command to put something into a pipeline. That’s bad style and the reason why Randal L. Schwartz (a seasoned programmer) used to hand out virtual “Useless use of cat” awards. Shell commands usually can take a filename as the last argument as an input. So this would be right:
grep something /var/log/syslog | wc -l
While this works but is considered bad style:
cat /var/log/syslog | grep something | wc
Or if you knew that grep even has a “-c” option to count lines the whole task could be done with just grep:
grep -c something /var/log/syslog
Lire la suite…
Introduction
In this guide we will create and deploy a scalable WordPress instance consisting of a MySQL database server, a GlusterFS distributed filesystem, Nginx web servers and an Nginx load balancer. By using user-data and droplet meta-data we will automate the deployment of our site. Finally we will provide a Ruby script which will automate this entire process and ease the creation of scalable WordPress sites. Through this tutorial you will learn about the power and flexibility of user-data and droplet meta-data in deploying services on DigitalOcean.
Step One – Planning our Deployment
The deployment we create in this tutorial will consist of a single MySQL database server, multiple GlusterFS servers in a cluster, multiple Nginx web servers and a single Nginx load balancer.

Before we begin we should know:
- What size droplet we will use for our MySQL server
- How many GlusterFS nodes we will create
- What size our GlusterFS nodes will be
- How many web server nodes we will need
- What size droplets we will use for our web servers
- What size droplet we will use for our load balancer
- The domain name we will use for our new site
We can add additional nodes or scale up the nodes we created if we need to later. Once we have decided on these details we can begin deploying our site.
Lire la suite…
Source: nixCraft
Q. Can you explain how to setup network parameters such as IP address, subnet, dhcp etc using /etc/network/interfaces file?
A. /etc/network/interfaces file contains network interface configuration information for the both Ubuntu and Debian Linux. This is where you configure how your system is connected to the network.
Defining physical interfaces such as eth0
Lines beginning with the word « auto » are used to identify the physical interfaces to be brought up when ifup is run with the -a option. (This option is used by the system boot scripts.) Physical interface names should follow the word « auto » on the same line. There can be multiple « auto » stanzas. ifup brings the named inter faces up in the order listed. For example following example setup eth0 (first network interface card) with 192.168.1.5 IP address and gateway (router) to 192.168.1.254:
iface eth0 inet static
address 192.168.1.5
netmask 255.255.255.0
gateway 192.168.1.254
Setup interface to dhcp
To setup eth0 to dhcp, enter:
auto eth0
iface eth0 inet dhcp
Lire la suite…