DevOps Blog

Linux Basics: A Beginner’s Guide to Essential Commands

1. Navigating the File System

pwd – Print Working Directory

Shows the current directory (folder) you're in.

pwd

Example Output:

/home/username

ls – List Directory Contents

Lists files and directories in the current folder.

ls # Basic list ls -l # Detailed list (permissions, size, etc.) ls -a # Shows hidden files (starting with '.')

cd – Change Directory

Moves you into a different directory.

cd Documents # Move into "Documents" cd .. # Go up one directory cd ~ # Return to home directory cd / # Go to the root directory

2. File & Directory Management

mkdir – Make Directory

Creates a new folder.

mkdir new_folder

touch – Create a File

Creates an empty file.

touch file.txt

cp – Copy Files/Directories

Copies a file or directory.

cp file.txt /backup/ # Copy file to another location cp -r folder/ backup/ # Copy a directory recursively

mv – Move or Rename Files

Moves files or renames them.

mv file.txt new_name.txt # Rename mv file.txt ~/Documents/ # Move to another directory

rm – Remove Files/Directories

Deletes files or directories (use with caution!).

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

3. Viewing & Editing Files

cat – Display File Contents

Prints the contents of a file.

cat file.txt

less / more – View Files Page by Page

Allows scrolling through large files.

less long_file.txt more long_file.txt

nano / vim – Text Editors

Simple text editors for modifying files.

nano file.txt # Easy-to-use editor vim file.txt # More advanced (press `i` to edit, `Esc` then `:wq` to save & exit)

4. System Information & Processes

df – Disk Space Usage

Shows disk space on mounted filesystems.

df -h # Human-readable format (MB/GB)

free – Memory Usage

Displays RAM and swap usage.

free -h

top / htop – Process Monitor

Lists running processes (press q to exit).

top # Basic process viewer htop # More interactive (may need installation)

ps – Process Status

Lists currently running processes.

ps aux # Detailed process list

5. Permissions & Ownership

chmod – Change File Permissions

Modifies read (r), write (w), and execute (x) permissions.

chmod +x script.sh # Make a file executable chmod 755 file.txt # Sets permissions numerically (rwxr-xr-x)

chown – Change File Owner

Changes the owner of a file/directory.

sudo chown user:group file.txt

6. Networking Commands

ping – Test Network Connection

Checks connectivity to a server.

ping google.com

ifconfig / ip – Network Interface Info

Displays network interfaces and IP addresses.

ifconfig # Older command (may require installation) ip a # Modern alternative

wget / curl – Download Files

Downloads files from the internet.

wget https://example.com/file.zip curl -O https://example.com/file.zip

7. Package Management (Debian/Ubuntu)

apt – Install/Remove Software

Manages packages on Debian-based systems.

sudo apt update # Update package list sudo apt install package # Install a package sudo apt remove package # Remove a package

Final Thoughts

These basic Linux commands will help you get started with file management, system navigation, and troubleshooting. As you become more comfortable, you can explore more advanced commands and scripting.

Have questions or need further explanations? Drop a comment below!

Happy Linux-ing!


Did you find this helpful? Share it with fellow Linux beginners!

Next up: Advanced Linux Commands for Power Users!

Would you like any additions or modifications to this post? Let me know!