Some UNIX command line notes
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
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
.
Device names may switch around randomly on each boot. Persistent naming allows you not to worry about this
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.
fdisk -l
df -h
mount /dev/sda1 /media/
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
๐ Docker Specific
Install Docker
curl -sSL https://get.docker.com | sh
sudo
Grant docker user access to run without 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
Restart named Docker Container
cmd
docker container restart CONTAINER_NAME
Huge thanks to Code Fallacy on Youtube for the excellent guides that got me through this