Commandi_linux/README.md
2025-03-24 16:40:10 +08:00

108 lines
No EOL
2.3 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,