These are personal notes to remind myself how to do certain types of actons 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.
All of these are linux commands.
- Install fonts
- Uxn commands
- Markdown to HTML with pandoc
- Copying hexadecimal code from Nasu
- Changing the computer's time/timezone
- Download a webpage with wget
- Change repo from master to main
- Using cmus
- Modifying a song's metadata
- How to kill an unresponsive program
- Ripping audio/video from Youtube
- 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
- Spritesheet conversion to GIF
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
- sudo pacman -Syu, update all packages(Manjaro)
To install a font on your system(all accounts), create a directory with the font name(say the font name is Funkyboy):
sudo mkdir /usr/share/fonts/funkyboy
Move the font to the 'funkyboy' directory. It's possible to specify a filename, but if '*' is used all .ttf files will be moved to the new location (useful if moving several fonts).
sudo mv *.ttf /usr/share/fonts/funkyboy/
Update your system's font cache so the new fonts can be integrated.
sudo fc-cache -f -v
Confirm that the fonts were installed:
fc-list | grep "funkyboy"
If creating variations on that same font(bold, italic..), add them to the main directory of that font(Funkyboy).
When using tool from a local repository, and that it needs an update. Write the following after pulling the update:
In terminal to install update, re-launch tool.
Finding a file by name
To find files and directories with a certain name use the terminal, use the -name option and put the name in quotes:
find . -name "picard.jpg"
Markdown to HTML with pandoc
pandoc doc_name.md -o doc_name.html
Copying hexadecimal code from Nasu
Select the sprite in Nasu, then ctrl+c. Open a terminal window, and navigate to the folder where the file is located. Type:
Copy the text from the terminal ctrl+option+c and paste it where you want
Changing the computer's time/timezone
To change the timezone, first find the timezone in the list using the following command(to cycle through the list, enter line numbers and press enter):
Then, set the chosen timezone using:
timedatectl set-timezone "timezone"
Ex: timedatectl set-timezone "America/Vancouver"
To change the time:
timedatectl set-time "yyyy-MM-dd hh:mm:ss"
Download webpage with wget
To download a website for local viewing:
wget --page-requisites --convert-links --span-hosts --no-directories https://www.example.com
- --page-requisites downloads the images, css and js files
- --convert-links makes the links suitable for local viewing.
- --span-hosts tells wget to download the files from different hosts like the CDN
- --no-directories downloads the files into a single flat and messy directory
Sourced from Tyler Smith.
Change repo from master to main
Master is an antiquated and innapropriate term. To change the repository branch to main, navigate to the correct repository, then enter:
git branch -m master main git push -u origin main git symbolic-ref refs/remotes/origin/HEAD refs/remotes/origin/main # change default branch git push origin --delete master
- x, play
- c, pause
- v, stop
- z, previous stack
- b, next track
- u, update cache
- tab, to select a track from inside an album on the right column
- s, shuffle
- r, repeat
- 5, main list
- /, search
- n, search next
- N, search previous
- y, copy selected tracks to playlist
- p, move track down
- P, move track up
- D, remove track
To add new music, press 5, then navigate to music using a. Switch back to simple view by pressing 2, or to tree view with 1.
Modifying song's metadata
To modify the metadata of a song, you can use VLC by opening a song with it, then going to Tools>Media Information (be sure to save).
It's also possible to do in the terminal, by installing eyeD3:
sudo pacman -S python-eyed3
eyeD3 -a 'Artist name' -A 'Album name' -t 'Song name' song.mp3
Artist (-a/--artist), album (-A/--album), title (-t/--title), and track number (-n/--track-num).
List sourced from Rostiger's website.
How to kill an unresponsive program
Identify parent process.
Where 1234 is the process ID I found using pstree. If application has not been terminated, do this:
kill -9 1234
Ripping audio/video YouTube
NOTE. Youtube-dl doesn't work anymore, it is now necessary to use yt-dlp, to install:
sudo pacman -Syu yt-dlp
Refer to the installation guide for other linux distributions or OSs. The new command for ripping audio:
yt-dlp -f 'ba' -x --audio-format mp3 https://www.youtube.com/watch?v=dQw4w9WgXcQ -o '%(id)s.%(ext)s'
A simpler option is:
yt-dlp -x -f bestaudio https://youtube.com/insertaddress
To download videos...
If you want to select a specific format, or audio only, enter the following along with the youtube video url:
yt-dlp --list-formats https://www.youtube.com/watch?v=f6wtF_2eyrU
You'll get a list of formats in the command line window. Each option is labelled with a number (far left). Options include versions of the video without audio in a variety of formats (mp4, webm), others are for audio only. If the goal is to get audio only, then one would write -f 140 in the command line:
yt-dlp -f 140 https://www.youtube.com/watch?v=f6wtF_2eyrU
To specify a name for the video, append -o '%(id)s.%(ext)s', like so:
yt-dlp https://www.youtube.com/watch?v=f6wtF_2eyrU -o '%(id)s.%(ext)s'
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
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:
You'll see the following:
/org/freedesktop/UPower/devices/line_power_ADP1 /org/freedesktop/UPower/devices/battery_BAT0 /org/freedesktop/UPower/devices/DisplayDevice
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 = firstname.lastname@example.org:
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
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
- 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"
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 On Manjaro... sudo pacman -S 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.
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:
Spritesheet conversion to GIF
ImageMagick can convert spritesheets to gif animations, here is the recipe I used:
convert -dispose 3 -delay 20 -loop 0 input.png -crop 64x64 +repage output.gif
Here is a breakdown of the recipe:
-dispose 3 'dispose" defines the way the displayed image is modified after the current frame of an animation has gone past, and before another frame is overlaid.
3 refers to 'previous', which clears to the image prior to the current frame's overlay.
-delay 20 displays the next image after pausing for a number of seconds.
-loop 0 set to zero the animation repeats an infinite number of times.
input.png is my starting spritesheet.
-crop cuts out one or more rectangular regions of my image to 64x64 pixels. For my animation, I had 5 frames, 64 is the width/height of the bounding box of the sprite (full width 320px / 5).
+repage adjusts the canvas and offset information of the image.
output.gif is the resulting, assembled gif image.
Back to top.