cheats/linux.md

79 lines
1.9 KiB
Markdown
Raw Normal View History

2020-02-13 20:20:26 +01:00
# Linux Cheats
2020-03-23 11:14:49 +01:00
## General (tested in Debian)
### Set script as startup
2020-02-18 18:19:28 +01:00
If, for some reason, apache isn't startup:
> `sudo update-rc.d apache2 defaults`
2020-03-23 11:14:49 +01:00
### Check a package version/info
2020-03-16 14:46:04 +01:00
> `dpkg -l matrix-synapse`
2020-03-23 11:14:49 +01:00
<br>
2020-02-18 18:19:28 +01:00
2020-04-02 13:38:13 +02:00
### Installing from tar.gz
Pure binaries:
> `sudo tar --directory=/opt -xvf <file>.tar.[bz2|gz]`
> add the directory to your path: `export PATH=$PATH:/opt/[package_name]/bin`
<br>
2020-02-13 20:20:26 +01:00
## 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 {} +`
2020-03-23 11:14:49 +01:00
<br>
2020-02-13 20:20:26 +01:00
## GROUPS
Create groups
> `groupadd <groupName>`
Add user to a group
> `usermod -a -G <group> <user>`
2020-02-18 18:19:28 +01:00
2020-03-23 11:14:49 +01:00
### Open ports with iptables
2020-02-18 18:19:28 +01:00
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`
2020-03-23 11:14:49 +01:00
+ [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)
2020-02-18 18:19:28 +01:00
2020-03-23 11:14:49 +01:00
<br>
2020-02-18 18:19:28 +01:00
2020-03-23 11:14:49 +01:00
### Partitions
2020-03-10 17:06:27 +01:00
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`
2020-03-23 11:14:49 +01:00
<br>
## Arduino
Find what 'channel'(?) the Arduino is plugged in at:
`dmesg | grep tty`
Do following commands to "talk" with an Arduino (with a set script):
> python
2020-03-30 12:07:56 +02:00
> import serial
2020-03-23 11:14:49 +01:00
> ser = serial.Serial('/dev/ttyACM0',115200)
> ser.readline()
2020-03-30 12:07:56 +02:00
> ser.write("PP\n")
2020-03-23 11:14:49 +01:00
To set the time of current clock-program, continue with:
2020-03-30 12:07:56 +02:00
> `from datetime import datetime`
> `ser.write("T"+datetime.now().strftime("%y%m%d0%w%H%M%S")+"\n")`
> `ser.readline()`