Update tech_docs/edge-compute-k3s.md
This commit is contained in:
@@ -416,6 +416,230 @@ This approach adds **actionable examples** to help you dive deeper into advanced
|
||||
|
||||
---
|
||||
|
||||
Absolutely! Here are additional **CLI learning tips** to enhance your mastery of Linux and shell scripting. These tips are designed to help you deepen your understanding of the command line, make your work more efficient, and improve your problem-solving skills.
|
||||
|
||||
---
|
||||
|
||||
### **1. Master Command-Line Navigation**
|
||||
|
||||
- **Tip**: Practice basic navigation commands until they become second nature:
|
||||
- `cd`: Change directory.
|
||||
- `ls`: List directory contents.
|
||||
- `pwd`: Print current working directory.
|
||||
- `mkdir`/`rmdir`: Create and remove directories.
|
||||
|
||||
- **Try this**:
|
||||
- Create a directory structure, navigate through it, and practice moving and renaming files:
|
||||
```bash
|
||||
mkdir -p ~/projects/k3s/python
|
||||
cd ~/projects/k3s
|
||||
mv python/ ~/projects/
|
||||
```
|
||||
|
||||
### **2. Command History and Shortcuts**
|
||||
|
||||
- **Tip**: Use the **command history** to save time when repeating or modifying commands.
|
||||
- Use the `up` and `down` arrow keys to scroll through previously executed commands.
|
||||
- Use `!!` to re-run the last command or `!<number>` to run a specific command from history.
|
||||
- `Ctrl + r`: Search through command history interactively.
|
||||
|
||||
- **Try this**:
|
||||
- Run multiple commands and practice recalling them using `history` and `!<number>`.
|
||||
```bash
|
||||
history
|
||||
!45 # Re-run command number 45
|
||||
```
|
||||
|
||||
### **3. Tab Completion and Wildcards**
|
||||
|
||||
- **Tip**: Use **tab completion** to autocomplete file names, paths, and commands, which will make you faster and reduce errors.
|
||||
|
||||
- **Wildcards**: Use wildcards like `*` and `?` to work with multiple files or patterns:
|
||||
- `*.txt`: Match all files with `.txt` extension.
|
||||
- `file?.txt`: Match files with one-character differences (e.g., `file1.txt`, `file2.txt`).
|
||||
|
||||
- **Try this**:
|
||||
- Practice file matching and renaming using wildcards:
|
||||
```bash
|
||||
mv *.log ~/logs/ # Move all .log files to logs directory
|
||||
```
|
||||
|
||||
### **4. Learn to Use `man` and `help`**
|
||||
|
||||
- **Tip**: Whenever you’re unsure how a command works, use `man` (manual pages) or `--help`:
|
||||
- `man ls`: Get the manual for the `ls` command.
|
||||
- `ls --help`: Get a quick overview of the command options.
|
||||
|
||||
- **Try this**:
|
||||
- Explore the options of a new command you haven’t used before, like `find` or `tar`:
|
||||
```bash
|
||||
man find
|
||||
```
|
||||
|
||||
### **5. Chain Commands with Pipes and Redirection**
|
||||
|
||||
- **Tip**: Learn how to **chain commands** together to process data more effectively:
|
||||
- Use `|` (pipe) to send the output of one command as input to another.
|
||||
```bash
|
||||
ps aux | grep python
|
||||
```
|
||||
- Use `>` to redirect output to a file, and `>>` to append.
|
||||
```bash
|
||||
df -h > disk-usage.txt # Save disk usage output to a file
|
||||
```
|
||||
|
||||
- **Try this**:
|
||||
- Combine pipes and redirection to filter and store information:
|
||||
```bash
|
||||
ps aux | grep k3s > k3s-processes.txt
|
||||
```
|
||||
|
||||
### **6. Automate Tasks with Aliases**
|
||||
|
||||
- **Tip**: Define **aliases** for frequently used commands to save time.
|
||||
- Open `~/.bashrc` and add your aliases:
|
||||
```bash
|
||||
alias ll='ls -lah'
|
||||
alias upd='sudo dnf update -y && sudo dnf upgrade -y'
|
||||
```
|
||||
- Reload the `.bashrc`:
|
||||
```bash
|
||||
source ~/.bashrc
|
||||
```
|
||||
|
||||
- **Try this**:
|
||||
- Define your own alias for frequently run commands or scripts, like K3s or Python management tasks.
|
||||
|
||||
### **7. Learn to Use `grep`, `awk`, and `sed`**
|
||||
|
||||
- **Tip**: Master text processing tools like `grep`, `awk`, and `sed` for searching and manipulating text output:
|
||||
- `grep`: Search for patterns in files or output.
|
||||
```bash
|
||||
grep "error" /var/log/syslog
|
||||
```
|
||||
- `awk`: Process and extract fields from structured data.
|
||||
```bash
|
||||
awk '{print $1, $5}' /path/to/file
|
||||
```
|
||||
- `sed`: Stream editor for text substitution.
|
||||
```bash
|
||||
sed 's/error/success/g' file.txt # Replace 'error' with 'success' in the file
|
||||
```
|
||||
|
||||
- **Try this**:
|
||||
- Extract useful information from logs or system commands using `grep`:
|
||||
```bash
|
||||
ps aux | grep k3s
|
||||
```
|
||||
|
||||
### **8. Create More Complex Bash Scripts**
|
||||
|
||||
- **Tip**: Start combining loops, conditionals, and functions in your scripts to automate more complex tasks:
|
||||
- **For loops**: Iterate over a list of items.
|
||||
```bash
|
||||
for file in *.txt; do
|
||||
echo "Processing $file"
|
||||
done
|
||||
```
|
||||
- **If statements**: Add conditional logic.
|
||||
```bash
|
||||
if [ -f /path/to/file ]; then
|
||||
echo "File exists"
|
||||
else
|
||||
echo "File not found"
|
||||
fi
|
||||
```
|
||||
|
||||
- **Try this**:
|
||||
- Create a script that checks if a service is running and restarts it if necessary:
|
||||
```bash
|
||||
#!/bin/bash
|
||||
if systemctl is-active --quiet k3s; then
|
||||
echo "K3s is running"
|
||||
else
|
||||
echo "K3s is not running, restarting..."
|
||||
sudo systemctl restart k3s
|
||||
fi
|
||||
```
|
||||
|
||||
### **9. Explore `tmux` or `screen` for Multitasking**
|
||||
|
||||
- **Tip**: Use `tmux` or `screen` to manage multiple CLI sessions within a single terminal. This is especially useful when running long tasks or managing multiple remote connections.
|
||||
|
||||
- **Try this**:
|
||||
- Install and use `tmux`:
|
||||
```bash
|
||||
sudo dnf install tmux
|
||||
tmux
|
||||
```
|
||||
- Split the screen and run different tasks in separate panes.
|
||||
|
||||
### **10. Learn Networking Commands**
|
||||
|
||||
- **Tip**: Gain familiarity with networking-related commands to troubleshoot connectivity:
|
||||
- `ping`: Check connectivity to another host.
|
||||
```bash
|
||||
ping 8.8.8.8
|
||||
```
|
||||
- `traceroute`: See the path packets take to a destination.
|
||||
```bash
|
||||
traceroute google.com
|
||||
```
|
||||
- `netstat`: Check open network connections.
|
||||
```bash
|
||||
netstat -tuln
|
||||
```
|
||||
|
||||
- **Try this**:
|
||||
- Run `netstat` or `ss` to inspect which ports are open and which services are listening:
|
||||
```bash
|
||||
netstat -tuln
|
||||
```
|
||||
|
||||
### **11. Practice Permissions and Ownership**
|
||||
|
||||
- **Tip**: Understanding file permissions is critical for securing your system. Learn the basics of `chmod`, `chown`, and `chgrp`.
|
||||
- `chmod`: Change file permissions.
|
||||
```bash
|
||||
chmod 755 script.sh
|
||||
```
|
||||
- `chown`: Change file ownership.
|
||||
```bash
|
||||
chown user:group file.txt
|
||||
```
|
||||
|
||||
- **Try this**:
|
||||
- Modify file permissions on a script to make it executable only by you:
|
||||
```bash
|
||||
chmod 700 myscript.sh
|
||||
```
|
||||
|
||||
### **12. Learn Job Control: Background Jobs and Process Management**
|
||||
|
||||
- **Tip**: Use job control features to manage processes in the foreground and background:
|
||||
- Run a command in the background by appending `&`:
|
||||
```bash
|
||||
long_process & # Runs long_process in the background
|
||||
```
|
||||
- Use `jobs` to list background jobs and `fg` to bring one to the foreground:
|
||||
```bash
|
||||
jobs
|
||||
fg %1 # Bring job 1 to foreground
|
||||
```
|
||||
|
||||
- **Try this**:
|
||||
- Start a long-running command in the background and monitor it using `jobs`.
|
||||
|
||||
---
|
||||
|
||||
### **Conclusion**
|
||||
|
||||
By incorporating these CLI learning tips, you’ll not only increase your proficiency with Linux commands but also develop more robust skills in automation, scripting, and problem-solving. As you continue setting up and managing your system, these techniques will help you work more efficiently and tackle increasingly complex tasks with confidence.
|
||||
|
||||
Make sure to practice these techniques daily and gradually incorporate them into your workflows. The more you explore the Linux command line, the more intuitive it will become.
|
||||
|
||||
---
|
||||
|
||||
# Learning Roadmap for K3s, Edge Computing, and Advanced Networking
|
||||
|
||||
## Networking Basics
|
||||
|
||||
Reference in New Issue
Block a user