The command line interface (CLI) is an indispensable tool for web developers. This comprehensive guide covers essential commands for daily development tasks, from file management to version control.

File System Navigation and Management

Basic Navigation

bashCopypwd                     # Print working directory
ls                     # List directory contents
ls -la                 # List all files including hidden ones with details
cd directory_name      # Change directory
cd ..                  # Move up one directory
cd ~                   # Go to home directory

File Operations

bashCopytouch filename         # Create empty file
mkdir directory_name   # Create directory
rmdir directory_name   # Remove empty directory
rm filename           # Remove file
rm -r directory_name  # Remove directory and contents
rm -rf directory_name # Force remove directory and contents (use with caution)
cp source destination # Copy file
mv source destination # Move/rename file

File Permissions

bashCopychmod 755 filename    # Change file permissions
chown user:group file # Change file ownership

SSH Operations

Connection

bashCopyssh username@hostname                  # Connect to remote server
ssh -p port username@hostname         # Connect using specific port
scp file.txt username@hostname:/path  # Copy file to remote server
scp username@hostname:/path file.txt  # Copy file from remote server

Key Management

bashCopyssh-keygen -t rsa                     # Generate SSH key pair
ssh-copy-id username@hostname         # Copy SSH key to server

Git Version Control

Repository Operations

bashCopygit init                              # Initialize repository
git clone repository_url              # Clone repository
git remote add origin repository_url  # Add remote repository
git remote -v                         # View remote repositories

Basic Commands

bashCopygit status                            # Check repository status
git add filename                      # Stage file
git add .                            # Stage all changes
git commit -m "message"              # Commit changes
git push origin branch_name          # Push changes
git pull origin branch_name          # Pull changes

Branch Management

bashCopygit branch                           # List branches
git branch branch_name               # Create branch
git checkout branch_name             # Switch branch
git checkout -b branch_name          # Create and switch branch
git merge branch_name                # Merge branch

WordPress CLI

Core Management

bashCopywp core download                      # Download WordPress
wp core install                      # Install WordPress
wp core update                       # Update WordPress

Plugin Management

bashCopywp plugin install plugin_name        # Install plugin
wp plugin activate plugin_name       # Activate plugin
wp plugin deactivate plugin_name    # Deactivate plugin
wp plugin update --all              # Update all plugins

Theme Operations

bashCopywp theme install theme_name         # Install theme
wp theme activate theme_name       # Activate theme
wp theme delete theme_name        # Delete theme

Server Management

Process Management

bashCopyps aux                             # List running processes
top                               # Monitor system processes
kill process_id                   # Terminate process
killall process_name             # Terminate all processes by name

System Information

bashCopydf -h                             # Disk usage
free -m                          # Memory usage
uptime                          # System uptime
uname -a                        # System information

File Content Operations

Viewing and Editing

bashCopycat filename                      # Display file contents
less filename                    # View file with pagination
head filename                   # View first 10 lines
tail filename                  # View last 10 lines
nano filename                 # Edit file with nano
vim filename                 # Edit file with vim

Search Operations

bashCopygrep "pattern" filename         # Search file for pattern
find . -name "pattern"        # Find files by name
locate filename              # Locate files (requires updatedb)

Network Operations

Connectivity

bashCopyping hostname                   # Test network connectivity
traceroute hostname           # Trace route to host
netstat -tulpn               # List network connections
wget url                    # Download file from internet
curl url                   # Transfer data from/to server

Security Best Practices

  1. Always verify commands before execution, especially with rm -rf
  2. Use SSH keys instead of passwords when possible
  3. Keep software and systems updated regularly
  4. Back up important data before major operations
  5. Use version control for code changes
  6. Set appropriate file permissions
  7. Monitor system logs for suspicious activity

Troubleshooting Tips

  1. Check command syntax with –help flag
  2. Verify file paths and permissions
  3. Monitor system resources during operations
  4. Keep backup copies of important files
  5. Use version control to track changes
  6. Test commands in development environment first

Remember to always exercise caution when using powerful commands, especially those that modify or delete files. Consider creating aliases for frequently used commands to improve efficiency and reduce typing errors.