Menu

Linux Commands List with Examples

List of most useful Linux commands with description and examples

Written by Selva Prabhakaran | 2 min read

Managing packages

python
apt update 
apt list 
apt install nano
apt remove nano
python
pwd          # to print the working directory
ls           # to list the files and directories
ls -l        # to print a long list 
cd /         # to go to the root directory
cd bin       # to go to the bin directory
cd ..        # to go one level up
cd ~         # to go to the home directory 

Manipulating files and directories

python
mkdir test              # to create the test directory
mv test docker          # to rename a directory 
touch file.txt          # to create file.txt
mv file.txt hello.txt   # to rename a file 
rm hello.txt            # to remove a file 
rm -r docker            # to recursively remove a directory

Editing and viewing files

python
nano file.txt        # to edit file.txt
cat file.txt         # to view file.txt
less file.txt        # to view with scrolling capabilities
head file.txt        # to view the first 10 lines
head -n 5 file.txt   # to view the first 5 lines 
tail file.txt        # to view the last 10 lines 
tail -n 5 file.txt   # to view the last 5 lines 

Searching for text

python
grep hello file.txt        # to search for hello in file.txt
grep -i hello file.txt     # case-insensitive search 
grep -i hello file*.txt    # to search in files with a pattern
grep -i -r hello .         # to search in the current directory

Finding files and directories

python
find               # to list all files and directories
find -type d       # to list directories only
find -type f       # to list files only
find -name “f*”    # to filter by name using a pattern

Managing environment variables

python
printenv           # to list all variables and their value
printenv PATH      # to view the value of PATH
echo $PATH         # to view the value of PATH
export name=bob    # to set a variable in the current session

Managing processes

python
ps                 # to list the running processes
kill 37            # to kill the process with ID 37

Managing users and groups

python
useradd -m john    # to create a user with a home directory
adduser john       # to add a user interactively
usermod            # to modify a user
userdel            # to delete a user

groupadd devs      # to create a group 
groups john        # to view the groups for john
groupmod           # to modify a group
groupdel           # to delete a group
Free Course
Master Core Python — Your First Step into AI/ML

Build a strong Python foundation with hands-on exercises designed for aspiring Data Scientists and AI/ML Engineers.

Start Free Course
Trusted by 50,000+ learners
Related Course
Master Linux — Hands-On
Join 5,000+ students at edu.machinelearningplus.com
Explore Course
Free Callback - Limited Slots
Not Sure Which Course to Start With?
Talk to our AI Counsellors and Practitioners. We'll help you clear all your questions for your background and goals, bridging the gap between your current skills and a career in AI.
10-digit mobile number
📞
Thank You!
We'll Call You Soon!
Our learning advisor will reach out within 24 hours.
(Check your inbox too — we've sent a confirmation)
⚡ Before you go

Python.
SQL. NumPy.
All free.

Get the exact 10-course programming foundation that Data Science professionals use.

🐍
Core Python — from first line to expert level
📈
NumPy & Pandas — the #1 libraries every DS job needs
🗃️
SQL Levels I–III — basics to Window Functions
📄
Real industry data — Jupyter notebooks included
R A M S K
57,000+ students
★★★★★ Rated 4.9/5
⚡ Before you go
Python. SQL.
All Free.
R A M S K
57,000+ students  ★★★★★ 4.9/5
Get Free Access Now
10 courses. Real projects. Zero cost. No credit card.
New learners enrolling right now
🔒 100% free ☕ No spam, ever ✓ Instant access
🚀
You're in!
Check your inbox for your access link.
(Check Promotions or Spam if you don't see it)
Or start your first course right now:
Start Free Course →
Scroll to Top
Scroll to Top
Course Preview

Machine Learning A-Z™: Hands-On Python & R In Data Science

Free Sample Videos:

Machine Learning A-Z™: Hands-On Python & R In Data Science

Machine Learning A-Z™: Hands-On Python & R In Data Science

Machine Learning A-Z™: Hands-On Python & R In Data Science

Machine Learning A-Z™: Hands-On Python & R In Data Science

Machine Learning A-Z™: Hands-On Python & R In Data Science