Basic Linux Command Guide

New to Linux? We've got you covered.

Here's a quick list of Linux commands that are useful when you're working in the terminal.

Beginner-Friendly Terminal Basics
Linux Logo

Finding Your Way Around

pwd Shows the directory you're currently in.
ls Shows the files and folders in the current directory. Use -a to show hidden ones too.
cd Moves you into another directory. Use .. if you want to go back one level.
tree Shows the folders and files in a tree-like layout.

Working With Files

mkdir Creates a new directory (folder).
touch Creates an empty file, or updates the timestamp of an existing file.
cp Copies files. Use -r when you need to copy a directory and its contents.
mv Moves a file or folder. It can also be used to rename things.
rm Removes files or directories. Be careful with this one because it normally doesn't send things to the Trash.

Looking Through Files

cat Quickly displays what's inside a file.
less Lets you read through a file one screen at a time.
grep Searches for specific text inside files.
find Searches for files and folders using things like their name, type, or location.
locate Finds files quickly by searching a database of their locations.

Users and Permissions

whoami Shows the username of the account you're currently using.
groups Shows the groups a user belongs to. You can also add a username to check another user.
chmod Changes the permissions of a file or directory.
chown Changes who owns a file or directory, including its group.
sudo Runs a command with administrator-level privileges when your account is allowed to do so.

Checking What Your System Is Doing

top Shows running processes and how much CPU and memory they're using.
htop A more interactive process viewer that's a bit easier to look at than top.
ps Shows information about running processes. ps aux is commonly used to see processes from all users.
kill Sends a signal to a process, usually to stop it.

Checking Disk and Memory

df Shows how much disk space is being used and how much is still available. Use -h for easier-to-read sizes.
du Shows how much disk space files and directories are taking up.
free Shows information about your RAM and swap memory.
uname -a Shows detailed information about the kernel and your system.

Useful Shell Commands

echo Basically the terminal's way of printing text. It can also print variables.
history Shows commands that you've recently used in the shell.
hostname Shows the name of the computer. It can also be used to temporarily change the hostname.
alias Lets you create a shorter name for a command you use often.
exit Closes the current shell session.

Packages, Downloads, and Remote Access

apt update Updates the package lists so your system knows about the latest available packages.
git A version-control tool used for working with Git repositories and projects.
curl Gets or sends data through a URL. It's also useful for testing websites and APIs from the terminal.
wget Downloads files from the internet directly from the terminal.
ssh Lets you connect to another computer through a secure remote shell.

Terminal Keyboard Shortcuts Pt. 1

Ctrl + A Move the cursor to the beginning of the current line.
Ctrl + E Move the cursor to the end of the current line.
Ctrl + U Deletes everything between the cursor and the beginning of the line.
Ctrl + K Deletes everything between the cursor and the end of the line.
Ctrl + Y Brings back the text you most recently deleted with a kill command.

Terminal Keyboard Shortcuts Pt. 2

Ctrl + Alt + C Copies selected text in some terminal environments. This can depend on the terminal you're using.
Ctrl + Alt + V Pastes copied text in some terminal environments.
Ctrl + B Moves the cursor backward by one character in many shells.
Ctrl + F Moves the cursor forward by one character in many shells.
Alt + B Moves the cursor backward by one word.
Alt + F Moves the cursor forward by one word.

Interactive Terminal:

user@device:~$

There's a lot more to Linux, but these commands are a good place to start.