Commandes Linux

9 Sep

Générer une clé ssh rsa :
ssh-keygen -t rsa -b 4096 -C « commentaire »
ssh-keygen -t dsa

Voir l’utilisation d’une ressource :
fuser

Voir les informations matériel :
dmidecode

Scanner les interfaces SAN :

echo « – – – » > /sys/class/scsi_host/host0/scan
echo « – – – » > /sys/class/scsi_host/host1/scan
echo « 1 » > /sys/class/fc_host/host4/issue_lip

partprobe

Synchronisation de l’horloge système vers l’horloge hardware
hwclock –systohc

sysstat
sar

curl -i

badblocks

mount -o,remout rw

mount -o remount /home/

mount -o ro

reseau :

Ajout d’une route :
ip r a x.x.x.0/24 via x.x.x.254

route add 10.x.x.x/32 gw 10.x.x.254

Tunnel SSH :
ssh -L 8000:172.16.x.x:8080 172.16.x.x

arping
arping -I eth1 10.x.x.254

nmap -sn 192.168.1.0/24

chkconfig bluetooth off

wall ‘bonjour’

SELinux :

getenforce

Certificat SSL :
CSR :
openssl genrsa -des3 2048 > nom.key

openssl req -new -key nom.key > nom.csr

openssl rsa -in nom.key -out nom.key.nopass

openssl x509 -req -days 365 -in nom.csr -signkey nom.key -out nom.crt

openssl pkcs12 -export -inkey nom.key.nopass -in nom.crt -name nom -out nom.p12

openssl pkcs12 -in nom.pfx -nocerts -out key.nom.pem

openssl rsa -in key.nom.pem -out key.nom.nopass.pem

openssl pkcs12 -in nom.pfx -clcerts -nokeys -out nom.pem

Voir détail d’un certificat :

openssl x509 -in cert.pem -text -noout

 

nc -uv ip port

nc -zv ip port

systool -c net -v

loadkeys fr

export set LANG=en_US.UTF-8

sendmail : makemap hash /etc/mail/access.db < /etc/mail/access

tcpdump -vvv -n -i eth0 port 80

dd in out

ss

strace

df

free

pwd

lsof

uname

uniq

sort

diff

 

Hash d’un fichier :

md5sum fichier

 

iostat

dstat
You did not select any stats, using -cdngy by default.
—-total-cpu-usage—- -dsk/total- -net/total- —paging– —system–
usr sys idl wai hiq siq| read writ| recv send| in out | int csw
1 0 98 0 0 0| 259k 259k| 0 0 | 113B 397B| 197 215
0 0 100 0 0 0| 0 0 | 204B 1052B| 0 0 | 80 137
0 0 100 0 0 0| 0 0 | 204B 700B| 0 0 | 71 133
0 0 100 0 0 0| 0 0 | 140B 508B| 0 0 | 75 138
0 0 100 0 0 0| 0 0 | 204B 636B| 0 0 | 72 128

 

Recherche de texte :

grep + regexp

 

Remplacement de texte :

sed -i « s/texte/nouveau texte/g » db.sql

ajouter une ligne
sed -i ‘1iligne1’ test.txt
sed -i ‘3iligne3’ test.txt

extraire une ligne
sed -n ‘5p’ test.txt

suppression de lignes
sed -i ‘7,9d’ test.txt

 

Création d’utilisateurs :

useradd -m nom_utilisateur

l’option -m permet la création du homedir de l’utilisateur.

Mise à jour du mot de passe de l’utilisateur :

passwd nom_utilisateur

Vider cache nscd :

nscd -i hosts

 

Changer l’éditeur par défaut, choisir vim :

update-alternatives –config editor
Il existe 4 choix pour l’alternative editor (qui fournit /usr/bin/editor).

Sélection Chemin Priorité État
————————————————————
* 0 /bin/nano 40 mode automatique
1 /bin/ed -100 mode manuel
2 /bin/nano 40 mode manuel
3 /usr/bin/vim.basic 30 mode manuel
4 /usr/bin/vim.tiny 10 mode manuel

Appuyez sur <Entrée> pour conserver la valeur par défaut[*] ou choisissez le numéro sélectionné :3
update-alternatives: utilisation de « /usr/bin/vim.basic » pour fournir « /usr/bin/editor » (editor) en mode manuel.

 

Quota :

Dans le fstab ajouter : usrquota

mount -o remount /home/

 

Compression des logs d’une arborescence :

find . -name ‘*.log’ -exec gzip {} \;

 

Droits et propriétaires des fichiers et répertoires :

chmod

chgrp

chown

 

ansible -i dev.inv all -m shell -a « uptime » -b

eval ‘ssh-agent -s’
ssh-add -k ~/.ssh/id_rsa

git commit –amend
git rebase -i
git rebase master

facter -p

yum install python-virtualenv
mkdir envpy
virtualenv envpy/ansible
source envpy/ansible/bin/activate

 

hostnamectl

yum-utils, needs-restarting -r

chattr
strace
lsof
dd
bg fg ctrl Z

timedatectl
lsblk
service –status-all

systemd, journalctl
systemctl list-unit-files
systemd-analyze blame

systemctl –type=service

systemctl status

apt list –upgradable
nohup

Laisser un commentaire

Votre adresse e-mail ne sera pas publiée. Les champs obligatoires sont indiqués avec *