132 lines
2.9 KiB
Markdown
132 lines
2.9 KiB
Markdown
# Linux comandi alla console
|
|
|
|
## Montare disco rigido
|
|
|
|
verificare che dischi ci sono
|
|
```bash
|
|
lsblk
|
|
```
|
|
comando generico per montare disco
|
|
```bash
|
|
sudo mount -t <type> /dev/<device> <directory>
|
|
```
|
|
se manca creare diectory e poi montare
|
|
```bash
|
|
sudo mkdir -p <directory>
|
|
sudo mount -t ext4 /dev/nvme0n1 /home/nvme
|
|
```
|
|
verifica se è stato correttamente montato con
|
|
```bash
|
|
lsblk -f
|
|
```
|
|
per installarlo sempre anche dopo un reboot
|
|
prima smontarlo
|
|
```bash
|
|
sudo umount /dev/nvme0n1
|
|
```
|
|
poi inserirlo in /etc/fstab
|
|
```bash
|
|
sudo nano /etc/fstab
|
|
```
|
|
inserendo
|
|
```bash
|
|
/dev/nvme0n1 /home/nvme ext4 defaults 0 0
|
|
```
|
|
quindi ricaricare tutti i dischi
|
|
```bash
|
|
systemctl daemon-reload
|
|
```
|
|
## Verificare porte utilizzate
|
|
|
|
verificare la porta 80 in TCP
|
|
```bash
|
|
sudo lsof -i tcp:80
|
|
```
|
|
verificare le porte aperte TCP
|
|
```bash
|
|
sudo lsof -nP -iTCP -sTCP:LISTEN
|
|
```
|
|
## File compressi con i permessi e gli owner
|
|
|
|
creare archivio
|
|
```bash
|
|
sudo tar -czvpf <nome>.tar.gz <folder>
|
|
```
|
|
verificare le porte aperte TCP
|
|
```bash
|
|
sudo tar -xzvpf <nome>.tar.gz
|
|
```
|
|
|
|
Options:
|
|
```
|
|
-c : Creates archive
|
|
-x : Extracts the archive
|
|
-f : creates archive with given filename
|
|
-t : displays or lists files in archived file
|
|
-u : archives and adds to an existing archive file
|
|
-v : Displays verbose information
|
|
-A : Concatenates the archive files
|
|
-z : compresses the tar file using gzip
|
|
-j : compresses the tar file using bzip2
|
|
-W : Verifies an archive file
|
|
-r : updates or adds file or directory in already existing .tar file
|
|
-p : with permissions and ownership
|
|
```
|
|
## RSYNC
|
|
|
|
rsync [options] source [destination]
|
|
|
|
se c'è l'accesso con ssh si può sincronizzare su altri server
|
|
|
|
rsync local_file_path user@remote-host:remote_file_path
|
|
rsync user@remote-host:remote_file_path local_file_path
|
|
|
|
|
|
Options:
|
|
```
|
|
-r : recursive
|
|
-a : archive
|
|
-z : compresses reduce transfer time
|
|
-P : display progress
|
|
-v : Displays verbose information
|
|
-p : with permissions and ownership
|
|
```
|
|
|
|
Example:
|
|
|
|
sudo rsync -razPvp calibre orangepi@192.168.1.4:/home/nvme/dockerdata
|
|
|
|
## Grep (ricerca stringa)
|
|
|
|
per cercare una stringa
|
|
|
|
grep -rl "string" /path
|
|
|
|
opzioni usate
|
|
|
|
-r (or --recursive) option is used to traverse also all sub-directories of /path, whereas
|
|
-l (or --files-with-matches) option is used to only print filenames of matching files
|
|
|
|
## Scaricare siti o parte di essi
|
|
|
|
per scaricare un sito completo
|
|
|
|
wget -m -A * -pk -e robots=off https://www.decomposerize.com/
|
|
|
|
wget -p -k https://www.composeverter.com/
|
|
|
|
per scaricare una dir di un sito
|
|
|
|
wget -rkpN -np -e robots=off -l1 https://brouter.de/brouter/profiles2/
|
|
|
|
## sed per sostituire e per inserire
|
|
|
|
per sostituire
|
|
|
|
sed -i 's/vite dev/vite dev --host 0.0.0.0 --port 8111/g' package.json
|
|
sed -i 's/<string out>/<string in>/g' <file>
|
|
|
|
per inserire righe dopo una stringa usando un file
|
|
|
|
sed -i '/link rel/r icon' src/app.html
|
|
sed -i '/<sting>/r <file da ins>' <file da mod>
|