Skip to content

Instantly share code, notes, and snippets.

@ayxos
Last active March 18, 2021 18:58
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ayxos/948c26c7bf52ab8fba761f4c82273869 to your computer and use it in GitHub Desktop.
Save ayxos/948c26c7bf52ab8fba761f4c82273869 to your computer and use it in GitHub Desktop.
Random Dev useful commands
: ~ $ cat .ssh / authorized_keys
command = "date" ssh-rsa AAAA [ ... ]
# https://www.virtono.com/community/tutorial-how-to/restrict-executable-ssh-commands-with-authorized-keys/

So how do we use chmod to modify these permissions? We’ll use a command like:

$ chmod 771 my_app

OR

$ chmod g+w my_app

In the context above, these two commands in fact mean the same thing. To see why, we have to understand that chmod has a peculiarity. It accepts instructions to change file permissions for different users either by using combinations of these letters (text or symbolic format), or by using a system of numbers (numeric or octal format). Here’s how the two systems correspond:

Permission to read, r, is given the numeric value of 4 Permission to write, w, is given the value 2 Permission to execute, x, is given the value 1

contrab -e
0 7 * * * /path/to/script
# Put a shell script in one of these folders: /etc/cron.daily, /etc/cron.hourly, /etc/cron.monthly or /etc/cron.weekly.
# If these are not enough for you, you can add more specific tasks e.g. twice a month or every 5 minutes. Go to the terminal and type:
crontab -e
# This will open your personal crontab (cron configuration file). The first line in that file explains it all! In every line you can define one command to run and its schedule, and the format is quite simple when you get the hang of it. The structure is:
# minute hour day-of-month month day-of-week command
# For all the numbers you can use lists, e.g. 5,34,55 in the minutes field will mean run at 5 past, 34 past, and 55 past whatever hour is defined.
# You can also use intervals. They are defined like this: */20. This example means every 20th, so in the minutes column it is equivalent to 0,20,40.
# So to run a command every Monday at 5:30 in the afternoon:
30 17 * * 1 /path/to/command
# or every 15 minutes
*/15 * * * * /path/to/command
# Note that the day-of-week goes from 0-6 where 0 is Sunday.
### Copy folder to host form container
- sudo docker cp CONTAINER_ID:/var/www/bookstack/storage/uploads .
## Backup Mysql
- docker exec CONTAINER_ID /usr/bin/mysqldump -u bookstack --password=secret bookstack > backup.sql
## Run MYSQL docker container
- docker run -d --net bookstack_nw -e MYSQL_ROOT_PASSWORD=secret -e MYSQL_DATABASE=bookstack -e MYSQL_USER=bookstack -e MYSQL_PASSWORD=secret --name="bookstack_db" mysql:5.7.21
## access docker container as root
- docker exec -u root -it [CONTAINER_ID] bash
### Grant www-data priviliges to folder
- sudo chown www-data:ww-data -R uploads/
### restart nginx if port changes
- sudo ln -s /etc/nginx/sites-available/wiki /etc/nginx/sites-enabled/\n
- sudo nginx -t
- sudo systemctl restart nginx
sabnzbd:
build: ./sabnzbd
command: /syzygy/run.sh
privileged: true
you can try just add
network_mode: "host"
example :
version: '2'
services:
feedx:
build: web
ports:
- "127.0.0.1:8000:8000"
network_mode: "host"
list option available
network_mode: "bridge"
network_mode: "host"
network_mode: "none"
network_mode: "service:[service name]"
network_mode: "container:[container name/id]"
server {
listen 80; #says to listen on standard port
server_name _; #the default server
location / { #location is the root of the site
root /test/a/; #root is located at /test/a/
index test; #index is for autocomplete
autoindex on; #this way files will be autoindexed
}
}
#!/bin/sh
ssh user@src.com -t bash -ci "logs" >> report.log
# Remove duplicated lines
sort report.log | uniq > report_temp.log
# replace new items
mv -f report_temp.log report.log
# generating reports
cat report.log | docker run --rm -i -e LANG=$LANG allinurl/goaccess -a -o html --log-format COMBINED - > reports/report.html
# Change owner user:group
chown tito:editors file.txt
chgrp webdev file.txt
chown -R webdev file.txt
# For example, to add the user geek to the group sudo , use the following command:
usermod -a -G sudo geek
# To change the primary group a user is assigned to, run the usermod command, replacingexamplegroup with the name of the group you want to be the primary and exampleusernamewith the name of the user account.
usermod -g groupname username
# If you just want to list all the usernames without any additional information, you can use the compgen command with -u option.
compgen -u
# For example, to find out the members of a group with the name developers you would use the following command:
getent group developers
# https://www.howtogeek.com/50787/add-a-user-to-a-group-or-second-group-on-linux/
You can execute any shell command using the shelljs module
const shell = require('shelljs')
shell.exec('./path_to_your_file')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment