SystemsBeginner2 - 3 tháng

Shell Bash

Lộ trình phát triển toàn diện Shell Bash theo tiêu chuẩn quốc tế nilbuild/developer-roadmap

Hướng dẫn từng bước từ nền tảng đến chuyên sâu giúp bạn làm chủ Shell Bash. Tích hợp tài liệu lý thuyết, bài viết thực chiến, video tham khảo và bài tập lập trình trực tiếp trên IDE.

Giai đoạn:5 Phases
Mô-đun:174 Kỹ năng
Thực hành:15 Bài Lab IDE
Tiêu chuẩn:nilbuild/roadmap
⚡ Trình biên dịch IDE trực tuyến: Làm chủ kỹ năng thông qua thực hành viết mã và kiểm thử tự động.
Mở IDE Thực Hành Lộ Trình Này →
Bộ lọc:
Thành thạo:0% (0/0)
01
Giai đoạn 1Xây dựng tư duy kiến trúc và công cụ nền tảng

Nền Tảng & Khái Niệm Cốt Lõi

Giai đoạn 1 tập trung hoàn thiện 35 chủ đề then chốt.

Cốt lõiKiến thức

$0 in Shell Scripting

In shell scripting, `$0` is a special variable that holds the name of the script being executed. It essentially represents the command used to invoke the script. This can be the script's filename, or if the script was invoked with a path, it will contain that path. `$0` is useful for identifying the script itself within the script's code, for example, in logging or error messages.

$0inEngineering
3 khái niệmChi tiết
Cốt lõiKiến thức

Positional Parameters

Positional parameters in shell scripting are variables that hold the command-line arguments passed to a script. These parameters are represented by special variables like `$1`, `$2`, `$3`, and so on, where each number corresponds to the order in which the argument was provided when the script was executed. `$1` holds the first argument, `$2` the second, and so forth, allowing scripts to access and process input provided by the user.

PositionalParametersEngineering
1 khái niệmChi tiết
Cốt lõiKiến thức

$*

`$*` is a special variable in shell scripting that expands to all the positional parameters (arguments) passed to a script or function. It represents all the arguments as a single string, with each argument separated by the first character of the `IFS` (Internal Field Separator) variable, which defaults to a space, tab, and newline. This allows you to easily access and iterate over all the arguments provided to your script.

$*CoreEngineering
1 khái niệmChi tiết
Khuyên họcKiến thức

