Day 2:  Beyond the Basics - Unveiling Powerful Linux Commands

Day 2: Beyond the Basics - Unveiling Powerful Linux Commands

Continuing my DevOps refresh! Today, we're diving deeper into Linux commands.

While staple commands are readily available online, I'll be focusing on some hidden gems

Command:

File and Directory Handling:

  • tree - Shows a visual tree-like representation of the directory structure.

  • stat filename - Displays detailed information about a file, including permissions, size, timestamps, inode, blocks, links, and owner.

  • du -h directory - Estimates disk usage of a directory and its contents in a human-readable format.

  • find . -name "*.txt" -type f -exec grep -l "pattern" {} ; - Finds all .txt files containing a specific pattern and prints their names.

  • ln -s source_file link_name - Creates a symbolic link to a file (like a shortcut).

  • touch filename - Creates an empty file or updates the timestamp of an existing one.

Searching and Viewing Data:

  • tail -f filename - Continuously displays the last lines of a growing file (useful for logs).

  • less filename - Views a file interactively with pagination and search capabilities.

  • grep "pattern" filename - Searches for a pattern within a file and prints matching lines.

  • awk '{print $2, $4}' filename - Processes a file by fields and extracts desired information.

  • sed 's/old/new/g' filename - Performs text replacement within a file (e.g., for substitutions).

System Information and Monitoring:

  • top - Displays real-time information about running processes and resource usage.

  • htop - An enhanced version of top with a visual interface and more interactive features.

  • free - Shows available and used memory in the system.

  • df -h - Shows disk usage and free space for mounted filesystems.

  • ps -aux - Lists information about all running processes.

Network Troubleshooting:

  • ping hostname - Checks connectivity to a remote host by sending ICMP echo requests.

  • traceroute hostname - Traces the path taken by packets to reach a remote host, identifying network hops.

  • netstat -tulpn - Lists active network connections and listening ports.

  • dig domain.com - Queries DNS information for a domain.

Text Manipulation and File Editing:

  • sort filename - Sorts lines of a text file alphabetically or numerically.

  • uniq filename - Removes duplicate lines from a text file.

  • head filename - Prints the first few lines of a file.

  • tail filename - Prints the last few lines of a file.

  • tee filename - Redirects output to both a file and the terminal.

Stay tuned for these lesser-known powerhouses in my blog post, and feel free to share your favorite under-appreciated commands in the comments below!