Mes commandes linux courantes
Des commandes vrac que j'utilise souvent. Ce n'est pas du tout trié.
Commandes linux courantes
Veracrypt
Mount
sudo veracrypt -t /dev/sda2 /media/nom_libre
sudo veracrypt -t -p 'xxx' /dev/sdb2 /media/nom_libre
Unmount
sudo veracrypt -t -d
Force unmount
sudo umount -l /media/veracrypt1
sudo veracrypt -t -d -f
Serveur
Redemarrer un service
sudo service apache2 restart
sudo service nginx restart
ou
sudo systemctl restart nginx
Nextcloud CLI
sudo -u www-data php /var/www/nextcloud/occ files:scan --all
Configuration php
sudo nano /etc/php/7.3/cli/php.ini
sudo nano /etc/php/7.3/fpm/php.ini
sudo /etc/init.d/php7.3-fpm restart
configurer samba
sudo nano /etc/samba/smb.conf
sudo service smbd restart
sudo useradd mon_user
sudo passwd mon_user
smbpasswd -a mon_user
[partage-mon_user]
Comment = Mon partage pour mon_user
Path = /media/nico/partage_pour_mon_user
valid users = mon_user
Browseable = yes
Writeable = yes
only guest = no
create mask = 0664
directory mask = 0755
Public = no
Guest ok = no
force group = nico
force user = nico
XMPP prosody
sudo nano /etc/prosody/prosody.cfg.lua
sudo /etc/init.d/prosody restart
sudo prosodyctl adduser xxx@fnx.nacq.me
sudo prosodyctl passwd xxx@fnx.nacq.me
Configurer fail2ban
sudo nano /etc/fail2ban/jail.conf
sudo service fail2ban restart
Configurer dyndns
sudo nano /etc/ddclient.conf
sudo systemctl restart ddclient.service
Configurer mysql
sudo nano /etc/mysql/my.cnf
sudo nano /etc/mysql/mariadb.conf.d/50-server.cnf
sudo /etc/init.d/mysql restart
Certbot
sudo systemctl stop nginx
sudo certbot certonly --standalone -d mon.domaine.com
sudo systemctl start nginx
Configurer gitea
sudo nano /etc/gitea/app.ini
sudo systemctl daemon-reload
sudo systemctl restart gitea
Backup SD card
# pour trouver le nom de la carte :
sudo fdisk -l
# Attention de bien prendre le device sans la partition à la fin (p1, p2, etc..)
# pour le backup
sudo dd bs=4M if=/dev/mmcblk0 of=~/rpi1_backup_2020-08-08.img status=progress conv=fsync
# pour restore
# vérifier que la carte est unmount, ça doit ne rien retourner :
sudo mount | grep mmcblk0
# sinon on unmount
sudo umount /dev/mmcblk0
#et on restore :
sudo dd bs=4M if=~/rpi1_backup_2020-10-17.img of=/dev/mmcblk0 status=progress conv=fsync
Firewall
sudo ufw status
sudo ufw allow from 10.0.0.202 to any port 22
Host file
sudo nano /etc/hosts
Partage clé SSH
ssh-keygen
ssh user@host
ssh-copy-id -i ~/.ssh/id_rsa user@host
Mount ssh
sshfs user@hosts:/home/chemin_dossier_distant /home/chemin_dossier_vide_local
tmux
tmux
#ctrl+b>d pour detach
#ctrl+b>& pour close
tmux list-sessions
tmux attach-session -t <session-name>
chercher dans des PDF
pdfgrep -i 'ma recherche' *
Divers
sudo shutdown -h now
sudo reboot