By Prakash Gangurde | BCA Student | Technical Content Creator | AI β’ Python β’ Linux
When I first opened a Linux terminal, I stared at a blinking cursor and had absolutely no idea what to do.
No buttons. No menus. Just a black screen waiting for me to type something.
If that sounds familiar β this article is for you.
Linux is not just for hackers and system administrators. As a CS student, you will encounter Linux in web servers, cloud platforms, cybersecurity, data science, and software development. The sooner you get comfortable with the terminal, the faster everything else becomes.
This article covers 20 commands I actually use β not a textbook list of every possible flag, but the ones that solve real problems you will face as a student. Each command comes with a real example, not just a definition.
Estimated reading time: 15β18 minutes
Tested on Ubuntu 22.04 LTS. Most commands work identically on any Debian-based Linux system and macOS terminal.
Opening the terminal:
Ctrl + Alt + T
Reading command syntax:
When you see something like command [option] <argument>
, it means:
command
β the actual command to type[option]
β optional flag (in square brackets)<argument>
β required input (in angle brackets)One rule before everything else:
Linux is case-sensitive.
File.txt
,file.txt
, andFILE.TXT
are three different files.
pwd
β Print Working Directory What it does: Shows you exactly where you are in the file system.
pwd
Output:
/home/prakash/projects
When you use it: Any time you get lost and need to know your current location. Think of it as "where am I right now?"
ls
β List Directory Contents What it does: Shows all files and folders in the current directory.
ls
Output:
Desktop Documents Downloads projects README.md
The version you will actually use:
ls -la
Output:
drwxr-xr-x 5 prakash prakash 4096 Jun 10 10:30 .
drwxr-xr-x 18 prakash prakash 4096 Jun 9 08:15 ..
-rw-r--r-- 1 prakash prakash 220 Jun 9 08:15 .bash_logout
drwxr-xr-x 3 prakash prakash 4096 Jun 10 09:45 projects
-rw-r--r-- 1 prakash prakash 1024 Jun 10 10:30 README.md
l
gives you detailed info (permissions, size, date). a
shows hidden files (files starting with .
).When you use it: Every single time you open a terminal.
cd
β Change Directory What it does: Moves you into a different folder.
cd projects # go into the projects folder
cd .. # go up one level
cd ~ # go to your home directory from anywhere
cd /var/www/html # go to an absolute path
cd - # go back to the previous directory
When you use it: Constantly. This is how you navigate your entire file system.
mkdir
β Make Directory What it does: Creates a new folder.
mkdir my-project # create one folder
mkdir -p projects/python/day1 # create nested folders all at once
The -p
flag is extremely useful β it creates all the parent folders if they don't exist yet.
When you use it: Every time you start a new project.
clear
β Clear the Terminal Screen What it does: Clears all the clutter from your terminal screen.
clear
Or just press Ctrl + L
β same result, faster.
When you use it: When your terminal gets too messy to read.
touch
β Create an Empty File What it does: Creates a new empty file instantly.
touch index.html
touch app.py
touch notes.txt
When you use it: Creating new files without opening an editor first.
cp
β Copy Files and Folders What it does: Copies a file or folder from one location to another.
cp app.py app_backup.py # copy a file
cp -r projects/ projects_backup/ # copy an entire folder
The -r
flag means "recursive" β required when copying folders.
When you use it: Before making big changes to a file β always keep a backup.
mv
β Move or Rename Files What it does: Moves a file to a new location OR renames it.
mv old_name.py new_name.py # rename a file
mv app.py /home/prakash/projects/ # move a file to a different folder
mv folder1/ folder2/ # rename a folder
When you use it: Organising files or renaming them without opening a file manager.
rm
β Remove Files and Folders What it does: Permanently deletes files or folders.
rm file.txt # delete a file
rm -r old_project/ # delete a folder and everything inside it
β οΈ
Warning:Linux has no recycle bin.rm
is permanent. Always double-check before running it. Never runrm -rf /
β it deletes everything on the system.
When you use it: Cleaning up old files and project folders.
cat
β Display File Contents What it does: Prints the contents of a file directly in the terminal.
cat README.md
cat requirements.txt
cat /etc/hosts
When you use it: Quickly reading a small file without opening an editor. Also useful for checking config files.
grep
β Search Inside Files What it does: Searches for a specific word or pattern inside files.
grep "import" app.py # find all lines with "import" in app.py
grep -r "password" . # search for "password" in all files recursively
grep -n "def " app.py # show line numbers where "def " appears
grep -i "error" log.txt # case-insensitive search
When you use it: Finding which file contains a specific function, variable, or text. I use grep -r
almost every day when working on projects.
find
β Find Files by Name What it does: Searches for files and folders by name, type, or size.
find . -name "app.py" # find a file named app.py
find . -name "*.txt" # find all .txt files
find . -type d -name "node_modules" # find all folders named node_modules
find /home -name "*.py" -size +1M # find Python files larger than 1MB
When you use it: When you know a file exists but can't remember where you put it.
chmod
β Change File Permissions What it does: Controls who can read, write, or execute a file.
chmod 755 script.py # owner can read/write/execute, others can read/execute
chmod +x run.sh # make a file executable
chmod 644 config.txt # owner can read/write, others can only read
Understanding 755:
When you use it: Any time you want to run a Python or shell script directly from the terminal, you need to make it executable with chmod +x
.
sudo
β Run as Administrator What it does: Runs a command with administrator (root) privileges.
sudo apt update # update package list
sudo apt install python3-pip # install software
sudo chmod 777 /var/www/html # change permissions on system folders
When you use it: Installing software, changing system files, or running anything that requires admin access.
β οΈ Only use
sudo
when you actually need it. Running everything as sudo is a security risk.
ps aux
β View Running Processes What it does: Shows all currently running processes on the system.
ps aux # show all processes
ps aux | grep python # find all running Python processes
ps aux | grep streamlit # check if your Streamlit app is running
The |
(pipe) sends the output of ps aux
directly into grep
β so you only see processes matching "python".
When you use it: When a script seems stuck and you need to find its process ID to stop it.
kill
β Stop a Running Process What it does: Stops a running process using its process ID (PID).
kill 1234 # politely ask process 1234 to stop
kill -9 1234 # force stop process 1234 immediately
To find the PID, use ps aux | grep python
first, then note the number in the second column.
When you use it: When a program freezes or a server won't stop with Ctrl+C.
ping
β Test Network Connection What it does: Checks if a server or website is reachable from your machine.
ping google.com # test internet connection
ping 192.168.1.1 # test connection to your router
ping -c 4 google.com # send exactly 4 packets then stop
When you use it: First step when diagnosing network problems. "Is the server down or is my internet down?"
curl
β Transfer Data from URLs What it does: Downloads content from a URL or sends HTTP requests.
curl https://example.com # get the HTML of a webpage
curl -O https://example.com/file.zip # download a file
curl -X POST https://api.example.com/data -d '{"key":"value"}' # send a POST request
When you use it: Testing your own APIs, down files, or checking if a web server is responding. Essential for backend development and cybersecurity testing.
apt
β Install and Manage Software (Ubuntu/Debian) What it does: Installs, updates, and removes software packages.
sudo apt update # refresh the list of available packages
sudo apt upgrade # upgrade all installed packages
sudo apt install python3-pip # install a specific package
sudo apt install git # install git
sudo apt remove package-name # uninstall a package
Always run sudo apt update
before installing anything β this ensures you get the latest version.
When you use it: Installing any tool or software on a Linux system.
history
β View Command History What it does: Shows a numbered list of all commands you have previously run.
history # show all previous commands
history | grep git # find all git commands you've run
history | tail -20 # show the last 20 commands
!42 # re-run command number 42 from history
!! # re-run the last command
When you use it: When you ran a command earlier and want to run it again but can't remember exactly what you typed. Also useful for finding commands you use often.
These are not commands but keyboard shortcuts that will make your terminal life significantly faster:
| Shortcut | What it does |
|---|---|
Ctrl + C |
|
| Cancel the current running command immediately | |
Ctrl + Z |
|
| the current process and send it to background | |
Tab |
|
| Auto-complete file names and commands β press once to complete, twice to see options | |
β arrow |
|
| Cycle through previous commands β faster than retyping | |
Ctrl + L |
|
Clear the screen (same as clear ) |
The Tab key is the single most underused feature in the terminal. Get in the habit of pressing Tab after typing the first few letters of any file name β it completes the rest automatically.
| # | Command | What it does |
|---|---|---|
| 1 | pwd |
|
| Show current location | ||
| 2 | ls -la |
|
| List all files with details | ||
| 3 | cd |
|
| Change directory | ||
| 4 | mkdir -p |
|
| Create folders | ||
| 5 | clear |
|
| Clear terminal screen | ||
| 6 | touch |
|
| Create empty file | ||
| 7 | cp -r |
|
| Copy files and folders | ||
| 8 | mv |
|
| Move or rename | ||
| 9 | rm -r |
|
| Delete files and folders | ||
| 10 | cat |
|
| Read file contents | ||
| 11 | grep -r |
|
| Search inside files | ||
| 12 | find |
|
| Find files by name | ||
| 13 | chmod |
|
| Change permissions | ||
| 14 | sudo |
|
| Run as administrator | ||
| 15 | ps aux |
|
| View running processes | ||
| 16 | kill |
|
| Stop a process | ||
| 17 | ping |
|
| Test network connection | ||
| 18 | curl |
|
| Transfer data from URLs | ||
| 19 | apt |
|
| Install software | ||
| 20 | history |
|
| View command history |
Open your terminal right now and try this sequence:
mkdir linux-practice
cd linux-practice
touch hello.py
echo "print('Hello from Linux!')" > hello.py
cat hello.py
python3 hello.py
ls -la
cd ..
rm -r linux-practice
This uses 7 commands from this article in one go. If everything ran without errors β you are already comfortable with the Linux terminal.
These 20 commands are your foundation. Once you are comfortable with them, explore:
| Topic | What it covers |
|---|---|
| Bash scripting | |
| Automate tasks by writing shell scripts | |
| File permissions in depth | |
Understanding rwx and chmod numbers fully |
|
| SSH | |
| Connect to remote servers securely | |
| Vim / Nano | |
| Edit files directly in the terminal | |
| Cron jobs | |
| Schedule commands to run automatically | |
| Networking tools | |
netstat , nmap , traceroute for deeper network analysis |
The terminal practice script from this article is in my GitHub:
π
GitHub Repository:
[https://github.com/prakashgangurde-ux/linux-notes]
If this article helped you, please clap on Medium β it helps other students find it.
Drop any question in the comments β I read and reply to every one.
Next article: How I Built an AI-Powered Network Intrusion Detection System as a BCA Student
Written by Prakash Gangurde β BCA Student | Technical Content Creator | AI β’ Python β’ Linux