Spellbook
These are personal notes to remind myself how to do certain types of installations via the command line in the terminal. Some notes are for actions I do often, others that I've only done once, but that the process I thought was worth noting.
- Ripping audio from Youtube videos
- Pandoc commands
- Sublime shortcuts
- Battery health
- Creating a working .desktop file
- Update remote from http(s) to ssh
- Export images to pdf with GIMP
- Make appimage executable
- How to format USB on Linux
- Install terminal dictionary
I use fish, a command line shell, commands may vary because of this.
A list of some useful commands:
- cd, change the current directory
- ls, list files and directories
- man, display a manual page on the screen
- mv, move (rename) files
- cp, copy files
- open, open files with the default application associated with each filetype
- less, list the contents of files
Ripping audio from YouTube videos
Get your paws on youtube-dl In the terminal, enter the following:
youtube-dl --audio-format mp3 -x 'youtube url'
[-x] is to extract the audio. If you don't specify an audio format it'll download as an M4a.
pandoc commands
To export a text file formatted in html to markdown (as a .txt file).
pandoc -o filename.txt filename.html
To export mardown text file into a styled pdf (see how to install pandoc, as well as TexLives and other useful extensions).
pandoc filename.txt --pdf-engine=xelatex -o filename_export.pdf
Sublime shortcuts
To select the space before the first character on every line in a paragraph.
shift+right, then crtl+d (repeat d key to select additional lines).
Checking battery health
To check battery health on your laptop time the following command:
upower -e
You'll see the following:
/org/freedesktop/UPower/devices/line_power_ADP1 /org/freedesktop/UPower/devices/battery_BAT0 /org/freedesktop/UPower/devices/DisplayDevice
Enter:
upower -i /org/freedesktop/UPower/devices/battery_BAT0
Check energy-full and energy-full-design to see the performance of your battery. To know if the battery needs to be replaced, divide the number next to “Energy when full” by “Energy (design)”, and multiply the result by 100. You’ll get a percentage.
The percentage you get is how much your battery holds of its original capacity. If the number is >50%, it might be time to replace the battery.
Creating a working .desktop file
Open a text editor. Paste and edit the following:
[Desktop Entry] Version=x.y Name=ProgramName Comment=This is my comment Exec=/home/alex/Documents/exec.sh Icon=/home/alex/Pictures/icon.png Terminal=false Type=Application Categories=Utility;Application;
Version is the version of the file.
Name is the application name, for example "krita" or "thunderbird".
Comment is a short description of said application.
Exec is the path to the executable application. Icon is the path to the icon you wish to use for the application.
Terminal is whether you want the application to run in a terminal window or not.
Type specifies the type of launcher file (other examples include link, or directory).
Categories is used to categorize applications.
Save the .desktop file. While in the same folder, open the terminal window and type the following to move the .desktop file to /usr/share/applications, or write the path to the .desktop file:
sudo mv programname.desktop /usr/share/applications
Navigate to usr/share/applications, find the file you just moved, select and drag it onto the launcher panel. Now your launcher (.desktop file) is locked on your launcher dash.
Update remote from http(s) to ssh
Look inside .git/config in your repo, and change the relevant remotes to look like:
url = git@github.com:/ .git
Export images to pdf with GIMP
Combine images in same file on layers. Export as a .mng file using the default export settings. Convert to PDF using imagemagick. If you don't have it, install it first.
sudo apt-get install imagemagick
Convert your files, that's it.
convert -reverse document.mng document.pdf
Back to top.
Make appimage executable
chmod +u
Back to top.
How to format USB on Linux
Insert the USB flash drive or SD card into your Linux machine and find the device name using the lsblk -fp command:
$ lsblk -fp NAME FSTYPE LABEL UUID MOUNTPOINT /dev/sda └─/dev/sda1 LVM2_member c52... ├─/dev/mapper/mint--vg-root ext4 183... / └─/dev/mapper/mint--vg-swap_1 swap 337... [SWAP] /dev/sdb └─/dev/sdb1 vfat USB Drive 345... /media/user/usb0
In the example above, the USB drive is recognized by the operating system as a disk named /dev/sdb with a single partition /dev/sdb1 mounted on /media/user/usb0. Unmount the USB drive if it is mounted:
sudo umount /media/user/usb0
Formatting types:
- NTFS: The NT File System (NTFS) is the file system that modern Windows versions use by default.
- HFS+: The Hierarchical File System (HFS+) is the file system modern macOS versions use by default.
- APFS: The proprietary Apple file system developed as a replacement for HFS+, with a focus on flash drives, SSDs, and encryption. APFS was released with iOS 10.3 and macOS 10.13, and will become the mandatory file system for those operating systems.
- FAT32: The File Allocation Table 32 (FAT32) was the standard Windows file system before NTFS.
- exFAT: The extended File Allocation Table (exFAT) builds on FAT32 and offers a lightweight system without all the overhead of NTFS.
- EXT 2, 3, & 4: The extended file system (EXT) was the first file system created specifically for the Linux kernel.
To convert to FAT32, enter desired label name (optional):
$ sudo mkfs.fat -F 32 /dev/sdb1 -n "USB Drive"
Back to top.
Install a terminal dictionary
Half of the online searches I make are for word definitions, or synonyms. A good physical dictionary is useful, but there are times when searching online is quicker. I didn't want to use anything with an interface, as they tend to be messy, and in this case, my needs are very simple. A terminal dictionary as for me, the better option. Enter SDCV.
SDCV, or StarDict Console Version, is the terminal utility version of StarDict extensible GUI dictionary application. Here's how to install it:
sudo apt-get install sdcv
SDCV is now installed, but has no dictionaries to search from yet. SDCV requires files in a DICT format. You can pick the ones you want from the list here, recommended by StarDict. To start, you can download the Collaborative International Dictionary of English.
Next, navigate to the folder where you will place your dictionary.
cd /usr/share
Make a directory named 'stardict', and another in it named 'dic'. To make a directory, use sudo mkdir followed by the name of your new directory.
Next, we'll uncompress and move the dictionary in one go, using the following command. Modify INSERTNAME with the name of the file you've downloaded.
sudo tar -xjvf INSERTNAME -C /usr/share/stardict/dic
Enter your password, and voila! To use SDCV, type sdcv followed by the word you're looking for, for example:
sdcv tortilla
Back to top.