Posts for: #Linux

How to create keystrokes on Debian

This is very useful when working with VPSes where you can’t paste into the VNC connection (maybe I’m doing something wrong and you can?). Below is a quick piece of code I use. This should be ran as the user and not root. This sleeps for 5 seconds so you can navigate to where you need. sleep 5s; xdotool type CODE_TO_TYPE_HERE This is very easy and simple, but since I just switched to Debian full time from Windows it was a nice/easy way.
MORE →

Fix battery drain while sleeping with laptop

I recnetly decided to switch to Debian full time for my personal laptop (Lenovo Thinkpad X1 Yoga Gen 3), after using it for a week or so I noticed that when I closed the lid it would die after less than a day. After some googleing I found the answer and they are below. I also noticed that the machine never seemed to wake up like it did on Windows (just open it and it should come alive), after switching over to deep_sleep it fixed that issue.
MORE →

dd Tricks

Here’s a couple tips and tricks while using dd on Linux You can view the status of an on-going dd command (I always forget to run with progress or the version you’re using doesn’t have it) You will need another terminal window. Not a problem for me as I always use tmux, some people say screen it better. Find PID of dd process -> ps aux | grep -v grep | grep dd
MORE →

Sudo Fun

I always add a file into /etc/sudoers.d/, just remeber the last entry is trump, so it can overturn the first entries. Because of this I always like to name the files like below. /etc/sudoers.d/999_nick /etc/sudoers.d/001_rick /etc/sudoers.d/111_slick-rick /etc/sudoers.d/222_slick-nick This means if there’s an entry in 999_nick that conficts with any of the others it will trump the other configs. This is how to run without password and only specific program, this is useful, for example my telegraf config when it has to run an exec, but the telegraf user doesn’t have perms.
MORE →

Keycloak behind NGiNX

