Cli

Enabling Hibernation on Linux Laptops

Enabling Hibernation on Linux Laptops

use a gimped picture of flapjack with my wretchedghost logo as flapjack and several other thinks like laptop brands as the whale and the other dude

After purchasing yet another second-hand laptop i have run several hurdles to get them Linux worthy and even that seemed to hard for some.

Why I do this to myself

Even when I have a setup that I enjoy my mind always wanders to what if there is something better. I would like my current laptop to be this or that, or I want a laptop to run for days without charging but also be super light and well, the list goes on.

Enabling Hibernation on Linux Laptops

Enabling Hibernation on Linux Laptops

Due to issues with the latest sleep states in laptops I’ve had to resort using hibernation or S4 as the strata for all my Linux laptops:

  1. Lenovo X1 Carbon Gen 8 (intel 10th gen CPU)
  2. HP Gram 17z90n (intel )
  3. Dell XPS 9315 13 i5

My older laptops like the System 76 Darter Pro before they moved to CoreBoot systems and Dell XPS 9380 still functions quite well in S3 state, not requiring hibernation.

Command Line Navigation Tips and Obscure Shortcuts

Command Line Navigation Tips and Obscure Shortcuts

If you’re spending any amount of time in the terminal, learning shortcuts can potentially save you hours in the future. Most people know the arrow keys and backspace, but bash has decades of shortcuts built in that almost nobody uses.

I’ve been using Linux since 2011, and I’m still discovering new ones. Here are the ones I actually use daily, plus some obscure gems.

I Love Ranger

I Love Ranger

My ranger config can be found here

ranger program linux

Here is a quick write up of a program that I have heard of before and installed but never found it necessary in my work flow. I have and still am happy to move around in the command line like I have been for the past ten years plus but now after finding a good reason to try it out this time since I have been moving around a lot more in the command line from writing blogs to notes to novels, and everything in between, I felt like my work flow wasn’t as optimized nor as speedy as it could be.

Vim Plugins Setup

Vim Plugins Setup

Why Use Vim Plugins?

In the Vim Basics series, we covered vanilla vim and how powerful it is right out of the box. And honestly, vanilla vim can handle 90% of your daily work as a sysadmin. But sometimes you want that extra 10% - better syntax highlighting, file navigation, or quality of life improvements that make your workflow even smoother.

The key is not to go overboard. I’ve seen people install 30+ plugins and end up with a slow, bloated vim that defeats the purpose of using a lightweight editor in the first place. As a system admin who jumps between servers constantly, I keep my plugin setup minimal and portable.

Vim Basics: Part 3

Vim Basics: Part 3

Building on the Basics

Now that we know how to open a file, edit it, move around in it, and save it, let us now look into how we can tweak it. My post to part 1 of vim basics can be found here: https://blog.lanlocked.xyz/post/vim-basics-part-1/. Part 2 can be found here: https://blog.lanlocked.xyz/post/vim-basics-part-2.

In this part, we’ll cover visual mode, text objects (which will change how you think about editing), and then dive into customizing vim with your .vimrc configuration file.

Vim Basics: Part 2

Vim Basics: Part 2

Welcome Back

In Part 1, we covered the basics of opening vim, understanding normal and insert modes, and moving around with the hjkl keys. If you haven’t read that yet, I’d recommend starting there as we’ll build on those concepts.

Now it’s time to tackle what might be the most infamous aspect of vim: how to actually save and exit the program. We’ll also dive into some useful editing commands that will start to show you why vim users are so passionate about this editor.

Vim Basics: Part 1

Vim Basics: Part 1

Getting to know vim

If you are looking for a way to get more efficient at editing configs and text then vim is what you are wanting. Even at its most basic interface with no added plugins, vim can help you manipulate a file with its efficient modes and commands.

vim is not the easiest to learn, especially for beginners where often newbies trying it out for the first time find they are not even able to exit the program. But, after some little quirks have been understood, you may soon ask yourself how you lived without it.

The Reasons I Keep Going Back to MikroTik

The Reasons I Keep Going Back to MikroTik

I have been using MikroTik (my-crow-tick or me-crow-teek), or however you want to pronounce it, for several years now and I just keep coming back to using it. MikroTik, for the uninitiated, can be quite a difficult system to learn and use. There are quite a bit of gotchas that can bite you along the way and even now, some things can still trip me up if I’m not paying attention to what I’m doing. Read below under Final Thoughts for the great benefits that I have found from using MikroTik and for those TLDR enthusiasts.

