More arduino and housecleaning

master
Eirik Svagård 2020-03-23 11:14:49 +01:00
parent 51069194ee
commit 69d767ddc5
1 changed files with 29 additions and 22 deletions

View File

@ -1,13 +1,57 @@
# Linux Cheats
## Set script as startup
## General (tested in Debian)
### Set script as startup
If, for some reason, apache isn't startup:
> `sudo update-rc.d apache2 defaults`
## Check a package version/info
### Check a package version/info
> `dpkg -l matrix-synapse`
<br>
## SSH
Copy files to/from an SSH connection: (SSH format: `user@host:/path` )
> `scp <source> <destination>`
Recursivly give directories execute privileges: (`-type f` for files instead)
> `find /path/to/base/dir -type d -exec chmod +c {} +`
<br>
## GROUPS
Create groups
> `groupadd <groupName>`
Add user to a group
> `usermod -a -G <group> <user>`
### Open ports with iptables
Don't do that. Use [UFW](https://www.digitalocean.com/community/tutorials/how-to-set-up-a-firewall-with-ufw-on-debian-10) instead.
Allow a connection with UFW:
> `sudo ufw allow <port/service>`
Enable ufw service:
> `sudo ufw enable`
+ [Source](https://www.linuxquestions.org/questions/linux-security-4/how-to-open-ports-with-iptables-237939/)
+ [Source2](https://www.digitalocean.com/community/tutorials/iptables-essentials-common-firewall-rules-and-commands)
<br>
### Partitions
The following command is not permanent:
> `mount /dev/sda11 /opt`
To mount partition permanently, instert the following into `/etc/fstab`:
> `UUID=03ec5dd3-45c0-4f95-a363-61ff321a09ff /opt ext4 defaults 0 2`
<br>
## Arduino
Find what 'channel'(?) the Arduino is plugged in at:
@ -20,44 +64,7 @@ Do following commands to "talk" with an Arduino (with a set script):
> ser.readline()
> ser.write("PP\n")
---
## SSH
Copy files to/from an SSH connection: (SSH format: `user@host:/path` )
> `scp <source> <destination>`
Recursivly give directories execute privileges: (`-type f` for files instead)
> `find /path/to/base/dir -type d -exec chmod +c {} +`
---
## GROUPS
Create groups
> `groupadd <groupName>`
Add user to a group
> `usermod -a -G <group> <user>`
## Open ports with iptables
Don't do that. Use [UFW](https://www.digitalocean.com/community/tutorials/how-to-set-up-a-firewall-with-ufw-on-debian-10) instead.
Allow a connection with UFW:
> `sudo ufw allow <port/service>`
Enable ufw service:
> `sudo ufw enable`
> [Source](https://www.linuxquestions.org/questions/linux-security-4/how-to-open-ports-with-iptables-237939/)
>
> [Source2](https://www.digitalocean.com/community/tutorials/iptables-essentials-common-firewall-rules-and-commands)
## Partitions
The following command is not permanent:
> `mount /dev/sda11 /opt`
To mount partition permanently, instert the following into `/etc/fstab`:
> `UUID=03ec5dd3-45c0-4f95-a363-61ff321a09ff /opt ext4 defaults 0 2`
To set the time of current clock-program, continue with:
> `from datetime import datetime`
> `ser.write("T"+datetime.now().strftime("%y%m%d0%w%H%M%S")+"\n")`
> `ser.readline()`