Configure NGiNX nano /etc/nginx/conf.d/sso.domain.com.conf server { listen 443 ssl http2; server_name sso.domain.com; ssl_certificate /etc/nginx/ssl/sso.domain.com/fullchain.crt; ssl_certificate_key /etc/nginx/ssl/sso.domain.com/key; ssl_session_timeout 5m; location / { proxy_pass http://127.0.0.1:8080/; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Host $host; proxy_set_header X-Forwarded-Server $host; proxy_set_header X-Forwarded-Port $server_port; proxy_set_header X-Forwarded-Proto $scheme; } } Configure Keycloak The following is needs to be ran for Keycloak to work behind nginx cd bin ./jboss-cli.sh 'embed-server,/subsystem=undertow/server=default-server/http-listener=default:write-attribute(name=proxy-address-forwarding,value=true)' ./jboss-cli.sh 'embed-server,/socket-binding-group=standard-sockets/socket-binding=proxy-https:add(port=443)' 4 ./jboss-cli.sh 'embed-server,/subsystem=undertow/server=default-server/http-listener=default:write-attribute(name=redirect-socket,value=proxy-https)'
MORE →

Two separate sonarr instances via systemd

Here is how to have two different Sonarr instances (for example 4k and standard deff). Change the location after --data= to wherever you want the data to be. Since lidarr/radarr are both based on sonarr I would assume you could do it the same way with those as well. nano /etc/systemd/system/sonarr.service [Unit] Description=Sonarr Daemon After=network.target [Service] User=plex Group=plex StandardOutput=null Type=simple ExecStart=/usr/bin/mono /opt/Sonarr/Sonarr.exe -nobrowser --data=/opt/DB/Sonarr TimeoutStopSec=20 KillMode=process Restart=on-failure [Install] WantedBy=multi-user.target nano /etc/systemd/system/sonarr4k.
MORE →

Full system backup with restic and minio

Minio Install mkdir /opt/minio cd /opt/minio wget https://dl.min.io/server/minio/release/darwin-amd64/minio wget https://dl.min.io/client/mc/release/linux-amd64/mc chmod +x mc minio echo 'PATH="${PATH}:/opt/minio"' >> /root/.bashrc useradd minio mkdir -p /data/minio chown minio: -R /opt/minio /data/minio Configure Systemd service nano /etc/systemd/system/minio.service Paste the following in the above file # https://github.com/minio/minio-service/tree/master/linux-systemd [Unit] Description=MinIO Documentation=https://docs.min.io Wants=network-online.target After=network-online.target AssertFileIsExecutable=/opt/minio/minio [Service] WorkingDirectory=/opt/minio User=minio Group=minio EnvironmentFile=/etc/default/minio ExecStartPre=/bin/bash -c "if [ -z \"${MINIO_VOLUMES}\" ]; then echo \"Variable MINIO_VOLUMES not set in /etc/default/minio\"; exit 1; fi" ExecStart=/opt/minio/minio server $MINIO_OPTS $MINIO_VOLUMES # Let systemd restart this service always Restart=always # Specifies the maximum file descriptor number that can be opened by this process LimitNOFILE=65536 # Specifies the maximum number of threads this process can create TasksMax=infinity # Disable timeout logic and wait until process is stopped TimeoutStopSec=infinity SendSIGKILL=no [Install] WantedBy=multi-user.
MORE →

Channels DVR with Pluto and Philo installed on Debian 10

Below I will be writing how to install and configure Channels DVR with Pluto using Pluto4Channels and Philo using TV Everywhere on Debian 10 First install ChannelsDVR, I will be doing this on Linux. This does work on RaspberryPi which is awesome useradd channels-dvr cd /opt This will install the ChannelsDVR in the current folder and install the systemd service curl -f -s https://getchannels.com/dvr/setup.sh | sh chown channels-dvr: -R /opt/channels-dvr
MORE →

Compile vaultwarden from souce with mysql support

I did a massive bitwarden_rs to vaultwarden rename so you might have to do a little different then what this says!! Here is how to install vaultwarden on Debian 10 with MYSQL support Below I will be writing how to install and configure vaultwarden to work with MYSQL without the need for Docker. Install required softwre Not everything below is required, but I like to install it anyway apt install -y tmux tmux apt install -y build-essential git pkg-config libssl-dev libmariadb-dev-compat libmariadb-dev htop curl wget Install Rust curl --proto '=https' --tlsv1.
MORE →

Basic InfluxDB CheatSheet

Here is a basic cheatsheet for InfluxDB I’ve learned from playing with the TIG stack How to find the hosts in the series. You run the below command and just go through the list to find the host you want to delete. You can delete with what you know the host is, but his is nice because it will insure there wasn’t a typo WHERE "host" = 'DESKTOP-NAME' Here is how you actually drop the data from the DB that way it’s not displayed in Grafana anymore
MORE →

DroneCI behind NGiNX reverse proxy

This so far has been working for me to have DroneCI behind an NGiNX reverse proxy working with Gitea NGiNX Code nano /etc/nginx/sites-available/droneci.domain.com ln -s /etc/nginx/sites-available/droneci.domain.com /etc/nginx/sites-enabled upstream droneci { server 127.0.0.1:8080; } server { server_name droneci.domain.com drone.domain.com; listen 443 ssl http2; ssl_certificate /etc/certs/droneci.domain.com/fullchain.crt; ssl_certificate_key /etc/certs/droneci.domain.com/key; ssl_session_cache builtin:1000 shared:SSL:10m; ssl_protocols TLSv1.2 TLSv1.3; location / { proxy_set_header X-Forwarded-For $remote_addr; proxy_set_header X-Forwarded-Proto $scheme; proxy_set_header Host droneci.domain.com; proxy_pass http://droneci; proxy_redirect off; proxy_http_version 1.1; proxy_buffering off; chunked_transfer_encoding off; } } Here is the code for the docker container docker run \ --volume=/var/lib/drone:/data \ --env=DRONE_GITEA_SERVER="https://git.
MORE →

Autostart Tdarr via systemd

The folowing are the systemd units locations and content nano /etc/systemd/system/tdarr-node.service [Unit] Description=Tdarr Node Daemon After=network.target [Service] User=plex Group=plex #StandardOutput=null Type=simple WorkingDirectory=/opt/tDarr/Tdarr_Node ExecStart=/opt/tDarr/Tdarr_Node/Tdarr_Node TimeoutStopSec=20 KillMode=process Restart=on-failure [Install] WantedBy=multi-user.target nano /etc/systemd/system/tdarr-server.service [Unit] Description=Tdarr Server Daemon After=network.target [Service] User=plex Group=plex #StandardOutput=null Type=simple WorkingDirectory=/opt/tDarr/Tdarr_Server ExecStart=/opt/tDarr/Tdarr_Server/Tdarr_Server TimeoutStopSec=20 KillMode=process Restart=on-failure [Install] WantedBy=multi-user.target nano /etc/systemd/system/tdarr-node.service [Unit] Description=Tdarr Node Daemon After=network.target [Service] User=plex Group=plex #StandardOutput=null Type=simple WorkingDirectory=/opt/tDarr/Tdarr_Node ExecStart=/opt/tDarr/Tdarr_Node/Tdarr_Node TimeoutStopSec=20 KillMode=process Restart=on-failure [Install] WantedBy=multi-user.target Now to enable everything you can type the following.
MORE →

Monitoring Domain Expiry

After using LibreNMS for years and it was giving me issues, I decided to give check_mk RAW a try. It works great. I was able to find a way to have check_mk check for Domain Expiry. The original post is HERE, but the formatting wasn’t working so I reposted it. nano /scripts/check-domain-expiry After you have edited this file make sure to add it to a daily crontab. We don’t check the every check cycle since you’d probably get blocked due to high requests.
MORE →

Default user for WSL OS on Windows 10

1. Open a command prompt or PowerShell. (You shouldn’t run as admin since this is based for the specific user). 2. Copy and paste the command below into the command prompt or PowerShell for the .exe file of the WSL distro name (ex: “Debian”) you want to set the default user for, and press Enter. (You can replace root with any user you’d like) [Ubuntu] > ubuntu config --default-user root
MORE →

Send email using postfix

There’s many times when I want to send an email for testing using postfix and I can never remember how to do it. Here is how.This is super useful to make sure your SMTP relay thru AWS/Postmark is working as it should. Then you can tail /var/log/mail.log to see if it worked or if it got rejected for whatever reason. First type the following to start sendmail sendmail [email protected] Now we can type in or paste the following
MORE →

Limit email/hour for just one domain on an account (addon, park, or sub domain).

Sometimes you have an email account and you want to edit the email/hour for only one of the domain on the account, here is how to do that. SSH to the server ssh domainHere.com Edit the file /var/cpanel/users/userAccount file Add or Edit a line like this MAX_EMAIL_PER_HOUR-domainHere.com=100 Replace domainHere.com with the domain name in question, and 100 with the number of emails per hour you wish to allow. Save the file and run /usr/local/cpanel/scripts/updateuserdomains
MORE →

Create cPanel WHM session from CLI

Sometimes you don’t know or want to change the root password to be able to log into WHM as root (yes I know you shouldn’t log in as root, but sometimes you do). Here’s the command to do that via CLI whmapi1 create_user_session user=root service=whostmgrd locale=en This will return something like to following data: cp_security_token: /cpsess9427258339 expires: '1596644759' locale: en service: whostmgrd session: root:J7omtbeEeUhJ9yPK:create_user_session,yAs86MVYrHT46avjRLAGxhHaEFrFV3Hf url: https://server.domain.com:2087/cpsess9427258339/login/?locale=en&session;=root%2UtnqjEJVUBNo2JnKH%3acreate_user_session%55nNCwxRW4tzqEe6NUYKwWrDM7N485TiYA metadata: command: create_user_session reason: Created session result: 1 version: 1 You will use the URL and it will take you right into WHM
MORE →

Multi-Domain SSL Setup with “Subject Alternative Names”

Here’s how to create a cert/csr with more than one domain name. First you’ll want to create the directory. I use NGiNX so I like to put my certs in /etc/nginx/ssl, but you can put yours anywhere So now we will create the directory mkdir /etc/nginx/ssl/domainName Now we will cd into the directory cd /etc/nginx/ssl/domainName Now we will paste the following in the sslConfig.txt file. [req] default_bits = 4096 prompt = no default_md = sha256 req_extensions = req_ext distinguished_name = dn [ dn ] C=US ST=YOURstateHERE L=YOURcityHERE O=YOURorgNAMEhere CN = YOURmainDOMAINhere [ req_ext ] subjectAltName = @alt_names [ alt_names ] DNS.
MORE →

Equalize Pricing Tables Height with Divi

How to make the pricing table height the same. When using the pricing tables module you will see that the height of each table is going to rely on the content you put there, so if you have different content in each table, you will see something like this: This might be okay, but you may want to have those tables show with the same height. You can use the following CSS code:
MORE →

Change username for cPanel user

Unfortunately it doesn’t appear cPanel allows you to easily change the username. Most documentation I’ve read says to use the “Rearrange an Account” option, but if you only have one disk that doesn’t seem to get you an option. The downside to this is that is doesn’t fully do a normal restore it will restore the new account to the new directory, but it will symlink the old username to the new directory.
MORE →

Acme.sh with NGiNX

First you have to install acme.sh. I like using acme.sh because it’s all bash based. As with all posts I take no responsibility for anything and this is more of a quick help instead of a full guide. I have a script that I use to deploy my WordPress sites. The only thing I recommend is if you use it make sure to add the xml-rpc.php block. I haven’t added that to it yet.
MORE →

Auto Expand last partition using parted

I was having issues finding the correct way to add the remaining free space to the last partition (afraid to do so since it was on a live machine). I was finally able to figure it out. Use this to see free space parted /dev/sdX print free Then this to expand parted /dev/sdX (parted) resizepart Partition number? ENTER NUMBER FROM ABOVE THAT HAS THE LVM End? [1075MB]? 100% (parted) q Then now since this was on a server that uses LVM you have to resize the PV
MORE →

Comments: