Skip to main content

Command Line Basics

Linux has two main ways of identifying a user’s access level:

  • $ indicates a normal user.
  • # indicates the root or privileged user.
CommandWhat it DoesWhy Use It
EchoDisplays the text you type outOutput messages or variables
PWD (print working directory)Prints your current directoryKnow your current location
LS (list directories)Lists files and sub-directoriesExplore contents of directories
TouchCreate new empty filesQuickly make files
FileShows file typeIdentify file formats
CatDisplays contents of a fileView small files
NanoText editorEdit files easily
LessNavigate through file page-by-pageRead large files without loading all at once
HistoryShows command historyRecall previous commands
Cp (copy)Copies a file to new locationDuplicate files
Mv (move)Moves or renames filesOrganize files efficiently
Mkdir (make directory)Creates directoriesOrganize files and folders
Rm (remove)Deletes files or directoriesRemove unwanted files
FindSearches files or directories by criteriaTrack down misplaced files
HelpDisplays help for a commandLearn how to use commands
ManShows manual/documentation of a commandIn-depth help
WhatisGives short description of a commandQuick explanation
Alias/UnaliasCreates/removes shortcuts for commandsSimplify repetitive tasks
ExitCloses the terminal or current shellEnd your session

Updating Linux

Always keep your system up-to-date:

sudo apt update && sudo apt upgrade -y

Echo

Description: Prints text or variables to the terminal. Useful for displaying messages or variable values.

echo "Hello, world!"

PWD (print working directory)

Description: Shows the full absolute path of your current directory.

pwd

LS (list directories)

Description: Lists files and directories in the current location. Add options for details or hidden files.

ls -l

Touch

Description: Creates a new, empty file or updates the timestamp of an existing file.

touch example.txt

File

Description: Shows the type of a file (text, directory, binary, etc.).

file example.txt

Cat

Description: Concatenates and displays the content of files in the terminal.

cat example.txt

Nano

Nano can be used as a text editor, which is usually found in most Linux distributions.

nano example.txt

Less

Description: Opens a file interactively so you can scroll through it, useful for long files.

less example.txt

History

Description: Displays a list of previously entered commands.

history

Cp (copy)

Description: Copies files or directories to a new location.

cp example.txt backup.txt

Mv (move)

Description: Moves or renames files and directories.

mv backup.txt archive.txt

Mkdir (Make Directory)

Description: Creates a new directory (folder).

mkdir myfolder

Rm (remove file)

Description: Deletes files or directories. Use with caution!

rm example.txt

Rmdir (remove directory)

rmdir testdir

Find

Description: Searches for files and directories matching criteria (name, type, etc.).

find . -name "example.txt"

Help (other tool name)

Description: Shows brief help for a command, listing options and usage.

ls --help

Man (other tool name)

Description: Displays the full manual (documentation) for a command.

man ls

Whatis (other tool name)

Description: Gives a one-line description of a command.

whatis ls

Alias/Unalias (name)

Description: Creates or removes shortcuts for commands (aliases).

alias ll='ls -l'

To get rid of an alias type:

unalias ll

Exit

Description: Closes the current terminal session or shell.

exit

Follow Us on Social Media

YouTube

Discord

Patreon

Reddit

Rumble