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.
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] commandCommon 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 recursivelyPrint Working Directory – pwd
# pwd // display the absolute path of the current directoryCreate or Update Files – touch
# touch file_name.ext // create an empty file
# touch existing_file // update access and modification timestampsOutput Text – echo
# echo "string" > file // overwrite file with string
# echo "string" >> file // append string to fileUnderstanding 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 sizesChange Directory – cd
# cd ~ // go to home directory
# cd - // return to previous directoryHotkeys / 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 // pasteDisplay File Content – cat
# cat file // print file to terminal
# cat -A file // show all characters including non‑printingCompile C – gcc
# gcc source.c // compile to a.out
# ./a.out // execute the compiled programFile 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 onlyDirectory 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 superuserCopy Files – cp
# cp file dir // copy file into directory
# cp -r dir1 dir2 // recursively copy directoryCommand Alias – alias
# alias ll='ls -l --color=auto' // example alias for colored long listingSearch – 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 locationsCommand Alias – alias
# alias name='command options' // define shortcut for a command with optionsPattern 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 searchSystem Monitor – top
# top // interactive process viewerCommon 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 directoryArchive – tar
# tar -czf archive.tgz files // create gzipped tarball
# tar -xzf archive.tgz // extract gzipped tarball
# tar -ztvf archive.tgz // list contents without extractingCalculator – 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 nameExit 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 commandReboot – reboot
# reboot // restart the systemShutdown – shutdown
# shutdown -h now // halt immediately
# shutdown -r now // reboot immediately
# shutdown -c // cancel a pending shutdownPoweroff – 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.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Open Source Linux
Focused on sharing Linux/Unix content, covering fundamentals, system development, network programming, automation/operations, cloud computing, and related professional knowledge.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
