← SnapRecaps

Linux Commands in 30 Mins (Real-World Example)

► 43,665 views ⏲ 32:12 Watch on YouTube ↗

Summary

This video demonstrates how chaining basic Linux commands into pipelines—like grep, find, xargs, and rsync—boosts productivity, using a log investigation scenario.

Executive Summary

This video demonstrates how mastering essential Linux commands can dramatically boost an engineer's productivity, using a realistic web application log investigation as the central scenario. It teaches a workflow of chaining simple tools—like ls, find, grep, cat, xargs, sort, and uniq—to recursively locate files, filter error messages, consolidate duplicates, and save results to a log. The tutorial also covers efficient backups with mkdir, cp, find -exec, and rsync, plus cleanup with rm, highlighting how pipelines and composition let small commands solve complex problems. A brief non-sponsorship segment clarifies F5's NGINX Ingress Controller status. The key takeaway is that Linux's real power comes from combining focused commands, and viewers should start by defining the use case before building the command chain.

Key Points

  • ▶ 0:00 Linux commands are essential for engineers and can " literally 10x your productivity" in managing servers, deploying apps, and troubleshooting.
  • ▶ 0:20 The video teaches commands through a real-world scenario: investigating error messages in a web app's log files, building up commands step by step.
  • ▶ 1:58 Basic file listing starts with ls; then recursive parameters reveal the full directory tree, and find . -type d lists only subfolders.
  • ▶ 4:06 Demonstrates recursive listing that shows only subfolders, not files.
  • ▶ 4:27 Goal is to filter the recursive file listing to show only application-related files.
  • ▶ 4:34 Sample files are hosted in a Git repository, downloadable with subfolders so viewers can follow along exactly.
  • ▶ 4:57 The presenter sets up a realistic example using a web app's logs directory, with separate monthly folders containing both application logs and service logs (Redis, database) to make the demonstration easy to follow.
  • ▶ 5:29 A recursive search is run to list all files under the directory structure, and its output is passed through a filter using the Linux pipe symbol (|), so the first command's output becomes the next command's input.
  • ▶ 6:08 The recursive output is piped into grep to isolate only the application log files (app.ext), which is especially useful at scale—even with many folders, services, and files, it produces a clean overview of just the desired logs.
  • ▶ 6:38 Use find . -type f -name app.ext to recursively search the current folder for files with an exact name like app.ext, returning only files and not directories.
  • ▶ 7:06 find is more informative than simple recursive listing because it shows the full path of each match, revealing exactly where the file is located.
  • ▶ 7:27 To find all files of a given type regardless of name, use a wildcard such as *.txt—this recursively matches every file ending in .txt, which is useful when handling hundreds of files and you only care about one extension.
  • ▶ 8:23 F5 gives a non-sponsorship shoutout to clarify confusion about the NGINX Ingress Controller retirement.
  • ▶ 8:48 The community-maintained controller is being retired after being run by only one or two developers, which led to serious security issues.
  • ▶ 9:06 F5's open-source, Apache 2.0-licensed NGINX Ingress Controller remains available, with all development done openly.
  • ▶ 9:15 EngineX development happens publicly on GitHub with a dedicated full-time team ensuring security updates and feature development.
  • ▶ 9:29 Migration is straightforward: EngineX uses the same engine users already know, most Ingress annotations have direct equivalents, and a migration guide keeps the learning curve minimal.
  • ▶ 9:45 EngineX is production-ready and widely adopted, powering about 40% of Kubernetes ingress deployments with over 10 million downloads.
  • ▶ 10:26 After locating files, the next step is to inspect their contents to investigate actual errors and issues in application logs.
  • ▶ 10:48 The cat command displays file contents, and the full file path (using . for current directory and / for subfolders) can be used directly.
  • ▶ 11:39 Running cat on each file individually is inefficient, so the goal becomes using a single command to show the contents of all relevant files (e.g., all app.txt files) at once.
  • ▶ 12:13 Use find . -type f -name "*.txt" to recursively locate all matching log files.
  • ▶ 12:42 Piping the file list directly into cat fails because cat expects filenames as arguments, not standard input.
  • ▶ 13:18 Use xargs to convert the previous command’s output into arguments, effectively running find . -type f -name "*.txt" | xargs cat to display all matched file contents.
  • ▶ 14:38 Extend the command chain with grep to filter out non-error lines, resulting in a much cleaner error-only output across all log files.
  • ▶ 16:14 Running sort on the filtered output does not group duplicate error messages as expected because each line begins with a timestamp, so it sorts chronologically by time.
  • ▶ 16:31 Sorting by timestamp can still be useful for timeline analysis, but it won't automatically group duplicate error messages together.
  • ▶ 17:33 Use sort -k4 to sort log lines by the error message field instead of the timestamp, grouping duplicate errors together.
  • ▶ 19:30 Pipe the sorted output into uniq -f to skip the timestamp fields and keep only unique error messages across all log files.
  • ▶ 20:46 Save the final pipeline output to a file with > (overwrite) or >> (append), e.g., errors.log, for easy reuse and inspection.
  • ▶ 22:57 Logs contain valuable info and get deleted by an automated cleanup script, so a backup of all log files is needed on a separate backup server.
  • ▶ 23:41 Create a backup directory with mkdir and verify it exists with ls; copying files one by one with cp is impractical for many files.
  • ▶ 26:01 The find -exec parameter runs a command like cp for every file found, using {} as a placeholder for each current file in a loop-like backup operation.
  • ▶ 27:41 find -exec requires an escaped semicolon (\;) to mark the end of the command block, so Linux treats it as a special terminator instead of a literal character.
  • ▶ 28:52 rsync solves the duplicate-filename problem by preserving the original directory structure, making it a more powerful tool for backups than plain cp.
  • ▶ 30:15 Cleanup can be done efficiently with rm and a regular expression to remove all matching files at once, rather than listing each file individually.
  • ▶ 30:38 Recap: analyzed log files, consolidated error messages, fixed issues, and backed up logs before cleanup.
  • ▶ 31:07 Key takeaway: Linux's power comes from combining simple commands to solve complex problems—small focused tools that work together.
  • ▶ 31:33 Advice: Practice combining commands, and start by defining the use case before choosing the command chain.

