Outils pour utilisateurs

Outils du site


tuto:linux:quelques_commandes_utiles

Différences

Ci-dessous, les différences entre deux révisions de la page.

Lien vers cette vue comparative

Les deux révisions précédentesRévision précédente
Prochaine révision
Révision précédente
tuto:linux:quelques_commandes_utiles [2015/10/16 21:35] – [partproble] roottuto:linux:quelques_commandes_utiles [2024/01/20 17:20] (Version actuelle) admin
Ligne 19: Ligne 19:
 où mot est le mot clé à rechercher dans toutes les pages de manuel. où mot est le mot clé à rechercher dans toutes les pages de manuel.
 La commande man est la commande d’aide standard sur tous les systèmes Unix. Cependant, Linux utilise un grand nombre de commandes écrites sous la licence GNU, et qui utilisent un format d’aide spécifique à GNU. La commande man est la commande d’aide standard sur tous les systèmes Unix. Cependant, Linux utilise un grand nombre de commandes écrites sous la licence GNU, et qui utilisent un format d’aide spécifique à GNU.
 +
 +On peut afficher toutes les pages de manuel par exemple pour ''read'' de cette façon :
 +  apropos . | grep -w ^read
  
 L’aide pour ces commandes peut être obtenue par la commande suivante : L’aide pour ces commandes peut être obtenue par la commande suivante :
Ligne 512: Ligne 515:
   lsof -i   lsof -i
  
-===== nmap ===== 
  
 +Voir les process qui ont des fichiers supprimés :
 +  lsof +aL1
 +  lsof -d DEL
 +===== nmap =====
 +* [[https://bencane.com/ten-nmap-commands-every-sysadmin-should-know-2390c559a7c3|Ten Nmap Commands Every Sysadmin Should Know
 +]]
 Nmap est un scanner de ports. Nmap est un scanner de ports.
  
Ligne 2812: Ligne 2820:
  
 ===== tshark ===== ===== tshark =====
 +* https://www.it-connect.fr/reseau-analyse-dune-connexion-tcp-et-de-ses-options-avec-wireshark/
 Wireshark en ligne de commande. Wireshark en ligne de commande.
  
