Linux Commands List with Examples - machinelearningplus
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
Wait — don't leave
without your free
AI/ML Roadmap

The step-by-step path used by 25,000+ learners to go from zero to career-ready in AI/ML.

Please fill in your name and a valid email.
🔒 100% Free ☕ No spam, ever ✓ Instant delivery

Roadmap sent to your inbox!

Can't find it? Check your spam or promotions tab.

Not sure where to start?

Book a free 15-min call — our team will map out the right path for your background. Zero sales pressure.

📞

Request a free callback

Team available · 15 min · No commitment

🇮🇳 +91
🇮🇳 India +91
🇺🇸 USA +1
🇬🇧 UK +44
🇦🇺 AUS +61
🇦🇪 UAE +971
🇸🇬 SG +65
🇲🇾 MY +60
🇵🇰 PK +92
🇧🇩 BD +880
🇳🇵 NP +977
🇱🇰 LK +94
🇫🇷 FR +33
🇩🇪 DE +49
🇮🇹 IT +39
🇪🇸 ES +34
🇳🇱 NL +31
🇸🇪 SE +46
🇨🇭 CH +41
🇵🇱 PL +48
🇹🇷 TR +90
🇸🇦 SA +966
🇶🇦 QA +974
🇰🇼 KW +965
🇴🇲 OM +968
🇧🇭 BH +973
🇪🇬 EG +20
🇿🇦 ZA +27
🇳🇬 NG +234
🇰🇪 KE +254
🇬🇭 GH +233
🇨🇳 CN +86
🇯🇵 JP +81
🇰🇷 KR +82
🇮🇩 ID +62
🇵🇭 PH +63
🇧🇷 BR +55
🇲🇽 MX +52
🇦🇷 AR +54
🇨🇦 CA +1
🇳🇿 NZ +64
🇮🇪 IE +353
Please enter your phone number.

Thank you for your submission!

Our team will call you shortly. You'll also receive a confirmation on your email.

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