Video Sections

  • ▶ 0:00 Introduction and Basic File Listing (0:00 - 4:12) - - Introduces Linux’s importance and covers listing files and directories with ls and find.
  • ▶ 4:12 Recursive Search and Log Investigation Setup (4:12 - 12:13) - - Sets up a practice repo, demonstrates recursive find/pipe filtering, includes a sponsor break, and prepares log inspection with cat and clearing the terminal.
  • ▶ 12:13 Using find, Pipes, and xargs (12:13 - 14:02) - - Chains find with xargs to display all matching log files at once.
  • ▶ 13:59 Filtering and Sorting Logs (13:59 - 16:47) - - Filters log noise with grep and begins identifying duplicate errors with sort.
  • ▶ 16:47 Sorting, Unique Lines, and Redirection (16:47 - 22:39) - - Refines output using sort -k and uniq, then saves results with > and appends with >>.
  • ▶ 22:39 Backup and Copying with find -exec (22:39 - 27:08) - - Creates a backup directory and copies multiple files using cp with find -exec.
  • ▶ 27:08 Copy Conflicts, rsync, and Cleanup (27:08 - 30:38) - - Covers -exec syntax, duplicate filename conflicts, rsync for preserving structure, and removing files with rm.
  • ▶ 30:38 Conclusion and Closing Remarks (30:38 - 32:14) - - Recaps combining small focused commands and invites viewers to share the video.

Exact Transcript

Load the full timestamped transcript on demand and click any time to jump in the video.