{"id":17383160,"url":"https://github.com/king04aman/bash-scripting-cheatsheet","last_synced_at":"2025-06-10T14:13:27.066Z","repository":{"id":219550873,"uuid":"749312521","full_name":"king04aman/Bash-Scripting-Cheatsheet","owner":"king04aman","description":"Explore Bash scripting mastery with our comprehensive repository. From beginner basics to advanced techniques, dive into practical examples and expert guides for efficient automation. Dive into practical examples and guides to enhance automation skills and streamline workflows efficiently.","archived":false,"fork":false,"pushed_at":"2024-01-28T08:33:06.000Z","size":19,"stargazers_count":4,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-27T20:49:42.798Z","etag":null,"topics":["automation","bash","bash-script","bash-scripts","bashscripting","command-line","devops","linux","programing","scripting","scripting-language","shell-scripting","shellscript","sysadmin"],"latest_commit_sha":null,"homepage":"https://github.com/king04aman/Bash-Scripting-Cheatsheet/","language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/king04aman.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2024-01-28T07:43:34.000Z","updated_at":"2025-02-13T15:33:45.000Z","dependencies_parsed_at":"2024-01-28T09:49:15.416Z","dependency_job_id":null,"html_url":"https://github.com/king04aman/Bash-Scripting-Cheatsheet","commit_stats":null,"previous_names":["king04aman/bash-scripting-cheatsheet"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/king04aman%2FBash-Scripting-Cheatsheet","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/king04aman%2FBash-Scripting-Cheatsheet/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/king04aman%2FBash-Scripting-Cheatsheet/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/king04aman%2FBash-Scripting-Cheatsheet/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/king04aman","download_url":"https://codeload.github.com/king04aman/Bash-Scripting-Cheatsheet/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245924498,"owners_count":20694728,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["automation","bash","bash-script","bash-scripts","bashscripting","command-line","devops","linux","programing","scripting","scripting-language","shell-scripting","shellscript","sysadmin"],"created_at":"2024-10-16T07:40:48.781Z","updated_at":"2025-03-27T20:49:51.882Z","avatar_url":"https://github.com/king04aman.png","language":null,"readme":"# Bash Scripting Cheat Sheet\n\n![Bash-Scripting-Cheat-Sheet](https://socialify.git.ci/king04aman/Bash-Scripting-Cheatsheet/image?description=1\u0026font=Jost\u0026forks=1\u0026issues=1\u0026language=1\u0026logo=https%3A%2F%2Fimages.weserv.nl%2F%3Furl%3Dhttps%3A%2F%2Favatars.githubusercontent.com%2Fu%2F62813940%3Fv%3D4%26h%3D250%26w%3D250%26fit%3Dcover%26mask%3Dcircle%26maxage%3D7d\u0026name=1\u0026owner=1\u0026pattern=Circuit%20Board\u0026pulls\u0026pulls=1\u0026stargazers=1\u0026theme=Dark)\n\n_Welcome to the Bash Scripting Cheat Sheet repository! This project aims to be a comprehensive and beginner-friendly resource for learning and mastering Bash scripting. Whether you're a seasoned developer or just starting with shell scripting, this cheat sheet will serve as a handy reference guide._\n\n## Table of Contents\n\n- [Introduction](#introduction)\n- [Getting Started](#getting-started)\n- [Basic Syntax](#basic-syntax)\n- [Variables](#variables)\n- [Control Structures](#control-structures)\n  - [Boolean Operators](#boolean-operators)\n  - [Numeric Operators](#numeric-operators)\n  - [String Operators](#string-operators)\n  - [If Statements](#if-statements)\n  - [Inline If Statements](#inline-if-statements)\n  - [While Loops](#while-loops)\n  - [For Loops](#for-loops)\n  - [Case Statements](#case-statements)\n- [Functions](#functions)\n- [File Operations](#file-operations)\n  - [Check Disk Usage](#check-disk-usage)\n  - [Monitor CPU Usage](#monitor-cpu-usage)\n  - [Display System Information](#display-system-information)\n  - [Backup Files](#backup-files)\n  - [Check Network Connectivity](#check-network-connectivity)\n  - [Check Available Memory](#check-available-memory)\n  - [Monitor Disk Usage of a Specific Directory](#monitor-disk-usage-of-a-specific-directory)\n  - [List Running Processes](#list-running-processes)\n  - [Display Current Date and Time](#display-current-date-and-time)\n  - [Generate Random Password](#generate-random-password)\n  - [Check System Load Average](#check-system-load-average)\n  - [Monitor Network Traffic](#monitor-network-traffic)\n  - [Search for a File](#search-for-a-file)\n  - [Display System Users](#display-system-users)\n  - [Check System Uptime](#check-system-uptime)\n- [Text Processing](#text-processing)\n  - [Replace in Files](#replace-in-files)\n  - [Symbolic Links](#symbolic-links)\n  - [Compressing Files](#compressing-files)\n    - [zip](#zip)\n    - [gzip](#gzip)\n    - [tar -c](#tar--c)\n  - [Decompressing Files](#decompressing-files)\n    - [unzip](#unzip)\n    - [gunzip](#gunzip)\n    - [tar -x](#tar--x)\n- [Command-Line Arguments](#command-line-arguments)\n- [Common Utilities](#common-utilities)\n  - [HTTP Requests](#http-requests)\n  - [Network Troubleshooting](#network-troubleshooting)\n  - [DNS](#dns)\n  - [Hardware](#hardware)\n  - [Terminal Multiplexers](#terminal-multiplexers)\n  - [Secure Shell Protocol (SSH)](#secure-shell-protocol-ssh)\n  - [Secure Copy](#secure-copy)\n  - [Bash Profile](#bash-profile)\n  - [Bash Script](#bash-script)\n    - [Variables](#variables)\n    - [Environment Variables](#environment-variables)\n    - [Functions](#functions)\n    - [Exit Codes](#exit-codes)\n  - [Conditional Statements](#conditional-statements)\n    - [Boolean Operators](#boolean-operators)\n    - [Numeric Operators](#numeric-operators)\n    - [String Operators](#string-operators)\n    - [If Statements](#if-statements)\n    - [Inline If Statements](#inline-if-statements)\n    - [While Loops](#while-loops)\n    - [For Loops](#for-loops)\n    - [Case Statements](#case-statements)\n- [Input/Ouput Redirectors](#input-output-redirectors)\n- [Command Line Processing Cycle](#command-line-processing-cycle)\n- [Debugging Script](#debugging-shell-scripts)\n- [Colors and Styles](#colors-and-styles)\n- [Tips and Tricks](#tips-and-tricks)\n- [Shortcut Keys](#shortcut-keys)\n- [Best Practices](#best-practices)\n- [Contributing](#contributing)\n- [License](#license)\n\n## Introduction\n\nBash (Bourne Again SHell) is a powerful and widely used shell scripting language in the Unix/Linux environment. It provides a command-line interface for interacting with the operating system and automating tasks.\n\nThis cheat sheet is designed to help you understand and utilize Bash scripting effectively. It covers essential concepts, syntax, and common patterns, making it an ideal resource for both beginners and experienced developers.\n\n## Getting Started\n\nIf you're new to Bash scripting, here are some resources to help you get started:\n\n- [Bash Guide for Beginners](http://tldp.org/LDP/Bash-Beginners-Guide/html/index.html)\n- [Bash Reference Manual](https://www.gnu.org/software/bash/manual/bash.html)\n- [Bash Academy](https://guide.bash.academy/)\n\n## Basic Syntax\n\nLearn the fundamental syntax of Bash scripting:\n\n```bash\n#!/bin/bash\n\n# Your code here\n```\n\n## Variables\n\nDeclare and use variables in Bash:\n\n```bash\nname=\"John\"\necho \"Hello, $name!\"\n```\n\n## Control Structures\n\nUnderstand control structures like if statements and loops:\n\n```bash\nif [ condition ]; then\n  # Code to execute if condition is true\nfi\n\nfor i in {1..5}; do\n  # Code to repeat 5 times\ndone\n```\n\n## Functions\n\nDefine and call functions in Bash:\n\n```bash\nfunction greet {\n  echo \"Hello, $1!\"\n}\n\ngreet \"Alice\"\n```\n\n## File Operations\n\nPerform file-related operations:\n\n```bash\n# Check if a file exists\nif [ -e \"file.txt\" ]; then\n  # Code to execute if file exists\nfi\n\n# Read from a file\ncontent=$(\u003cfile.txt)\n```\n\n## Text Processing\n\nManipulate text using powerful tools like `sed` and `awk`:\n\n```bash\n# Replace text in a file\nsed 's/old/new/g' input.txt \u003e output.txt\n\n# Print specific columns from a CSV\nawk -F',' '{print $1, $3}' data.csv\n```\n\n## Command-Line Arguments\n\nHandle command-line arguments in your scripts:\n\n```bash\n#!/bin/bash\n\n# Access command-line arguments\necho \"Script name: $0\"\necho \"First argument: $1\"\n```\n\n## Common Utilities\n\nExplore common Bash utilities:\n\n- `grep`: Search for patterns in files.\n- `cut`: Extract specific columns from text.\n- `find`: Search for files in a directory hierarchy.\n- `sort`: Sort lines of text files.\n\n## Command History\n\n```bash\n!!                      # Re-run the previous command\n\ntouch foo.sh\nchmod +x !$             # Apply executable permissions to the last argument of the previous command (foo.sh)\n```\n\n## Navigating Directories\n\n```bash\npwd                             # Print the current directory path\nls                              # List directories\nls -a|--all                     # List all directories, including hidden ones\nls -l                           # List directories in long format\nls -l -h|--human-readable       # List directories in long format with human-readable sizes\nls -t                           # List directories by modification time, with newest first\nstat foo.txt                    # Display size, creation, and modification timestamps for a file\nstat foo                        # Display size, creation, and modification timestamps for a directory\ntree                            # Display directory and file tree\ntree -a                         # Display directory and file tree, including hidden entries\ntree -d                         # Display directory tree\ncd foo                          # Change directory to 'foo'\ncd                              # Change directory to home directory\ncd ~                            # Change directory to home directory\ncd -                            # Change directory to the last visited directory\npushd foo                       # Change directory to 'foo' and add the previous directory to the directory stack\npopd                            # Return to the directory saved by the last 'pushd' command\n```\n\n## Creating Directories\n\n```bash\nmkdir foo                                # Create a directory named 'foo'\nmkdir foo bar                            # Create multiple directories\nmkdir -p|--parents foo/bar               # Create a nested directory\nmkdir -p|--parents {foo,bar}/baz         # Create multiple nested directories\n\nmktemp -d|--directory                    # Create a temporary directory\n```\n\n## Moving Directories\n\n```bash\ncp -R|--recursive foo bar                                       # Copy directory 'foo' to 'bar'\nmv foo bar                                                      # Move directory 'foo' to 'bar'\n\nrsync -z|--compress -v|--verbose /foo /bar                      # Copy directory, overwriting destination\nrsync -a|--archive -z|--compress -v|--verbose /foo /bar         # Copy directory, without overwriting destination\nrsync -avz /foo username@hostname:/bar                          # Copy local directory to remote directory\nrsync -avz username@hostname:/foo /bar                          # Copy remote directory to local directory\n```\n\n## Deleting Directories\n\n```bash\nrmdir foo                               # Delete empty directory 'foo'\nrm -r|--recursive foo                   # Delete directory 'foo' and its contents\nrm -r|--recursive -f|--force foo        # Delete directory 'foo' and its contents, ignoring nonexistent files and never prompting\n```\n\n## Creating Files\n\n```bash\ntouch foo.txt                           # Create or update file 'foo.txt'\ntouch foo.txt bar.txt                   # Create multiple files\ntouch {foo,bar}.txt                     # Create multiple files\ntouch test{1..3}                        # Create test1, test2, and test3 files\ntouch test{a..c}                        # Create testa, testb, and testc files\n\nmktemp                                  # Create a temporary file\n```\n\n## Standard Output, Standard Error, and Standard Input\n\n```bash\necho \"foo\" \u003e bar.txt        # Overwrite file 'bar.txt' with content\necho \"foo\" \u003e\u003e bar.txt       # Append content to file 'bar.txt'\n\nls exists 1\u003e stdout.txt     # Redirect standard output to a file\nls noexist 2\u003e stderror.txt  # Redirect standard error output to a file\nls 2\u003e\u00261 \u003e out.txt           # Redirect standard output and error to a file\nls \u003e /dev/null              # Discard standard output and error\n\nread foo                    # Read from standard input and assign to variable 'foo'\n```\n\n## Moving Files\n\n```bash\ncp foo.txt bar.txt                                 # Copy file 'foo.txt' to 'bar.txt'\nmv foo.txt bar.txt                                 # Move file 'foo.txt' to 'bar.txt'\n\nrsync -z|--compress -v|--verbose /foo.txt /bar     # Copy file quickly if it's changed\nrsync z|--compress -v|--verbose /foo.txt /bar.txt  # Copy and rename file quickly if it's changed\n```\n\n## Deleting Files\n\n```bash\nrm foo.txt              # Delete file 'foo.txt'\nrm -f|--force foo.txt   # Delete file 'foo.txt', ignore nonexistent files, and never prompt\n```\n\n## Reading Files\n\n```bash\ncat foo.txt             # Print all contents\nless foo.txt            # View contents paginated (g - go to top, SHIFT+g - go to bottom, /foo - search for 'foo')\nhead foo.txt            # Display top 10 lines of the file\ntail foo.txt            # Display bottom 10 lines of the file\nopen foo.txt            # Open file in the default editor\nwc foo.txt              # Count lines, words, and characters in the file\n```\n\n## File Permissions\n\n| #   | Permission               | rwx | Binary |\n| --- | ------------------------ | --- | ------ |\n| 7   | read, write, and execute | rwx | 111    |\n| 6   | read and write           | rw- | 110    |\n| 5   | read and execute         | r-x | 101    |\n| 4   | read only                | r-- | 100    |\n| 3   | write and execute        | -wx | 011    |\n| 2   | write only               | -w- | 010    |\n| 1   | execute only             | --x | 001    |\n| 0   | none                     | --- | 000    |\n\nFor a directory, execute means you can enter the directory.\n\n| User | Group | Others | Description                                                                                           |\n| ---- | ----- | ------ | ----------------------------------------------------------------------------------------------------- |\n| 6    | 4     | 4      | User can read and write, everyone else can read (Default file permissions)                            |\n| 7    | 5     | 5      | User can read, write, and execute, everyone else can read and execute (Default directory permissions) |\n\n- u - User\n- g - Group\n- o - Others\n- a - All of the above\n\n```bash\nls -l /foo.sh           # List file permissions\nchmod +100 foo.sh       # Add execute permission for the user\nchmod -100 foo.sh       # Remove execute permission for the user\nchmod u+x foo.sh        # Grant execute permission to the user\nchmod g+x foo.sh        # Grant execute permission to the group\nchmod u-x,g-x foo.sh    # Revoke execute permission from the user and group\nchmod u+x,g+x,o+x foo.sh # Grant execute permission to everyone\nchmod a+x foo.sh        # Grant execute permission to everyone\nchmod +x foo.sh         # Grant execute permission to everyone\n```\n\n## Finding Files\n\nFind the binary files for a command.\n\n```bash\ntype wget                   # Find the binary\nwhich wget                  # Find the binary\nwhereis wget                # Find the binary, source, and manual page files\n```\n\n`locate` uses an index and is fast.\n\n```bash\nupdatedb                    # Update the index\n\nlocate foo.txt              # Find a file\nlocate --ignore-case foo.txt # Find a file and ignore case\nlocate f*.txt               # Find text files starting with 'f'\n```\n\n`find` doesn't use an index and is slow.\n\n```bash\nfind /path -name foo.txt                  # Find a file\nfind /path -iname foo.txt                 # Find a file with case-insensitive search\nfind /path -name \"*.txt\"                  # Find all text files\nfind /path -name foo.txt -delete          # Find a file and delete it\nfind /path -name \"*.png\" -exec pngquant {} # Find and execute pngquant on all .png files\nfind /path -type f -name foo.txt          # Find a file\nfind /path -type d -name foo              # Find a directory\nfind /path -type l -name foo.txt          # Find a symbolic link\nfind /path -type f -mtime +30             # Find files not modified in 30 days\nfind /path -type f -mtime +30 -delete     # Delete files not modified in 30 days\n```\n\n## Find in Files\n\n```bash\ngrep 'foo' /bar.txt                        # Search for 'foo' in file 'bar.txt'\ngrep 'foo' /bar -r|--recursive             # Search for 'foo' in directory 'bar'\ngrep 'foo' /bar -R|--dereference-recursive # Search for 'foo' in directory 'bar' and follow symbolic links\ngrep 'foo' /bar -l|--files-with-matches    # Show files that match\ngrep 'foo' /bar -L|--files-without-match   # Show files that don't match\ngrep 'Foo' /bar -i|--ignore-case           # Case-insensitive search\ngrep 'foo' /bar -x|--line-regexp           # Match the entire line\ngrep 'foo' /bar -C|--context 1             # Add N lines of context above and below each search result\ngrep 'foo' /bar -v|--invert-match          # Show lines that don't match\ngrep 'foo' /bar -c|--count                 # Count lines that match\ngrep 'foo' /bar -n|--line-number           # Add line numbers\ngrep 'foo' /bar --colour                   # Add color to output\ngrep 'foo\\|bar' /baz -R                    # Search for 'foo' or 'bar' in directory 'baz'\ngrep --extended-regexp|-E 'foo|bar' /baz -R# Use regular expressions\negrep 'foo|bar' /baz -R                    # Use regular expressions\n```\n\n### Replace in Files\n\n```bash\nsed 's/fox/bear/g' foo.txt               # Replace 'fox' with 'bear' in foo.txt and display to console\nsed 's/fox/bear/gi' foo.txt              # Replace 'fox' (case insensitive) with 'bear' in foo.txt and display to console\nsed 's/red fox/blue bear/g' foo.txt      # Replace 'red' with 'blue' and 'fox' with 'bear' in foo.txt and display to console\nsed 's/fox/bear/g' foo.txt \u003e bar.txt     # Replace 'fox' with 'bear' in foo.txt and save to bar.txt\nsed 's/fox/bear/g' foo.txt -i|--in-place # Replace 'fox' with 'bear' in foo.txt and overwrite foo.txt\n```\n\n## Symbolic Links\n\n```bash\nln -s|--symbolic foo bar            # Create a symbolic link 'bar' to the 'foo' folder\nln -s|--symbolic -f|--force foo bar # Overwrite an existing symbolic link 'bar'\nls -l                               # Display where symbolic links are pointing\n```\n\n## Compressing Files\n\n### zip\n\nCompresses one or more files into \\*.zip files.\n\n```bash\nzip foo.zip /bar.txt                # Compress bar.txt into foo.zip\nzip foo.zip /bar.txt /baz.txt       # Compress bar.txt and baz.txt into foo.zip\nzip foo.zip /{bar,baz}.txt          # Compress bar.txt and baz.txt into foo.zip\nzip -r|--recurse-paths foo.zip /bar # Compress directory bar into foo.zip\n```\n\n### gzip\n\nCompresses a single file into \\*.gz files.\n\n```bash\ngzip /bar.txt foo.gz           # Compress bar.txt into foo.gz and then delete bar.txt\ngzip -k|--keep /bar.txt foo.gz # Compress bar.txt into foo.gz\n```\n\n### tar -c\n\nCompresses (optionally) and combines one or more files into a single _.tar, _.tar.gz, _.tpz, or _.tgz file.\n\n```bash\ntar -c|--create -z|--gzip -f|--file=foo.tgz /bar.txt /baz.txt # Compress bar.txt and baz.txt into foo.tgz\ntar -c|--create -z|--gzip -f|--file=foo.tgz /{bar,baz}.txt    # Compress bar.txt and baz.txt into foo.tgz\ntar -c|--create -z|--gzip -f|--file=foo.tgz /bar              # Compress directory bar into foo.tgz\n```\n\n## Decompressing Files\n\n### unzip\n\n```bash\nunzip foo.zip          # Unzip foo.zip into the current directory\n```\n\n### gunzip\n\n```bash\ngunzip foo.gz           # Unzip foo.gz into the current directory and delete foo.gz\ngunzip -k|--keep foo.gz # Unzip foo.gz into the current directory\n```\n\n### tar -x\n\n```bash\ntar -x|--extract -z|--gzip -f|--file=foo.tar.gz # Un-compress foo.tar.gz into the current directory\ntar -x|--extract -f|--file=foo.tar              # Un-combine foo.tar into the current directory\n```\n\n## Disk Usage\n\n```bash\ndf                     # List disks, size, used, and available space\ndf -h|--human-readable # List disks, size, used, and available space in a human-readable format\n\ndu                     # List current directory, subdirectories, and file sizes\ndu /foo/bar            # List specified directory, subdirectories, and file sizes\ndu -h|--human-readable # List current directory, subdirectories, and file sizes in a human-readable format\ndu -d|--max-depth      # List current directory, subdirectories, and file sizes within the max depth\ndu -d 0                # List current directory size\n```\n\n## Memory Usage\n\n```bash\nfree                   # Show memory usage\nfree -h|--human        # Show human-readable memory usage\nfree -h|--human --si   # Show human-readable memory usage in power of 1000 instead of 1024\nfree -s|--seconds 5    # Show memory usage and update continuously every five seconds\n```\n\n## Packages\n\n```bash\napt update                   # Refresh the repository index\napt search wget              # Search for a package\napt show wget                # List information about the wget package\napt list --all-versions wget # List all versions of the package\napt install wget             # Install the latest version of the wget package\napt install wget=1.2.3       # Install a specific version of the wget package\napt remove wget              # Remove the wget package\napt upgrade                  # Upgrade all upgradable packages\n```\n\n## Shutdown and Reboot\n\n```bash\nshutdown                     # Shutdown in 1 minute\nshutdown now \"Cya later\"     # Immediately shut down\n\n\nshutdown +5 \"Cya later\"      # Shutdown in 5 minutes\n\nshutdown --reboot            # Reboot in 1 minute\nshutdown -r now \"Cya later\"  # Immediately reboot\nshutdown -r +5 \"Cya later\"   # Reboot in 5 minutes\n\nshutdown -c                  # Cancel a shutdown or reboot\n\nreboot                       # Reboot now\nreboot -f                    # Force a reboot\n```\n\n## Identifying Processes\n\n```bash\ntop                    # List all processes interactively\nhtop                   # List all processes interactively\nps all                 # List all processes\npidof foo              # Return the PID of all foo processes\n\nCTRL+Z                 # Suspend a process running in the foreground\nbg                     # Resume a suspended process and run in the background\nfg                     # Bring the last background process to the foreground\nfg 1                   # Bring the background process with the PID to the foreground\n\nsleep 30 \u0026             # Sleep for 30 seconds and move the process into the background\njobs                   # List all background jobs\njobs -p                # List all background jobs with their PID\n\nlsof                   # List all open files and the process using them\nlsof -itcp:4000        # Return the process listening on port 4000\n```\n\n## Process Priority\n\nProcess priorities go from -20 (highest) to 19 (lowest).\n\n```bash\nnice -n -20 foo        # Change the process priority by name\nrenice 20 PID          # Change the process priority by PID\nps -o ni PID           # Return the process priority of PID\n```\n\n## Killing Processes\n\n```bash\nCTRL+C                 # Kill a process running in the foreground\nkill PID               # Shut down the process by PID gracefully. Sends TERM signal.\nkill -9 PID            # Force shutdown of the process by PID. Sends SIGKILL signal.\npkill foo              # Shut down the process by name gracefully. Sends TERM signal.\npkill -9 foo           # Force shut down the process by name. Sends SIGKILL signal.\nkillall foo            # Kill all processes with the specified name gracefully.\n```\n\n## Date \u0026 Time\n\n```bash\ndate                   # Print the date and time\ndate --iso-8601        # Print the ISO8601 date\ndate --iso-8601=ns     # Print the ISO8601 date and time\n\ntime tree              # Time how long the tree command takes to execute\n```\n\n## Scheduled Tasks\n\n```pre\n   *      *         *         *           *\nMinute, Hour, Day of month, Month, Day of the week\n```\n\n```bash\ncrontab -l                 # List the cron tab\ncrontab -e                 # Edit the cron tab in Vim\ncrontab /path/crontab      # Load the cron tab from a file\ncrontab -l \u003e /path/crontab # Save the cron tab to a file\n\n* * * * * foo              # Run foo every minute\n*/15 * * * * foo           # Run foo every 15 minutes\n0 * * * * foo              # Run foo every hour\n15 6 * * * foo             # Run foo daily at 6:15 AM\n44 4 * * 5 foo             # Run foo every Friday at 4:44 AM\n0 0 1 * * foo              # Run foo at midnight on the first of the month\n0 0 1 1 * foo              # Run foo at midnight on the first of the year\n\nat -l                      # List scheduled tasks\nat -c 1                    # Show the task with ID 1\nat -r 1                    # Remove the task with ID 1\nat now + 2 minutes         # Create a task in Vim to execute in 2 minutes\nat 12:34 PM next month     # Create a task in Vim to execute at 12:34 PM next month\nat tomorrow                # Create a task in Vim to execute tomorrow\n```\n\n## HTTP Requests\n\n```bash\ncurl https://example.com                               # Retrieve response body\ncurl -i|--include https://example.com                  # Include status code and HTTP headers\ncurl -L|--location https://example.com                 # Follow redirects\ncurl -o|--remote-name foo.txt https://example.com      # Save response to a text file\ncurl -H|--header \"User-Agent: Foo\" https://example.com # Add a custom HTTP header\ncurl -X|--request POST -H \"Content-Type: application/json\" -d|--data '{\"foo\":\"bar\"}' https://example.com # POST JSON\ncurl -X POST -H --data-urlencode foo=\"bar\" http://example.com                           # POST URL Form Encoded\n\nwget https://example.com/file.txt .                            # Download a file to the current directory\nwget -O|--output-document foo.txt https://example.com/file.txt # Save response to a file with the specified name\n```\n\n## Network Troubleshooting\n\n```bash\nping example.com            # Send multiple ping requests using the ICMP protocol\nping -c 10 -i 5 example.com # Make 10 attempts, 5 seconds apart\n\nip addr                     # List IP addresses on the system\nip route show               # Show IP addresses to router\n\nnetstat -i|--interfaces     # List all network interfaces and in/out usage\nnetstat -l|--listening      # List all open ports\n\ntraceroute example.com      # List all servers the network traffic goes through\n\nmtr -w|--report-wide example.com                                    # Continually list all servers the network traffic goes through\nmtr -r|--report -w|--report-wide -c|--report-cycles 100 example.com # Output a report that lists network traffic 100 times\n\nnmap 0.0.0.0                # Scan for the 1000 most common open ports on localhost\nnmap 0.0.0.0 -p1-65535      # Scan for open ports on localhost between 1 and 65535\nnmap 192.168.4.3            # Scan for the 1000 most common open ports on a remote IP address\nnmap -sP 192.168.1.1/24     # Discover all machines on the network by ping'ing them\n```\n\n## DNS\n\n```bash\nhost example.com            # Show the IPv4 and IPv6 addresses\n\ndig example.com             # Show complete DNS information\n\ncat /etc/resolv.conf        # resolv.conf lists nameservers\n```\n\n## Hardware\n\n```bash\nlsusb                  # List USB devices\nlspci                  # List PCI hardware\nlshw                   # List all hardware\n```\n\n## Terminal Multiplexers\n\nStart multiple terminal sessions. Active sessions persist reboots. `tmux` is more modern than `screen`.\n\n```bash\ntmux             # Start a new session (CTRL-b + d to detach)\ntmux ls          # List all sessions\ntmux attach -t 0 # Reattach to a session\n\nscreen           # Start a new session (CTRL-a + d to detach)\nscreen -ls       # List all sessions\nscreen -R 31166  # Reattach to a session\n\nexit             # Exit a session\n```\n\n## Secure Shell Protocol (SSH)\n\n```bash\nssh hostname                 # Connect to hostname using your current user name over the default SSH port 22\nssh -i foo.pem hostname      # Connect to hostname using the identity file\nssh user@hostname            # Connect to hostname using the user over the default SSH port 22\nssh user@hostname -p 8765    # Connect to hostname using the user over a custom port\nssh ssh://user@hostname:8765 # Connect to hostname using the user over a custom port\n```\n\nSet default user and port in `~/.ssh/config`, so you can just enter the name next time:\n\n```bash\n$ cat ~/.ssh/config\nHost name\n  User foo\n  Hostname 127.0.0.1\n  Port 8765\n$ ssh name\n```\n\n## Secure Copy\n\n```bash\nscp foo.txt ubuntu@hostname:/home/ubuntu # Copy foo.txt into the specified remote directory\n```\n\n## Bash Profile\n\n- bash - `.bashrc`\n- zsh - `.zshrc`\n\n```bash\n# Always run ls after cd\nfunction cd {\n  builtin cd \"$@\" \u0026\u0026 ls\n}\n\n# Prompt user before overwriting any files\nalias cp='cp --interactive'\nalias mv='mv --interactive'\nalias rm='rm --interactive'\n\n# Always show disk usage in a human readable format\nalias df='df -h'\nalias du='du -h'\n```\n\n## Bash Script\n\n### Variables\n\n```bash\n#!/bin/bash\n\nfoo=123                # Initialize variable foo with 123\ndeclare -i foo=123     # Initialize an integer foo with 123\ndeclare -r foo=123     # Initialize readonly variable foo with 123\necho $foo              # Print variable foo\necho ${foo}_'bar'      # Print\n\n variable foo followed by _bar\necho ${foo:-'default'} # Print variable foo if it exists otherwise print default\n\nexport foo             # Make foo available to child processes\nunset foo              # Make foo unavailable to child processes\n```\n\n### Environment Variables\n\n```bash\n#!/bin/bash\n\nenv            # List all environment variables\necho $PATH     # Print PATH environment variable\nexport FOO=Bar # Set an environment variable\n```\n\n### Functions\n\n```bash\n#!/bin/bash\n\ngreet() {\n  local world=\"World\"\n  echo \"$1 $world\"\n  return \"$1 $world\"\n}\ngreet \"Hello\"\ngreeting=$(greet \"Hello\")\n```\n\n### Exit Codes\n\n```bash\n#!/bin/bash\n\nexit 0   # Exit the script successfully\nexit 1   # Exit the script unsuccessfully\necho $?  # Print the last exit code\n```\n\n### Conditional Statements\n\n#### Boolean Operators\n\n- `$foo` - Is true\n- `!$foo` - Is false\n\n#### Numeric Operators\n\n- `-eq` - Equals\n- `-ne` - Not equals\n- `-gt` - Greater than\n- `-ge` - Greater than or equal to\n- `-lt` - Less than\n- `-le` - Less than or equal to\n- `-e foo.txt` - Check if the file exists\n- `-z foo` - Check if the variable exists\n\n#### String Operators\n\n- `=` - Equals\n- `==` - Equals\n- `-z` - Is null\n- `-n` - Is not null\n- `\u003c` - Is less than in ASCII alphabetical order\n- `\u003e` - Is greater than in ASCII alphabetical order\n\n#### If Statements\n\n```bash\n#!/bin/bash\n\nif [[ $foo = 'bar' ]]; then\n  echo 'one'\nelif [[ $foo = 'bar' ]] || [[ $foo = 'baz' ]]; then\n  echo 'two'\nelif [[ $foo = 'ban' ]] \u0026\u0026 [[ $USER = 'bat' ]]; then\n  echo 'three'\nelse\n  echo 'four'\nfi\n```\n\n#### Inline If Statements\n\n```bash\n#!/bin/bash\n\n[[ $USER = 'rehan' ]] \u0026\u0026 echo 'yes' || echo 'no'\n```\n\n#### While Loops\n\n```bash\n#!/bin/bash\n\ndeclare -i counter\ncounter=10\nwhile [[ $counter -gt 2 ]]; do\n  echo The counter is $counter\n  counter=counter-1\ndone\n```\n\n#### For Loops\n\n```bash\n#!/bin/bash\n\nfor i in {0..10..2}\n  do\n    echo \"Index: $i\"\n  done\n\nfor filename in file1 file2 file3\n  do\n    echo \"Content: \" \u003e\u003e $filename\n  done\n\nfor filename in *;\n  do\n    echo \"Content: \" \u003e\u003e $filename\n  done\n```\n\n#### Case Statements\n\n```bash\n#!/bin/bash\n\necho \"What's the weather like tomorrow?\"\nread weather\n\ncase $weather in\n  sunny | warm ) echo \"Nice weather: \" $weather\n  ;;\n  cloudy | cool ) echo \"Not bad weather: \" $weather\n  ;;\n  rainy | cold ) echo \"Terrible weather: \" $weather\n  ;;\n  * ) echo \"Don't understand\"\n  ;;\nesac\n```\n\n### Script to Check Disk Usage\n\n```bash\n#!/bin/bash\n\ndisk_usage=$(df -h | grep '/dev/sda1')\necho \"Disk Usage Information:\"\necho \"$disk_usage\"\n```\n\n### Script to Monitor CPU Usage\n\n```bash\n#!/bin/bash\n\ncpu_usage=$(top -bn1 | grep \"Cpu(s)\" | sed \"s/.*, *\\([0-9.]*\\)%* id.*/\\1/\" | awk '{print 100 - $1\"%\"}')\necho \"CPU Usage: $cpu_usage\"\n```\n\n### Script to Display System Information\n\n```bash\n#!/bin/bash\n\necho \"System Information:\"\necho \"Hostname: $(hostname)\"\necho \"Operating System: $(uname -s)\"\necho \"Kernel Version: $(uname -r)\"\necho \"CPU Architecture: $(uname -m)\"\necho \"Total Memory: $(free -h | awk '/Mem/{print $2}')\"\necho \"Available Memory: $(free -h | awk '/Mem/{print $7}')\"\necho \"Uptime: $(uptime -p)\"\n```\n\n### Script to Backup Files\n\n```bash\n#!/bin/bash\n\nbackup_dir=\"/path/to/backup\"\nsource_dir=\"/path/to/source\"\n\ntimestamp=$(date +%Y%m%d%H%M%S)\nbackup_file=\"backup_$timestamp.tar.gz\"\n\necho \"Creating backup...\"\ntar -czf \"$backup_dir/$backup_file\" \"$source_dir\"\necho \"Backup created: $backup_file\"\n```\n\n### Script to Check Network Connectivity\n\n```bash\n#!/bin/bash\n\nping_result=$(ping -c 4 google.com)\n\nif [[ $? -eq 0 ]]; then\n  echo \"Network is reachable.\"\nelse\n  echo \"Network is unreachable.\"\nfi\n```\n\n### Script to Check Available Memory\n\n```bash\n#!/bin/bash\n\navailable_memory=$(free -h | awk '/Mem/{print $7}')\necho \"Available Memory: $available_memory\"\n```\n\n### Script to Monitor Disk Usage of a Specific Directory\n\n```bash\n#!/bin/bash\n\ndirectory=\"/path/to/directory\"\ndisk_usage=$(du -sh \"$directory\" 2\u003e/dev/null | cut -f1)\n\nif [[ -z $disk_usage ]]; then\n  echo \"Directory not found or permission denied.\"\nelse\n  echo \"Disk Usage of $directory: $disk_usage\"\nfi\n```\n\n### Script to List Running Processes\n\n```bash\n#!/bin/bash\n\necho \"Running Processes:\"\nps aux\n```\n\n### Script to Display Current Date and Time\n\n```bash\n#!/bin/bash\n\ncurrent_datetime=$(date +\"%Y-%m-%d %H:%M:%S\")\necho \"Current Date and Time: $current_datetime\"\n```\n\n### Script to Generate Random Password\n\n```bash\n#!/bin/bash\n\npassword=$(openssl rand -base64 12)\necho \"Generated Password: $password\"\n```\n\n### Script to Check System Load Average\n\n```bash\n#!/bin/bash\n\nload_average=$(cat /proc/loadavg | awk '{print $1, $2, $3}')\necho \"System Load Average: $load_average\"\n```\n\n### Script to Monitor Network Traffic\n\n```bash\n#!/bin/bash\n\necho \"Network Traffic:\"\nnetstat -i\n```\n\n### Script to Search for a File\n\n```bash\n#!/bin/bash\n\nfile_to_search=\"filename\"\necho \"Searching for $file_to_search...\"\nfind / -name \"$file_to_search\" 2\u003e/dev/null\n```\n\n### Script to Display System Users\n\n```bash\n#!/bin/bash\n\necho \"System Users:\"\ncut -d: -f1 /etc/passwd\n```\n\n### Script to Check System Uptime\n\n```bash\n#!/bin/bash\n\nuptime=$(uptime)\necho \"System Uptime: $uptime\"\n```\n\n## Input Output Redirectors\n\n```bash\ncmd1|cmd2  # Pipe; takes standard output of cmd1 as standard input to cmd2\n\u003c file     # Takes standard input from file\n\u003e file     # Directs standard output to file\n\u003e\u003e file    # Directs standard output to file; append to file if it already exists\n\u003e|file     # Forces standard output to file even if noclobber is set\nn\u003e|file    # Forces output to file from file descriptor n even if noclobber is set\n\u003c\u003e file    # Uses file as both standard input and standard output\nn\u003c\u003efile    # Uses file as both input and output for file descriptor n\nn\u003efile     # Directs file descriptor n to file\nn\u003cfile     # Takes file descriptor n from file\nn\u003e\u003efile    # Directs file description n to file; append to file if it already exists\nn\u003e\u0026        # Duplicates standard output to file descriptor n\nn\u003c\u0026        # Duplicates standard input from file descriptor n\nn\u003e\u0026m       # File descriptor n is made to be a copy of the output file descriptor\nn\u003c\u0026m       # File descriptor n is made to be a copy of the input file descriptor\n\u0026\u003efile     # Directs standard output and standard error to file\n\u003c\u0026-        # Closes the standard input\n\u003e\u0026-        # Closes the standard output\nn\u003e\u0026-       # Closes the output from file descriptor n\nn\u003c\u0026-       # Closes the input from file descriptor n\n\n|tee \u003cfile\u003e# Output command to both terminal and a file (-a to append to file)\n```\n\n## Command Line Processing Cycle\n\n```bash\ncommand  # Removes alias and function lookup. Only built-ins and commands found in the search path are executed\nbuiltin  # Looks up only built-in commands, ignoring functions and commands found in PATH\nenable   # Enables and disables shell built-ins\n\neval     # Takes arguments and runs them through the command-line processing steps all over again\ntrap     # Sets up signal handling for the shell, allowing you to execute commands when signals are received\n```\n\n## Debugging Shell Scripts\n\n```bash\n# Check for syntax errors without executing commands\nbash -n scriptname\nset -o noexec  # Alternative (set option in script)\n\n# Echo commands before running them\nbash -v scriptname\nset -o verbose  # Alternative (set option in script)\n\n# Echo commands after command-line processing\nbash -x scriptname\nset -o xtrace  # Alternative (set option in script)\n\n# Print out the values of variables at script exit\ntrap 'echo $varname' EXIT\n\nfunction errtrap {\n  es=$?\n  echo \"ERROR line $1: Command exited with status $es.\"\n}\n\n# Run whenever a command exits with non-zero status\ntrap 'errtrap $LINENO' ERR\n\nfunction dbgtrap {\n  echo \"badvar is $badvar\"\n}\n\n# Execute before every statement in a function or script\ntrap dbgtrap DEBUG\n\n# Turn off the DEBUG trap after the problematic section\ntrap - DEBUG\n\nfunction returntrap {\n  echo \"A return occurred\"\n}\n\n# Execute each time a shell function or a script finishes executing\ntrap returntrap RETURN\n```\n\n## Colors and Styles\n\n```bash\n# Note: \\e or \\x1B also work instead of \\033\n\n# Reset\nColor_Off='\\033[0m' # Text Reset\n\n# Regular Colors\nBlack='\\033[0;30m'  # Black\nRed='\\033[0;31m'    # Red\nGreen='\\033[0;32m'  # Green\nYellow='\\033[0;33m' # Yellow\nBlue='\\033[0;34m'   # Blue\nPurple='\\033[0;35m' # Purple\nCyan='\\033[0;36m'   # Cyan\nWhite='\\033[0;97m'  # White\n\n# Additional colors\nLGrey='\\033[0;37m'  # Light Gray\nDGrey='\\033[0;90m'  # Dark Gray\nLRed='\\033[0;91m'   # Light Red\nLGreen='\\033[0;92m' # Light Green\nLYellow='\\033[0;93m'# Light Yellow\nLBlue='\\033[0;94m'  # Light Blue\nLPurple='\\033[0;95m'# Light Purple\nLCyan='\\033[0;96m'  # Light Cyan\n\n# Bold\nBBlack='\\033[1;30m' # Black\nBRed='\\033[1;31m'   # Red\nBGreen='\\033[1;32m' # Green\nBYellow='\\033[1;33m'# Yellow\nBBlue='\\033[1;34m'  # Blue\nBPurple='\\033[1;35m'# Purple\nBCyan='\\033[1;36m'  # Cyan\nBWhite='\\033[1;37m' # White\n\n# Underline\nUBlack='\\033[4;30m' # Black\nURed='\\033[4;31m'   # Red\nUGreen='\\033[4;32m' # Green\nUYellow='\\033[4;33m'# Yellow\nUBlue='\\033[4;34m'  # Blue\nUPurple='\\033[4;35m'# Purple\nUCyan='\\033[4;36m'  # Cyan\nUWhite='\\033[4;37m' # White\n\n# Background\nOn_Black='\\033[40m' # Black\nOn_Red='\\033[41m'   # Red\nOn_Green='\\033[42m' # Green\nOn_Yellow='\\033[43m'# Yellow\nOn_Blue='\\033[44m'  # Blue\nOn_Purple='\\033[45m'# Purple\nOn_Cyan='\\033[46m'  # Cyan\nOn_White='\\033[47m' # White\n\n# Example of usage\necho -e \"${Green}This is GREEN text${Color_Off} and normal text\"\necho -e \"${Red}${On_White}This is Red text on White background${Color_Off}\"\n# Option -e is mandatory, it enables interpretation of backslash escapes\nprintf \"${Red} This is red \\n\"\n```\n\n## Tips and Tricks\n\n```bash\n# Set an alias\ncd; nano .bash_profile\n\u003e alias gentlenode='ssh admin@gentlenode.com -p 3404'  # Add your alias in .bash_profile\n\n# To quickly go to a specific directory\ncd; nano .bashrc\n\u003e shopt -s cdable_vars\n\u003e export websites=\"/Users/mac/Documents/websites\"\n\nsource .bashrc\ncd $websites\n\n# Shortcut for going back to the previous directory\ncd -\n\n# Quickly create a new directory and navigate into it\nmkcd() { mkdir -p \"$@\" \u0026\u0026 cd \"$1\"; }\n\n# Easily extract compressed files\nextract() {\n    if [ -f \"$1\" ] ; then\n        case $1 in\n            *.tar.bz2)   tar xvjf \"$1\"     ;;\n            *.tar.gz)    tar xvzf \"$1\"     ;;\n            *.tar.xz)    tar xvJf \"$1\"     ;;\n            *.bz2)       bunzip2 \"$1\"      ;;\n            *.rar)       unrar x \"$1\"      ;;\n            *.gz)        gunzip \"$1\"       ;;\n            *.tar)       tar xvf \"$1\"      ;;\n            *.tbz2)      tar xvjf \"$1\"     ;;\n            *.tgz)       tar xvzf \"$1\"     ;;\n            *.zip)       unzip \"$1\"        ;;\n            *.Z)         uncompress \"$1\"   ;;\n            *.7z)        7z x \"$1\"         ;;\n            *)           echo \"'$1' cannot be extracted\" ;;\n        esac\n    else\n        echo \"'$1' is not a valid file\"\n    fi\n}\n\n# Generate a random string\nrandom_string() {\n    head /dev/urandom | tr -dc A-Za-z0-9 | head -c ${1:-32}\n}\n\n# Quick search for a command in the history\nhistgrep() {\n    history | grep \"$@\"\n}\n\n# Display a progress bar while running a command\nprogressbar() {\n    local duration=\"${1}\"\n    local cols=$(tput cols)\n    local fillchar=\"█\"\n    local progresschar=\"▌\"\n    local blankchar=\"░\"\n    local progress=\"\"\n    local percentage=\"\"\n    local elapsed=\"0\"\n\n    while [ \"${elapsed}\" -lt \"${duration}\" ]; do\n        percentage=$(( elapsed * 100 / duration ))\n        progress=$(( cols * percentage / 100 ))\n        printf \"\\r${fillchar}%-${progress}s${blankchar}%-$(( cols - progress ))s ${percentage}%%\" | tr ' ' \"${progresschar}\"\n        sleep 1\n        (( elapsed++ ))\n    done\n\n    printf \"\\n\"\n}\n\n# Show disk usage for current directory sorted by size\nduh() {\n    du -h --max-depth=1 | sort -hr\n}\n\n# Find a file with a pattern in the current directory and its subdirectories\nfindf() {\n    find . -type f -iname \"*$1*\"\n}\n\n# Print the last few lines of a file\ntailn() {\n    tail -n \"${1:-10}\"\n}\n\n# Open the current directory in a file explorer\nopendir() {\n    if command -v xdg-open \u003e/dev/null 2\u003e\u00261; then\n        xdg-open .\n    elif command -v open \u003e/dev/null 2\u003e\u00261; then\n        open .\n    elif command -v explorer \u003e/dev/null 2\u003e\u00261; then\n        explorer .\n    else\n        echo \"Could not detect a supported file explorer.\"\n    fi\n}\n\n# Count the number of lines in a file\nlinecount() {\n    wc -l \u003c \"$1\"\n}\n\n# Convert Markdown files to HTML using pandoc\nmd2html() {\n    if [ $# -eq 0 ]; then\n        echo \"Usage: md2html \u003cinput_file.md\u003e [output_file.html]\"\n        return 1\n    fi\n    input_file=\"$1\"\n    output_file=\"${2:-${input_file%.md}.html}\"\n    pandoc -s -o \"$output_file\" \"$input_file\"\n    echo \"HTML file generated: $output_file\"\n}\n\n# Quickly access frequently used directories with bookmarks\nbookmark() {\n    case $1 in\n        add)\n            if [ $# -eq 2 ]; then\n                echo \"alias $2='cd $(pwd)'\" \u003e\u003e ~/.bashrc\n                source ~/.bashrc\n                echo \"Bookmark added for $(pwd)\"\n            else\n                echo \"Usage: bookmark add \u003calias\u003e\"\n            fi\n            ;;\n        remove)\n            if [ $# -eq 2 ]; then\n                sed -i \"/alias $2=/d\" ~/.bashrc\n                unalias \"$2\"\n                source ~/.bashrc\n                echo \"Bookmark removed: $2\"\n            else\n                echo \"Usage: bookmark remove \u003calias\u003e\"\n            fi\n            ;;\n        list)\n            grep \"alias \" ~/.bashrc | grep -oP \"(?\u003c=alias ).*(?=')\"\n            ;;\n        *)\n            echo \"Usage: bookmark [add|remove|list]\"\n            ;;\n    esac\n}\n\n# Quickly convert images to a different format\nconvert_image() {\n    if [ $# -lt 2 ]; then\n        echo \"Usage: convert_image \u003cinput_file\u003e \u003coutput_format\u003e\"\n        return 1\n    fi\n    input_file=\"$1\"\n    output_format=\"$2\"\n    output_file=\"${input_file%.*}.$output_format\"\n    convert \"$input_file\" \"$output_file\"\n    echo \"Image converted to $output_format: $output_file\"\n}\n```\n\n## Shortcut Keys\n\n```bash\n#!/bin/bash\n\n# Movement Shortcuts\nCTRL+A  # Move to the beginning of the line\nCTRL+B  # Move backward one character\nCTRL+E  # Move to the end of the line\nCTRL+F  # Move forward one character\nALT+B   # Move backward one word\nALT+F   # Move forward one word\n\n# Deletion Shortcuts\nCTRL+D  # Delete one character backward or log out of the current session\nCTRL+H  # Delete one character under the cursor (same as DELETE)\nCTRL+K  # Delete forward to the end of the line\nCTRL+W  # Delete the word behind the cursor\nALT+D   # Delete the next word\nALT+H   # Delete one character backward\n\n# Line Editing Shortcuts\nCTRL+C  # Halt the current command\nCTRL+G  # Abort the current editing command and ring the terminal bell\nCTRL+L  # Clear the screen and redisplay the line\nCTRL+M  # Same as RETURN\nCTRL+J  # Same as RETURN\nCTRL+N  # Move to the next line in command history\nCTRL+P  # Move to the previous line in command history\nCTRL+Q  # Resume suspended shell output\nCTRL+R  # Search backward\nCTRL+S  # Search forward or suspend shell output\nCTRL+T  # Transpose two characters\nCTRL+U  # Kill backward from the point to the beginning of the line\nCTRL+V  # Make the next character typed verbatim\nCTRL+Y  # Retrieve (yank) the last item killed\nCTRL+Z  # Stop the current command, resume with fg in the foreground or bg in the background\n\n# Word Editing Shortcuts\nALT+T   # Transpose two words\nALT+U   # Capitalize every character from the current cursor position to the end of the word\nALT+L   # Uncapitalize every character from the current cursor position to the end of the word\nALT+C   # Capitalize the letter under the cursor\nALT+R   # Revert any changes to a command pulled from history\nALT+?   # List possible completions for what is typed\nALT+^   # Expand line to the most recent match from history\n\n# Other Shortcuts\nCTRL+X then (       # Start recording a keyboard macro\nCTRL+X then )       # Finish recording keyboard macro\nCTRL+X then E       # Invoke text editor specified by $EDITOR on current command line then execute results as shell commands\nCTRL+A then D       # Logout from screen but don't kill it, if any command exists, it will continue\n\n# Character Deletion Shortcuts\nBACKSPACE  # Delete one character backward\nDELETE     # Delete one character under the cursor\n```\n\n## Best Practices\n\nFollow best practices to write clean and maintainable Bash scripts:\n\n- Use meaningful variable names.\n- Add comments to explain complex sections.\n- Check for errors and handle them gracefully.\n\n## Contributing\n\nWe welcome contributions from the community! If you have improvements or additional content to add, please follow our [contribution guidelines](CONTRIBUTING.md).\n\n## License\n\nThis Bash Scripting Cheat Sheet is licensed under the [MIT License](LICENSE.md). Feel free to use, share, and modify the content as per the terms of the license.\n\n\u003ch3 align='center'\u003e🎉 😃 Happy Scripting 🚀 🎉 \u003c/h3\u003e\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fking04aman%2Fbash-scripting-cheatsheet","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fking04aman%2Fbash-scripting-cheatsheet","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fking04aman%2Fbash-scripting-cheatsheet/lists"}