20% of Linux Commands You'll Use 80% of the Time (Real-World Example) - Summary

Summary

**Summary**

The video shows how to quickly obtain a Linux environment using Docker (install Docker Desktop, pull a custom image, run it as a container) and then walks through a practical troubleshooting scenario for a junior engineer. Inside the container, the presenter demonstrates essential Linux commands:

- **Orientation & navigation** – `uname` (verify OS), `pwd` (print working directory), `ls`/`ls -l` (list files with details), `cd` (change directory).
- **File inspection** – `cat` (view file contents), `grep` (filter lines), pipelines (`|`) to chain commands, `wc -l` (count matching lines).
- **File management** – `cp` (copy files, optionally to a different path), creating backups.
- **Searching the filesystem** – `find` with patterns (`*.conf`) combined with `grep` to locate configuration files.
- **Comparing files** – `diff` to spot differences between a config file and its backup.
- **Editing files** – basic `vim` usage (insert mode with `i`, save & quit with `:wq`), handling permission errors.
- **Permissions** – `chmod` to modify read/write/execute bits (e.g., `chmod 600 file` for owner read/write).
- **Service checks** – `curl -I localhost:5432` to test if a PostgreSQL service is reachable on the expected port.

The troubleshooting flow: check logs → locate error lines → count occurrences → find the DB config file → discover the port is mis‑set (5433 instead of 5432) → verify the DB is actually listening on 5432 → edit the config to correct the port → (optionally) reset permissions and exit the container with `exit`. Throughout, the emphasis is on learning by doing, showing how these core Linux commands let you navigate, inspect, modify, and validate systems efficiently.

Facts

1. The video demonstrates using Linux commands in a terminal.
2. The speaker learned Linux commands as a junior software developer.
3. Learning by doing improves retention of the knowledge.
4. To practice Linux on Mac or Windows, install Docker Desktop.
5. After installing Docker Desktop, run two simple commands to start a Linux environment.
6. Pull a custom Docker image that contains Linux and required tools.
7. Run the image as a container to obtain a Linux terminal.
8. The `uname` command shows the operating system name.
9. `uname` stands for Unix name; Linux is built on Unix.
10. A Linux cheat sheet for the video is available in the video description.
11. A use case involves a junior engineer debugging an inaccessible application.
12. First step in troubleshooting is to check the application logs.
13. Use `pwd` to print the current working directory.
14. Use `cd` to change to the application log directory, e.g., `/var/log/application`.
15. Use `ls` to list files in a directory.
16. Use `ls -l` to view detailed file information including size and permissions.
17. Use `cat` to print the contents of a file.
18. Filter lines containing a specific word with a pipe (`|`) and `grep`.
19. Save command output to a file using the redirection operator (`>`).
20. Verify a file’s existence with `ls`.
21. Confirm a file is not empty with `ls -l` or `cat`.
22. Copy a file for backup using `cp source destination`.
23. Example: copy `database_errors.txt` to `/root/DB_errors.txt`.
24. Count occurrences of a phrase by piping `grep` output to `wc -l`.
25. The error log shows “connection refused” messages.
26. The application attempts to connect to the database on port 5433.
27. The default PostgreSQL port is 5432.
28. Locate configuration files with `find / -name "*.conf"`.
29. Filter results for files containing “db” using `grep`.
30. The configuration file `db.conf` is found in `/c/application`.
31. Use `diff` to compare `db.conf` and its backup to identify changes.
32. The difference shows the port changed from 5432 to 5433.
33. Test database accessibility on port 5432 with `curl -I http://localhost:5432`.
34. A response indicates PostgreSQL is running on port 5432.
35. To fix the issue, edit the config file to set the correct port.
36. Change file permissions to allow editing with `chmod 666 db.conf`.
37. Use `vim` to edit the file: press `i` to insert, make changes, press `Esc`, then type `:wq` to save and quit.
38. After saving, restart the application to connect on the correct port.
39. Exit the Docker container and return to the host terminal with `exit`.
40. Verify the host operating system with `uname`, which shows Darwin on macOS.