Linux Cheatsheet

By Jamie Flores and Leif Wesche

Description

Linux is the OS you all are using on your VM/docker. Unix (a variant of which is MacOS) is another OS that has many of the same commands. Here are some of the most useful ones! Hopefully you never open the file explorer on your VM again after reading this!

Terminal

In this class, and in CS in general, the terminal is the best way to interact with your computer. Plus it’s easier to learn than you’d think. From the terminal you can run programs and manipulate the file system.

Autocomplete

You can always have the terminal guess what you are trying to say by pressing tab. This doubles as a handy way to avoid typos. If it doesn’t find anything to autocomplete with, or finds too many possible matches, tab will do nothing.

Previous commands

To rerun a command you already ran, you don’t have to type it out again. You can use the up arrow on your keyboard to look through previously ran commands.

Directory Aliases

A directory is what you think of as a folder.

The filesystems of modern OSes are heirarchies, meaning there is some root directory any other directory can be reached from. When referring to directories from the command line:

So, if you are in ~/user/cs104/hw-username/:

Commands

Any of these command should run in your Unix/Linux/MacOS terminal.

Keep Things Neat

Creating a Directory

Moving Files Around

Flags

Create a file

Opening a Text Editor

If you are using VS Code,

NOTE: if you are using Sublime, just replace code with subl. For Emacs, replace with emacs. For VI, replace with vim.

Deleting Stuff

sudo

Searching

Creating Your Own Scripts