How to Upgrade Gitea

How to Upgrade Gitea

Updating gitea is a simple as replacing the binary in /usr/local/bin/gitea.

  1. Stop the gitea service

$ sudo systemctl stop gitea

  1. Move the current binary from gitea to gitea.old just in case things break.

$ sudo mv /usr/local/bin/gitea /usr/local/bin/gitea.old

  1. Use wget to get the the current version: example -> https://github.com/go-gitea/gitea/releases/download/v1.20.2/gitea-1.20.2-linux-amd64. This is not the latest version, this is just an example.

cd ~/Downloads && wget https://github.com/go-gitea/gitea/releases/download/v1.20.2/gitea-1.20.2-linux-amd64

  1. Change the name of the file from gitean-x.x.x-linux-amd to gitea

$ mv gitea-x.x.x-linux-amd gitea

My MikroTik Firewall Rules

My MikroTik Firewall Rules

I wanted to show a little firewall rule that I setup that will allow an entity to attempt to login via SSH or Winbox and have them locked out for 21 days after so many attempts. You can tweak this to allow for more attempts and or have them locked out indefinably. This might be considered a tar pit for those that know that term except this is a manual tar pit that acts a little differently than the one MikroTik has built-in.

How to Sync AntennaPod with Nextcloud | Part 1

How to Sync AntennaPod with Nextcloud | Part 1

After much research and trial and error I have found the gpodder implementation to be very terrible. The only known way to get synchronization across devices is to setup a Nextcloud server and install the plugin/addin gpodder. The other ways that I have tested but could not get any to work due to broken links and or not enough information are with micro-gpodder-server and gpodder2go. Both failed miserably.

The official link/website and how-to from gpodder.net called mygpodder has a broken link and requires various weird ways to get it to work using sqlite3, cargo, npm, etc. The cargo program is run in .exe making me think they have this running on windows and not on Linux.

Using Perl-Rename For File Substitution

Using Perl-Rename For File Substitution

I tried to use sed to rename filenames but found it rather cumbersome. sed is great when used to edit the content of a file which you can find some examples I created here, but I found this handy program that can do the same but for filenames instead.

Installed on my Arch, BTW, system I already had the program called rename which is not the same as the one we need called perl-rename. To install it I just ran it using pacman -S perl-rename. From here I was then able to rename a whole ton of files that I had scraped from the internet, cough cough youtube, quite easily.

Web Scraping for Preservation's Sake

Web Scraping for Preservation's Sake

Due to the higher complexities of running a modern website or blog securely or rather, for making it easier for people via CloudFlare and the like, I have found that when one of those main sites are down, again like CloudFlare, sites that rely on their DNS redirecting and whatnot, go down too. Many blogs that I follow are starting to jump on that band-wagon which is annoying since it can be quite a bit of time for a site to return to working order whether it was on CloudFlare’s side or the blog owner. Regardless of this I have looked into ways to have backup copies of their sites while this is still an option.

Vim Substitution

Vim Substitution

vim logo

vim substitution is one tool any advanced vim user should know. Basically, vim substitution is similar to search and replace used on other file editors but vim goes much further than just searching and replacing files and characters. For anyone who creates bash scripts and edits a ton of config files like myself, will attest to the need to comment and uncomment many lines at a time.

I’ll start with the basic uses of substitution and go into the more meaty commands as we go along.

Auto Screen Lock With Suspend and Resume in i3 With Systemd

Auto Screen Lock With Suspend and Resume in i3 With Systemd

After using i3-wm, formally known as i3-gaps, for several years on my personal workstation I have not really needed to use the i3lock features that often due to my workstation being in my office where no one else touches it. right They wouldn’t know how to use it in they did try and mess with my workstation. But now that I am using my same i3 config across more systems including my work computer where I now use it manage and maintain the network and servers of my work, I began looking for ways to make my computer more secure. 

The Watch Command

The Watch Command

The watch command is used when you want to have a program run every so many seconds that you define. I often use it to see the stream of files that are being transferred or for checking the status of scripts while I test them.

Running The Watch Command

Here is a common way that I use watch after I have run rsync just to make sure things are going the way they should:

i3-wm Advanced Lessons

i3-wm Advanced Lessons

After using i3-wm (which I will call i3 from here on out) for over 5 years now, I have pretty much got it almost exactly how I like it. For reference here is my latest i3 config which can be found at https://git.wretchednet.com/wretchedghost/i3-wretchedbox This config might change here and there so check often as some things might have been updated since this post.

