Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Fundamental Linux Terminal

The Linux terminal is one of the most important parts of a Linux development environment.

Almost everything that can be done through a graphical interface can also be performed from the terminal. In many engineering workflows, the terminal is faster, easier to automate, easier to reproduce, and more practical for remote systems.

From the terminal, you can:

  • install software and development tools;
  • create, copy, move, rename, and delete files and directories;
  • inspect files and directory trees;
  • modify permissions and ownership;
  • create users and groups;
  • archive and compress data;
  • redirect and combine command output;
  • execute scripts;
  • transfer files;
  • configure environment variables;
  • schedule work;
  • inspect system state;
  • manage packages;
  • work with remote machines.

The goal of this chapter is not to memorize every Linux command.

The goal is to become comfortable enough with the terminal that it stops feeling like a special tool and becomes a normal part of everyday engineering work.

Important: Many Linux commands can modify or permanently delete data. Read commands carefully before executing them, especially when using sudo, rm -rf, recursive permission changes, disk tools, or administrative commands.


Opening the Terminal

On Linux Mint and many other Linux desktop environments, a common shortcut is:

Ctrl + Alt + T

You can also open the terminal from the application menu or define your own shortcut in system settings.

A shell prompt may look similar to:

developer@machine:~$

The exact username, hostname, colors, and symbols depend on your environment.


Navigation and Directory Inspection

ls - List Directory Contents

The ls command lists files and directories in the current working directory.

ls

A more detailed listing can be shown with:

ls -la

Common options include:

OptionMeaning
-aInclude hidden entries beginning with .
-lUse long listing format
-dList directories themselves rather than their contents
-RList subdirectories recursively
-sShow allocated size in blocks
-tSort by modification time

Use:

ls --help

or:

man ls

to explore the full option list.


Understanding ls -l

Example:

drwxr-xr-x  3 developer developers 4096 Sep 17 12:10 project
-rw-r--r--  1 developer developers 3890 Sep 17 11:50 .bashrc

The first character describes the object type:

d    directory
-    regular file
l    symbolic link

The next nine characters describe permissions:

rwxr-xr-x

They are divided into three groups:

rwx  r-x  r-x
│    │    │
│    │    └── others
│    └────── group
└─────────── user / owner

Permission symbols are:

r    read
w    write
x    execute
-    permission not granted

The remaining columns normally show information such as:

  • number of hard links;
  • owner;
  • group;
  • size;
  • modification time;
  • file or directory name.

pwd - Print Working Directory

To see your current location:

pwd

Example:

/home/developer/projects

cd - Change Directory

Move into a directory:

cd projects

Move to an absolute path:

cd /home/developer/projects

Move one level upward:

cd ..

Move two levels upward:

cd ../..

Go to your home directory:

cd ~

or simply:

cd

Absolute and Relative Paths

An absolute path starts from the filesystem root:

/home/developer/projects/demo

A relative path starts from your current working directory:

projects/demo

Example:

cd /home/developer/projects/demo

and:

cd projects/demo

can point to the same location depending on your current directory.

Understanding the difference between absolute and relative paths is fundamental because almost every Linux command accepts paths.


Creating and Removing Directories

mkdir - Create Directories

Create one directory:

mkdir project

Create multiple directories:

mkdir project-a project-b project-c

Brace expansion can also be used:

mkdir {project-a,project-b,project-c}

Creating Parent Directories With mkdir -p

If intermediate directories do not yet exist:

mkdir -p projects/backend/api

Linux creates the missing parent directories as needed.

This works with both relative and absolute paths.


Creating a Directory With Permissions

mkdir -m can assign a mode when creating a directory:

mkdir -m 750 private-project

We will explain numeric permission modes in the next section.


rmdir - Remove Empty Directories

Remove an empty directory:

rmdir project

Remove multiple empty directories:

rmdir project-a project-b

rmdir does not remove non-empty directories.


rm - Remove Files and Directory Trees

Remove a file:

rm file.txt

Remove a directory recursively:

rm -r project

Useful options include:

OptionMeaning
-r, -RRemove recursively
-fForce; do not prompt for nonexistent files
-dRemove empty directories

Be Extremely Careful With rm -rf

This command:

rm -rf some-directory

can permanently remove an entire directory tree without confirmation.

Always verify the path first.

For learning, prefer:

