computers have so many commands! it is hard to remember them all. hopefully this page can help for the next time you are staring nervously at the shell.

by category

command example description
cd cd ../folder/subfolder change directory from one folder to another
ls ls list the contents of a folder
pwd pwd print the full working directory you're currently in

media

command example description
magick magick in.png out.jpg convert image files
ffmpeg ffmpeg -i in.mov out.mp4 convert video and audio files
yt-dlp yt-dlp https://youtu.be/INa_SYywZis download videos & audio from YouTube and other platforms

text

command example description
cat cat in.txt print out a file
less less in.txt page through a file
head head -n 5 in.txt view the beginning of a file
tail tail -n 5 in.txt view the end of a file
grep grep "search" in.txt search a file for some text
sed sed -i 's/old/new/' in.txt find and replace text in a file
nano nano out.txt a pretty simple text editor, like the "Notepad" of linux
emacs emacs out.txt a really powerful text editor that's a bit harder to use
vim vim out.txt an unhinged text editor that some people have opinions about

web

command example description
wget wget http://a.horse/disc.iso download a file
curl curl http://ip.me send a HTTP request to a server
caddy caddy run host a web server
php8.4 php8.4 page.php run a php script and check it for errors

network

command example description
dig dig pronounmail.com lookup DNS records for a domain
nslookup nslookup pronounmail.com lookup DNS name server for a domain
ping ping pronounmail.com check if two computers can see each other
lsof lsof -i -P -n list open ports on the current machine

services

command example description
systemctl systemctl status my_unit start/stop/check statuses of services
journalctl journalctl -xeu my_unit check logs for a service

help

command example description
tldr tldr git pull command usage examples
man man git command usage details

funky things you can do in the shell

the shell has a lot of funky features!!

put stuff in a file

If you want to take the stuff a command is printing out and instead of printing it out, put it in a file, you can use the > symbol. For example, if you wanted to take the last line of a long file and copy it to another file you could do:

tail -n 1 long_file.txt > last_line.txt

Just one > will overwrite the file if it already exists. If you use two like this >> it will append stuff to the end of the file if it already exists.

chain commands together

There's a really powerful feature of the shell called "piping" that lets you chain multiple small commands together to do something more complex. You can use the | character for this. For example, if you have a command that prints out a lot of stuff, you can trim it to the last 50 lines and then search for the text "keyword" by chaining commands together like this:

cat long_file.txt | tail -n 50 | grep "keyword"

run multiple commands at once

You can have one command run only if another one succeeds by chaining them together with &&. If you don't care whether the first command succeeds, you can use ; instead.

You can run a command in the background by putting & after it. Just be careful cuz a command running in the background can't be stopped like normal with Ctrl+C. Instead, you'll need to find it's PID and use the kill command.

paths

Every file on a computer has a path which is how you get there. Imagine we had some folders like this and you're currently hanging out in /home/me/folderA

/
home
me
folderA
file1.txt
file2.txt
folderB
file3.txt

Imagine you wanted to print out the contents of file3.txt, there's a few ways you could do this:

cat /home/me/folderB/file3.txt – use the full absolute path

cat ../folderB/file3.txt – use a path relative to .. the parent directory right above your current folder which right now, happens to be /home/me

cat ~/folderB/file3.txt – use a path relative to ~ your home directory which for the user me will always be /home/me