---
# System prepended metadata

title: Ubuntu 常用指令
tags: [Ubuntu]

---

# Ubuntu 常用指令

###### tags: `Ubuntu`

## Permission
### Modified folders permission to 755
```bash=
find . -type d -exec chmod 755 {} +
```

### Modified files permission to 644
``` bash=
find . -type f -exec chmod 644 {} +
```


### Delete all specific files in a folder
```bash=
find /path/to/folder -maxdepth 1 -type f -name "file" -delete
```
#### Multiple targets
```bash=
find /path/to/folder -maxdepth 1 -type d \( -name "file1" -o -name "file2" \) -exec rm -r "{}" \;
```

```bash=
find /path/to/folder -maxdepth 4 -type d -name "*-old" -exec rm -r "{}" \;

find public_html -maxdepth 4 -type d -name "updraft/backup_*.zip" -exec rm -r "{}" \;
```

### Show Block Device
```bash=
lsblk
```

### Mount USB
```bash=
sudo mkdir /mnt/usb
sudo mount /dev/[Usb] /mnt/usb
```

### Umount USB
```bash=
sudo umount /dev/[Usb]
```

## Rsync
### Install
```bash=
sudo apt-get install rsync
```

### Rsync Folder
```bash=
rsync -avh /path/to/folder [path]
```