diff --git a/technology/applications/cli/Shell.md b/technology/applications/cli/Shell.md index 2c020e2..20a775f 100644 --- a/technology/applications/cli/Shell.md +++ b/technology/applications/cli/Shell.md @@ -2,8 +2,9 @@ obj: concept arch-wiki: https://wiki.archlinux.org/title/Command-line_shell wiki: https://en.wikipedia.org/wiki/Unix_shell -rev: 2024-03-07 +rev: 2024-09-05 --- + # Shell The shell is a command-line interpreter that provides a user interface to an operating system's services. It allows users to interact with the system through text-based commands and scripts. Shell scripting refers to writing a series of commands in a script file to automate tasks and perform complex operations. @@ -17,6 +18,33 @@ command Commands can be either a script, a binary or anything that can be executed. If you don't provide a full path to the file you want to run the shell will search in the locations defined in the `$PATH` environment variable. +### Keyboard Shortcuts +- `Ctrl + C`: Terminate the current running process or command. +- `Ctrl + Z`: Suspend the current process and push it to the background. +- `Ctrl + D`: Exit the terminal or send EOF (End Of File) if running a script or command. +- `Ctrl + L`: Clear the terminal screen (similar to the clear command). +- `Ctrl + A`: Move the cursor to the beginning of the line. +- `Ctrl + E`: Move the cursor to the end of the line. +- `Ctrl + U`: Delete everything from the cursor position to the beginning of the line. +- `Ctrl + K`: Delete everything from the cursor position to the end of the line. +- `Ctrl + W`: Delete the word before the cursor. +- `Ctrl + R`: Search command history backward interactively. +- `Ctrl + T`: Swap the current character with the previous one (transpose). +- `Ctrl + Y`: Paste (yank) the last killed text. +- `Ctrl + P`: Previous command in history (similar to the Up arrow key). +- `Ctrl + N`: Next command in history (similar to the Down arrow key). +- `Alt + F`: Move forward one word. +- `Alt + B`: Move backward one word. +- `Alt + D`: Delete the word after the cursor. +- `Shift + PageUp/PageDown`: Scroll the terminal output up or down. +- `Tab`: Auto-complete file or directory names. + +### Process Management +- `Ctrl + Z`: Suspend a running process. +- `fg`: Resume the last suspended process in the foreground. +- `bg`: Resume the last suspended process in the background. +- `jobs`: List all jobs currently running or suspended. + ### Arguments Everything after the command will be provided to the command as arguments. Each argument is separated by a space character. To avoid that you could quote an argument or escape the space character. @@ -229,7 +257,7 @@ Assume variable **a** holds 10 and variable **b** holds 20 then − | * (Multiplication) | Multiplies values on either side of the operator | `expr $a \* $b` will give 200 | | / (Division) | Divides left hand operand by right hand operand | `expr $b / $a` will give 2 | | % (Modulus) | Divides left hand operand by right hand operand and returns remainder | `expr $b % $a` will give 0 | -| = (Assignment) | Assigns right operand in left operand | `a = $b` would assign value of b into a | +| = (Assignment) | Assigns right operand in left operand | `a = $b` would assign value of b into a | | == (Equality) | Compares two numbers, if both are same then returns true. | `[$a == $b ]` would return false. | | != (Not Equality) | Compares two numbers, if both are different then returns true. | `[ $a != $b ]` would return true. | @@ -250,8 +278,8 @@ Assume variable **a** holds 10 and variable **b** holds 20 then − ##### Boolean Operators Assume variable **a** holds 10 and variable **b** holds 20 then − -| Operator | Description | Example | -| -------- | -------------------------------------------------------------------------------------------------------- | ------------------------------------- | +| Operator | Description | Example | +| -------- | -------------------------------------------------------------------------------------------------------- | --------------------------------------- | | **!** | This is logical negation. This inverts a true condition into false and vice versa. | `[ ! false ]` is true. | | **-o** | This is logical **OR**. If one of the operands is true, then the condition becomes true. | `[ $a -lt 20 -o $b -gt 100 ]` is true. | | **-a** | This is logical **AND**. If both the operands are true, then the condition becomes true otherwise false. | `[ $a -lt 20 -a $b -gt 100 ]` is false. |