Learning Linux Commands in a Docker Environment
Introduction
- Transform your terminal skills into a superpower.
- Learn by doing: Follow along with Linux commands.
- Use Docker to set up a Linux environment on Mac or Windows.
Setting Up Docker
- Download Docker Desktop
- Available for Windows or Mac.
- No prior knowledge of Docker needed.
- Run Docker Image
- Download a custom Linux Docker image (link provided in the video description).
- Execute the command to fetch and run the image as a container.
Basic Linux Commands
Validate Linux Environment
- Command:
uname
- Checks and displays the operating system name.
Navigating the File System
- Current Directory:
PWD (Print Working Directory)
- Shows current directory path.
- Change Directory:
CD [directory]
- Navigate to desired directory, e.g.,
/var/log/application.
Listing Files
- List Files:
LS
- Displays files and directories in current directory.
- Extended File Info:
LS -L
- Shows detailed file info including size and permissions.
Viewing and Manipulating Files
- View File Content:
cat [file]
- Outputs contents of a file.
- Filter Content:
grep [pattern]
- Filters lines containing specific words or phrases.
- Use pipe
| to chain commands.
- Save Output to File:
> [output-file]
- Redirects and saves command output to a file.
File Operations
- Copy Files:
CP [source] [destination]
- Copies files to a new location.
- Count Specific Lines:
grep [pattern] | wc -l
- Counts lines containing specific pattern.
Debugging and Configuration
Identifying Configuration Issues
- Search Configuration Files:
find [directory] -name "*.conf"
- Finds configuration files across directories.
- Compare Files:
diff [file1] [file2]
- Shows differences between two files.*
Networking and Service Checks
- Check Service Accessibility:
curl -I [url]
- Checks if a service is running on a specific port.
Editing Files
- Edit Files with Vim:
vim [file]
- Command line text editor; use
i for edit mode, esc for navigation.
- Change File Permissions:
chmod [permissions] [file]
- Modify file permissions (e.g.,
chmod 666 for read/write).
Wrapping Up
- Exit Docker Container:
exit
- Returns to the host operating system terminal.
Conclusion
- Using Linux commands enhances troubleshooting and operational efficiency.
- Commands allow file navigation, editing, permission changes, and more.
- Share the knowledge with others who might benefit.
Feel free to share the video with friends or colleagues to help them master Linux command-line skills.