rm -ri some-directory

when you want interactive confirmation.

Never copy and execute an rm -rf command without understanding exactly what it targets.


Permission Modes

Linux permissions can be represented symbolically:

rwxr-xr--

or numerically.

Values are:

r = 4
w = 2
x = 1

Examples:

rwx = 4 + 2 + 1 = 7
r-x = 4 + 0 + 1 = 5
rw- = 4 + 2 + 0 = 6
r-- = 4 + 0 + 0 = 4
--- = 0 + 0 + 0 = 0

Three numbers represent:

user  group  others

Examples:

777 = rwxrwxrwx
750 = rwxr-x---
644 = rw-r--r--
600 = rw-------

Do not automatically use 777.

Permissions should be only as broad as necessary.


Terminal Keyboard Shortcuts

Useful shell shortcuts include:

ShortcutAction
Ctrl + LClear the visible terminal screen
TabAutocomplete commands, paths, and filenames
Up ArrowPrevious command
Down ArrowNext command in history
Ctrl + PPrevious command
Ctrl + NNext command
Ctrl + AMove to beginning of line
Ctrl + EMove to end of line
Ctrl + LeftMove one word left
Ctrl + RightMove one word right
Ctrl + KCut from cursor to end of line
Ctrl + UCut from cursor to beginning of line
Ctrl + Shift + CCopy selected terminal text
Ctrl + Shift + VPaste into terminal
Ctrl + DSend EOF / exit an interactive shell

These shortcuts become extremely useful once the terminal becomes part of your daily workflow.


Working With Files

touch - Create Files

Create an empty file:

touch example.txt

Create multiple files:

touch file1.txt file2.txt file3.txt

You can use either relative or absolute paths:

touch /home/developer/example.txt

mv - Move and Rename

General form:

mv SOURCE DESTINATION

Move a file:

mv example.txt archive/

Move multiple files:

mv file1.txt file2.txt archive/

Rename a file:

mv old-name.txt new-name.txt

Useful options include:

OptionMeaning
-iAsk before overwriting
-fForce overwrite
-nDo not overwrite existing destination
-uMove only when source is newer or destination is missing
-vVerbose output

For learning and important files, -i can be useful:

mv -iv source destination

cp - Copy Files and Directories

General form:

cp [OPTIONS] SOURCE DESTINATION

Copy a file:

cp file.txt backup/

Copy several files:

cp file1.txt file2.txt backup/

Copy a directory recursively:

cp -R project/ backup/

Useful options include:

OptionMeaning
-aArchive mode; preserve attributes where possible
-fForce copy
-iAsk before overwrite
-nDo not overwrite
-R, -rRecursive copy
-uCopy when source is newer
-vVerbose output

Changing Permissions and Ownership

chmod - Change Permissions

Set numeric permissions:

chmod 750 script.sh

Add execute permission for the current user:

chmod u+x script.sh

Apply permissions recursively:

chmod -R 750 project/

Warning: Recursive permission changes can affect every file and directory below a path. Also remember that directories need execute (x) permission to be entered/traversed.


chown - Change Ownership

General form:

chown USER:GROUP FILE

Example:

sudo chown developer:developers file.txt

Recursive ownership change:

sudo chown -R developer:developers project/

Ownership changes usually require administrative privileges when changing objects to another user.


Editing Text With Nano

nano - Terminal Text Editor

Open a file:

nano file.txt

Use sudo nano only when the file genuinely requires administrative privileges:

sudo nano /etc/hosts

Useful Nano shortcuts:

ShortcutAction
Ctrl + XExit
Ctrl + OWrite/save file
Ctrl + WSearch
Ctrl + \Replace
Ctrl + KCut current line
Ctrl + UPaste from Nano cut buffer
Ctrl + CShow cursor position
Alt + GGo to line and column
Alt + UUndo
Alt + ERedo
Ctrl + ABeginning of line
Ctrl + EEnd of line
Ctrl + PPrevious line
Ctrl + NNext line

Standard Output and Redirection

Linux commands normally write output to streams.

The two most important are:

stdout    standard output
stderr    standard error

echo

Print text:

echo "Hello Linux World!"

Redirect output into a file:

echo "Hello Linux World!" > message.txt

Append to an existing file:

echo "Second line" >> message.txt

> - Overwrite Redirection

command > file.txt

