« Raspbian Commandes » : différence entre les versions

(36 versions intermédiaires par le même utilisateur non affichées)
Ligne 1 : Ligne 1 :
=== Redémarrer ===
=== Redémarrer ===
<pre>
<syntaxhighlight lang="bash" line copy>
sudo reboot
sudo reboot
</pre>
</syntaxhighlight>
 
=== Arrêt ===
=== Arrêt ===
<pre>
<syntaxhighlight lang="bash" line copy>
sudo shutdown -h now
sudo shutdown -h now
</pre>
</syntaxhighlight>
 
=== Firewall ===
=== Firewall ===
<syntaxhighlight lang="bash" line copy>
# Créer /etc/init.d/firewall
# Afin de l'ajouter aux scripts appelés au démarrage :
# Ajouter une entête dans le fichier
#!/bin/sh
### BEGIN INIT INFO
# Provides:          firewall rules
# Required-Start:    $remote_fs $syslog
# Required-Stop:    $remote_fs $syslog
# Default-Start:    2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Firewall deamon
# Description:      Enable service provided by daemon.
### END INIT INFO
</syntaxhighlight>
<syntaxhighlight lang="bash" line copy>
# Sauvegarde
sudo systemctl enable firewall
</syntaxhighlight>
<syntaxhighlight lang="bash" line copy>
"Relance
sudo update-rc.d firewall defaults
</syntaxhighlight>
démarrer un deamon -> http://manpages.ubuntu.com/manpages/trusty/fr/man8/update-rc.d.8.html


#<=> stop & start /etc/init.d/firewall
<syntaxhighlight lang="bash" line copy>
<span style="color: red;font-weight:bold;">sudo update-rc.d firewall defaults</span>
sudo /etc/init.d/firewall status
démarrer un deamon -> http://manpages.ubuntu.com/manpages/trusty/fr/man8/update-rc.d.8.html
</syntaxhighlight>


=== cron ===
=== cron ===
<pre>
<syntaxhighlight lang="bash" line copy>
#relancer service cron
#relancer service cron
sudo /etc/init.d/cron restart
sudo /etc/init.d/cron restart
</pre>
</syntaxhighlight>
 
=== IPv6 ===
<syntaxhighlight lang="bash" line copy>
/etc/sysctl.d/enableipv6.conf
journalctl | grep -Ei 'dhcp6'
ip -6 route
</syntaxhighlight>
 
=== Désactivation ===
==== Bluetooth & Wifi ====
<syntaxhighlight lang="bash" line copy>
dans /boot/config.txt
dtoverlay=pi3-disable-wifi
dtoverlay=pi3-disable-bt
puis sudo reboot
</syntaxhighlight>
 
==== ipv6 ====
<syntaxhighlight lang="bash" line copy>
# * au démarage
# dans /etc/sysctl.d/
#créer /etc/sysctl.d/disableipv6.conf
#avec :
 
# désactivation de ipv6 pour toutes les interfaces
net.ipv6.conf.all.disable_ipv6=1
 
# désactivation de l’auto configuration pour toutes les interfaces
net.ipv6.conf.all.autoconf=0
 
# désactivation de ipv6 pour les nouvelles interfaces (ex:si ajout de carte réseau)
net.ipv6.conf.default.disable_ipv6=1
 
# désactivation de l’auto configuration pour les nouvelles interfaces
net.ipv6.conf.default.autoconf=0
</syntaxhighlight>


=== version matériel ===
=== version matériel ===
cat /proc/cpuinfo
<syntaxhighlight lang="bash" line copy>
#Raspberry Pi 3 Model B Rev 1.2
cat /proc/cpuinfo
#Raspberry Pi 3 Model B Rev 1.2
</syntaxhighlight>


=== CPU infos ===
=== CPU infos ===
lscpu
<syntaxhighlight lang="bash" line copy>
lscpu
</syntaxhighlight>


=== Paquets APT ===
=== Paquets APT ===
 
[[ APT | voir APT]]
#mettre à jour un paquet :
<span style="color: red;font-weight:bold;">sudo apt update (mise à jour de '''la liste''' des paquets) </span>
<span style="color: red;font-weight:bold;">sudo apt list --upgradable (pour voir ce qui doit être mis à jour) </span>
<span style="color: red;font-weight:bold;">sudo apt install --only-upgrade firefox </span>
#voir tous les paquets
<span style="color: red;font-weight:bold;">dpkg --list</span>
#voir si un paquet est à jour
<span style="color: red;font-weight:bold;">apt-cache policy firefox</span>


