Note: I’m not an expert. I’m writing this blog just to document my learning journey. 🚀
🔹 What Is the Linux Command Line?
The command line (or terminal) is where you type text commands to control the computer directly.
Linux is built around the command line. You can create files, move around, install software — all by typing commands.
✅ Most Useful Basic Commands
1. pwd
– Where am I?
This shows your current location (folder) in the computer.
pwd
Example output:
/home/yourname
2. ls
– What is here?
Shows files and folders in the current location.
ls
You can also use options:
-
ls -l
: more details (like size and date) -
ls -a
: show hidden files (start with.
)
3. cd
– Go to another folder
This moves you into a different folder.
cd foldername # Go into a folder
cd .. # Go up one level
cd /home/yourname # Go to a specific path
cd # Go to your home folder
4. mkdir
– Make a folder
mkdir newfolder
Creates a folder called newfolder
.
5. touch
– Make a file
touch file.txt
Creates an empty file called file.txt
.
6. cp
– Copy files or folders
cp file.txt copy.txt # Copy a file
cp -r folder1 folder2 # Copy a folder and its contents
7. mv
– Move or rename
mv file.txt /other/place # Move file
mv old.txt new.txt # Rename file
8. rm
– Delete
rm file.txt # Delete a file
rm -r foldername # Delete a folder and its contents
⚠️ Warning: This deletes immediately — no trash bin.
9. cat
– Show file content
cat file.txt
Prints the contents of a file.
10. less
– Read file one page at a time
less file.txt
Use arrow keys or q
to quit.
11. head
and tail
– Show top/bottom of file
head file.txt # First 10 lines
tail file.txt # Last 10 lines
tail -f log.txt # Follow file as it grows
12. whoami
– Show your username
whoami
13. clear
– Clear the screen
clear
14. man
– Manual/help for a command
man ls
Gives full help about the ls
command. Press q
to quit.
15. history
– See commands you’ve run
history
16. sudo
– Run as administrator
Some commands need permission. Use sudo
to run as admin.
sudo apt update
🎯 Summary Table
Purpose | Command Example |
---|---|
Show location | pwd |
List files | ls |
Change folder | cd foldername |
Make folder | mkdir newfolder |
Create file | touch file.txt |
Copy | cp file1 file2 |
Move/rename | mv file1 file2 |
Delete file/folder |
rm file.txt , rm -r folder
|
View file | cat file.txt |
Manual/help | man command |
Admin task | sudo apt install name |
Top comments (0)