DEV Community

tamilvanan
tamilvanan

Posted on

Learn Linux Commands - 001

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
Enter fullscreen mode Exit fullscreen mode

Example output:

/home/yourname
Enter fullscreen mode Exit fullscreen mode

2. ls – What is here?

Shows files and folders in the current location.

ls
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

4. mkdir – Make a folder

mkdir newfolder
Enter fullscreen mode Exit fullscreen mode

Creates a folder called newfolder.


5. touch – Make a file

touch file.txt
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

7. mv – Move or rename

mv file.txt /other/place     # Move file
mv old.txt new.txt           # Rename file
Enter fullscreen mode Exit fullscreen mode

8. rm – Delete

rm file.txt           # Delete a file
rm -r foldername      # Delete a folder and its contents
Enter fullscreen mode Exit fullscreen mode

⚠️ Warning: This deletes immediately — no trash bin.


9. cat – Show file content

cat file.txt
Enter fullscreen mode Exit fullscreen mode

Prints the contents of a file.


10. less – Read file one page at a time

less file.txt
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

12. whoami – Show your username

whoami
Enter fullscreen mode Exit fullscreen mode

13. clear – Clear the screen

clear
Enter fullscreen mode Exit fullscreen mode

14. man – Manual/help for a command

man ls
Enter fullscreen mode Exit fullscreen mode

Gives full help about the ls command. Press q to quit.


15. history – See commands you’ve run

history
Enter fullscreen mode Exit fullscreen mode

16. sudo – Run as administrator

Some commands need permission. Use sudo to run as admin.

sudo apt update
Enter fullscreen mode Exit fullscreen mode

🎯 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)