=== Redémarrer unbound ===
=== Redémarrer unbound ===
<span style="color: red;font-weight:bold;">sudo service unbound restart</font>
<syntaxhighlight lang="bash" line copy>
sudo service unbound restart
</syntaxhighlight>


=== Lighttpd ===
=== DHCPCD (static ip_address) ===
<span style="color: red;font-weight:bold;">sudo service lighttpd status</span>
<pre>
<span style="color: red;font-weight:bold;">sudo service lighttpd restart</span>
DHCPCD signifie DHCP Client Daemon. Comme son nom l'indique, c'est un client DHCP s'exécutant en tâche de fond. Mais son nom est également trompeur car il ne se limite pas à récupérer une adresse IP via DHCP, c'est aussi sur lui que repose toute la configuration réseau d'une machine Linux.
==== vhost ====
DHCPCD est emmené à remplacer la configuration du réseau que l'on fait via le fichier /etc/network/interfaces et le service networking sous les distributions Linux dérivées de Debian.
<span style="color: red;font-weight:bold;">ln -s /etc/lighttpd/conf-available/91-exemple.com.conf /etc/lighttpd/conf-enabled/91-exemple.com.conf</span>
</pre>
*voir:[https://www.jesus-forain.fr/blog/configuration-de-dhcpcd-52.html Configuration de DHCPCD]


=== Pihole ===
<syntaxhighlight lang="bash" line copy>
#update pihole
sudo service dhcpcd status
<span style="color: red;font-weight:bold;">pihole -up</span>
</syntaxhighlight>
/etc/dhcpcd.conf


==== Black Lists ====
<syntaxhighlight lang="bash" line copy>
[https://fleuryk.kappatau.fr/pihole-blocklist/ pihole-blocklist]
dhcpcd man
* https://raw.githubusercontent.com/deathbybandaid/piholeparser/master/Subscribable-Lists/ParsedBlacklists/Block-EU-Cookie-Shit-List.txt
</syntaxhighlight>
* https://raw.githubusercontent.com/deathbybandaid/piholeparser/master/Subscribable-Lists/CountryCodesLists/France.txt
* https://easylist-downloads.adblockplus.org/liste_fr%2Beasylist.txt
* https://blocklist.site/app/dl/malware
* https://blocklist.site/app/dl/ransomware
* https://blocklist.site/app/dl/phishing
* https://blocklist.site/app/dl/ads
* https://gist.githubusercontent.com/BBcan177/4a8bf37c131be4803cb2/raw/343ff780e15205b4dd0de37c86af34cfb26b2fbe/MS-2
* https://raw.githubusercontent.com/anudeepND/youtubeadsblacklist/master/domainlist.txt
* https://blocklist.site/app/dl/spam
* https://hosts.ubuntu101.co.za/domains.list
* https://hosts.ubuntu101.co.za/ips.list


=== PiVpn ===
<pre>
#ajouter un client vpn
static value
  <span style="color: red;font-weight:bold;">pivpn add nopass</span>
            Configures a static value. If you set ip_address then dhcpcd will not attempt to obtain a lease and will just use the value for the address with an infinite lease time. If you
  #pour voir qui est connecté
            set ip6_address, dhcpcd will continue auto-configuration as normal.
<span style="color: red;font-weight:bold;">pivpn clients</span>
==== upgrading ====
*mise à jour<br>


[https://github.com/pivpn/pivpn/wiki/Upgrading pivpn/wiki/Upgrading]<br>
            Here is an example which configures two static address, overriding the default IPv4 broadcast address, an IPv4 router, DNS and disables IPv6 auto-configuration.  You could also
            use the inform6 command here if you wished to obtain more information via DHCPv6.  For IPv4, you should use the inform ipaddress option instead of setting a static address.
                  interface eth0
                  noipv6rs
                  static ip_address=192.168.0.10/24
                  static broadcast_address=192.168.0.63
                  static ip6_address=fd51:42f8:caae:d92e::ff/64
                  static routers=192.168.0.1
                  static domain_name_servers=192.168.0.1 fd51:42f8:caae:d92e::1


*Voir la version en cours d'openvpn disponible pour le raspberry<br>
            Here is an example for PPP which gives the destination a default route.  It uses the special destination keyword to insert the destination address into the value.
                  interface ppp0
                  static ip_address=
                  destination routers
</pre>


[https://packages.debian.org/search?arch=armhf&keywords=openvpn debian dépot armhf]
=== Lighttpd ===
<syntaxhighlight lang="bash" line copy>
sudo service lighttpd status
sudo service lighttpd restart
</syntaxhighlight>
==== vhost ====
<syntaxhighlight lang="bash" line copy>
ln -s /etc/lighttpd/conf-available/91-exemple.com.conf /etc/lighttpd/conf-enabled/91-exemple.com.conf
</syntaxhighlight>


=== Réseaux ===
=== Commandes Réseaux ===
<syntaxhighlight lang="bash" line>
# voir les ip du reseaux et le mac adress
arp
# Pour voir les DNS en cours
# cat /etc/resolv.conf
dig pi-hole.net @127.0.0.1 -p 53
# table de routage (IPv4/IPv6)
ip route
iip -6 neigh show
# Vérification des interfaces
ifconfig
# Lister les ports ouverts et les services réseaux en écoute sur son serveur Linux grâce à netstat.
netstat -lntup
# Lister tous les ports :
netstat -a
# Lister tous les ports TCP :
netstat -at
# Lister tous les ports UDP :
netstat -au
# Lister tous les ports en écoute :
netstat -l
# Lister uniquement les ports TCP en écoutes :
netstat -lt
# Lister uniquement les ports UDP en écoutes :
netstat -lu
# Afficher les statistique de tous les ports :
netstat -s
# Affichier les statistique des Port TCP :
netstat -st
# Affichier les statistique des Port UDP :
netstat -su
# Affiche le nom du programme et le PID associé :
# Cette commande est très utile lorsque vous souhaitez connaitre quel programme est exécuté sur un port particulier.
netstat -p
# Afficher directement les IP et pas de résolution de nom :
# Pour afficher toutes les connexions et tous les ports en écoute mais n’affiche que les adresses IP sans la résolutions des noms.
netstat -an
# Affiche le numéro d’identification des processus (PID) associé à chaque connexion :
netstat -o
# Afficher la table de routage IPV4 et IP6 :
netstat -r
# Affichage à un interval de temps régulier en seconde :
netstat -t “temps en seconde” #( Exemple : netstat -t 5 )
netstat -t 5
</syntaxhighlight>


voir les ip du reseaux et le mac adress
==== 1. Lister les machines à explorer ====
<span style="color: red;font-weight:bold;">arp</span>
:Cette commande va se contenter de lister les machines que nmap explorerait sur le réseau en question.
Pour voir les DNS en cours
:La valeur 24 indique que les trois premières valeurs sont fixes et que seule la dernière va varier.
<span style="color: red;font-weight:bold;">cat /etc/resolv.conf</span>
<syntaxhighlight lang="bash" line>
<span style="color: red;font-weight:bold;">dig pi-hole.net @127.0.0.1 -p 53</span>
nmap -sL 192.168.0.1/24
table de routage (IPv4/IPv6)
</syntaxhighlight>
<span style="color: red;font-weight:bold;">ip route</span>
==== 2. Scanner les machines du réseau ====
Vérification des interfaces
:On va maintenant passer la même commande en faisant un ping sur chaque machine.
<span style="color: red;font-weight:bold;">ifconfig</span>
<syntaxhighlight lang="bash" line>
Lister les ports ouverts et les services réseaux en écoute sur son serveur Linux grâce à netstat.
nmap -sP 192.168.0.1/24
<span style="color: red;font-weight:bold;">netstat -lntup</span>
</syntaxhighlight>
Lister tous les ports :
==== 3. Scanner une machine ====
<span style="color: red;font-weight:bold;">netstat -a</span>
<syntaxhighlight lang="bash" line>
Lister tous les ports TCP :
nmap 192.168.0.72
<span style="color: red;font-weight:bold;">netstat -at</span>
</syntaxhighlight>
Lister tous les ports UDP :
==== 4. Scanner une machine plus en détail ====
<span style="color: red;font-weight:bold;">netstat -au</span>
:On peut en plus activer la détection du système d'exploitation et des versions dans la commande précédente an ajoutant le flag -A:
Lister tous les ports en écoute :
<syntaxhighlight lang="bash" line>
<span style="color: red;font-weight:bold;">netstat -l</span>
nmap -A 192.168.0.72
Lister uniquement les ports TCP en écoutes :
</syntaxhighlight>
<span style="color: red;font-weight:bold;">netstat -lt</span>
:Si maintenant on scanne la Box Internet:
Lister uniquement les ports UDP en écoutes :
<syntaxhighlight lang="bash" line>
<span style="color: red;font-weight:bold;">netstat -lu</span>
nmap -A 192.168.0.254
Afficher les statistique de tous les ports :
</syntaxhighlight>
<span style="color: red;font-weight:bold;">netstat -s</span>
==== 5. Accélérer le scan de la machine ====
Affichier les statistique des Port TCP :
:Le précédent scan ayant duré 17mn, on va essayer d'obtenir un résultat plus rapidement en changeant la politique de temporisation de nmap:
<span style="color: red;font-weight:bold;">netstat -st</span>
<syntaxhighlight lang="bash" line>
Affichier les statistique des Port UDP :
nmap -A -T5 192.168.0.254
<span style="color: red;font-weight:bold;">netstat -su</span>
</syntaxhighlight>
Affiche le nom du programme et le PID associé :
Cette commande est très utile lorsque vous souhaitez connaitre quel programme est exécuté sur un port particulier.
<span style="color: red;font-weight:bold;">netstat -p</span>
Afficher directement les IP et pas de résolution de nom :
Pour afficher toutes les connexions et tous les ports en écoute mais n’affiche que les adresses IP sans la résolutions des noms.
<span style="color: red;font-weight:bold;">netstat -an</span>
Affiche le numéro d’identification des processus (PID) associé à chaque connexion :
<span style="color: red;font-weight:bold;">netstat -o</span>
Afficher la table de routage IPV4 et IP6 :
<span style="color: red;font-weight:bold;">netstat -r</span>
Affichage à un interval de temps régulier en seconde :
netstat -t “temps en seconde” ( Exemple : netstat -t 5 )
<span style="color: red;font-weight:bold;">netstat -t 5</span>


1. Lister les machines à explorer
=== Heure ===
Cette commande va se contenter de lister les machines que nmap explorerait sur le réseau en question.
<pre>
La valeur 24 indique que les trois premières valeurs sont fixes et que seule la dernière va varier.
#serveurs NTP
<span style="color: red;font-weight:bold;">nmap -sL 192.168.0.1/24</span>
#Fichier de configuration des serveurs NTP : /etc/systemd/timesyncd.conf
#Permet la synchronisation NTP même si aucun serveur DNS n’est joignable :
#NTP=145.238.203.14 145.238.203.10


2. Scanner les machines du réseau
#Vérifier la prise en compte du serveur avec
On va maintenant passer la même commande en faisant un ping sur chaque machine.
systemctl status systemd-timesyncd.service
<span style="color: red;font-weight:bold;">nmap -sP 192.168.0.1/24</span>
timedatectl status
timedatectl set-timezone "Europe/Paris"
timedatectl set-ntp true
</pre>
* [https://www.jbnet.fr/systeme/raspbian/raspberry-pi-installation-mode-serveur.html www.jbnet.fr]


3. Scanner une machine
=== Voir version installé ===
<span style="color: red;font-weight:bold;">nmap 192.168.0.72</span>
<pre>
 
Sur les systèmes similaires à Debian, dans le dossier /proc :
4. Scanner une machine plus en détail
“cpuinfo” contient des informations sur votre processeur.
On peut en plus activer la détection du système d'exploitation et des versions dans la commande précédente an ajoutant le flag -A:
“meminfo” concerne la RAM.
<span style="color: red;font-weight:bold;">nmap -A 192.168.0.72</span>
</pre>
 
Si maintenant on scanne la Box Internet:
<span style="color: red;font-weight:bold;">nmap -A 192.168.0.254</span>
 
5. Accélérer le scan de la machine
Le précédent scan ayant duré 17mn, on va essayer d'obtenir un résultat plus rapidement en changeant la politique de temporisation de nmap:
<span style="color: red;font-weight:bold;">nmap -A -T5 192.168.0.254</span>


[[Catégorie: Raspian]]
[[Catégorie: Raspian]]