Today’s lesson will revolve around some advanced tweaks to add to your config for a more finely tuned system on i3.

Mounting Mulitple Drives at Boot Time using LUKS (dm-crypt)

Mounting Mulitple Drives at Boot Time using LUKS (dm-crypt)

Mounting more than just the root partition at boot using LUKS/dm-crypt is a little more complicating than setting up just the one. Rather than just placing your UUID of the root partition in the /etc/default/grub file you have to go through several more steps. Follow along as I describe a simple way to get more than one partitions/disks mounted at boot time.

When you might not want mount-encrypted drives at boot.

A descriptive caption

Having encryption at rest built into a partition/disk is a great way to keep those who have physically compromised said disk out from reading your data easily.

Gitea Setup and Install on Ubuntu 20.04 and Others

Gitea Setup and Install on Ubuntu 20.04 and Others

A descriptive caption

After an exhaustive exercise of finger tapping on my keyboard and several attempts to clear my head by walking away from the computer, I have finally setup a Gitea instance. Following the how-tos online seemed simple enough. Follow the steps, install a user, setup permissions, download a file and bam you are good to go. But that is the furthest from the truth for my experience. I have followed what seemed to be ten different how-tos that somehow seem to differ even between the same distro install. Each of which if you were setting up a server on your local machine would work but in my case of setting it up on my Linode instance where you have no access to the GUI and or a web interface that is able to look at the localhost or 127.0.0.1 it was just was nigh impossible. The logs showed I was reaching the server every time but still nothing showed up. But I digress.

bmon CLI Network Traffic Viewer

bmon CLI Network Traffic Viewer

A descriptive caption

In my ever continuing effort to use the command-line more, one tool that allows any command-line-junky to view their network traffic in real time is called bmon. It can be installed via any package manager: ie, apt, pacman, portage, etc.

Test HDD, SSD, and USB Read/Write Speeds with dd

Test HDD, SSD, and USB Read/Write Speeds with dd

I have found a fancy way to test the speeds of my media devices by using the dd tool. For those that don’t know what the dd command stands for or does, Disk/data Duplicator is a tool that was used in the old BSD/AT&T days but still has great functionality today.

Mostly dd is used for writing a .iso to a USB to be used to boot into a Linux distro or what have you. It can also be used to copy a block file or an entire disk to another disk or partition, which is kinda what we are going to be doing in this speed test example today.

Custom Git Commit Push Alias

Custom Git Commit Push Alias

I normally don’t create nor use tons of aliases in my .bashrc file. I have a few that tweak how grep and ls show color in the prompt and others where I can change directory by typing .. or … which perform cd ../ and cd ../../ respectively, but because of my roaming nature, where I bounce around from one computer/server to another where it may or may not have a configured .bashrc nor .vimrc, I have always tried to keep my dot-config-files mostly vanilla. My bashrc can be found here: github.com/wretchedghost/bashconfig I am also of the mind that aliases can make you dumb since you will be relying on the alias you created and not on what the alias might be doing in the background, but I digress.

Backing Up to Google Drive Using Rclone

Backing Up to Google Drive Using Rclone

After I recently setup rsnapshot as my backup solution, which can be found here https://blog.wretchednet.com/post/rsnapshot/ I started looking at options on how to remotely backup my workstation. I used Backblaze for a while but I wasn’t too happy with their interface. I looked at getting another cloud backup solutions but each one would either cost quite a bit more per month and or had similar or worse user interfaces.

I decided to go with Google Drive since I’ve had it for years, its free for up to 15 GB, and the interface is simple to index and use. Most of my initial backups would only be a few gigs, but whenever it came time to get the higher tier from Google Drive, I can get 100 GB for not too crazy of a price.

Git Init Pull

Git Init Pull

Creating a new git repo is a little more involved than one that is already setup but here are the simple steps to get one rolling. I prefer to use SSH over HTTPS due to security and ease of use from the command line.

Setup

We need to first do a few things to make a commit as easy as possible.

  1. Create a ssh key if you haven’t already. This will be placed in ~/.ssh unless you tell it otherwise with the -f flag.

Save a File as Sudo Without Exiting Vim

Save a File as Sudo Without Exiting Vim

I have often opened a file which I did not first run as sudo in vim, edited the file, then to only find out that it is in read-only mode. I would then have to close the file then re-open it as superuser then make the changes needed. I found this to be very frustrating and found out there are several ways to get the file edited by inserting commands in command-mode using vim.