Number of Script Arguments ($#)

`$#` is a special variable in shell scripting that represents the number of arguments passed to a script when it is executed. It's a simple integer value that allows you to determine how many inputs the user provided when running your script, enabling you to write logic that handles different scenarios based on the number of arguments.

NumberofEngineering
3 khái niệmChi tiết
Cốt lõiKiến thức

Exit Codes and $?

Exit codes are numerical values returned by a program or script upon completion, signaling whether it executed successfully or encountered an error. The special variable `$?` in Bash stores the exit code of the most recently executed command. A value of 0 typically indicates success, while any non-zero value signifies failure, with different numbers often representing specific error types.

ExitCodesEngineering
2 khái niệmChi tiết
Khuyên họcKiến thức

Curly Braces Wildcards

Curly braces `{}` are used for multiple matches. Each string can be an exact name, or a wildcard. It will find anything that matches any of the given strings using an or relationship (one OR the other). For example, `touch file{1,2,3}.txt` will create three files: `file1.txt`, `file2.txt`, and `file3.txt`.

CurlyBracesEngineering
3 khái niệmChi tiết
Cốt lõiKiến thức

Square Bracket Wildcards in Shell/Bash

Square brackets `[]` in shell wildcards define a character class, matching any single character _within_ the brackets. This allows you to specify a range or set of characters to match in a filename or string. For example, `[abc]` will match either 'a', 'b', or 'c'. You can also use ranges like `[a-z]` to match any lowercase letter or `[0-9]` to match any digit. A caret `^` inside the brackets negates the character class, matching any character _not_ listed (e.g., `[^0-9]` matches anything that isn't a digit).

SquareBracketEngineering
3 khái niệmChi tiết
Khuyên họcKiến thức

Wildcard Question Mark (?)

The question mark (?) wildcard is a single-character wildcard. It matches exactly one occurrence of any character. This means that when used in a pattern, it will be replaced by any single character in a filename or string, allowing you to match files or strings with slight variations in their names or content.

WildcardQuestionEngineering
3 khái niệmChi tiết
Cốt lõiKiến thức

Script Arguments using $@

`$@` is a special variable in shell scripting that expands to all the positional parameters (arguments) passed to a script. Each argument is treated as a separate word, even if it contains spaces, ensuring that the script receives and processes each argument individually. This is particularly useful when you need to iterate over or manipulate each argument provided to your script.

ScriptArgumentsEngineering
1 khái niệmChi tiết
Khuyên họcKiến thức

Asterisk Wildcard

The asterisk (\*) is a wildcard character that represents zero or more characters. It's used in commands and file paths to match multiple files or directories based on a pattern. For example, `*.txt` will match all files ending with ".txt", and `data*` will match files or directories starting with "data".

AsteriskWildcardEngineering
3 khái niệmChi tiết
Cốt lõiKiến thức

apt

`apt` (Advanced Package Tool) is a command-line package management system used primarily on Debian-based Linux distributions like Ubuntu. It simplifies the process of installing, updating, removing, and managing software packages by retrieving them from configured repositories and handling dependencies automatically. `apt` provides a user-friendly interface for interacting with the underlying Debian package management system (`dpkg`).

aptCoreEngineering
1 khái niệmChi tiết
Khuyên họcKiến thức

Arithmetic Expansion

Arithmetic expansion allows you to perform mathematical calculations directly within your shell scripts. It uses the `$((...))` syntax to evaluate expressions, treating the contents inside the parentheses as an arithmetic expression. This enables you to perform operations like addition, subtraction, multiplication, division, and modulo, and assign the results to variables or use them in conditional statements.

ArithmeticExpansionEngineering
3 khái niệmChi tiết
Cốt lõiKiến thức

Arithmetic Operators in Bash

Arithmetic operators in Bash are symbols used to perform mathematical calculations within shell scripts. These operators allow you to add, subtract, multiply, divide, and find the remainder of numbers directly within your scripts, enabling you to perform calculations and manipulate numerical data. Bash primarily uses integer arithmetic, but there are ways to work with floating-point numbers as well.

ArithmeticOperatorsEngineering
2 khái niệmChi tiết
Khuyên họcKiến thức

Arrays

Arrays are ordered collections of elements, where each element can be accessed using an index. They allow you to store multiple values under a single variable name, making it easier to manage and manipulate related data. In Bash, arrays can hold strings or numbers, and they are indexed starting from zero.

ArraysCoreEngineering
2 khái niệmChi tiết
Cốt lõiIDE Lab

Associative Arrays

Associative arrays, also known as dictionaries or hash maps in other programming languages, are data structures that store key-value pairs. Unlike regular arrays which use numerical indexes to access elements, associative arrays use strings (or other data types in some languages) as keys. This allows you to retrieve values based on meaningful names rather than just positions.

AssociativeArraysEngineering
1 khái niệmChi tiết
Khuyên họcKiến thức

at

The `at` command in Unix-like operating systems is used to schedule commands to be executed at a specific time. It allows you to specify a time and date, and then provide a command that will be run automatically at that designated time. This is useful for automating tasks that need to be performed at a later time without requiring manual intervention.

atCoreEngineering
2 khái niệmChi tiết
Cốt lõiKiến thức

Awk for Numeric Operations

Awk is a powerful text processing tool that can also perform numeric calculations. It reads input line by line and executes a set of instructions for each line. These instructions can include arithmetic operations, comparisons, and variable assignments, making awk useful for tasks like calculating sums, averages, and performing other data manipulations directly within the shell.

AwkforEngineering
2 khái niệmChi tiết
Khuyên họcIDE Lab

awk

`awk` is a powerful text processing tool in Unix-like operating systems. It scans input files line by line, searching for lines that match a specified pattern. When a matching line is found, `awk` performs a specified action on that line, such as printing it, modifying it, or extracting specific fields. It's particularly useful for manipulating data within files and generating reports.

awkCoreEngineering
3 khái niệmChi tiết
Cốt lõiKiến thức

Bash -n

The `bash -n` option is a debugging tool that allows you to perform a syntax check on your Bash script without actually executing it. This is useful for identifying errors like typos, missing keywords, or incorrect syntax before running the script and potentially causing unintended consequences. It essentially parses the script and reports any syntax errors it finds.

Bash-nEngineering
1 khái niệmChi tiết
Khuyên họcKiến thức

Bash Alias

A Bash alias is a shortcut or a custom name you assign to a command or a sequence of commands. Instead of typing a long command every time, you can create an alias that represents it. When you type the alias in the terminal, Bash replaces it with the original command before executing it. This simplifies command-line usage and improves efficiency.

BashAliasEngineering
3 khái niệmChi tiết
Cốt lõiKiến thức

Bash Data Types

Bash, unlike some other programming languages, doesn't have explicit data types like integers, floats, or strings that you need to declare. Instead, everything is treated as a string. However, Bash can perform arithmetic operations on strings that contain numbers, effectively treating them as numerical values when needed. Arrays are also supported, allowing you to store collections of string values.

BashDataEngineering
2 khái niệmChi tiết
Khuyên họcKiến thức

Bash Debug

The Bash Debug extension for VS Code, powered by `bashdb`, allows you to debug Bash scripts directly within the VS Code editor. It provides features like breakpoints, stepping through code, inspecting variables, and evaluating expressions, making it easier to identify and fix errors in your Bash scripts. This helps streamline the debugging process, offering a more visual and interactive experience compared to traditional methods like using `set -x` or `echo` statements.

BashDebugEngineering
3 khái niệmChi tiết
Cốt lõiKiến thức

Bash Operators

Bash operators are special symbols or characters that perform specific actions or comparisons within a Bash script or command line. They are fundamental building blocks for controlling program flow, manipulating data, and performing various operations like arithmetic calculations, string comparisons, file manipulations, and logical evaluations. Understanding and using these operators effectively is crucial for writing robust and efficient Bash scripts.

BashOperatorsEngineering
1 khái niệmChi tiết
Khuyên họcKiến thức

Bash Script Anatomy

A Bash script is essentially a plain text file containing a series of commands that the Bash interpreter executes sequentially. It typically starts with a shebang line specifying the interpreter to use, followed by comments explaining the script's purpose, and then the actual commands that perform the desired actions, including variable assignments, control structures (like loops and conditional statements), and function definitions.

BashScriptEngineering
3 khái niệmChi tiết
Cốt lõiKiến thức

Bash

Bash, short for Bourne Again Shell, is a command-line interpreter and a shell scripting language. It's a program that allows users to interact with the operating system by typing commands. Bash interprets these commands and instructs the operating system to perform specific actions, making it a fundamental tool for system administration, automation, and software development.

BashCoreEngineering
2 khái niệmChi tiết
Khuyên họcIDE Lab

Basic Editor Operations

Basic editor operations involve fundamental actions performed within a text editor to create, modify, and manage files. These operations include opening, saving, and closing files, as well as inserting, deleting, copying, and pasting text. Navigating through a file, searching for specific content, and replacing text are also key components of basic editor operations.

BasicEditorEngineering
2 khái niệmChi tiết
Cốt lõiIDE Lab

Basic Regex Syntax

Regular expressions (regex) are sequences of characters that define a search pattern. They are used to match, locate, and manipulate text based on patterns. Basic regex syntax involves using special characters and metacharacters to represent different types of patterns, such as specific characters, character classes, repetitions, and anchors within a string. These patterns are then used by tools like `grep`, `sed`, and `awk` to perform powerful text processing tasks.

BasicRegexEngineering
3 khái niệmChi tiết
Khuyên họcKiến thức

bc

`bc` is a command-line utility for arbitrary-precision arithmetic. It allows you to perform calculations with numbers of any size and with a specified level of decimal precision, making it suitable for tasks where standard shell arithmetic is insufficient. `bc` can be used interactively or non-interactively, reading expressions from standard input or from files.

bcCoreEngineering
2 khái niệmChi tiết
Cốt lõiKiến thức

Break and Continue in Loops

`break` and `continue` are control flow statements used within loops to alter their execution. The `break` statement immediately terminates the loop, transferring control to the next statement after the loop. The `continue` statement skips the rest of the current iteration of the loop and proceeds to the next iteration.

BreakandEngineering
3 khái niệmChi tiết
Khuyên họcKiến thức

Homebrew

Homebrew is a package manager for macOS (and Linux). It simplifies the installation of software on these operating systems by automating the process of downloading, compiling, and installing software packages from the command line. It's often used to install tools and utilities that aren't included by default in the operating system.

HomebrewCoreEngineering
2 khái niệmChi tiết
Cốt lõiKiến thức

bzip2 and xz

`bzip2` and `xz` are command-line tools used for file compression in Unix-like operating systems. They reduce the size of files, making them easier to store and transfer. `bzip2` generally offers higher compression than `gzip` but is slower, while `xz` provides even better compression ratios and is often used for distributing software packages, though it can be slower than both `gzip` and `bzip2`.

bzip2andEngineering
2 khái niệmChi tiết
Khuyên họcKiến thức

Case Conversion

Case conversion involves changing the case of characters within a string. This typically means converting lowercase letters to uppercase, uppercase letters to lowercase, or applying title case (where the first letter of each word is capitalized). It's a common operation for standardizing data, improving readability, or fulfilling specific formatting requirements.

CaseConversionEngineering
2 khái niệmChi tiết
Cốt lõiKiến thức

Case Statements

Case statements provide a way to execute different blocks of code based on the value of a variable or expression. They offer a structured alternative to multiple `if-elif-else` statements, making code more readable and maintainable when dealing with several possible conditions. Each condition is associated with a specific pattern, and when the variable's value matches a pattern, the corresponding code block is executed.

CaseStatementsEngineering
1 khái niệmChi tiết
Khuyên họcKiến thức

cat

`cat` is a command-line utility that is primarily used to display the contents of one or more files on the standard output (usually your terminal screen). It can also be used to concatenate files, meaning to combine them into a single output stream. The name "cat" is short for "concatenate."

catCoreEngineering
2 khái niệmChi tiết
Cốt lõiKiến thức

cd

`cd` is a fundamental command used to change the current working directory in a shell environment. It allows you to navigate through the file system, moving from one directory to another. By specifying a target directory as an argument, `cd` updates the shell's internal record of the current location, affecting subsequent commands that operate relative to that location.

cdCoreEngineering
2 khái niệmChi tiết
02
Giai đoạn 2Làm chủ các thư viện, framework và luồng xử lý chính

Kỹ Năng Trọng Tâm & Thực Hành

Giai đoạn 2 tập trung hoàn thiện 35 chủ đề then chốt.

Cốt lõiKiến thức

chgrp

`chgrp` is a command-line utility used to change the group ownership of a file or directory. It allows you to specify a new group that should be associated with the file, controlling which users have specific access rights based on group membership. This is a fundamental tool for managing file access and security in Unix-like operating systems.

chgrpCoreEngineering
2 khái niệmChi tiết
Cốt lõiKiến thức

chmod

`chmod` is a command-line utility used to change the access permissions of files or directories. These permissions determine who can read, write, or execute a file. It allows you to control access to your files, ensuring security and proper functionality within a system.

chmodCoreEngineering
3 khái niệmChi tiết
Cốt lõiKiến thức

chown

`chown` is a command-line utility used to change the ownership of files or directories. It allows you to modify the user and/or group associated with a file, effectively controlling who has access and what they can do with it. This is crucial for managing security and access control within a Linux or Unix-like operating system.

chownCoreEngineering
2 khái niệmChi tiết
Khuyên họcIDE Lab

CLI vs GUI

A Command Line Interface (CLI) is a text-based interface used to interact with a computer system by typing commands. A Graphical User Interface (GUI), on the other hand, utilizes visual elements such as windows, icons, and menus to enable users to interact with the system using a mouse, touchpad, or touchscreen.

CLIvsEngineering
1 khái niệmChi tiết
Cốt lõiKiến thức

cmd

cmd, also known as the Command Prompt, is the default command-line interpreter on Windows operating systems. It allows users to interact with the operating system by entering text-based commands. These commands can be used to navigate the file system, execute programs, and perform various system administration tasks.

cmdCoreEngineering
2 khái niệmChi tiết
Khuyên họcKiến thức

Command Substitution

Command substitution allows you to use the output of a command as an argument to another command. It essentially captures the standard output of a command and inserts it into the command line of another command, enabling you to dynamically generate arguments or values based on the results of other commands. This is useful for tasks like assigning the output of a command to a variable, using the output as input to another command, or constructing complex command lines.

CommandSubstitutionEngineering
1 khái niệmChi tiết
Cốt lõiKiến thức

Comments

Comments are explanatory notes added to code to make it easier to understand. They are ignored by the interpreter or compiler, meaning they don't affect how the program runs. They are primarily for human readers to understand the purpose and logic behind the code.

CommentsCoreEngineering
3 khái niệmChi tiết
Khuyên họcKiến thức

Comparison Operators in Bash

Comparison operators in Bash are used to compare values, typically numbers or strings. These operators allow you to create conditional statements within your scripts, enabling different code blocks to execute based on whether a comparison is true or false. They are fundamental for making decisions and controlling the flow of execution in your Bash scripts.

ComparisonOperatorsEngineering
2 khái niệmChi tiết
Cốt lõiKiến thức

Conditionals

Conditionals in shell scripting allow you to execute different blocks of code based on whether a certain condition is true or false. This enables your scripts to make decisions and respond dynamically to different situations, making them more versatile and powerful. Common conditional statements include `if`, `elif` (else if), and `else`, which are used to control the flow of execution based on the evaluation of expressions.

ConditionalsCoreEngineering
3 khái niệmChi tiết
Khuyên họcKiến thức

cp Command

The `cp` command in Unix-like operating systems is used to copy files and directories from one location to another. It creates an exact duplicate of the source file or directory at the specified destination, leaving the original intact. The command can be used to copy single files, multiple files, or entire directory structures.

cpCommandEngineering
3 khái niệmChi tiết
Cốt lõiKiến thức

Variables in Shell Scripting

Variables in shell scripting are named storage locations that hold data. You can create a variable by assigning a value to a name. Printing a variable displays its stored value, and modifying a variable involves changing the value it holds, allowing you to update data within your scripts dynamically.

VariablesinEngineering
2 khái niệmChi tiết
Khuyên họcKiến thức

cron and crontab

cron is a time-based job scheduler in Unix-like operating systems. It allows users to schedule tasks (commands or scripts) to run automatically at specific times, dates, or intervals. The crontab (cron table) is a file that contains the schedule of cron jobs for a user. Each user has their own crontab file, and the system also has a system-wide crontab for administrative tasks.

cronandEngineering
3 khái niệmChi tiết
Cốt lõiKiến thức

curl

curl is a command-line tool used to transfer data with URLs. It supports various protocols like HTTP, HTTPS, FTP, and more, allowing you to download files, send data to servers, and interact with APIs directly from the command line. It's a versatile tool for automating tasks involving network communication.

curlCoreEngineering
2 khái niệmChi tiết
Khuyên họcKiến thức

cut and paste

`cut` and `paste` are command-line utilities used for manipulating text files. `cut` extracts specific sections (columns) from each line of a file based on delimiters or character positions. `paste` merges lines from multiple files into a single output stream, typically by concatenating corresponding lines side-by-side.

cutandEngineering
2 khái niệmChi tiết
Cốt lõiKiến thức

dash

dash (Debian Almquist Shell) is a Unix shell that is smaller, faster, and requires fewer resources compared to Bash. It's often used as the default `/bin/sh` on Debian-based systems and is designed to be POSIX-compliant, focusing on speed and efficiency in script execution. This makes it suitable for boot scripts and other system-level tasks where resource usage is critical.

dashCoreEngineering
2 khái niệmChi tiết
Khuyên họcKiến thức

Debugging

Debugging is the process of identifying and removing errors or defects from software code. It involves systematically testing, analyzing, and correcting issues that cause a program to behave unexpectedly or produce incorrect results. Effective debugging relies on using tools and techniques to trace the flow of execution, inspect variable values, and pinpoint the source of the problem.

DebuggingCoreEngineering
1 khái niệmChi tiết
Cốt lõiKiến thức

df and du Commands

`df` (disk free) and `du` (disk usage) are command-line utilities used to monitor disk space on Unix-like operating systems. `df` provides a summary of available and used disk space on mounted file systems, while `du` estimates the file space usage of files and directories. Together, they help system administrators understand how storage is being utilized and identify potential space issues.

dfandEngineering
1 khái niệmChi tiết
Khuyên họcKiến thức

Direct Execution

Direct execution involves running a shell script by specifying its path directly to the shell. This method requires the script to have execute permissions set. When you directly execute a script, the operating system uses the shebang line (e.g., `#!/bin/bash`) at the beginning of the script to determine which interpreter should be used to execute the script's commands.

DirectExecutionEngineering
3 khái niệmChi tiết
Cốt lõiKiến thức

disown

`disown` is a shell built-in command used to remove jobs from the shell's job control. When you start a process in the background (using `&`), the shell keeps track of it. If you close the terminal, the shell usually sends a SIGHUP signal to these background processes, which often causes them to terminate. `disown` removes a process from this job control, preventing the shell from sending that signal when the terminal closes, allowing the process to continue running independently.

disownCoreEngineering
2 khái niệmChi tiết
Khuyên họcKiến thức

dnf

dnf is a package manager for RPM-based Linux distributions, serving as the successor to YUM (Yellowdog Updater, Modified). It is used to install, update, and remove software packages, as well as manage dependencies. dnf aims to improve upon YUM by offering better performance, more features, and a more modern architecture.

dnfCoreEngineering
2 khái niệmChi tiết
Cốt lõiKiến thức

Echo

`echo` is a fundamental command-line utility used to display lines of text. It essentially prints its arguments to standard output, which is typically your terminal screen. This makes it useful for displaying messages, variable values, or the output of other commands within shell scripts.

EchoCoreEngineering
3 khái niệmChi tiết
Khuyên họcKiến thức

Emacs

Emacs is a highly customizable and extensible text editor, known for its powerful features and extensive ecosystem of extensions. It's more than just a text editor; it's often described as an operating system within an operating system due to its ability to handle tasks like file management, email, and even web browsing, all within its environment. Emacs is favored by programmers and power users who appreciate its flexibility and control over their editing environment.

EmacsCoreEngineering
3 khái niệmChi tiết
Cốt lõiKiến thức

Environment vs. Shell Variables

Environment variables are a set of dynamic named values that can affect the way running processes will behave on a computer. They are part of the environment in which a process runs. Shell variables, on the other hand, are variables that are specific to the current shell session and are not automatically inherited by child processes. They are used to store temporary values or configure the shell's behavior.

Environmentvs.Engineering
2 khái niệmChi tiết
Khuyên họcKiến thức

Error Handling

Error handling in shell scripting refers to the methods and techniques used to detect, manage, and respond to errors that occur during the execution of a script. It involves checking the exit status of commands, using conditional statements to handle different error scenarios, and implementing mechanisms to gracefully exit or recover from errors, ensuring the script's reliability and preventing unexpected behavior.

ErrorHandlingEngineering
3 khái niệmChi tiết
Cốt lõiKiến thức

Error Logging

Error logging is the process of recording errors that occur during the execution of a script or program. This involves capturing information about the error, such as the type of error, the time it occurred, and the location in the code where it happened. Effective error logging facilitates debugging, troubleshooting, and monitoring application health by providing a historical record of issues.

ErrorLoggingEngineering
1 khái niệmChi tiết
Khuyên họcKiến thức

Error Redirection

Error redirection in shell scripting involves capturing and managing error messages generated by commands. By default, standard error (stderr) is displayed on the terminal. Error redirection allows you to redirect these error messages to a file, discard them, or pipe them to another command for further processing, providing better control over script output and debugging.

ErrorRedirectionEngineering
2 khái niệmChi tiết
Cốt lõiKiến thức

Exit Codes

Exit codes are numerical values returned by a program or script upon completion. These codes signal whether the execution was successful or if any errors occurred. By convention, an exit code of 0 typically indicates success, while any non-zero value signifies a failure or specific error condition. These codes are crucial for scripting and automation, allowing scripts to make decisions based on the outcome of previous commands.

ExitCodesEngineering
2 khái niệmChi tiết
Khuyên họcKiến thức

Exit Codes

Exit codes are numerical values returned by a program or script upon completion. These codes signal whether the execution was successful or if any errors occurred. By convention, an exit code of 0 typically indicates success, while any non-zero value signifies a failure or specific error condition. These codes are crucial for scripting and automation, allowing scripts to make decisions based on the outcome of previously executed commands.

ExitCodesEngineering
2 khái niệmChi tiết
Cốt lõiKiến thức

Expr

`expr` is a command-line utility used to evaluate expressions. It can perform arithmetic operations, string manipulations, and logical comparisons. The `expr` command takes arguments as operands and operators, evaluates the expression, and writes the result to standard output. It's often used in shell scripts for performing calculations and making decisions based on numerical or string values.

ExprCoreEngineering
3 khái niệmChi tiết
Khuyên họcIDE Lab

Extended Regular Expressions

Extended regular expressions (EREs) are a more powerful and flexible version of basic regular expressions. They offer additional metacharacters and features that simplify pattern matching and make complex searches easier to express. EREs are commonly used with tools like `grep -E`, `awk`, and `sed -E` in shell scripting.

ExtendedRegularEngineering
2 khái niệmChi tiết
Cốt lõiKiến thức

fg and bg

`fg` and `bg` are shell commands used to manage processes. `bg` moves a process to the background, allowing you to continue using the terminal while the process runs. `fg` brings a background process to the foreground, giving it control of the terminal. This is useful for managing long-running tasks or temporarily pausing a process.

fgandEngineering
3 khái niệmChi tiết
Khuyên họcKiến thức

File Permissions

File permissions in Unix-like operating systems, such as Linux and macOS, control who can access and modify files and directories. These permissions are typically represented by three categories: owner, group, and others. Each category can have read, write, and execute permissions, determining what actions users in that category can perform on the file or directory.

FilePermissionsEngineering
1 khái niệmChi tiết
Cốt lõiKiến thức

File Test Operators

File test operators in Bash are used to check the type and attributes of files. These operators allow you to determine if a file exists, if it's a regular file or a directory, if it's readable, writable, or executable, and other file-related properties. The result of a file test is a boolean value (true or false), which can be used in conditional statements to control the flow of a script.

FileTestEngineering
1 khái niệmChi tiết
Khuyên họcKiến thức

Files & Directories

Files and directories are fundamental building blocks of a file system. Files store data, such as text, images, or executable code. Directories, also known as folders, organize files and other directories in a hierarchical structure, allowing users to navigate and manage their data effectively.

Files&Engineering
2 khái niệmChi tiết
Cốt lõiIDE Lab

Find

The `find` command is a powerful utility used to locate files and directories within a file system hierarchy. It allows you to search based on various criteria, such as name, size, modification time, permissions, and file type. The `find` command recursively traverses directories, making it suitable for locating files across an entire file system or within specific subdirectories.

FindCoreEngineering
2 khái niệmChi tiết
03
Giai đoạn 3Kỹ thuật chuyên sâu, hiệu năng và chuẩn thiết kế

Kiến Trúc Nâng Cao & Tối Ưu

Giai đoạn 3 tập trung hoàn thiện 35 chủ đề then chốt.

Cốt lõiIDE Lab

Find

`find` is a command-line utility for searching files and directories within a specified directory hierarchy. It allows you to locate files based on various criteria, such as name, type, size, modification time, permissions, and more. The `find` command recursively traverses the directory structure, applying the specified search criteria to each file and directory it encounters, and then displays the results that match.

FindCoreEngineering
1 khái niệmChi tiết
Cốt lõiKiến thức

fish

fish is a user-friendly command-line shell for UNIX-like operating systems. It focuses on providing a more interactive and discoverable experience compared to traditional shells like Bash or Zsh. Key features include autosuggestions, syntax highlighting, and a simplified scripting language.

fishCoreEngineering
3 khái niệmChi tiết
Cốt lõiKiến thức

For Loops

A "for" loop is a control flow statement that allows you to repeatedly execute a block of code a specific number of times or for each item in a list. It's a fundamental programming construct used to automate repetitive tasks and iterate over collections of data. The loop continues until a specified condition is met, making it a powerful tool for processing data and performing actions multiple times.

ForLoopsEngineering
1 khái niệmChi tiết
Khuyên họcKiến thức

Free

`free` is a command-line utility used to display the amount of free and used physical and swap memory in a system. It provides a snapshot of the memory usage at a given point in time, showing total memory, used memory, free memory, shared memory, buffer/cache memory, and available memory. This information is crucial for understanding how efficiently a system is utilizing its memory resources and identifying potential memory bottlenecks.

FreeCoreEngineering
1 khái niệmChi tiết
Cốt lõiKiến thức

Function Scopes

Function scope determines the visibility and accessibility of variables within a function. In shell scripting, variables can have either global or local scope. Global variables are accessible from anywhere in the script, including within functions, while local variables are only accessible within the function where they are defined. Understanding scope is crucial for avoiding naming conflicts and ensuring that functions operate predictably.

FunctionScopesEngineering
3 khái niệmChi tiết
Khuyên họcKiến thức

Functions

Functions in shell scripting are reusable blocks of code that perform a specific task. They allow you to organize your scripts, avoid repetition, and make your code more readable and maintainable. You can define a function, give it a name, and then call it multiple times throughout your script, passing arguments if needed.

FunctionsCoreEngineering
2 khái niệmChi tiết
Cốt lõiIDE Lab

grep

`grep` is a command-line utility used for searching plain-text data sets for lines matching a regular expression. It outputs the lines that contain the specified pattern, making it a powerful tool for filtering and locating specific information within files or streams of data. Its name comes from the ed command `g/re/p` (globally search a regular expression and print).

grepCoreEngineering
2 khái niệmChi tiết
Khuyên họcKiến thức

gzip and gunzip

`gzip` is a command-line utility used to compress files, reducing their size and making them easier to store or transmit. The compressed files typically have a `.gz` extension. `gunzip` is the corresponding command used to decompress files that have been compressed with `gzip`, restoring them to their original state.

gzipandEngineering
2 khái niệmChi tiết
Cốt lõiKiến thức

head and tail

`head` and `tail` are command-line utilities used to display the beginning or end of a file, respectively. `head` shows the first few lines of a file, while `tail` shows the last few lines. They are useful for quickly inspecting log files, configuration files, or any text-based data without opening the entire file in a text editor.

headandEngineering
2 khái niệmChi tiết
Khuyên họcKiến thức

Help Commands

Help commands in a shell environment provide users with information about available commands, their syntax, and options. They are essential tools for understanding how to use commands effectively and discovering new functionalities within the shell. These commands allow users to quickly access documentation and usage examples directly from the command line.

HelpCommandsEngineering
2 khái niệmChi tiết
Cốt lõiKiến thức

Here Documents

Here documents (or "heredocs") are a way to redirect multiple lines of input to a command. Instead of typing input directly into the terminal or reading from a file, you can embed the input directly within your script. This is particularly useful for passing multi-line strings or configuration data to commands.

HereDocumentsEngineering
2 khái niệmChi tiết
Khuyên họcKiến thức

Here Strings

Here strings provide a way to pass strings to commands as standard input. They are a simplified form of here documents, designed for single-line input. Instead of redirecting a file or typing input directly, you can embed the string directly within the command using the `<<<` operator. This is particularly useful for commands that expect input from stdin but you want to provide it inline within your script.

HereStringsEngineering
2 khái niệmChi tiết
Cốt lõiKiến thức

Conditionals - if

The `if` statement in shell scripting allows you to execute different blocks of code based on whether a certain condition is true or false. It's a fundamental control flow mechanism that enables scripts to make decisions and behave differently depending on the input or state of the system. The `if` statement evaluates an expression, and if the expression is true, a specific set of commands is executed. Otherwise, the script can optionally execute a different set of commands defined in `else` or `elif` blocks.

Conditionals-Engineering
2 khái niệmChi tiết
Khuyên họcKiến thức

ifconfig and ip Commands

`ifconfig` and `ip` are command-line utilities used to configure and manage network interfaces on Unix-like operating systems. They allow you to view, configure, and control network interfaces, including assigning IP addresses, setting network masks, and enabling or disabling interfaces. While `ifconfig` is an older tool, `ip` is the modern replacement offering more features and flexibility.

ifconfigandEngineering
1 khái niệmChi tiết
Cốt lõiKiến thức

Input Redirection

Input redirection enables a command to obtain its input from a source other than the standard input (typically the keyboard). Instead of typing input directly, a command can read data from a file or another command's output. This is achieved using operators like `<` to specify the input source.

InputRedirectionEngineering
2 khái niệmChi tiết
Khuyên họcKiến thức

Input/Output

Input/Output (I/O) refers to the communication between a computer program and the outside world. This involves receiving data (input) from sources like the keyboard, files, or other programs, and sending data (output) to destinations such as the terminal, files, or other programs. In essence, it's how a program interacts with its environment to receive instructions and display results.

Input/OutputCoreEngineering
2 khái niệmChi tiết
Cốt lõiKiến thức

Introduction

Shell, often referred to as Bash (Bourne Again Shell), is a command-line interpreter. It acts as an interface between the user and the operating system, allowing users to execute commands, run scripts, and manage files. It interprets the commands entered by the user and instructs the operating system to perform the corresponding actions.

IntroductionCoreEngineering
2 khái niệmChi tiết
Khuyên họcKiến thức

iostat and vmstat

`iostat` and `vmstat` are command-line utilities used for system monitoring. `iostat` reports CPU utilization and disk I/O statistics, providing insights into storage device performance. `vmstat` reports virtual memory statistics, including information about processes, memory, paging, block I/O, traps, and CPU activity, helping to identify performance bottlenecks related to memory and CPU usage.

iostatandEngineering
2 khái niệmChi tiết
Cốt lõiKiến thức

Jobs

In a shell environment, a job represents a process or a group of processes that are running in the background or foreground. The `jobs` command provides a way to list the currently active jobs, check their status (running, stopped, terminated), and manage them, such as bringing them to the foreground or terminating them. It's a crucial tool for controlling and monitoring processes initiated from the shell.

JobsCoreEngineering
1 khái niệmChi tiết
Khuyên họcKiến thức

Join and Split

`join` and `split` are command-line utilities used for manipulating text files. `join` combines lines from two files based on a common field, creating a new file with the merged data. `split`, conversely, divides a single file into multiple smaller files, either by line count, file size, or a custom pattern.

JoinandEngineering
2 khái niệmChi tiết
Cốt lõiKiến thức

ksh

ksh, or the Korn shell, is an interactive command language and scripting language. It's designed to be backward-compatible with the Bourne shell (sh) while incorporating many features from other shells like csh. ksh offers improvements in scripting capabilities, command-line editing, and job control, making it a powerful tool for both interactive use and automating tasks.

kshCoreEngineering
1 khái niệmChi tiết
Khuyên họcIDE Lab

less and more

`less` and `more` are command-line utilities used to view the contents of text files, one screen at a time. They allow users to navigate through the file, search for specific patterns, and perform other basic text manipulation tasks directly from the terminal. `less` is generally preferred over `more` because it offers more features, including the ability to scroll backwards.

lessandEngineering
2 khái niệmChi tiết
Cốt lõiKiến thức

Let Command

The `let` command in Bash is used to perform arithmetic operations. It allows you to evaluate arithmetic expressions and assign the result to a variable. It's a way to do integer calculations directly within your shell scripts without needing external commands like `expr`.

LetCommandEngineering
3 khái niệmChi tiết
Khuyên họcKiến thức

Logical Operators in Bash

Logical operators in Bash are used to combine or modify conditional expressions. They allow you to create more complex tests within your scripts, enabling you to execute commands based on multiple conditions being true or false. The primary logical operators are `&&` (AND), `||` (OR), and `!` (NOT). These operators are essential for controlling the flow of your scripts based on the evaluation of different conditions.

LogicalOperatorsEngineering
3 khái niệmChi tiết
Cốt lõiKiến thức

Loops

Loops are programming constructs that allow you to repeatedly execute a block of code. They automate repetitive tasks by iterating over a sequence of values or until a certain condition is met. This avoids writing the same code multiple times and makes scripts more efficient and easier to maintain.

LoopsCoreEngineering
3 khái niệmChi tiết
Khuyên họcKiến thức

ls

`ls` is a command-line utility used to list files and directories within a specified directory. By default, it displays the contents of the current working directory. It offers various options to control the output, such as displaying file sizes, modification dates, permissions, and hidden files.

lsCoreEngineering
2 khái niệmChi tiết
Cốt lõiKiến thức

mkdir

`mkdir` is a command-line utility used to create new directories (folders) in a file system. It allows users to organize files by grouping them into logical structures. The command takes the name(s) of the directory(s) to be created as arguments, and it can also be used to create multiple directories at once or create parent directories if they don't already exist.

mkdirCoreEngineering
2 khái niệmChi tiết
Khuyên họcKiến thức

mv Command

The `mv` command in Unix-like operating systems is used to move or rename files and directories. It allows you to relocate files from one directory to another, effectively changing their location within the file system. Additionally, `mv` can be used to change the name of a file or directory without altering its location.

mvCommandEngineering
2 khái niệmChi tiết
Cốt lõiKiến thức

Nano

Nano is a simple, beginner-friendly text editor for Unix-like operating systems. It's designed to be easy to use, with a straightforward interface that displays command shortcuts at the bottom of the screen. Nano is often pre-installed on many systems, making it readily available for quick text editing tasks.

NanoCoreEngineering
2 khái niệmChi tiết
Khuyên họcKiến thức

Navigate Between Directories

Navigating between directories in a shell environment involves moving from one location in the file system to another. This is primarily achieved using the `cd` (change directory) command, which allows users to specify the destination directory, whether it's a relative path from the current location or an absolute path from the root directory. Special notations like `.` (current directory), `..` (parent directory), and `~` (home directory) provide convenient shortcuts for common navigation tasks.

NavigateBetweenEngineering
3 khái niệmChi tiết
Cốt lõiKiến thức

netstat and ss

`netstat` and `ss` are command-line tools used to display network connections, routing tables, interface statistics, masquerade connections, and multicast memberships. They provide insights into the network activity of a system, allowing users to diagnose network issues, monitor connections, and understand network traffic patterns. While `netstat` has been a long-standing tool, `ss` (socket statistics) is a newer utility that offers faster and more detailed information about network sockets.

netstatandEngineering
3 khái niệmChi tiết
Khuyên họcKiến thức

nl

`nl` is a command-line utility that numbers the lines of a file or standard input. It reads lines, adds line numbers, and writes the result to standard output. You can customize the numbering style, starting number, and increment between numbers. It's useful for adding line numbers to code, documents, or any text file for easier reference.

nlCoreEngineering
3 khái niệmChi tiết
Cốt lõiKiến thức

nohup

`nohup` is a command-line utility used to run a command immune to hangups, with output redirected to a file. This allows a process to continue running in the background even after the user who started the process logs out or closes the terminal. It's particularly useful for long-running tasks that shouldn't be interrupted by a terminal disconnection.

nohupCoreEngineering
2 khái niệmChi tiết
Khuyên họcKiến thức

Numeric Data in Bash

Bash, by default, treats all variables as strings. However, Bash can perform arithmetic operations on variables that contain numeric values. While Bash doesn't have explicit data types like integers or floats in the same way as other programming languages, it interprets strings as numbers when used in arithmetic contexts. This allows you to perform calculations, comparisons, and other numeric manipulations within your shell scripts.

NumericDataEngineering
3 khái niệmChi tiết
Cốt lõiKiến thức

Output Redirection

Output redirection in shell scripting allows you to control where the output of a command is sent. Instead of displaying on the terminal, you can redirect it to a file, either overwriting the file or appending to it. This is achieved using special operators like `>`, `>>`, `2>`, and `&>`. These operators provide a way to manage standard output (stdout), standard error (stderr), and both, making it easier to process and store command results.

OutputRedirectionEngineering
3 khái niệmChi tiết
04
Giai đoạn 4Kiểm thử, CI/CD, đám mây và quy chuẩn sản xuất

Hệ Sinh Thái & Triển Khai Thực Tế

Giai đoạn 4 tập trung hoàn thiện 35 chủ đề then chốt.

Cốt lõiKiến thức

Package Management

Package management is the process of installing, updating, configuring, and removing software packages on a computer system. It provides a standardized way to handle software dependencies, ensuring that all necessary components are present and compatible. Package managers also simplify the process of keeping software up-to-date and removing unwanted applications cleanly.

PackageManagementEngineering
1 khái niệmChi tiết
Cốt lõiKiến thức

Pattern Replacement

Pattern replacement in shell scripting involves finding specific patterns within strings and substituting them with other strings. This is a fundamental text processing technique used to modify and transform data, allowing for tasks like cleaning up input, standardizing formats, or extracting relevant information. Shell tools like `sed`, parameter expansion, and `awk` are commonly used to achieve pattern replacement.

PatternReplacementEngineering
1 khái niệmChi tiết
Cốt lõiKiến thức

Ping

Ping is a command-line utility used to test the reachability of a host on an Internet Protocol (IP) network. It works by sending Internet Control Message Protocol (ICMP) "echo request" packets to the target host and waiting for ICMP "echo reply" packets. The ping command measures the round-trip time (RTT) for these packets, indicating the latency of the connection, and also reports any packet loss.

PingCoreEngineering
1 khái niệmChi tiết
Khuyên họcKiến thức

Pipes

Pipes in shell scripting are a form of redirection that allows you to send the output of one command as the input to another command. This creates a chain of commands where the data flows from one process to the next, enabling you to perform complex data manipulation and filtering concisely and efficiently. The pipe operator, represented by the vertical bar `|`, connects the standard output of the command on the left to the standard input of the command on the right.

PipesCoreEngineering
3 khái niệmChi tiết
Cốt lõiKiến thức

Popular Shells

A shell is a command-line interpreter that provides a user interface for interacting with an operating system. Different shells offer varying features, syntax, and capabilities, leading to the existence of several popular choices. These shells determine how you interact with the system, execute commands, and automate tasks.

PopularShellsEngineering
3 khái niệmChi tiết
Khuyên họcKiến thức

PowerShell

PowerShell is a cross-platform task automation and configuration management framework, consisting of a command-line shell and associated scripting language. It's built on the .NET Common Language Runtime (CLR) and accepts and returns .NET objects, which allows for more complex and structured data manipulation compared to traditional text-based shells. PowerShell is designed to be extensible and can be used to manage various systems and applications.

PowerShellCoreEngineering
3 khái niệmChi tiết
Cốt lõiKiến thức

printf Formatting

`printf` is a command-line utility used to format and print text in a specific way. It allows you to control the appearance of output by using format specifiers, which define how different types of data (strings, numbers, etc.) should be displayed. This includes specifying the width, precision, alignment, and other attributes of the output.

printfFormattingEngineering
3 khái niệmChi tiết
Khuyên họcKiến thức

Process Management

Process management involves controlling and monitoring the execution of programs within an operating system. It includes tasks such as creating new processes, scheduling their execution, allocating resources, and handling inter-process communication. Effective process management ensures efficient utilization of system resources and prevents conflicts between running programs.

ProcessManagementEngineering
1 khái niệmChi tiết
Cốt lõiKiến thức

Process Substitution

Process substitution allows you to treat the output of a process as if it were a file. It achieves this by creating a temporary file (or using a pipe in some systems) and connecting the standard output of a command to it. This temporary file's name is then substituted into the command line, allowing commands that expect file arguments to read the output of another command. This is particularly useful for commands that require multiple file inputs or when you want to compare the output of two different commands.

ProcessSubstitutionEngineering
1 khái niệmChi tiết
Khuyên họcKiến thức

Process Substitution

Process substitution allows you to treat the output of a process as if it were a file. It provides a way to pass the output of one command as input to another command, without using temporary files or named pipes. This is achieved by creating a temporary file-like object (either a named pipe or a file in `/dev/fd`) that the command writes its output to, and then passing the name of this object to another command as an argument.

ProcessSubstitutionEngineering
1 khái niệmChi tiết
Cốt lõiKiến thức

ps

`ps` is a command-line utility that displays information about active processes running on a Linux or Unix-like operating system. It provides a snapshot of the current processes, including their process IDs (PIDs), resource usage, and other relevant details. This allows users and administrators to monitor system activity and identify processes that may be consuming excessive resources or causing issues.

psCoreEngineering
3 khái niệmChi tiết
Khuyên họcKiến thức

pwd

`pwd` (print working directory) is a command-line utility that displays the absolute path of the current directory you are working in. It essentially tells you where you are located within the file system hierarchy from the root directory. This is useful for navigating and understanding your position within the directory structure.

pwdCoreEngineering
2 khái niệmChi tiết
Cốt lõiKiến thức

Read User Input

Reading user input in a shell script allows the script to interact with the person running it. This is achieved by pausing the script's execution and waiting for the user to type something and press Enter. The entered text can then be stored in a variable and used later in the script for various purposes, such as making decisions or providing customized output.

ReadUserEngineering
2 khái niệmChi tiết
Khuyên họcKiến thức

Recursive Functions

Recursive functions are functions that call themselves within their own definition. This allows a function to repeat a process until a specific condition is met, breaking down a complex problem into smaller, self-similar subproblems. Each call adds a new layer to the execution stack, and it's crucial to have a base case to prevent infinite loops.

RecursiveFunctionsEngineering
2 khái niệmChi tiết
Cốt lõiKiến thức

Redirects & Pipelines

Redirects and pipelines are fundamental features in the shell that allow you to control the flow of data between commands. Redirects change where a command's input comes from or where its output goes, allowing you to read from files or write to files. Pipelines connect the output of one command directly to the input of another, enabling you to chain commands together to perform complex operations in a sequence.

Redirects&Engineering
3 khái niệmChi tiết
Khuyên họcIDE Lab

Regular Expressions

Regular expressions (regex) are sequences of characters that define a search pattern. They are used to match, locate, and manipulate text based on specific patterns. Regex provides a powerful way to search for strings that match a certain format, such as email addresses, phone numbers, or specific keywords within a larger body of text.

RegularExpressionsEngineering
2 khái niệmChi tiết
Cốt lõiKiến thức

Repeat Commands

In the shell, you can easily access and reuse previously executed commands. The most common way to do this is using the up and down arrow keys to navigate through your command history. Alternatively, you can use the `history` command to view a numbered list of past commands, and then execute a specific command by typing `!n`, where `n` is the command's number in the history list. You can also use `!!` to repeat the last command, or `!string` to execute the most recent command that starts with "string".

RepeatCommandsEngineering
3 khái niệmChi tiết
Khuyên họcKiến thức

rm Command

The `rm` command in Unix-like operating systems is used to remove files or directories. It permanently deletes the specified files, so caution is advised when using it. By default, `rm` does not remove directories; specific options are needed to remove directories and their contents recursively.

rmCommandEngineering
2 khái niệmChi tiết
Cốt lõiKiến thức

rmdir

`rmdir` is a command-line utility used to remove empty directories. It's a straightforward tool that helps in cleaning up directory structures by deleting directories that no longer contain any files or subdirectories. The command will return an error if the directory is not empty.

rmdirCoreEngineering
2 khái niệmChi tiết
Khuyên họcKiến thức

rsync

rsync is a command-line utility for efficiently transferring and synchronizing files between a computer and an external hard drive or across networked computers. It minimizes data transfer by only copying the differences between the source and destination, making it faster than simple copy commands, especially for large files or directories. rsync is commonly used for backups, mirroring data, and updating websites.

rsyncCoreEngineering
1 khái niệmChi tiết
Cốt lõiKiến thức

Running Shell Scripts

Running a shell script involves executing a file containing a series of commands that the shell interprets and performs. This allows you to automate tasks, create reusable tools, and manage system operations by grouping commands into a single executable unit. The script is typically a plain text file with a `.sh` extension, and it needs execute permissions to be run directly.

RunningShellEngineering
3 khái niệmChi tiết
Khuyên họcKiến thức

Running with Bash

Running a shell script with Bash involves explicitly invoking the Bash interpreter to execute the commands within the script. This is typically done by using the `bash` command followed by the script's filename as an argument. This method ensures that the script is interpreted and executed using the Bash shell, regardless of the script's shebang line or the user's default shell.

RunningwithEngineering
1 khái niệmChi tiết
Cốt lõiKiến thức

Running Shell Scripts with Source

Sourcing a shell script executes the commands within the script in the _current_ shell environment, rather than in a subshell. This means that any variables, functions, or aliases defined or modified within the script will directly affect the shell you're currently working in. This is in contrast to simply executing a script, which creates a new process and any changes are isolated to that process.

RunningShellEngineering
3 khái niệmChi tiết
Khuyên họcKiến thức

rwx File Permissions

In Unix-like operating systems, file permissions control who can access and modify files and directories. The "rwx" notation represents the three fundamental permission types: "r" for read, allowing users to view the contents of a file or list the contents of a directory; "w" for write, allowing users to modify a file or create/delete files within a directory; and "x" for execute, allowing users to run a file as a program or enter a directory. These permissions are assigned to three categories of users: the owner of the file, the group associated with the file, and all other users.

rwxFileEngineering
1 khái niệmChi tiết
Cốt lõiKiến thức

scp

`scp`, short for secure copy, is a command-line utility that allows you to securely transfer files between a local host and a remote host or between two remote hosts. It uses the SSH protocol for data transfer, ensuring that the data is encrypted during transmission, thus protecting it from eavesdropping. `scp` is commonly used for tasks like uploading website files to a server, backing up data to a remote location, or sharing files between team members.

scpCoreEngineering
3 khái niệmChi tiết
Khuyên họcKiến thức

Script Arguments

Script arguments are values passed to a shell script when it is executed. These arguments allow you to customize the script's behavior without modifying the script's code directly. They are accessed within the script using positional parameters like `$1`, `$2`, `$3`, and so on, where `$1` represents the first argument, `$2` the second, and so forth. The special variable `$0` holds the name of the script itself, and `$#` contains the number of arguments passed.

ScriptArgumentsEngineering
3 khái niệmChi tiết
Cốt lõiIDE Lab

sed

`sed` (Stream EDitor) is a powerful command-line utility used for text transformation. It operates on a stream of text, performing operations like searching, replacing, deleting, and inserting text based on patterns or line numbers. `sed` is commonly used in shell scripting for automating text editing tasks and manipulating data within files or pipelines.

sedCoreEngineering
1 khái niệmChi tiết
Khuyên họcKiến thức

set -e

`set -e` is a shell command that instructs the shell to exit immediately if a command exits with a non-zero status. This is a way to ensure that your script stops executing as soon as an error occurs, preventing subsequent commands from running based on potentially incorrect or incomplete results. It's a common practice to include `set -e` at the beginning of a script to enforce stricter error checking.

set-eEngineering
2 khái niệmChi tiết
Cốt lõiKiến thức

set -o

The `set -o` command in shell scripting is used to modify shell options, which control the behavior of the shell. These options can affect how the shell interprets commands, handles errors, and performs other tasks. By using `set -o` with specific option names, you can customize the shell's environment to suit your needs, enabling features like error handling, debugging, and more strict command execution.

set-oEngineering
2 khái niệmChi tiết
Khuyên họcKiến thức

set -u

The `set -u` command in shell scripting treats unset variables as an error. When this option is enabled, the script will exit immediately if it tries to use a variable that has not been assigned a value. This helps to catch potential bugs caused by typos or missing variable assignments, making scripts more robust.

set-uEngineering
2 khái niệmChi tiết
Cốt lõiKiến thức

set -x

`set -x` is a debugging tool used in shell scripts to trace the execution of commands. When enabled, the shell will print each command to standard error (stderr) before it is executed, preceded by a `+` symbol. This allows you to see exactly what commands are being run and in what order, making it easier to identify errors or unexpected behavior in your scripts.

set-xEngineering
1 khái niệmChi tiết
Khuyên họcKiến thức

Setting Up Bash

Setting up Bash involves configuring your shell environment to suit your preferences and workflow. This includes customizing the appearance of your command prompt, defining aliases for frequently used commands, setting environment variables to control program behavior, and creating custom functions to automate tasks. Properly setting up Bash can significantly improve your productivity and make working with the command line more efficient.

SettingUpEngineering
1 khái niệmChi tiết
Cốt lõiKiến thức

Shellcheck

Shellcheck is a static analysis tool for shell scripts. It helps identify and fix common syntax errors, semantic issues, and stylistic problems in your Bash/Shell scripts before you even run them. By analyzing your code, shellcheck can suggest improvements and help prevent potential bugs, resulting in more robust and maintainable scripts.

ShellcheckCoreEngineering
1 khái niệmChi tiết
Khuyên họcKiến thức

Shift

The `shift` command in shell scripting renames the command-line arguments. Specifically, it moves each argument one position to the left. The value of `$2` becomes `$1`, the value of `$3` becomes `$2`, and so on. The original value of `$1` is lost. This is particularly useful when you need to process a variable number of arguments passed to a script.

ShiftCoreEngineering
3 khái niệmChi tiết
Cốt lõiIDE Lab

Sort

`sort` is a command-line utility that arranges lines of text in a specific order. It can sort alphabetically, numerically, by month, or even based on custom criteria. By default, `sort` treats each line as a string and sorts them in ascending ASCII order, but its behavior can be modified using various options to handle different data types and sorting preferences.

SortCoreEngineering
2 khái niệmChi tiết
05
Giai đoạn 5Các giải pháp quy mô lớn và tư duy dẫn dắt kỹ thuật

Chuyên Gia & Mở Rộng Hệ Thống

Giai đoạn 5 tập trung hoàn thiện 34 chủ đề then chốt.

Cốt lõiKiến thức

Special Variables

Special variables in shell scripting are predefined variables that automatically hold specific values related to the shell's operation or the script's execution environment. These variables provide access to information like the script's name, the number of arguments passed to it, the exit status of the last command, and process IDs. They are read-only in most cases, meaning you can't directly modify their values, but you can use them to make decisions and control the flow of your scripts.

SpecialVariablesEngineering
3 khái niệmChi tiết
Cốt lõiIDE Lab

SSH

SSH (Secure Shell) is a cryptographic network protocol that enables secure communication between two computers over an insecure network. It's commonly used for remote command-line access, remote execution of commands, and secure file transfer. SSH encrypts the data transmitted between the client and the server, protecting it from eavesdropping and tampering.

SSHCoreEngineering
2 khái niệmChi tiết
Cốt lõiKiến thức

stdin, stdout, and stderr

In computing, standard streams are preconnected input and output communication channels between a computer program and its environment. Specifically, _stdin_ (standard input) is the channel through which a program receives input, typically from the keyboard or another program. _stdout_ (standard output) is the channel through which a program writes its normal output, usually displayed on the screen. _stderr_ (standard error) is the channel through which a program writes error messages and diagnostic information, also typically displayed on the screen, but kept separate from _stdout_ to allow for easier handling of errors.

stdin,stdout,Engineering
3 khái niệmChi tiết
Khuyên họcKiến thức

Stop Execution

Stopping execution in a shell script refers to halting the script's progress, often due to an error, a specific condition being met, or a user's request. This can be achieved through various commands and techniques that control the flow of the script, ensuring that it doesn't continue running when it shouldn't. Properly stopping execution is crucial for preventing unintended consequences and maintaining the integrity of the system.

StopExecutionEngineering
3 khái niệmChi tiết
Cốt lõiKiến thức

String Length

Determining the length of a string is a common task in scripting. It involves finding the number of characters present in a given string, which can be useful for validation, formatting, or other string processing operations. In shell scripting, there are several ways to achieve this, each with its own syntax and potential use cases.

StringLengthEngineering
2 khái niệmChi tiết
Khuyên họcKiến thức

String Manipulation

String manipulation involves modifying or extracting parts of text data. This can include tasks like finding specific characters, replacing substrings, changing the case of letters, or extracting portions of a string based on delimiters or patterns. These operations are fundamental for processing and transforming textual information.

StringManipulationEngineering
2 khái niệmChi tiết
Cốt lõiKiến thức

String Operators

String operators in Bash are symbols or keywords used to perform operations on strings, such as checking if a string is empty, comparing strings, extracting substrings, or determining the length of a string. These operators are essential for manipulating and evaluating string values within shell scripts, enabling conditional logic and data processing based on string content.

StringOperatorsEngineering
3 khái niệmChi tiết
Khuyên họcKiến thức

Strings in Bash

In Bash, strings are sequences of characters. They can be enclosed in single quotes (`'...'`) or double quotes (`"..."`). Single quotes treat everything literally, meaning no variable substitution or command execution happens within them. Double quotes, on the other hand, allow for variable expansion and command substitution. Suppose you want to include a literal single quote within a single-quoted string. In that case, you'll need to escape it (usually by closing the single-quoted string, adding an escaped single quote, and then reopening the single-quoted string).

StringsinEngineering
3 khái niệmChi tiết
Cốt lõiKiến thức

Substring Extraction

Substring extraction involves selecting a portion of a string based on its position within the string. This is done by specifying the starting point and the length of the desired substring. It allows you to isolate and work with specific parts of a larger text string.

SubstringExtractionEngineering
3 khái niệmChi tiết
Khuyên họcKiến thức

Exit Codes: Success vs. Failure

Exit codes are numerical values returned by a program or script upon completion, signaling whether it executed successfully or encountered an error. A zero (0) exit code typically indicates success, while any non-zero value signifies failure, with different non-zero codes often representing specific types of errors. These codes are crucial for scripting and automation, allowing scripts to make decisions based on the outcome of previous commands.

ExitCodes:Engineering
3 khái niệmChi tiết
Cốt lõiKiến thức

Systemd Timers

Systemd timers are a systemd feature that allows you to schedule tasks to run at specific times or intervals, similar to cron. They provide a more flexible and powerful alternative to cron, offering features like dependency management, event-based activation, and integration with systemd's logging and service management capabilities. Systemd timers are defined using unit files, just like systemd services, and can be used to automate a wide range of system administration tasks.

SystemdTimersEngineering
3 khái niệmChi tiết
Khuyên họcKiến thức

Tab Completion

Tab completion is a feature in command-line interfaces that automatically completes commands, filenames, or other input based on what you've already typed. By pressing the Tab key, the shell attempts to fill in the rest of the word you're typing, saving you time and reducing errors. If multiple possibilities exist, pressing Tab twice usually displays a list of options.

TabCompletionEngineering
1 khái niệmChi tiết
Cốt lõiKiến thức

tar

`tar` (Tape Archive) is a command-line utility in Unix-like operating systems used for archiving and extracting files. It combines multiple files into a single archive file, often referred to as a "tarball." While `tar` itself doesn't compress the archive, it's commonly used in conjunction with compression tools like gzip or bzip2 to create compressed archives (e.g., `.tar.gz` or `.tar.bz2` files), reducing file size for storage or distribution.

tarCoreEngineering
3 khái niệmChi tiết
Khuyên họcKiến thức

tcsh

tcsh is an enhanced version of the C shell (csh), a Unix shell program. It's designed as an interactive login shell and a shell script command processor. tcsh provides features like command-line editing, filename completion, and a history mechanism, making it more user-friendly than its predecessor.

tcshCoreEngineering
2 khái niệmChi tiết
Cốt lõiKiến thức

Text Editors

Text editors are software programs that allow users to create, open, view, and modify plain text files. They are fundamental tools for writing code, scripts, configuration files, and general text-based documents. Unlike word processors, text editors focus on the raw text content without applying rich formatting or styles.

TextEditorsEngineering
3 khái niệmChi tiết
Khuyên họcKiến thức

top and htop

`top` and `htop` are command-line utilities used for real-time system monitoring. They display a dynamic, ordered list of processes running on a system, along with information about CPU usage, memory consumption, and other system resources. `htop` is an enhanced, interactive version of `top`, offering features like color-coding, improved process management, and horizontal scrolling.

topandEngineering
1 khái niệmChi tiết
Cốt lõiKiến thức

touch

The `touch` command is a fundamental utility used to update the access and modification times of files and directories. If a file doesn't exist, `touch` creates an empty file with the specified name. It's commonly used to create new, empty files or to quickly update the timestamps of existing files without modifying their content.

touchCoreEngineering
2 khái niệmChi tiết
Khuyên họcKiến thức

tr Command

The `tr` command in Unix-like operating systems is a command-line utility that translates or deletes characters. It reads standard input, performs the specified transformations, and writes the result to standard output. `tr` is often used for tasks like converting uppercase to lowercase, deleting specific characters, or replacing one set of characters with another.

trCommandEngineering
2 khái niệmChi tiết
Cốt lõiKiến thức

Trap

`trap` is a shell command used to specify actions to be taken upon receiving signals. Signals are notifications sent to a process to indicate an event, such as termination, interruption, or an error. The `trap` command allows you to define custom handlers that execute when a specific signal is received, enabling you to gracefully handle errors, clean up resources, or perform other necessary actions before the script exits or continues.

TrapCoreEngineering
2 khái niệmChi tiết
Khuyên họcKiến thức

uniq

`uniq` is a command-line utility that filters adjacent matching lines from an input file (or standard input) and writes a single copy of the matching line to the output. It's primarily used to remove duplicate lines, but it requires that the duplicates be next to each other to be effective. Options allow you to count the number of occurrences of each line, display unique lines, or display only duplicate lines.

uniqCoreEngineering
3 khái niệmChi tiết
Cốt lõiKiến thức

Until Loops

An `until` loop in shell scripting repeatedly executes a block of code as long as a specified condition is false. The loop continues to iterate until the condition becomes true, at which point the loop terminates. It's essentially the opposite of a `while` loop, providing a way to execute commands until a desired state is reached.

UntilLoopsEngineering
3 khái niệmChi tiết
Khuyên họcKiến thức

Uptime

Uptime is a command-line utility that displays how long the system has been running. It provides a concise summary of the current time, how long the system has been up, the number of users currently logged in, and the system's load average over the past 1, 5, and 15 minutes. This information is useful for quickly assessing the system's stability and resource utilization.

UptimeCoreEngineering
2 khái niệmChi tiết
Cốt lõiKiến thức

Variable Scopes

Variable scope determines the region of a program where a declared variable can be accessed. It defines the visibility and lifetime of a variable. Understanding variable scope is crucial for writing clean, maintainable, and bug-free shell scripts, as it helps prevent naming conflicts and ensures that variables are used in the intended context.

VariableScopesEngineering
2 khái niệmChi tiết
Khuyên họcKiến thức

Variables Best Practices

Using variables effectively in shell scripts involves following certain guidelines to improve readability, maintainability, and prevent errors. This includes choosing descriptive names, initializing variables before use, using appropriate scoping, and quoting variables to avoid unexpected behavior due to word splitting and globbing. Adhering to these practices leads to more robust and understandable shell scripts.

VariablesBestEngineering
1 khái niệmChi tiết
Cốt lõiKiến thức

Vi

Vi is a powerful text editor that's been a standard part of Unix-like systems for decades. It operates in different modes, primarily command mode for issuing instructions and insert mode for typing text. Vi is known for its efficiency and keyboard-centric approach, allowing users to perform complex editing tasks without relying heavily on a mouse.

ViCoreEngineering
2 khái niệmChi tiết
Khuyên họcKiến thức

Vim

Vim is a highly configurable text editor built to enable efficient text editing. It's an improved version of the vi editor distributed with most UNIX systems. Vim is known for its modal editing, allowing users to switch between different modes for inserting, deleting, and navigating text, making it a powerful tool for developers and system administrators.

VimCoreEngineering
2 khái niệmChi tiết
Cốt lõiKiến thức

wc

`wc` is a command-line utility that displays the number of lines, words, and bytes (or characters) in a file. It's a simple yet powerful tool for quickly getting a summary of the size and content of text files. You can use it to count the number of lines in a log file, the number of words in a document, or the size of a configuration file.

wcCoreEngineering
2 khái niệmChi tiết
Khuyên họcKiến thức

wget

`wget` is a command-line utility used to retrieve files from the internet. It supports downloading files using HTTP, HTTPS, and FTP protocols. `wget` is non-interactive, meaning it can work in the background without user intervention, making it suitable for scripting and automation.

wgetCoreEngineering
2 khái niệmChi tiết
Cốt lõiKiến thức

What is Bash?

Bash, short for Bourne Again Shell, is a command-line interpreter and a shell scripting language. It's essentially a program that allows users to interact with the operating system by typing commands. Bash interprets these commands and instructs the operating system to perform specific actions, such as running programs, manipulating files, and managing system resources. It also provides features for automating tasks through scripts.

WhatisEngineering
3 khái niệmChi tiết
Khuyên họcKiến thức

What is Scripting?

Scripting is the process of writing a series of commands that are executed in a specific order by a program or scripting engine. These commands, often written in a simple, human-readable language, automate tasks, control software applications, or interact with operating systems. Instead of manually entering commands one by one, a script allows you to run a sequence of instructions with a single command.

WhatisEngineering
3 khái niệmChi tiết
Cốt lõiKiến thức

While Loops

A `while` loop in shell scripting repeatedly executes a block of code as long as a specified condition remains true. It's a fundamental control flow statement that allows you to automate repetitive tasks based on a dynamic condition that can change during the loop's execution. The loop continues iterating until the condition becomes false.

WhileLoopsEngineering
2 khái niệmChi tiết
Khuyên họcIDE Lab

yum

yum (Yellowdog Updater, Modified) is a command-line package management tool for systems using the RPM Package Manager. It automates the process of installing, updating, removing, and searching for software packages and their dependencies from configured repositories. yum simplifies software management by resolving dependencies automatically, ensuring that all required components are installed for a program to function correctly.

yumCoreEngineering
1 khái niệmChi tiết
Cốt lõiKiến thức

zip and unzip

`zip` and `unzip` are command-line utilities used for compressing and decompressing files and directories. `zip` packages files into a single archive, reducing their size and making them easier to share or store. `unzip` extracts the contents of a zip archive, restoring the original files and directories.

zipandEngineering
3 khái niệmChi tiết
Khuyên họcKiến thức

zsh

Zsh, also known as the Z shell, is a Unix shell that can be used as an interactive login shell and as a shell script command interpreter. It's designed to be highly customizable and offers features like improved tab completion, shared command history across multiple terminal windows, and powerful theming options. Zsh is often considered an alternative to Bash, offering enhanced functionality and a more user-friendly experience for many users.

zshCoreEngineering
3 khái niệmChi tiết