Ligne 3194: Ligne 3202:
 <code>$ sysdig -c lsof "'fd.type=ipv4 and user.name=root'"</code> <code>$ sysdig -c lsof "'fd.type=ipv4 and user.name=root'"</code>
 <code>$ sysdig -c ps "'fd.type=ipv4 and fd.is_server=true and fd.sport!=80'"</code> <code>$ sysdig -c ps "'fd.type=ipv4 and fd.is_server=true and fd.sport!=80'"</code>
 +
 +===== sg_persist =====
 +  * Voir les info :
 +<xtermrtf>
 +$ sg_persist --in --report-capabilities -v /dev/sda
 +    inquiry cdb: 12 00 00 00 24 00 
 +  SUSE      RBD               4.0 
 +  Peripheral device type: disk
 +    Persistent Reservation In cmd: 5e 02 00 00 00 00 00 20 00 00 
 +Report capabilities response:
 +  Compatible Reservation Handling(CRH): 1
 +  Specify Initiator Ports Capable(SIP_C): 0
 +  All Target Ports Capable(ATP_C): 0
 +  Persist Through Power Loss Capable(PTPL_C): 1
 +  Type Mask Valid(TMV): 1
 +  Allow Commands: 1
 +  Persist Through Power Loss Active(PTPL_A): 1
 +    Support indicated in Type mask:
 +      Write Exclusive, all registrants: 1
 +      Exclusive Access, registrants only: 1
 +      Write Exclusive, registrants only: 1
 +      Exclusive Access: 1
 +      Write Exclusive: 1
 +      Exclusive Access, all registrants: 1
 +</xtermrtf>
 +
 +  * Voir la clé de réservation :
 +Sans clé de réservation :
 +<xtermrtf>
 +$ sg_persist --in -k -d /dev/sda
 +  SUSE      RBD               4.0 
 +  Peripheral device type: disk
 +  PR generation=0x7, there are NO registered reservation keys
 +</xtermrtf>
 +
 +Avec une clé de réservation :
 +<xtermrtf>
 +$ sg_persist --in -k -d /dev/sdb
 +  SUSE      RBD               4.0 
 +  Peripheral device type: disk
 +  PR generation=0x8, 1 registered reservation key follows:
 +    0xdeadbeef
 +</xtermrtf>
 +
 +ou 
 +<xtermrtf>
 +$ sg_persist /dev/mapper/mpatha
 +>> No service action given; assume Persistent Reserve In command
 +>> with Read Keys service action
 +  SUSE      RBD               4.0 
 +  Peripheral device type: disk
 +  PR generation=0x14, 1 registered reservation key follows:
 +    0xdeadbeef
 +</xtermrtf>
 +
 +  * Voir la réservation :
 +<xtermrtf>
 +$ sg_persist --in -r -d /dev/sda
 +  SUSE      RBD               4.0 
 +  Peripheral device type: disk
 +  PR generation=0x7, there is NO reservation held
 +</xtermrtf>
 +
 +<xtermrtf>
 +$ sg_persist --in -r -d /dev/sda
 +  SUSE      RBD               4.0 
 +  Peripheral device type: disk
 +  PR generation=0x8, Reservation follows:
 +    Key=0xdeadbeef
 +    scope: LU_SCOPE,  type: Exclusive Access
 +</xtermrtf>
 +
 +  * Positionner une clé de réservation (la clé est au format HEX jusqu'à 8 chiffres) :
 +<xtermrtf>
 +$ sg_persist --out --register --param-sark=0xDEADBEEF /dev/sda
 +  SUSE      RBD               4.0 
 +  Peripheral device type: disk
 +</xtermrtf>
 +
 +<note>
 +Il est possible de convertir l'IP en HEX pour positionner la clé :
 +<xtermrtf>
 +$ printf '%02X' $(hostname -i | awk '{ print $NF }' | sed 's@\.@ @g'); echo
 +</xtermrtf>
 +</note>
 +  * Placer un type réservation :
 +<xtermrtf>
 +$ sg_persist --out --reserve --param-rk=0xDEADBEEF --prout-type=5 /dev/sda
 +  SUSE      RBD               4.0 
 +  Peripheral device type: disk
 +</xtermrtf>
 +
 +Ci-dessous les différents types :
 +
 +1) **Exclusive Access :** don't let anybody else use my disc at all, and don't let anybody take my reservation.
 +
 +3) **Write Exclusive :** don't let anybody else write to my disc, and don't let anybody take my reservation.
 +
 +5) **Exclusive Access, Registrants Only :** Don't let anybody but my group of friends use the disc, and don't let anybody take my reservation.
 +
 +6) **Write Exclusive, Registrants Only :** Don't let anybody but my group of friends write to the the disc, and don't let anybody take my reservation.
 +
 +7) **Exclusive Access, All Registrants :** Don't let anybody but my group of friends use the disc, and share my reservation with all of them as well.
 +
 +8) **Write Exclusive, All Registrants :** Don't let anybody but my group of friends write to the disc, and share my reservation with all of them as well.
 +
 +  * Supprimer la réservation :
 +<xtermrtf>
 +$ sg_persist --out --release --param-rk=0xDEADBEEF  --prout-type=5 /dev/sda
 +</xtermrtf>
 +
 +  * Supprimer la clé de réservation :
 +<xtermrtf>
 +$ sg_persist --out --register --param-rk=0xDEADBEEF /dev/sda
 +</xtermrtf>
 +
 +  * Supprimer la clé et la réservation :
 +<xtermrtf>
 +$ sg_persist --out --clear --param-rk=0xDEADBEEF /dev/sda
 +</xtermrtf>
 +
 +===== upower =====
 +Lister les sources d'énergie :
 +<xtermrtf>
 +$ upower -e         
 +/org/freedesktop/UPower/devices/line_power_AC
 +/org/freedesktop/UPower/devices/battery_BAT0
 +/org/freedesktop/UPower/devices/DisplayDevice
 +</xtermrtf>
 +
 +Information sur une source d'énergie :
 +<xtermrtf>
 +$ upower -i /org/freedesktop/UPower/devices/battery_BAT0 
 +  native-path:          BAT0
 +  vendor:               SMP
 +  model:                DELL TP1GT61
 +  serial:               2617
 +  power supply:         yes
 +  updated:              mer. 08 nov. 2017 23:12:56 CET (5 seconds ago)
 +  has history:          yes
 +  has statistics:       yes
 +  battery
 +    present:             yes
 +    rechargeable:        yes
 +    state:               charging
 +    warning-level:       none
 +    energy:              6,5892 Wh
 +    energy-empty:        0 Wh
 +    energy-full:         59,736 Wh
 +    energy-full-design:  59,9944 Wh
 +    energy-rate:         30,6888 W
 +    voltage:             7,868 V
 +    time to full:        1,7 hours
 +    percentage:          11%
 +    capacity:            99,5693%
 +    technology:          lithium-polymer
 +    icon-name:          'battery-low-charging-symbolic'
 +  History (charge):
 +    1510179176 11,000 charging
 +  History (rate):
 +    1510179176 30,689 charging
 +</xtermrtf>
 +
 +Information sur le démon :
 +<xtermrtf>
 +$ upower -d
 +...
 +Daemon:
 +  daemon-version:  0.99.6
 +  on-battery:      no
 +  lid-is-closed:   no
 +  lid-is-present:  yes
 +  critical-action: PowerOff
 +</xtermrtf>
 +
 +Voir aussi [[#acpi]].
 +
 +===== acpi =====
 +Information sur la batterie (voir aussi [[#upower]]):
 +<xtermrtf>
 +$ acpi -i -b                                             
 +Battery 0: Discharging, 28%, 02:50:39 remaining
 +Battery 0: design capacity 7894 mAh, last full capacity 6028 mAh = 76%
 +</xtermrtf>
 +
 +===== showkey =====
 +Afficher la valeur d'une touche :
 +<xtermrtf>
 +$ showkey -a
 +</xtermrtf>
 +
 +===== rpm =====
 +==== Metadonnées rpm ====
 +Afficher les vendors:
 +<xtermrtf>
 +$ rpm -qa --qf '%{VENDOR}\n' | sort | uniq
 +</xtermrtf>
 +
 +Afficher les rpms:
 +<xtermrtf>
 +$ rpm -qa --qf '%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH} %{VENDOR}\n' | sort
 +</xtermrtf>
 +
 +Pour afficher tous les tags:
 +<xtermrtf>
 +rpm --querytags
 +</xtermrtf>
 +
 +===== patchelf =====
 +[[https://nixos.org/patchelf.html|Patchelf]] permet de relinker un binaire detype ''elf'':
 +<xtermrtf>
 +$ patchelf --set-interpreter /my/lib/my-ld-linux.so.2 program
 +$ patchelf --set-rpath /opt/my-libs/lib:/foo/lib program
 +$ patchelf --shrink-rpath program
 +</xtermrtf>
 +
 +===== growpart =====
 +Etend au max la partition:
 +<xtermrtf>
 +$ growpart /dev/sda 1
 +</xtermrtf>
 +
 +Ensuite on augmente le fs:
 +<xtermrtf>
 +$ btrfs filesystem resize max /mounted
 +</xtermrtf>
 +
 +===== nvme =====
 +<xtermrtf>
 +$ nvme list
 +Node             SN                   Model                                    Namespace Usage                      Format           FW Rev  
 +---------------- -------------------- ---------------------------------------- --------- -------------------------- ---------------- --------
 +/dev/nvme0n1     27CB40Y7KSHU         THNSN5512GPUK NVMe TOSHIBA 512GB                 512,11  GB / 512,11  GB    512   B +  0 B   5KDA4103
 +</xtermrtf>
 +
 +<xtermrtf>
 +$ nvme smart-log /dev/nvme0
 +Smart Log for NVME device:nvme0 namespace-id:ffffffff
 +critical_warning : 0
 +temperature : 44 C
 +available_spare : 100%
 +available_spare_threshold : 50%
 +percentage_used : 11%
 +endurance group critical warning summary: 0
 +data_units_read : 14 094 762
 +data_units_written : 19 359 069
 +host_read_commands : 274 444 402
 +host_write_commands : 263 000 581
 +controller_busy_time : 2 411
 +power_cycles : 1 547
 +power_on_hours : 4 677
 +unsafe_shutdowns : 90
 +media_errors : 0
 +num_err_log_entries : 0
 +Warning Temperature Time : 11
 +Critical Composite Temperature Time : 0
 +Temperature Sensor 1           : 44 C
 +Thermal Management T1 Trans Count : 0
 +Thermal Management T2 Trans Count : 0
 +Thermal Management T1 Total Time : 0
 +Thermal Management T2 Total Time : 0
 +</xtermrtf>
tuto/linux/quelques_commandes_utiles.1445031326.txt.gz · Dernière modification : 2015/10/16 21:35 de root