The destination file is replaced with the new output.

Example:

echo "new content" > example.txt

>> - Append Redirection

command >> file.txt

New output is added to the end of the file.

Example:

echo "another line" >> example.txt

Redirecting Errors

Redirect standard error:

command 2> errors.txt

Append standard error:

command 2>> errors.txt

Redirect stdout and stderr into the same file:

command > output.txt 2>&1

Bash also supports:

command &> output.txt

Append both streams:

command &>> output.txt

Text Inspection Commands

cat

Print file content:

cat file.txt

Combine several files:

cat file1.txt file2.txt

Redirect combined output:

cat file1.txt file2.txt > combined.txt

wc

Count lines:

wc -l file.txt

You will also commonly see:

cat file.txt | wc -l

but the direct form is simpler when only one file is involved.


Show the first ten lines:

head file.txt

Show a specific number of lines:

head -n 5 file.txt

tail

Show the last ten lines:

tail file.txt

Show the last two lines:

tail -n 2 file.txt

Follow a growing log file:

tail -f application.log

diff

Compare two files:

diff file-a.txt file-b.txt

This is useful for quickly inspecting textual differences.


split

Split a file after a number of lines per output file:

split -l 100 large-file.txt

The original file remains unchanged.


Pipes

The pipe operator:

|

sends the output of one command into the input of another.

Example:

ls -la | grep ".txt"

Conceptually:

command A
    ↓ stdout
command B

Pipes are one of the most important ideas in Unix-like environments.

Small commands can be combined into larger workflows.


Shell Scripts

A shell script is a text file containing shell commands.

Create one:

nano script.sh

Example content:

#!/usr/bin/env bash

ls -la
pwd

Make it executable:

chmod u+x script.sh

Run it:

./script.sh

You can also explicitly invoke Bash:

bash script.sh

The .sh extension is conventional but not what makes a file executable. Permissions and the interpreter determine execution.


Archiving and Compression

tar

Create a tar archive:

tar -cvf archive.tar project/ file1.txt file2.txt

List archive contents:

tar -tf archive.tar

Extract:

tar -xvf archive.tar

tar.gz

Create a gzip-compressed tar archive:

tar -cvzf archive.tar.gz project/

Extract:

tar -xzvf archive.tar.gz

For less verbose output, omit v:

tar -czf archive.tar.gz project/
tar -xzf archive.tar.gz

gzip

Compress a file:

gzip archive.tar

Decompress:

gzip -d archive.tar.gz

Show gzip information:

gzip -l archive.tar.gz

Users and Groups

Inspect the Current User

whoami

Detailed identity information:

id

Show group membership:

groups

Create a User

On Linux Mint and other Debian/Ubuntu-based systems:

sudo adduser student

Add the user to the sudo group when administrative access is intentionally required:

sudo usermod -aG sudo student

Change a Password

sudo passwd student

Delete a User

Keep the user’s home directory:

sudo deluser student

Remove the user’s home directory too:

sudo deluser --remove-home student

Administrative user management can destroy user data. Verify the username before executing removal commands.


Create and Manage Groups

Create a group:

sudo groupadd developers

Append a user to a supplementary group:

sudo usermod -aG developers student

Inspect the group:

getent group developers

Change a user’s primary group:

sudo usermod -g developers student

Important User and Group Files

Linux user and group information is represented through system files including:

/etc/passwd
/etc/shadow
/etc/group
/etc/gshadow

Do not modify these files manually unless you understand the consequences.

For learning, inspect them read-only:

cat /etc/passwd
getent passwd
getent group

/etc/shadow contains protected password-related information and normally requires administrative access.


Soft and Hard Links

Create a symbolic link:

ln -s source.file softlink.file

A symbolic link stores a path to another object.

If the target disappears, the symbolic link becomes broken.

Symbolic links:

  • can cross filesystem boundaries;
  • can point to directories;
  • have their own inode;
  • refer to a path.

Create a hard link:

ln source.file hardlink.file

A hard link refers to the same underlying inode/data as the original directory entry.

Both names reference the same file data.

If one name is removed, the data remains accessible through the other name as long as another hard link still exists.

Hard links normally:

  • remain within the same filesystem;
  • cannot normally be created for directories by ordinary users;
  • share the same inode;
  • reflect content and permission changes because they refer to the same underlying file.

Inspect inode numbers with:

