Compare commits

...

2 Commits

Author SHA1 Message Date
exu
30dceb6cb7 Add style guide sudo 2023-07-21 13:21:53 +02:00
exu
f64d142177 Use cool su instead of sudo 2023-07-21 13:17:01 +02:00
2 changed files with 29 additions and 12 deletions

View File

@ -30,6 +30,23 @@ lsusb -d 0781:55a3 -v | grep bcdUSB
(out)bcdUSB 3.20
```
#### Sudo
Although I try to avoid using `sudo`, in some cases it is quite handy. Examples can be seen on the Nextcloud page, where commands **need** to be executed as `www-data`.
Following a [post on lemmy](https://programming.dev/post/569497), I learned of a cool way to do this with just `su`
This example copies a file in the web directory, using the user `www-data`. Command blocks using this style should be prefixed with `#` using `[shroot]`
````
[shroot]
```
su -s /bin/sh -c 'cp /var/www/html/html1 /var/www/html/html2' www-data
```
[/shroot]
````
## Variables / Fill your own
Values that should be replaced by the reader are generally represented this way:

View File

@ -122,13 +122,13 @@ systemctl restart apache2
To execute regular jobs, I personally use cron.
Edit `crontab` as the `www-data` user.
[shuser]
[shroot]
```sh
sudo -u www-data crontab -e
su -s /bin/sh -c 'crontab -e' www-data
```
[/shuser]
[/shroot]
Add this following line:
@ -180,25 +180,25 @@ Array of trusted domains.
Enable maintenance mode to prevent data inconsistencies
[shuser]
[shroot]
```sh
sudo -u www-data php /var/www/nextcloud/occ maintenance:mode --on
su -s /bin/sh -c 'php /var/www/nextcloud/occ maintenance:mode --on' www-data
```
[/shuser]
[/shroot]
To disable maintenance mode again, run the same command with `--off` instead of `--on`
### Upgrade with CLI
[shuser]
[shroot]
```sh
sudo -u www-data php /var/www/nextcloud/updater/updater.phar
su -s /bin/sh -c 'php /var/www/nextcloud/updater/updater.phar' www-data
```
[/shuser]
[/shroot]
Always check the admin status page after an upgrade. Sometimes additional steps are needed to fully complete the upgrade
@ -206,13 +206,13 @@ Always check the admin status page after an upgrade. Sometimes additional steps
The missing indices can be added using `occ`
[shuser]
[shroot]
```sh
sudo -u www-data php /var/www/nextcloud/occ db:add-missing-indices
su -s /bin/sh -c 'php /var/www/nextcloud/occ db:add-missing-indices' www-data
```
[/shuser]
[/shroot]
### Backup Database