rsync Fun
Only copy specific file extentions in folder
rsync -a --include '*/' --include '*.mp3' --exclude '*' source/ target/
Speed up rsync over SSH without needed to change any configs. arcfour is faster, but no longer enabled by default meanwhile aes128-ctr is
rsync -avhP -e "ssh -c aes128-ctr" /src/ [email protected]:/dst/
rsync ssh with non standard port
rsync -avhP -e "ssh -p number" /src/ [email protected]:/dst/
rsync ssh with non standard port and show full progress
SystemD Fun
Show logs from when systemd service last restarted. (This needs systemd > v232)
journalctl _SYSTEMD_INVOCATION_ID=$(systemctl show -p InvocationID --value SERVICE_NAME.service) | head -n15
NFS Mount with NFS and /etc/fstab
From all of my reading over the years it’s always been said to add _netdev to the /etc/fstab mount, but that never worked for me. After more reading it appears that was for SystemV which is dead. I figured it out after much Googleing.
Apaches Alias with ProxyPass
I was trying to get an alias to work with a ProxyPass. This is pretty easy in NGiNX you just add locations where they need to be, but it appears in Apache/HTTPD you have to specify to ignore the location without the ProxyPass Module
The below needs to be added into your VirtualHost. This specific use was for the AppRise_API server
Alias "/s" "/opt/apprise/server/apprise_api/static" <Directory "/opt/apprise/server/apprise_api/static"> AllowOverride None Require all granted </Directory> ReWriteEngine on ProxyPassMatch ^/s !
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
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.
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
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.
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
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.
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:
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.
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.
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
XCP-NG Quick Notes
I learned about XCP-NG not to log ago and love it. It’s great and easy to use. My only issue is I guess on newer versions of Windows 10/Server 2019 they were having freezing issues. I had the issue with Windows 10. I just went with Windows 7 VMs for what I needed until they get the problem worked out. XCP-NG works great with Linux. Here are some useful commands I’ve found.
NextCloud with Apache behind NGINX reverse proxy on CentOS
This is probably useful to figure out how to reverse proxy Apache behind NGINX, but I was finally able to get NextCloud working on NGINX with no problem I like to use NGINX as my web server because that’s what I’ve always worked with. I’ve tried a couple times to get NGINX to work with NextCloud, but it would also end up not letting me log in. I did some Googleing and I guess it has something to do with how the cache is handled in NGINX.
Static IP KVM Guest
Copied from Here
If you don’t want to do any configuration inside the guest, then the only option is a DHCP server that hands out static IP addresses. If you use bridge mode, that will probably be some external DHCP server. Consult its manual to find out how to serve static leases.
But at least in forward modes nat or route, you could use libvirt’s built-in dnsmasqd (More recent versions of libvirtd support the dnsmasq’s “dhcp-hostsfile” option).
How to use SSH keys
create public and private keys. You can just hit enter or change the options.
ssh-keygen -t rsa Now we need to copy our public key to the servers authorized keys
cat ~/.ssh/id_rsa.pub | ssh [email protected] "mkdir -p ~/.ssh && chmod 700 ~/.ssh && cat >> ~/.ssh/authorized_keys" Now once you’ve completed teh above you should just be able to ssh to the remote host.
If you want to be able to ssh as root.
Add Linux Mint to Active Diretory
First we are going to become root
sudo su Next we are going to join the realm. This should installed everything needed after you run the command below
realm join domain.com --user domainadmin Permit all users to log in.
realm permit --all Add user group as root
nano /etc/sudoers Paste into above file
%[email protected] ALL=(ALL:ALL) ALL Allow sssd to create user directory
nano /etc/pam.d/common-session Paste into above file
session optional pam_mkhomedir.
Install php7, nginx, mariadb centos 7
I am not a pro, this is just what I’ve learned over the years and noticed that a bunch of tutorials didn’t have all the info I needed/used so I figured I’d make my own.
rpm -Uvh https://rpms.remirepo.net/enterprise/remi-release-7.rpm yum update yum install -y nginx mariadb-server mariadb git yum --enablerepo=remi-php72 install php-fpm php-common php-opcache php-pecl-apcu php-cli php-pear php-pdo php-mysqlnd php-pgsql php-pecl-mongodb php-pecl-redis php-pecl-memcache php-pecl-memcached php-gd php-mbstring php-mcrypt php-xml php-pecl-zip php-gmp
Next we are going to want to enable everything to run on start up systemctl enable php-fpm systemctl enable nginx systemctl enable mariadb systemctl start mariadb
Make nginx return 403 error when accessing non defined sites or direct IP
I was running into an issue where when people would go to the IP of my server or a domain was pointed at my server and the domain wasn’t configured in NGINX it would for some reason redirect to one of my domains when I didn’t want it to. Below is the config block that I added to a file. This make NGINX return a 403 error when accessing the server via IP or an reconfigured domain.