Basic Linux Commands

Basic Linux Commands

Basic Linux Commands

1. pwdPrint Working Directory

What it does: Shows the full path of your current directory.

pwd

Example Output:

/home/yourname/projects

2. lsList Directory Contents

What it does: Lists files and folders in the current directory.

ls

Variants:

  • ls -l – long format (detailed)

  • ls -a – shows hidden files

  • ls -lh – human-readable sizes

Example:

ls -lah

3. cdChange Directory

What it does: Navigate to a different directory.

cd folder_name

Examples:

cd Documents cd .. # Go one level up cd / # Go to root directory cd ~ # Go to home directory

4. mkdirMake Directory

What it does: Creates a new folder.

mkdir new_folder

5. touchCreate an Empty File

What it does: Creates a new, empty file.

touch file.txt

You can also create multiple:

touch file1.txt file2.txt

6. rmRemove Files or Folders

What it does: Deletes files or directories.

⚠️ Be careful with this one!

rm file.txt # Delete a file rm -r folder_name # Delete a folder and its contents

7. cpCopy Files or Folders

cp file1.txt file2.txt # Copy file1 to file2 cp -r dir1 dir2 # Copy entire folder

8. mvMove or Rename Files

mv oldname.txt newname.txt # Rename file mv file.txt /path/to/folder/ # Move file to a folder

9. catView File Contents

cat file.txt

To create and write a file:

cat > file.txt

10. nano or vimEdit Files

nano file.txt # Easy text editor vim file.txt # Advanced (but steeper learning curve)

11. clearClear the Terminal

clear

Shortcut: Ctrl + L

12. historyShow Command History

history

You can re-run a command:

!123 # Run command number 123

13. manManual (Help) for a Command

man ls

To quit the manual: press q.

14. df -hShow Disk Space Usage

df -h

-h means human-readable (MB, GB, etc.)

15. topShow Running Processes (Live Monitor)

top

Press q to exit.

Bonus: Combine Commands

You can chain commands with &&:

mkdir test && cd test

Would you like this turned into a cheat sheet PDF, or should I explain more advanced commands like permissions (chmod), searching (grep), or networking tools?

Soeng Souy

Soeng Souy

Website that learns and reads, PHP, Framework Laravel, How to and download Admin template sample source code free.

Post a Comment

CAN FEEDBACK
close