My favorite linux command lines
Command lines I use often. It's not sorted out at all.
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
Server
restart a 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
configure 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 = Shared folder for my_user
Path = /media/nico/shared_folder_for_my_user
valid users = my_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@nacq.me
sudo prosodyctl passwd xxx@nacq.me
Configure fail2ban
sudo nano /etc/fail2ban/jail.conf
sudo service fail2ban restart
Configure dyndns
sudo nano /etc/ddclient.conf
sudo systemctl restart ddclient.service
Configure 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
Configure gitea
sudo nano /etc/gitea/app.ini
sudo systemctl daemon-reload
sudo systemctl restart gitea
Backup SD card
# find out the card name :
sudo fdisk -l
# Use the device name and not the partition (ending with p1, p2, etc..)
# backup
sudo dd bs=4M if=/dev/mmcblk0 of=~/rpi1_backup_2020-08-08.img status=progress conv=fsync
# restore
# check if card is unmounted, it should return nothing :
sudo mount | grep mmcblk0
# or else unmount
sudo umount /dev/mmcblk0
# then 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
share SSH key
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>
search in PDFs
pdfgrep -i 'my keyword' *
Misc
sudo shutdown -h now
sudo reboot