DEV Community

Cover image for Keep calm and learn Linux
Osagie Anolu
Osagie Anolu

Posted on • Edited on

4

Keep calm and learn Linux

Comprehensive Guide to Essential Linux Commands

Image description

Essential Linux Commands: A Practical Guide

Linux's power lies in its command-line interface (CLI), making it a favorite among developers and system administrators. This guide covers the fundamental commands you'll need for effective system management.

Basic Navigation

pwd     # Print working directory
cd      # Change directory
cd ..   # Move up one level
cd ~    # Go to home directory
Enter fullscreen mode Exit fullscreen mode

File and Directory Operations

Listing and Creating

ls      # List files and directories
ls -lah # Detailed list (long format, all files, human-readable sizes)
touch   # Create empty file
mkdir   # Create directory
mkdir -p # Create nested directories
Enter fullscreen mode Exit fullscreen mode

Manipulating Files

cp file1 file2     # Copy files
cp -r dir1 dir2    # Copy directories recursively
mv old new         # Move or rename
rm file           # Delete file
rm -r dir         # Delete directory recursively
Enter fullscreen mode Exit fullscreen mode

File Permissions

chmod 755 file    # Set permissions (rwxr-xr-x)
chmod u+x file    # Add execute permission for user
chown user:group file  # Change ownership
Enter fullscreen mode Exit fullscreen mode

Text File Operations

Viewing Content

cat file          # Display entire file
less file         # Page through file
head -n 10 file   # Show first 10 lines
tail -n 10 file   # Show last 10 lines
Enter fullscreen mode Exit fullscreen mode

Text Editing

  • nano: Beginner-friendly editor
  • vim: Advanced editor with powerful features
  • grep "term" file: Search within files
  • grep -i "term" file: Case-insensitive search

Process Management

ps aux           # List all processes
top             # Real-time process monitor
kill PID        # Terminate process by ID
killall name    # Terminate process by name
Enter fullscreen mode Exit fullscreen mode

Network Operations

ip addr         # Show network interfaces
ping host       # Test connectivity
netstat -tuln   # Show network connections
ss             # Modern alternative to netstat
Enter fullscreen mode Exit fullscreen mode

System Information

df -h           # Disk space usage
du -h           # Directory space usage
uname -a        # System information
uptime         # System uptime and load
Enter fullscreen mode Exit fullscreen mode

Pro Tips

  1. Use Tab completion to avoid typing full paths
  2. Access command history with up/down arrows
  3. Chain commands with && (AND) or || (OR)
  4. Use man command for detailed documentation
  5. Combine commands with pipes (|) for powerful operations

Remember: Linux commands are case-sensitive, and most can be modified with flags (options) that start with - or --. When in doubt, use --help or man to learn more about any command.

Do your career a big favor. Join DEV. (The website you're on right now)

It takes one minute, it's free, and is worth it for your career.

Get started

Community matters

Top comments (1)

Collapse
 
joseph_ibeh profile image
Joseph Ibeh

Nice. Weldon brother

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Immerse yourself in a wealth of knowledge with this piece, supported by the inclusive DEV Community—every developer, no matter where they are in their journey, is invited to contribute to our collective wisdom.

A simple “thank you” goes a long way—express your gratitude below in the comments!

Gathering insights enriches our journey on DEV and fortifies our community ties. Did you find this article valuable? Taking a moment to thank the author can have a significant impact.

Okay