DEV Community

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

Posted on Edited on

Keep calm and learn Linux

Comprehensive Guide to Essential Linux Commands

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.

Top comments (1)

Collapse
 
sir-j profile image
Joseph Ibeh

Nice. Weldon brother