Cette page regroupe des commandes pratiques, procédures courantes et snippets utiles pour l’administration Linux : gestion de fichiers, réseau, automatisation, périphériques, outils système, et dépannage.
wget -m ftp://USER:PASSWORD@SERVEURFTP/www
du -sh * --exclude=mnt/*
find . -name "@eaDir" | while read line; do
echo ">>>> $line"
rm -r "$line"
done
find . -name "*.txt" -type f -exec sed -i "s/chaine1/chaine2/g" {} \;
Aller à la ligne XX : taper XXG
126G
dd bs=4M if=/path/to/archlinux.iso of=/dev/sdx && sync
⚠️ Remplacer /dev/sdx par le bon périphérique !
nmap -sn 172.32.0.5/25
root@beurresurlatartine:~# nc -vz 5.196.93.215 25566
Connection to 5.196.93.215 25566 port [tcp/*] succeeded!
curl -4 ifconfig.me
#Ajouter une IP statique temporaire
sudo ip addr add 192.168.1.100/24 dev eth0
#Supprimer une IP
sudo ip addr del 192.168.1.100/24 dev eth0
#Activer / désactiver une interface
sudo ip link set eth0 up
sudo ip link set eth0 down
cat /proc/mdstat
mdadm --detail /dev/md3
lsblk
fdisk -l
smartctl -a /dev/sda
smartctl -a /dev/sdb
mdadm --fail /dev/md3 /dev/sdb3
mdadm --remove /dev/md3 /dev/sdb3
fdisk /dev/sdb
Dans fdisk, saisir les commandes suivantes :
n # créer une nouvelle partition
p # partition primaire
3 # numéro de partition (3)
# accepter le premier secteur par défaut
# accepter le dernier secteur pour prendre tout l’espace
t # modifier le type de partition
3 # sélectionner la partition n°3
fd # type "Linux raid autodetect"
w # écrire les modifications et quitter
mdadm --add /dev/md3 /dev/sdb3
watch cat /proc/mdstat
ou :
mdadm --detail /dev/md3
cat /proc/mdstat
mdadm --detail /dev/md3
smartctl -a /dev/sdb
# passez le disque en mode fault
root@mougeat:~# mdadm --fail /dev/md3 /dev/sdb3
mdadm: set /dev/sdb3 faulty in /dev/md3
# supprimer le disque du RAID
root@mougeat:~# mdadm --remove /dev/md3 /dev/sdb3
mdadm: hot removed /dev/sdb3 from /dev/md3
# supprimer le superblock du disque
mdadm --zero-superblock /dev/sdb3
root@mougeat:~# sfdisk -d /dev/sda | sfdisk /dev/sdb
Checking that no-one is using this disk right now ... OK
Disk /dev/sdb: 1.82 TiB, 2000398934016 bytes, 3907029168 sectors
Disk model: HGST HUS724020AL
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x9f110b76
Old situation:
Device Boot Start End Sectors Size Id Type
/dev/sdb3 2048 3907029167 3907027120 1.8T fd Linux raid autodetect
>>> Script header accepted.
>>> Script header accepted.
>>> Script header accepted.
>>> Script header accepted.
>>> Script header accepted.
>>> Script header accepted.
>>> Script header accepted.
>>> Created a new GPT disklabel (GUID: 387099F2-EFD0-491A-92F8-4E392833EA38).
/dev/sdb1: Created a new partition 1 of type 'BIOS boot' and of size 1 MiB.
/dev/sdb2: Created a new partition 2 of type 'Linux RAID' and of size 1 GiB.
/dev/sdb3: Created a new partition 3 of type 'Linux RAID' and of size 1.8 TiB.
/dev/sdb4: Created a new partition 4 of type 'Linux filesystem' and of size 512 MiB.
/dev/sdb5: Created a new partition 5 of type 'Linux filesystem' and of size 2 MiB.
/dev/sdb6: Done.
New situation:
Disklabel type: gpt
Disk identifier: 387099F2-EFD0-491A-92F8-4E392833EA38
Device Start End Sectors Size Type
/dev/sdb1 2048 4095 2048 1M BIOS boot
/dev/sdb2 4096 2101247 2097152 1G Linux RAID
/dev/sdb3 2101248 3905976319 3903875072 1.8T Linux RAID
/dev/sdb4 3905976320 3907024895 1048576 512M Linux filesystem
/dev/sdb5 3907025072 3907029134 4063 2M Linux filesystem