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
Before you go...

Get Your Free AI/ML Engineer Roadmap

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

šŸ”’ 100% Free ā˜• No spam, ever āœ“ Instant delivery
Your roadmap is on the way to your inbox

Want help choosing the right AI/ML path?

Book a free guidance call and our team will help you find right starting point for your AI/ML journey.

Get a free guidance call
šŸ‡®šŸ‡³ +91 ā–¾
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