Skip to main content

Command Palette

Search for a command to run...

Essential Linux Commands: A Complete Guide for Beginners

Updated
•7 min read•View as Markdown
Essential Linux Commands: A Complete Guide for Beginners

Linux provides powerful command-line tools for managing files, users, processes, networking, and the system itself. This guide summarizes the most essential commands with simple examples to help you get comfortable with daily terminal workflows.


1. File & Directory Management

Basic Navigation

CommandDescriptionExample
pwdShow current directorypwd
lsList filesls -l
cdChange directorycd /etc

Create & Remove Directories

CommandDescriptionExample
mkdirCreate directorymkdir new_folder
rmdirRemove empty directoryrmdir test_dir

File Operations

CommandDescriptionExample
rmRemove files/directoriesrm -rf temp/
cpCopy files/directoriescp file.txt backup.txt
mvMove/rename filesmv old.txt new.txt
touchCreate an empty filetouch test.txt
fileIdentify file typefile script.sh

2. File Content Operations

View File Content

CommandDescriptionExample
catView filecat notes.txt
lessPaged view (scroll)less syslog
morePaged viewmore test.txt

View Specific Parts

CommandDescriptionExample
headFirst lineshead -n 5 file.txt
tailLast linestail -n 10 file.txt
tail -fFollow live updatestail -f /var/log/syslog

Utilities

CommandDescriptionExample
wcCount words/lines/charswc -l data.txt
sortSort linessort names.txt
uniqRemove duplicatesuniq sorted.txt
cutExtract text sectionscut -d ':' -f1 /etc/passwd

3. Searching

CommandDescriptionExample
grepSearch in filesgrep "main" app.py
findLocate files on systemfind . -name "*.sh"
locateFast file searchlocate nginx.conf
whichShow binary locationwhich python3
whereisFind binary & sourcewhereis ls
basenameExtract file namebasename /home/user/test.txt
dirnameExtract directory pathdirname /home/user/test.txt
xargsPass input as arguments`lsxargs`
diffCompare filesdiff file1 file2
cmpByte-wise comparecmp file1 file2

4. File Permissions & Ownership

CommandDescriptionExample
chmodChange permissionschmod +x script.sh
chownChange ownerchown user:group file.txt
chgrpChange groupchgrp dev file.txt
umaskSet default permissionsumask 022
statDetailed file infostat file.txt

5. User Management

CommandDescriptionExample
whoamiShow current userwhoami
idShow UID/GIDid
adduserAdd user (easy)sudo adduser devops
useraddAdd user (manual)sudo useradd -m test
passwdChange passwordpasswd user
usermodModify userusermod -aG sudo devops
userdelDelete useruserdel -r test
groupaddCreate groupgroupadd admins
groupsList groupsgroups aditya
whoLogged-in userswho

6. System Information

CommandDescriptionExample
unameSystem infouname -a
hostnamectlSet hostnamehostnamectl set-hostname dev-server
uptimeUptime/loaduptime
topTask managertop
htopEnhanced tophtop
freeRAM infofree -h
vmstatSystem statsvmstat
dmesgKernel logsdmesg
lscpuCPU detailslscpu
lsblkStorage deviceslsblk

7. Disk & Filesystem

CommandDescriptionExample
dfDisk usagedf -h
duDirectory sizedu -sh *
mountMount filesystemmount /dev/sdb1 /mnt
umountUnmountumount /mnt
blkidDisk UUIDblkid
fdiskPartition managerfdisk /dev/sda
mkfsFormat partitionmkfs.ext4 /dev/sdb1
tune2fsTune filesystemtune2fs -l /dev/sda1
fsckDisk checkfsck /dev/sda1
syncFlush cachesync

8. Networking

CommandDescriptionExample
ip aShow interfacesip a
ifconfigLegacy toolifconfig
pingTest connectivityping google.com
curlHTTP requestscurl example.com
wgetDownload fileswget http://file.com/file.zip
netstatConnectionsnetstat -tuln
ssSocketsss -tuln
tracerouteTrace routetraceroute google.com
hostDNS lookuphost google.com
nslookupDNS toolnslookup github.com

9. Package Management

Debian/Ubuntu

CommandDescriptionExample
apt updateUpdate indexsudo apt update
apt installInstall packagesudo apt install nginx
apt removeRemove packagesudo apt remove nginx
dpkgManage .deb filesdpkg -i package.deb
apt listList installedapt list --installed
apt-cacheSearch packagesapt-cache search apache
snapSnap storesnap install code

RHEL/CentOS

CommandDescriptionExample
yumInstall packageyum install httpd
dnfModern pkg managerdnf update
rpmRPM package managerrpm -ivh pkg.rpm

10. Process Management

CommandDescriptionExample
ps auxList processesps aux
killKill by PIDkill 1234
killallKill by namekillall nginx
bgBackground processbg
fgForeground processfg
jobsList jobsjobs
niceSet start prioritynice -n 10 ./script.sh
reniceChange priorityrenice 10 -p 1234
watchRepeat commandwatch -n 2 free -h
straceTrace syscallsstrace ls

11. Superuser / Admin

CommandDescriptionExample
sudoRun as rootsudo reboot
suSwitch usersu -
visudoEdit sudoerssudo visudo

12. Archiving & Compression

CommandDescriptionExample
tarArchive & compresstar -czvf backup.tar.gz folder/
gzipCompress filegzip logfile.txt
gunzipDecompressgunzip logfile.txt.gz
zipCreate zipzip data.zip *.csv
unzipExtract zipunzip data.zip

13. Shell & Scripting

CommandDescriptionExample
echoPrint textecho "Hello"
readTake inputread name
aliasCreate shortcutalias ll='ls -la'
exportSet environment variableexport PATH=$PATH:/opt/bin