Basics of Debugging Linux Shell Scripts

Basics of Debugging Linux Shell Scripts

There are two ways to specify debugging options. One is to specify options when executing the <span>bash</span> command: # -x prints commands and their arguments during execution bash -x debug.sh The other is to set it in the <span>bash</span> script using the built-in command <span>set</span>: #!/bin/bash set -x # Enable debugging # Here is some … Read more

Daily Linux Knowledge: What is a Shell Script

Daily Linux Knowledge: What is a Shell Script

A Shell is a command interpreter responsible for receiving user input commands and passing them to the operating system kernel for execution. Common shells include Bash (Bourne Again Shell), Zsh, and Ksh, with Bash being the default shell for most Linux distributions. A Shell script is a series of shell commands written in text form, … Read more

Usage and Best Practices of Linux Shebang (#!)

In many script files, we can see the following code on the <span>first line</span>: #!/bin/bash 或 #!/usr/bin/env python Carefully observe that the first line of the script file starts with the characters <span>#!</span>. This character sequence consisting of <span>hash</span> and <span>exclamation mark</span> is called <span>Shebang</span> (also known as <span>Hashbang</span>). Its purpose is to tell the … Read more

Parsing Command Line Arguments in Linux Using Shift

<span>shift</span> is a built-in command in <span>Bash</span> that shifts the positional parameters to the left, reassigning the values of <span>$1</span>, <span>$2</span>, <span>$3</span>, etc. $ bash -c "help shift" shift: shift [n] The positional parameters from $N+1 … are renamed to $1 … If N is not given, it is assumed to be 1. It is … Read more

Understanding the exec 3<&0 Mechanism in Linux

One day, I suddenly wanted to implement a Redis client using Bash, adhering to the principle of <span>not reinventing the wheel</span>, and discovered an open-source library redi.sh[1]. As a client, it is essential to establish a TCP connection with the server. Driven by curiosity, I studied its source code: exec {FD}&lt;&gt; /dev/tcp/"$REDIS_HOST"/"$REDIS_PORT" As shown above, … Read more

Frequently Used Linux Shortcuts (Part 1)

In the Linux environment, many shortcuts are used regularly. Here, I share some shortcuts and methods that can improve efficiency, hoping they will be useful to you. In Linux, implementing command auto-matching from history mainly relies on command line completion and history command search. Below are several commonly used methods: 1. Quickly match historical commands … Read more

Some Cool Tricks with the Linux Bash Prompt

Some Cool Tricks with the Linux Bash Prompt

(Click the public account above to quickly follow) Author: Dave Neary, Translation: Linux China/toyijiu linux.cn/article-8711-1.html If you have good articles to submit, please click → here for details When you open a Shell terminal in a Linux environment, you will see a Bash prompt that looks something like this: [user@$host ~]$ Did you know that … Read more

Comprehensive Guide to Linux Shell Scripting

Comprehensive Guide to Linux Shell Scripting

This section shares tutorials on shell scripting programming under Linux. We introduce the content starting from the most basic concepts, allowing beginners to grasp this skill through the tutorials. Each knowledge point is detailed with corresponding code examples. You can access the link below to enter: http://www.mdrsec.com/#/ctoplus_article/e89ae5f7a30c68f5b6d4725feb7a8e1d You can also enter from the official system’s … Read more

Automated Docker Deployment Script on Rocky Linux 9

Automated Docker Deployment Script on Rocky Linux 9

Note: This script is currently limited to <span>Rocky Linux 9</span> and has not been tested on other system versions. Future updates will enhance the script’s compatibility, robustness, and options. The installed <span>Docker</span> version defaults to the latest version. 🛠️ Preparation Work A minimal installation of the Rocky Linux 9 operating system A stable internet connection … Read more

User Management Guide for Linux Beginners: Master User Management Skills!

User Management Guide for Linux Beginners: Master User Management Skills!

Linux | Red Hat Certification | IT Technology | Operations Engineer👇 Join our technical exchange QQ group with 1000 members Note: [Official Account] for faster approval 1. Relevant Knowledge To complete this section’s tasks, you need to master the following knowledge: Linux create user command Linux delete user command 1.1 Linux Create User Command 1.1.1 … Read more