sed With the last g all text is replaced not just the first
Replace text inline using sed (does not work with symlinks)
sed -i 's/TO_BE_REPLACED/NEW_TEXT/g' FILE_HERE
Replace text output to stdout
sed 's/TO_BE_REPLACED/NEW_TEXT/g' FILE_HERE
awk Show specific column of line
awk '{ print $N }' where N is column number
cut cut -d' ' -fN where d is the delimiter and N is the colum number
perl Replace new line with space
I’m honesly not sure if these are vi or vim specific as I use a mac and Debian machine, but here’s some fun stuff I’ve learned over the years. I started as a nano person, but am finaly sitting down and using vi/m more and more.
In command mode (make sure to hit esc) Go to start of file gg
Go to end of file G
Delete from line to start of file dgg
To use max XZ compression and all cores add export XZ_OPT='-T0 -9' to the end of your ~/.bashrc file.
To use all cores add export XZ_OPT='-T0' to the end of your ~/.bashrc file.
To use max XZ compression add export XZ_OPT='-9' to the end of your ~/.bashrc file.
Then exit terminal and go back or source ~/.bashrc
Here’s some fun stuff to learn about the urbackup appliance
By default there is no firewall, but it’s locked down so one’s not needed, but I installed one anyway
You should be able to sudo su - from the admin user, if not; shut the appliance down, then in grub hit e, then add init=/bin/bash at the end of the line that says quiet, then CTRL+X to boot, then echo 'admin ALL=(ALL) NOPASSWD: ALL' > /etc/sudoers.
This is just basic hints, not a full guide This assumes you have some basic linux knowledge Download identity and storagenode from github (I like to download these things to /opt/storj/)
Create auth token HERE
Create identity HERE (This took about 4 hours on my node | E3-1280 V2)
storagenode setup. This will create config file and other needed files in ~/.local/share/storj/storagenode/config.yaml and ~/.local/share/storj/storagenode/storage
Now you need to edit ~/.local/share/storj/storagenode/config.yaml and make changes as needed (wallet, identity files and data storage locations, email, storage size)
On most Linux distros it is possible to generate the htpasswd file entries simply using the htpasswd command line util.
On FreeBSD the easiest way to accomplish the same task is using OpenSSL itself
openssl passwd -apr1 >> /path/to/htpasswd.file
Enter the password twice and the hash will be printed into the file
Then open the file and add the username followed with a : before the hash
It will look like username:password_hash
The files might change, but pretty much just add /S as a switch to the software to do it quietly
UrBackup Client *.exe /S
$programfiles\UrBackup\Uninstall.exe /S
This is still a WIP. Prepare image Download Appliance
Unzip unzip urbackup-app-10-0.img.zip
Now upload unzipped image somewhere public. Backblaze/S3 would be a great use for this
Write image to disk in ServerCheap.net Create new instance
Shutdown new instance
Enable Rescue Mode
SSH into rescued device using creds given
Install required software apt update; apt install curl
Download image and burn to disk curl https://URL-TO-FILE/urbackup-system-disk.img | dd of=/dev/vda
You should now be able to disable rescue mode and boot it up
By default the policyd is using IPv6. This needs to be forced to use IPv4 since the VPS I’m using doesn’t seem to have IPv6 enabled
nano /etc/supervisor/conf.d/policyd.conf
Replace command=/srv/modoboa/env/bin/python /srv/modoboa/instance/manage.py policy_daemon with command=/srv/modoboa/env/bin/python /srv/modoboa/instance/manage.py policy_daemon --host 127.0.0.1
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.
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.
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
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.
Make sure Backblaze is working with Cloudflare. This can be found HERE
Uncomment out the below. I made my Backblaze URL s3.DOMAIN.COM
nano /etc/pleroma/config.exs
# Configure S3 support if desired. # The public S3 endpoint (base_url) is different depending on region and provider, # consult your S3 provider's documentation for details on what to use. # config :pleroma, Pleroma.Upload, uploader: Pleroma.Uploaders.S3, base_url: "https://s3.DOMAIN.COM/file" # config :pleroma, Pleroma.Uploaders.S3, bucket: "BUCKET_NAME", # bucket_namespace: "my-namespace", # truncated_namespace: nil, streaming_enabled: true, strip_exif: true # # Configure S3 credentials: config :ex_aws, :s3, access_key_id: "0000000000000000000000000", secret_access_key: "AAAAAAAAAAAAAAAAAAAAA", # region: "us-west-002", scheme: "https://" # # For using third-party S3 clones like wasabi, also do: config :ex_aws, :s3, host: "s3.
You have to have at least two keys. Enter car as normal (DUH!! :-b)
Find back up key slot, ours is under the cup holder insert, it has a little indent that looks like our key
Put key in slot
Put in accessory mode by pushing start without foot on brake
Wait 3-5 seconds
Shutoff car
Remove key
Put 2nd key in place
Put in accessory mode by pushing start without foot on brake once again
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.
Today I was finally able to figure out how to stdin from a file for systemctl edit :-)
env SYSTEMD_EDITOR=tee sudo -E systemctl edit --system [your_unit_name] < [your_content_file] I found it HERE.
Here’s how to install Duplicati as a Windows Service
Download Duplicati from HERE
During install don’t mark Auto Start up option
Open CMD as admin
Navigate to the installation folder in CMD (this should be the same as long as you left it as default) cd "C:\Program Files\Duplicati 2\"
Now we will install the service .\Duplicati.WindowsService.exe install
Now restart your computer (this isn’t needed, but it’s a good way to test)
Go to https://www.microsoft.com/en-us/software-download/windows10ISO and use the dev tools F12 on browsers to change device to mobile. Then you should be able to choose the version/lang/type and then you’ll get a direct link from Microsoft.
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
So I finally switched to iPhone and ordered an Apple Credit Card (I love this thing). The cash back is put on you Apple Cash account, if your account can’t be verified than you don’t get the cash back. So I started the process of verifying my account. I put in my First Name, Last Name, Middle Name, and full address. Well they need you to use the address that’s on you’re license, makes sense, but I just moved so I used the incorrect one.
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
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.