Fundamentals 30 min read

Master Essential Linux Commands: A Complete Beginner’s Guide

This comprehensive guide introduces Linux developers to the most frequently used shell commands, covering basic concepts, command syntax, built‑in vs external utilities, file operations, text processing, system monitoring, compression tools, and useful shortcuts, enabling readers to become proficient Linux users.

Open Source Linux
Open Source Linux
Open Source Linux
Master Essential Linux Commands: A Complete Beginner’s Guide

Linux Basic Commands

Linux platform developers commonly use these commands; mastering them enables proficient use of Linux.

Simple Introduction to Shell

Shell is a command interpreter that translates user commands to the kernel and returns results, protects the operating system, and creates child processes for each command.

The shell program is typically /usr/bin/bash (bash), written in C. When you log into a server, a shell is automatically attached.

Basic Command Format

# command [-options] ...

Built‑in Commands vs External Commands

Linux commands are divided into built‑in commands (integrated in the shell) and external commands (installed as separate binaries, usually located in /bin, /usr/bin, /sbin, etc.). Built‑ins are faster because they do not require a new process.

Check Command Type – type

# type [-afptP] command

Common output types: builtin , file , function , keyword , alias , unfound .

Get Help – help and --help

For built‑in commands use help command. For external commands use command --help (if supported).

Directory Operations

# mkdir directory_name               // create a directory
# mkdir -p d1/d2/d3                 // create nested directories recursively

Print Working Directory – pwd

# pwd                               // display the absolute path of the current directory

Create or Update Files – touch

# touch file_name.ext                // create an empty file
# touch existing_file                // update access and modification timestamps

Output Text – echo

# echo "string" > file              // overwrite file with string
# echo "string" >> file             // append string to file

Understanding Paths

Paths starting with . are hidden. / is the root. . denotes the current directory, .. the parent directory. Windows uses backslashes ( \), Linux uses forward slashes ( /).

List Files – ls

# ls -l                             // long format with permissions
# ls -t                             // sort by modification time
# ls -rt                            // reverse time order
# ls -ul                            // display UID information
# ls -ld /                          // list directory itself, not its contents
# ll -h                             // human‑readable sizes

Change Directory – cd

# cd ~                              // go to home directory
# cd -                              // return to previous directory

Hotkeys / Linux Keyboard Shortcuts

The Tab key provides command auto‑completion. Pressing Tab twice shows all possible matches.

Tree View – tree

# tree [directory]                  // display directory structure as a tree
# yum install -y tree               // install on CentOS/RHEL (use apt‑get on Ubuntu)

Text Editor – nano

# nano file                         // open file with nano editor
# Ctrl+G  // help
# Ctrl+X  // exit
# Ctrl+O  // save
# Ctrl+W  // search
# Ctrl+K  // cut line
# Ctrl+U  // paste

Display File Content – cat

# cat file                         // print file to terminal
# cat -A file                      // show all characters including non‑printing

Compile C – gcc

# gcc source.c                     // compile to a.out
# ./a.out                          // execute the compiled program

File Status – stat

# stat file                        // show file attributes (access, modify, change times)

Remove Files and Directories – rm and rmdir

# rm file                          // delete file
# rm -f file                       // force delete without prompt
# rm -r dir                        // recursively delete directory
# rm -rf dir                       // force recursive delete
# rmdir dir                        // delete empty directory only

Directory Permissions

Regular users can create files only under /home/username/…; root can create files anywhere.

Number of Linux Commands

On a typical Alibaba Cloud lightweight instance there are about 1,265 commands.

Manual Pages – man

# yum install -y man-pages        // install manual pages
# man command                      // view manual for a command
# man 2 printf                     // section 2 (system calls)
# man 3 printf                     // section 3 (C library)

Privilege Escalation – sudo

# sudo command                     // run command as superuser

Copy Files – cp

# cp file dir                       // copy file into directory
# cp -r dir1 dir2                  // recursively copy directory

Command Alias – alias

# alias ll='ls -l --color=auto'    // example alias for colored long listing

Search – find , which , whereis

# find /path -name filename        // locate file by name
# which command                    // show full path of executable
# whereis command                  // show binary, source, and man page locations

Command Alias – alias

# alias name='command options'      // define shortcut for a command with options

Pattern Search – grep

# grep 'keyword' file              // print lines containing keyword
# grep -v 'keyword' file           // print lines NOT containing keyword
# grep -i 'keyword' file            // case‑insensitive search
# grep -E 'pattern1|pattern2' file // extended regex OR search

System Monitor – top

# top                              // interactive process viewer

Common options: -a (sort by memory), -b (batch mode), -n (number of iterations), -p PID (show specific PID), -u USER (show processes of a user), etc.

Compression – zip and unzip

# zip archive.zip file1 file2       // create zip archive
# zip -r archive.zip directory      // recursively zip a directory
# unzip archive.zip                 // extract to current directory
# unzip archive.zip -d /path        // extract to specified directory

Archive – tar

# tar -czf archive.tgz files        // create gzipped tarball
# tar -xzf archive.tgz              // extract gzipped tarball
# tar -ztvf archive.tgz             // list contents without extracting

Calculator – bc

# bc                               // start interactive calculator
# echo "1+2*3/2" | bc              // evaluate expression (outputs 4)

System Information – uname

# uname -a                         // all system information
# uname -r                         // kernel release
# uname -m                         // machine hardware name

Exit Terminal – exit

# exit                             // close the shell (Ctrl+D works as well)

Command History – history

# history                         // show recent commands
# history > file.txt               // save history to a file
# !123                             // execute command number 123
# !!                               // repeat last command

Reboot – reboot

# reboot                           // restart the system

Shutdown – shutdown

# shutdown -h now                 // halt immediately
# shutdown -r now                 // reboot immediately
# shutdown -c                     // cancel a pending shutdown

Poweroff – poweroff

# poweroff                         // turn off the machine (equivalent to halt)

Useful Keyboard Shortcuts

Ctrl+S – pause terminal output; Ctrl+Q – resume.

Ctrl+C – terminate the current foreground process.

Ctrl+R – reverse search through command history.

Arrow keys – navigate command line.

In Linux, everything is a file – keyboards, displays, and even processes can be read from or written to.
Linux commands illustration
Linux commands illustration
Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

ShellUnixSysadminTutorialBashcommand-line
Open Source Linux
Written by

Open Source Linux

Focused on sharing Linux/Unix content, covering fundamentals, system development, network programming, automation/operations, cloud computing, and related professional knowledge.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.