Accueil » Ligne de commande » Page 8
On commence par lister tous nos domaines:
virsh list --all
ID Nom État
----------------------------------------------------
- Centreon fermé
- generic fermé
- Ubuntu fermé
- win10 fermé
Ici nous voulons faire un snapshot du domaine « Ubuntu », nous allons donc regarder si il y a des snapshot existant pour ce domaine:
virsh snapshot-list --domain Ubuntu
Nom Creation Time État
------------------------------------------------------------
On vérifie si le fichier disque est bien au format qemu/qcow2:
virsh dumpxml Ubuntu | grep -i qemu
<driver name='qemu' type='qcow2' cache='none'/>
<driver name='qemu' type='qcow2'/>
Pour un domaine éteint:
virsh snapshot-create-as --domain Ubuntu --name "Snapshot_test" --description "Snapshot de test"
Domain snapshot Snapshot_test created
Pour un domaine en fonctionnement:
virsh snapshot-create-as --domain Ubuntu --name "Snapshot_test" --description "Snapshot de test" --live
Domain snapshot Snapshot_test created
On peut maintenant voir notre snapshot:
virsh snapshot-list --domain Ubuntu
Nom Creation Time État
------------------------------------------------------------
Snapshot_test 2018-03-14 20:39:53 +0100 shutoff
Pour restaurer le snapshot:
virsh shutdown --domain Ubuntu
virsh snapshot-revert --domain Ubuntu --snapshotname Snapshot_test --running
Pour supprimer le snapshot:
virsh snapshot-delete --domain Ubuntu --snapshotname Snapshot_test
Domain snapshot Snapshot_test deleted
Suite à la dernière mise à jour du client bittorrent Transmission (v2.93), impossible de le démarrer. Au bout d’une minute, le service tombe KO:
Mar 7 20:24:12 XXXX systemd[1]: transmission-daemon.service: Start operation timed out. Terminating.
Mar 7 20:24:13 XXXX transmission-daemon[1200]: Closing transmission session... done.
Mar 7 20:24:13 XXXX systemd[1]: transmission-daemon.service: Unit entered failed state.
Mar 7 20:24:13 XXXX systemd[1]: transmission-daemon.service: Failed with result 'timeout'.
On peut contourner le problème et démarrer transmission de cette façon:
sudo su -
vi /etc/systemd/system/multi-user.target.wants/transmission-daemon.service
On va modifier le type de service via le paramètre « type » :
[Unit]
Description=Transmission BitTorrent Daemon
After=network.target
[Service]
User=transmission
Type=notification
ExecStart=/usr/bin/transmission-daemon -f --log-error
ExecReload=/bin/kill -s HUP $MAINPID
[Install]
WantedBy=multi-user.target
Qui devient:
[Unit]
Description=Transmission BitTorrent Daemon
After=network.target
[Service]
User=transmission
Type=simple
ExecStart=/usr/bin/transmission-daemon -f --log-error
ExecReload=/bin/kill -s HUP $MAINPID
[Install]
WantedBy=multi-user.target
On fait prendre en compte la modification par Systemd:
systemctl daemon-reload
On redemarre le service:
systemctl stop transmission-daemon
systemctl start transmission-daemon
Et là, ça fonctionne!
Avec wget qui va interrogé sera checkip.dyndns.org:
wget http://checkip.dyndns.org/ -O - -o /dev/null | cut -d: -f 2 | cut -d\< -f 1
Avec dig qui va interrogé OpenDNS.com:
dig +short myip.opendns.com @resolver1.opendns.com
Avec cURL qui va interrogé ifconfig.me avec l’outil cURL:
curl ifconfig.me
Recherche simple:
grep ext4 /etc/fstab
awk /ext4/ /etc/fstab
Recherche en ignorant la casse:
grep -i ext4 /etc/fstab
awk /ext4/ IGNORECASE=1 /etc/fstab
Compter le nombre d’occurrence:
grep -c ext4 /etc/fstab
awk '/ext4/{x++;}END{print x}' /etc/fstab
Liste des fichiers contenant le mot recherché:
grep -l ext4 *
awk '/ext4/{print FILENAME;nextfile}' *
Afficher le numéro des lignes contenant le mot recherché:
grep -n ext4 /etc/fstab
awk '/ext4/{print NR":"$0}' /etc/fstab
Recherche de plusieurs occurrences:
grep -E 'ext4|swap' /etc/fstab
awk '/ext4|swap/' /etc/fstab
Afficher les lignes qui ne contiennent pas le mot recherché:
grep -v ext4 /etc/fstab
awk '!/ext4/' /etc/fstab
Pour afficher les lignes contenant le mot rechercher ainsi que la ligne suivante:
grep -A1 ext4 /etc/fstab
awk '/ext4/{print;getline;print}' /etc/fstab
Pour afficher les lignes contenant le mot rechercher ainsi que la ligne précédente:
grep -B1 ext4 /etc/fstab
awk '/ext4/{print x;print;next}{x=$0;}' /etc/fstab
Pour afficher les lignes contenant le mot rechercher ainsi que la ligne précédente et la ligne suivante:
grep -C1 ext4 /etc/fstab
awk '/ext4/{print x;print;getline;print;next}{x=$0;}' /etc/fstab
Pour afficher le contenu d’un fichier sans ses lignes de commentaires:
grep "^[^#|^$|^;]" smb.conf
Masquer les commentaires
Pour afficher le contenu d’un fichier sans ses lignes de commentaires: