I called this post “Get comfy in the Ubuntu terminal” because I use Ubuntu, not because these commands are only available in Ubuntu. So, before diving into the command line, let’s clear up a common confusion. While Linux, Unix, Ubuntu, and Mint are related, they’re not exactly the same:

  • Unix is the original operating system developed in the 1970s
  • Linux is an open-source, Unix-like operating system kernel
  • Ubuntu and Mint are Linux distributions (distros) – complete operating systems built on the Linux kernel

Think of it like this: Linux is the foundation, and Ubuntu/Mint are specific, user-friendly builds on top of that foundation.

All that said what you see here is going to work on whichever version of Linux that you use. I just happen to use Ubuntu for my development work, unless some boss man has paid for me to have a Mac. Otherwise Macs are way too expensive for my taste.

Also all of these commands won’t make you an expert in Ubuntu by any means. They are just a sampling of the things that I use most often to get you off the ground.

Command Line Basics

When you open the terminal, you’ll see a prompt that typically looks like this:

username@computername:~$

This is your command line. They can look different of course. Mine looks something like this:

Code>

But that is just because I edited the file that my terminal reads settings from when it first loads up (.zshrc in my case).

The cd, pwd & ls commands

cd stands for “change directory” and is your primary way of moving through folders:

  • cd .. moves you up one level in the folder hierarchy
  • cd some_folder moves you down into a specific folder
  • cd ~ takes you to your home directory
  • ls will list the files and folders in the current directory
  • ls -la shows everything, including hidden files
  • -l gives a detailed list view
  • -a shows all files (including hidden ones starting with a dot)
  • pwd means “print working directory”. It shows your current location in the file system:

Here is an example of how I would normally move around via the command line.

$ pwd
/home/user/Code

$ ls
_RubyGems
a_rails_project
bloggy

$ cd a_rails_project

$ pwd
/home/user/Code/a_rails_project

$ ls
Dockerfile	README.md	bin		db		old		storage		vendor
Gemfile		Rakefile	config		lib		public		test
Gemfile.lock	app		config.ru	log		script		tmp

Creating and removing files and folders

Creating Directories

# Create a single directory
mkdir new_folder

Creating Files

# Create an empty file
touch newfile.txt

Copying Files and Directories

# Copy a file
cp source.txt destination.txt

Moving and Renaming

# Move a file
mv oldlocation/file.txt newlocation/file.txt

# The move (mv) command is also used in Linux to rename a file
mv oldname.txt newname.txt

Removing Files and Directories

# Remove a file
rm file.txt

# Remove an empty directory
rmdir empty_folder

# Remove a directory and its contents
rm -r folder_to_delete

Programming version Management with mise

mise is a powerful, fast, and flexible version manager for multiple programming languages. It isn’t strictly a command line thing but it is very useful to have one tool to install and manage versions of programming languages.

Install mise like below or get the full instructions at: https://github.com/jdx/mise

curl https://mise.run | sh
~/.local/bin/mise --version

With mise it is very easy to install a specific version of a language for a project. Mise will set the version of the language for the project if you use ‘mise use language@1.2.3’.

# Use a specific version of a language (will also install the language/version if it is not present.
mise use python@3.11.0
mise use nodejs@18.17.0

# Set global default version
mise global python@3.11.0

# Set local project version
mise use python@3.10.5

# List installed versions
mise list

Quick Reference

  • mkdir: Create directories
  • cp: Copy files/directories
  • mv: Move/rename files
  • rm: Remove files/directories
  • chmod: Change file permissions
  • mise: Manage language versions
  • cd: Change directory
  • ls: List directory contents
  • pwd: Print working directory

That concludes the quick hits that you need to get started in the terminal. There is bunches more to learn about the terminal (and I certainly don’t know it all) but this will get you started.