Some UNIX command line notes

Archived Posts from previous blogs that might still be useful to someone.

Last modified 2025-03-03

Table of content
  1. Brief Intro
  2. 🥧 Raspberry Pi Specifc Commands
  3. Raspberry Pi Imager
  4. 🐧 The Linux Section
  5. Mounting & Unmounting USBs
  6. Editing a file with pico
  7. Get Hostname
  8. GUI/Visual Interface for Partitioning Drives
  9. Mounting Parition on boot
  10. 🐋 Docker Specific
  11. Install Docker
  12. Grant docker user access to run without sudo
  13. Install docker-compose
  14. List of active docker containers
  15. Find the docker compose file location for a specific container
  16. Run a command line in a docker container
  17. Restart Docker Container

Brief Intro

In the process of setting up Jellyfin on the Raspberry Pi I had laying around, I've run into quite the abundance of issues. Since it's been a few years since I've worked with a Linux terminal I figured it would be helpful to put some of the commands in a place I could find them easily along with any notes I have about them. As with any command line code, I recommend you research it yourself to know what you're about to paste into your terminal before you do. In alignment with this philosophy, I will be dropping sudo from commands that (in my experience) need it.

🥧 Raspberry Pi Specifc Commands

Raspberry Pi Imager

Raspberry Pi Imager is a tool for easily wiping and flashing an OS onto a USB or other storage device.

apt install rpi-imager
rpi-imager

🐧 The Linux Section

Mounting & Unmounting USBs

Device names may switch around randomly on each boot. Persistent naming allows you not to worry about this

-- Source

Learning how fdisk works solved the biggest issue I was having with getting my usb drive set up as a connected source. This article in particular walked though all the steps in a friendly way.

This will show all partitions and storage on/attached to the device. Use this to find the "device name" - something like /dev/sda1 or /dev/sdb2.

fdisk -l

This command will show the space available in a -h[uman readable] format:

df -h

Manually mount a device's partition:

mount /dev/sda1 /media/ # Note that the first value should be a partition, not device (sda)

Unmount a device's partition:

umount /dev/sda1

Editing a file with pico

I just like using Pico because that's what we used in the college class where I learned Linux.

pico FILE_PATH.EXTENSION pico compose.yaml

To save the file, Ctrl + X then Enter then y.

Get Hostname

hostname -I

Possiblely useful guide: How to change hostname on Linux from the Command line

GUI/Visual Interface for Partitioning Drives

gparted

Mounting Parition on boot

The file which controls the boot processes:

/etc/fstab

Note that there are various options that can be included. Importantly, nofail - which will indicate that if that line didn't process properly, the boot process will continue. AKA if you don't indicate this and unplug a usb your device might not boot up (ask me how I know 😅).

Get ids of partitions:

blkid

🐋 Docker Specific

Install Docker

curl -sSL https://get.docker.com | sh

Grant docker user access to run without sudo

Note - This one requires sudo to run

usermod -aG docker $USER

Install docker-compose

The first few tutorials I followed didn't include this, and it seems like this would have been a huge convenience.

apt install docker-compose

List of active docker containers

docker ps

Find the docker compose file location for a specific container

Note that CONTAINER_ID will come from the above docker ps command and should look like a alphanumeric identifier.

inspect CONTAINER_ID | grep compose

Run a command line in a docker container

docker exec -it CONTAINER_NAME sh

Restart Docker Container

docker container restart CONTAINER_NAME

Code Fallacy on Youtube