Calibre Server Installation on a Raspberry Pi
These instructions are for installing the Calibre book management software on a Raspberry Pi 4 running Ubuntu 20.04 but should work with Raspian or other Debian-derived operating systems. This is just a briefer version of the same instructions that are posted here.
Install the calibre-bin package and its dependencies:
$ sudo apt update && sudo apt install -y $ sudo apt install calibre-bin
Gitea Server Installation on a Raspberry Pi
Create a ‘git’ user:
$ sudo adduser git
Login as the ‘git’ user and download the gitea binary from the gitea website (choose the latest version):
wget -O gitea https://dl.gitea.io/gitea/1.14.5/gitea-1.14.5-linux-amd64 chmod +x gitea
Create a service. We’re keeping it simple here so we don’t need a lot of the database-specific stuff:
Bash Environment Variables
Here are some bash environment variables that are useful to know when you’re using the command prompt:
$0 - name of shell or shell script $1, $2, $3, … - positional parameters to script $# - count of positional parameters $? - exit status of most recent foreground task $- - current options that are set for the shell $$ - PID of the current shell (not subshell) $! - the PID of the most recent background command $DESKTOP_SESSION - path to the current display manager $EDITOR - preferred text editor $LANG - current language $PATH - directory list to search for executables (programs) $PWD - current working directory $SHELL - current shell $USER - current username $HOME - current user’s home directory $HOSTNAME - current name of the host $TERM - current terminal
Bash CLI Keyboard Shortcuts
Here are some quick keyboard shortcuts you can use at the command prompt:
ctrl-l – clear screen ctrl-r – does a search in the previously given commands so that you don’t have to repeat long command. ctrl-u – clears the typing before the hotkey. ctrl-a – takes you to the begining of the command you are currently typing. ctrl-e – takes you to the end of the command you are currently typing in. esc-b – takes you back by one word while typing a command. ctrl-c – kills the current command or process. ctrl-d – kills the shell. ctrl-h – deletes one letter at a time from the command you are typing in. ctrl-z – puts the currently running process in background, the process can be brought back to run state by using fg command. esc-p – like ctrl-r lets you search through the previously given commands. esc-. – gives the last command you typed.
How To Find All of the Shell Scripts In a Directory
This is a quick and dirty way which will list all of the files that are shell scripts:
for i in * do type=$(file ${i}|awk -F, ‘{print $2}’) if [[ “${type}” = " ASCII text executable" ]]; then echo “${i} is a shell script” fi done
Diff 2 Folders Over SSH
If you need to do a ‘diff’ on 2 folders and one of them is remote then you can accomplish that as follows:
$ diff <(ssh username@192.168.1.60 ls -R /home/username/dir1) <(ls -R /home/username/dir2)
How to Enable the Administrator Account in Windows
To activate the Administrator account on Windows, open the Command Prompt as Administrator from the Start Menu, or you can right-click on the “Start” menu and select the “Powershell” menu item, then enter:
net user administrator /active: yes
into the window. You should disable the account again when you’re done.
Convert HTML Files to EPUB Using Pandoc
If you want to convert one or more HTML files to EPUB quickly using the command line you can try pandoc.
pandoc -f html -t epub3 -o output.epub input.html
You can add metadata for epub:
pandoc -f html -t epub3 --epub-metadata=metadata.xml -o output.epub input.html
You can find other resources here:
How to convert various eBook formats for Amazon Kindle on Linux
Mastodon Automated Postings using the API
You can post to Mastodon using their API using cURL.
Create or Find Your Access Token
Once you have a Mastodon account, you need your account’s access token. The steps you need to get that:
- Sign into your Mastodon account
- Click on In the
"Preferences"link. - On the bottom left corner of that page, click the
"Development"link. - On the
"Your Applications"page, click the blueNEW APPLICATIONbutton. - Give your application a name, and decide what kind of access you want to have when you connect to your account via the Mastodon API (i
read,write, andfolloware the defaults). You can always change this later. - At the bottom of the page, click the blue
SUBMITbutton. - You will be directed back to the
Your applicationspage, but now you should see your application name. Click that. - In your application’s page, there are three tokens. For this tutorial, you need the
Your access tokenone. Note: if your access token is ever compromised, you can click regenerate, and your old access token will stop working, and you’ll be shown a new one.
Post a Status Update using cURL
Creating Passwordless SSH Keys
Create the key. Note those are two single quotes after the -N (for a blank passwd) $ ssh-keygen -t rsa -b 4096 -N ’’ Copy it to the target server $ cat .ssh/id_rsa.pub | ssh username@192.168.1.123 ‘cat » .ssh/authorized_keys’ Test it $ ssh username@192.168.1.123