ls -li

Downloading Files With wget

wget is a non-interactive command-line download utility.

Example:

wget https://example.com/file.tar.gz

It supports common protocols such as HTTP and HTTPS and is useful in scripts and remote sessions.


Running Multiple Commands

;

Commands separated with ; are executed sequentially regardless of whether the previous command succeeded:

mkdir demo; cd demo; touch file.txt

&&

The next command runs only if the previous command succeeds:

mkdir demo && cd demo && touch file.txt

This is usually safer when later steps depend on earlier steps.


Multi-Line Commands

Use a backslash at the end of a shell line to continue:

mkdir project \
    && cd project \
    && touch README.md

Aliases

Aliases create short names for commands.

Temporary alias:

alias ll="ls -la"

List aliases:

alias

Remove one:

unalias ll

Permanent Bash Aliases

For Bash, add aliases to:

~/.bashrc

Example:

echo 'alias ll="ls -la"' >> ~/.bashrc

Reload:

source ~/.bashrc

Avoid aliases that make destructive commands easier to execute accidentally.

For example, an alias wrapping rm -rf is a poor default for a learning environment.


The $PATH Environment Variable

When you type:

git

or:

go

the shell needs to find the executable.

The $PATH variable contains directories that the shell searches.

Inspect it:

echo "$PATH"

Find the executable resolved for a command:

which git

A modern shell also provides:

command -v git

Common executable locations include:

/usr/bin
/usr/local/bin
/usr/sbin
/usr/local/sbin

Extending $PATH

Example:

export PATH="$PATH:$HOME/bin"

To persist it for Bash:

echo 'export PATH="$PATH:$HOME/bin"' >> ~/.bashrc
source ~/.bashrc

Always quote $PATH expansions in shell configuration when practical.


Package Management With APT

Linux Mint uses the Debian/Ubuntu package-management ecosystem.

Refresh package information:

sudo apt update

Upgrade installed packages:

sudo apt upgrade

Install a package:

sudo apt install git

Search:

apt search package-name

Remove:

sudo apt remove package-name

apt-get remains available and is widely used in scripts:

sudo apt-get update
sudo apt-get install git

For interactive use, apt is usually more convenient.


sudo

sudo allows an authorized user to execute commands with elevated privileges.

Example:

sudo apt update

Administrative privileges should be used only when necessary.

Do not place sudo in front of commands automatically.

Ask:

Does this operation really need root privileges?


About /etc/sudoers

The original Team413 terminal guide demonstrates passwordless sudo through a NOPASSWD sudoers entry.

For a normal learning workstation, this edition does not recommend disabling sudo password prompts globally.

If you ever need to modify sudo policy, use:

sudo visudo

rather than editing /etc/sudoers directly with a general-purpose editor.

visudo validates the configuration before saving and reduces the chance of breaking administrative access.


Use the Built-In Documentation

Linux commands usually document themselves.

Try:

command --help

or:

man command

Examples:

ls --help
man chmod
man tar
man usermod

Learning how to read command documentation is more valuable than trying to memorize every option.


Fundamental Command Checklist

You should become comfortable with at least these commands and concepts:

ls
pwd
cd
mkdir
rmdir
rm
touch
mv
cp
chmod
chown
nano
cat
echo
wc
head
tail
diff
split
tar
gzip
ln
wget
id
whoami
groups
adduser
usermod
groupadd
apt
sudo
man
--help
PATH
stdout
stderr
>
>>
2>
|
&&
;

You do not need to memorize them in one day.

Use them repeatedly.

The terminal becomes natural through repetition.


Final Perspective

The Linux terminal is not a list of commands.

It is an environment for combining small tools.

The real power appears when you understand:

files
+
paths
+
permissions
+
streams
+
processes
+
shell syntax
+
small commands

and begin combining them.

At that point, the terminal stops being something you “learn for Linux”.

It becomes one of the primary interfaces through which you understand and operate a computer.

Scalionix Docs

Keyboard Shortcuts

Navigate the documentation without leaving the keyboard.
Navigation
Previous subject
←
Next subject
→
Previous subsection
Alt + ↑
Next subsection
Alt + ↓
Interface
Documentation Home
Ctrl + Enter
Search
Alt + Q
Open shortcuts
?
Close dialog
Esc
Scalionix Docs

Search Documentation