dev to main periodic update #71
| @@ -24,6 +24,7 @@ | ||||
|   - [Become the superuser (su) on Linux](#become-the-superuser-su-on-linux) | ||||
|   - [Exit a session](#exit-a-session) | ||||
|   - [Know the current user](#know-the-current-user) | ||||
|   - [See the path of a package](#see-the-path-of-a-package) | ||||
|   - [Set the path of a package](#set-the-path-of-a-package) | ||||
|   - [See the current path](#see-the-current-path-1) | ||||
|   - [Find the current shell](#find-the-current-shell) | ||||
| @@ -127,11 +128,11 @@ You can also set a number of counts with `-c` on Linux and MAC and `-n` on Windo | ||||
| Here are the steps to install [Go](https://go.dev/). | ||||
|  | ||||
| * Install go | ||||
|   * ``` | ||||
|     ``` | ||||
|     sudo apt install golang-go | ||||
|     ``` | ||||
| * Verify that go is properly installed | ||||
|   * ``` | ||||
|     ``` | ||||
|     go version | ||||
|     ``` | ||||
|  | ||||
| @@ -142,19 +143,19 @@ Here are the steps to install [Go](https://go.dev/). | ||||
| Follow those steps to install [Brew](https://brew.sh/) | ||||
|  | ||||
| * Installation command from Brew: | ||||
|   * ``` | ||||
|     ``` | ||||
|     /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" | ||||
|     ``` | ||||
| * Add the path to the **.profile** directory. Replace <user_name> by your username. | ||||
|   * ``` | ||||
|     ``` | ||||
|     echo 'eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"' >> /home/<user_name>/.profile | ||||
|     ``` | ||||
| * Evaluation the following: | ||||
|   * ``` | ||||
|     ``` | ||||
|     eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)" | ||||
|     ``` | ||||
| * Verify the installation | ||||
|   * ```  | ||||
|     ```  | ||||
|     brew doctor | ||||
|     ``` | ||||
|  | ||||
| @@ -163,27 +164,27 @@ Follow those steps to install [Brew](https://brew.sh/) | ||||
| ### Brew basic commands | ||||
|  | ||||
| * To update brew in general: | ||||
|   * ```  | ||||
|     ```  | ||||
|     brew update | ||||
|     ``` | ||||
| * To update a specific package: | ||||
|   * ```  | ||||
|     ```  | ||||
|     brew update <package_name> | ||||
|     ``` | ||||
| * To install a package: | ||||
|   * ```  | ||||
|     ```  | ||||
|     brew install <package_name> | ||||
|     ``` | ||||
| * To uninstall a package: | ||||
|   * ```  | ||||
|     ```  | ||||
|     brew uninstall <package_name> | ||||
|     ``` | ||||
| * To search a package: | ||||
|   * ```  | ||||
|     ```  | ||||
|     brew search <package_name> | ||||
|     ``` | ||||
| * [Uninstall Brew](https://github.com/homebrew/install#uninstall-homebrew) | ||||
|   * ``` | ||||
|     ``` | ||||
|     /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/uninstall.sh)" | ||||
|     ``` | ||||
|  | ||||
| @@ -194,11 +195,11 @@ Follow those steps to install [Brew](https://brew.sh/) | ||||
| Installing Terraform with Brew is very simple by following the [Terraform documentation](https://developer.hashicorp.com/terraform/downloads). | ||||
|  | ||||
| * Compile HashiCorp software on Homebrew's infrastructure | ||||
|   * ``` | ||||
|     ``` | ||||
|     brew tap hashicorp/tap | ||||
|     ``` | ||||
| * Install Terraform | ||||
|   * ``` | ||||
|     ``` | ||||
|     brew install hashicorp/tap/terraform | ||||
|     ``` | ||||
|  | ||||
| @@ -207,27 +208,27 @@ Installing Terraform with Brew is very simple by following the [Terraform docume | ||||
| ### Yarn basic commands | ||||
|  | ||||
| * Add a package | ||||
|   * ``` | ||||
|     ``` | ||||
|     yarn add | ||||
|     ``` | ||||
| * Initialize the development of a package | ||||
|   * ``` | ||||
|     ``` | ||||
|     yarn init | ||||
|     ``` | ||||
| * Install all the dependencies in the **package.json** file | ||||
|   * ``` | ||||
|     ``` | ||||
|     yarn install | ||||
|     ``` | ||||
| * Publish a package to a package manager | ||||
|   * ``` | ||||
|     ``` | ||||
|     yarn publish | ||||
|     ``` | ||||
| * Remove unused package from the current package | ||||
|   * ``` | ||||
|     ``` | ||||
|     yarn remove | ||||
|     ``` | ||||
| * Clean the cache | ||||
|   * ``` | ||||
|     ``` | ||||
|     yarn cache clean | ||||
|     ``` | ||||
|  | ||||
| @@ -260,11 +261,11 @@ ls -ld .?* | ||||
| You can use **tree** to display the files and organization of a directory: | ||||
|  | ||||
| * General command | ||||
|   * ``` | ||||
|     ``` | ||||
|     tree | ||||
|     ``` | ||||
| * View hidden files | ||||
|   * ``` | ||||
|     ``` | ||||
|     tree -a | ||||
|     ``` | ||||
|  | ||||
| @@ -336,10 +337,10 @@ which <application_name> | ||||
|  | ||||
| On MAC and Linux, you can use **coreutils** and **realpath** from Brew: | ||||
|  | ||||
| * ``` | ||||
|   ``` | ||||
|   brew install coreutils | ||||
|   ``` | ||||
| * ``` | ||||
|   ``` | ||||
|   realpath file_name | ||||
|   ``` | ||||
|  | ||||
| @@ -350,11 +351,11 @@ On MAC and Linux, you can use **coreutils** and **realpath** from Brew: | ||||
| You can use either command: | ||||
|  | ||||
| * Option 1 | ||||
|   * ``` | ||||
|     ``` | ||||
|     sudo -i | ||||
|     ``` | ||||
| * Option 2 | ||||
|   * ``` | ||||
|     ``` | ||||
|     sudo -s | ||||
|     ``` | ||||
|  | ||||
| @@ -364,10 +365,10 @@ You can use either command: | ||||
|  | ||||
| You can use either command depending on your shell: | ||||
|  | ||||
| * ``` | ||||
|   ``` | ||||
|   exit | ||||
|   ``` | ||||
| * ``` | ||||
|   ``` | ||||
|   logout | ||||
|   ``` | ||||
|  | ||||
| @@ -377,7 +378,7 @@ You can use either command depending on your shell: | ||||
|  | ||||
| You can use the following command: | ||||
|  | ||||
| * ``` | ||||
|   ``` | ||||
|   whoami | ||||
|   ``` | ||||
|  | ||||
| @@ -387,7 +388,7 @@ You can use the following command: | ||||
|  | ||||
| To see the path of a package, you can use the following command: | ||||
|  | ||||
| * ``` | ||||
|   ``` | ||||
|   whereis <package_name> | ||||
|   ``` | ||||
|  | ||||
| @@ -414,11 +415,11 @@ pwd | ||||
| ### Find the current shell | ||||
|  | ||||
| * Compact version | ||||
|   * ``` | ||||
|     ``` | ||||
|     echo $SHELL | ||||
|     ``` | ||||
| * Detailed version | ||||
|   * ``` | ||||
|     ``` | ||||
|     ls -l /proc/$$/exe | ||||
|     ``` | ||||
|  | ||||
| @@ -427,35 +428,35 @@ pwd | ||||
| ### SSH into Remote Server | ||||
|  | ||||
| * Create SSH key pair | ||||
|   * ``` | ||||
|     ``` | ||||
|     ssh-keygen | ||||
|     ``` | ||||
| * Install openssh-client on the local computer* | ||||
|   * ``` | ||||
|     ``` | ||||
|     sudo apt install openssh-client | ||||
|     ``` | ||||
| * Install openssh-server on the remote computer* | ||||
|   * ``` | ||||
|     ``` | ||||
|     sudo apt install openssh-server | ||||
|     ``` | ||||
| * Copy public key | ||||
|   * ``` | ||||
|     ``` | ||||
|     cat ~/.ssh/id_rsa.pub | ||||
|     ``` | ||||
| * Create the ssh directory on the remote computer | ||||
|   * ``` | ||||
|     ``` | ||||
|     mkdir ~/.ssh | ||||
|     ``` | ||||
| * Add public key in the file **authorized_keys** on the remote computer | ||||
|   * ``` | ||||
|     ``` | ||||
|     nano ~/.ssh/authorized_keys | ||||
|     ``` | ||||
| * Check openssh-server status | ||||
|   * ```  | ||||
|     ```  | ||||
|     sudo service ssh status | ||||
|     ``` | ||||
| * SSH into the remote machine | ||||
|   * ``` | ||||
|     ``` | ||||
|     ssh <username>@<remote_server_IP_or_hostname> | ||||
|     ``` | ||||
|  | ||||
| @@ -468,11 +469,11 @@ To enable remote login on a MAC, [read this section](#enable-remote-login-on-mac | ||||
| ### Replace a string by another string in a text file | ||||
|  | ||||
| * Replace one string by another (e.g. **old_string**, **new_string**) | ||||
|   * ``` | ||||
|     ``` | ||||
|     sed -i 's/old_string/new_string/g' <file_path>/<file_name> | ||||
|     ``` | ||||
| * Use environment variables (double quotes) | ||||
|   * ``` | ||||
|     ``` | ||||
|     sed -i "s/old_string/$env_variable/g" <file_path>/<file_name> | ||||
|     ``` | ||||
|  | ||||
| @@ -529,11 +530,11 @@ date | ||||
| You can use [Dig](https://man.archlinux.org/man/dig.1) to gather DNS information of a website | ||||
|  | ||||
| * Template | ||||
|   * ``` | ||||
|     ``` | ||||
|     dig <website.tld> | ||||
|     ``` | ||||
| * Example | ||||
|   * ``` | ||||
|     ``` | ||||
|     dig threefold.io | ||||
|     ``` | ||||
|  | ||||
| @@ -546,31 +547,31 @@ You can also use online tools such as [DNS Checker](https://dnschecker.org/). | ||||
| We present one of many ways to partition and mount a disk. | ||||
|  | ||||
| * Create partition with [gparted](https://gparted.org/) | ||||
|   * ``` | ||||
|     ``` | ||||
|     sudo gparted | ||||
|     ``` | ||||
| * Find the disk you want to mount (e.g. **sdb**) | ||||
|   * ``` | ||||
|     ``` | ||||
|     sudo fdisk -l | ||||
|     ``` | ||||
| * Create a directory to mount the disk to | ||||
|   * ``` | ||||
|     ``` | ||||
|     sudo mkdir /mnt/disk | ||||
|     ``` | ||||
| * Open fstab | ||||
|   * ``` | ||||
|     ``` | ||||
|     sudo nano /etc/fstab | ||||
|     ``` | ||||
| * Append the following to the fstab with the proper disk path (e.g. **/dev/sdb**) and mount point (e.g. **/mnt/disk**) | ||||
|   * ``` | ||||
|     ``` | ||||
|     /dev/sdb    /mnt/disk    ext4    defaults    0    0 | ||||
|     ``` | ||||
| * Mount the disk | ||||
|   * ``` | ||||
|     ``` | ||||
|     sudo mount /mnt/disk | ||||
|     ``` | ||||
| * Add permissions (as needed) | ||||
|   * ``` | ||||
|     ``` | ||||
|     sudo chmod -R 0777 /mnt/disk | ||||
|     ``` | ||||
|  | ||||
| @@ -583,36 +584,36 @@ We present one of many ways to partition and mount a disk. | ||||
| You can use [gocryptfs](https://github.com/rfjakob/gocryptfs) to encrypt files. | ||||
|  | ||||
| * Install gocryptfs | ||||
|   * ``` | ||||
|     ``` | ||||
|     apt install gocryptfs | ||||
|     ``` | ||||
| * Create a vault directory (e.g. **vaultdir**) and a mount directory (e.g. **mountdir**) | ||||
|   * ``` | ||||
|     ``` | ||||
|     mkdir vaultdir mountdir | ||||
|     ``` | ||||
| * Initiate the vault | ||||
|   * ``` | ||||
|     ``` | ||||
|     gocryptfs -init vaultdir | ||||
|     ``` | ||||
| * Mount the mount directory with the vault | ||||
|   * ``` | ||||
|     ``` | ||||
|     gocryptfs vaultdir mountdir | ||||
|     ``` | ||||
| * You can now create files in the folder. For example: | ||||
|   * ``` | ||||
|     ``` | ||||
|     touch mountdir/test.txt | ||||
|     ``` | ||||
| * The new file **test.txt** is now encrypted in the vault   | ||||
|   * ``` | ||||
|     ``` | ||||
|     ls vaultdir | ||||
|     ``` | ||||
| * To unmount the mountedvault folder: | ||||
|   * Option 1 | ||||
|     * ``` | ||||
|       ``` | ||||
|       fusermount -u mountdir | ||||
|       ``` | ||||
|   * Option 2 | ||||
|     * ``` | ||||
|       ``` | ||||
|       rmdir mountdir | ||||
|       ``` | ||||
|  | ||||
| @@ -623,27 +624,27 @@ To encrypt files, you can use [Veracrypt](https://www.veracrypt.fr/en/Home.html) | ||||
|  | ||||
| * Veracrypt GUI | ||||
|   * Download the package | ||||
|     * ``` | ||||
|       ``` | ||||
|       wget https://launchpad.net/veracrypt/trunk/1.25.9/+download/veracrypt-1.25.9-Ubuntu-22.04-amd64.deb | ||||
|       ``` | ||||
|   * Install the package | ||||
|     * ``` | ||||
|       ``` | ||||
|       dpkg -i ./veracrypt-1.25.9-Ubuntu-22.04-amd64.deb | ||||
|       ``` | ||||
| * Veracrypt console only | ||||
|   * Download the package | ||||
|     * ``` | ||||
|       ``` | ||||
|       wget https://launchpad.net/veracrypt/trunk/1.25.9/+download/veracrypt-console-1.25.9-Ubuntu-22.04-amd64.deb | ||||
|       ``` | ||||
|   * Install the package | ||||
|     * ``` | ||||
|       ``` | ||||
|       dpkg -i ./veracrypt-console-1.25.9-Ubuntu-22.04-amd64.deb | ||||
|       ``` | ||||
|  | ||||
| You can visit [Veracrypt download page](https://www.veracrypt.fr/en/Downloads.html) to get the newest releases. | ||||
|  | ||||
| * To run Veracrypt | ||||
|   * ``` | ||||
|     ``` | ||||
|     veracrypt | ||||
|     ``` | ||||
| * Veracrypt documentation is very complete. To begin using the application, visit the [Beginner's Tutorial](https://www.veracrypt.fr/en/Beginner%27s%20Tutorial.html). | ||||
| @@ -661,11 +662,11 @@ ifconfig | ||||
| ### See identity and info of IP address | ||||
|  | ||||
| * See abuses related to an IP address: | ||||
|   * ``` | ||||
|     ``` | ||||
|     https://www.abuseipdb.com/check/<IP_Address> | ||||
|     ``` | ||||
| * See general information of an IP address:  | ||||
|   * ``` | ||||
|     ``` | ||||
|     https://www.whois.com/whois/<IP_Address> | ||||
|     ``` | ||||
|  | ||||
| @@ -674,124 +675,124 @@ ifconfig | ||||
| ### ip basic commands | ||||
|  | ||||
| * Manage and display the state of all network  | ||||
|   * ``` | ||||
|     ``` | ||||
|     ip link | ||||
|     ``` | ||||
| * Display IP Addresses and property information (abbreviation of address) | ||||
|   * ``` | ||||
|     ``` | ||||
|     ip addr | ||||
|     ``` | ||||
| * Display and alter the routing table | ||||
|   * ``` | ||||
|     ``` | ||||
|     ip route | ||||
|     ``` | ||||
| * Manage and display multicast IP addresses | ||||
|   * ``` | ||||
|     ``` | ||||
|     ip maddr | ||||
|     ``` | ||||
| * Show neighbour object | ||||
|   * ``` | ||||
|     ``` | ||||
|     ip neigh | ||||
|     ``` | ||||
| * Display a list of commands and arguments for | ||||
| each subcommand | ||||
|   * ``` | ||||
|     ``` | ||||
|     ip help | ||||
|     ``` | ||||
| * Add an address | ||||
|   * Template | ||||
|     * ``` | ||||
|       ``` | ||||
|       ip addr add | ||||
|       ``` | ||||
|   * Example: set IP address to device **enp0** | ||||
|     * ``` | ||||
|       ``` | ||||
|       ip addr add 192.168.3.4/24 dev enp0 | ||||
|       ``` | ||||
| * Delete an address | ||||
|   * Template | ||||
|     * ``` | ||||
|       ``` | ||||
|       ip addr del | ||||
|       ``` | ||||
|   * Example: set IP address to device **enp0** | ||||
|     * ``` | ||||
|       ``` | ||||
|       ip addr del 192.168.3.4/24 dev enp0 | ||||
|       ``` | ||||
| * Alter the status of an interface | ||||
|   * Template | ||||
|     * ``` | ||||
|       ``` | ||||
|       ip link set | ||||
|       ``` | ||||
|   * Example 1: Bring interface online (here device **em2**) | ||||
|     * ``` | ||||
|       ``` | ||||
|       ip link set em2 up | ||||
|       ``` | ||||
|   * Example 2: Bring interface offline (here device **em2**) | ||||
|     * ``` | ||||
|       ``` | ||||
|       ip link set em2 down | ||||
|       ``` | ||||
| * Add a multicast address | ||||
|   * Template | ||||
|     * ``` | ||||
|       ``` | ||||
|       ip maddr add | ||||
|       ``` | ||||
|   * Example : set IP address to device **em2** | ||||
|     * ``` | ||||
|       ``` | ||||
|       ip maddr add 33:32:00:00:00:01 dev em2 | ||||
|       ``` | ||||
| * Delete a multicast address | ||||
|   * Template | ||||
|     * ``` | ||||
|       ``` | ||||
|       ip maddr del | ||||
|       ``` | ||||
|   * Example: set IP address to device **em2** | ||||
|     * ``` | ||||
|       ``` | ||||
|       ip maddr del 33:32:00:00:00:01 dev em2 | ||||
|       ``` | ||||
| * Add a routing table entry | ||||
|   * Template | ||||
|     * ``` | ||||
|       ``` | ||||
|       ip route add | ||||
|       ``` | ||||
|   * Example 1: Add a default route (for all addresses) via a local gateway | ||||
|     * ``` | ||||
|       ``` | ||||
|       ip route add default via 192.168.1.1 dev em1 | ||||
|       ``` | ||||
|   * Example 2: Add a route to 192.168.3.0/24 via the gateway at 192.168.3.2 | ||||
|     * ``` | ||||
|       ``` | ||||
|       ip route add 192.168.3.0/24 via 192.168.3.2 | ||||
|       ``` | ||||
|   * Example 3: Add a route to 192.168.1.0/24 that can be reached on | ||||
| device em1 | ||||
|     * ``` | ||||
|       ``` | ||||
|       ip route add 192.168.1.0/24 dev em1 | ||||
|       ``` | ||||
| * Delete a routing table entry | ||||
|   * Template | ||||
|     * ``` | ||||
|       ``` | ||||
|       ip route delete | ||||
|       ``` | ||||
|   * Example: Delete the route for 192.168.1.0/24 via the gateway at | ||||
| 192.168.1.1 | ||||
|     * ``` | ||||
|       ``` | ||||
|       ip route delete 192.168.1.0/24 via 192.168.1.1 | ||||
|       ``` | ||||
| * Replace, or add, a route | ||||
|   * Template | ||||
|     * ``` | ||||
|       ``` | ||||
|       ip route replace | ||||
|       ``` | ||||
|   * Example: Replace the defined route for 192.168.1.0/24 to use | ||||
| device em1 | ||||
|     * ``` | ||||
|       ``` | ||||
|       ip route replace 192.168.1.0/24 dev em1 | ||||
|       ``` | ||||
| * Display the route an address will take | ||||
|   * Template | ||||
|     * ``` | ||||
|       ``` | ||||
|       ip route get | ||||
|       ``` | ||||
|   * Example: Display the route taken for IP 192.168.18.25 | ||||
|     * ``` | ||||
|       ``` | ||||
|       ip route replace 192.168.18.25/24 dev enp0 | ||||
|       ``` | ||||
|  | ||||
| @@ -804,23 +805,23 @@ References: https://www.commandlinux.com/man-page/man8/ip.8.html | ||||
| ### Display socket statistics | ||||
|  | ||||
| * Show all sockets | ||||
|   * ``` | ||||
|     ``` | ||||
|     ss -a | ||||
|     ``` | ||||
| * Show detailed socket information | ||||
|   * ``` | ||||
|     ``` | ||||
|     ss -e | ||||
|     ``` | ||||
| * Show timer information | ||||
|   * ``` | ||||
|     ``` | ||||
|     ss -o | ||||
|     ``` | ||||
| * Do not resolve address | ||||
|   * ``` | ||||
|     ``` | ||||
|     ss -n | ||||
|     ``` | ||||
| * Show process using the socket | ||||
|   * ``` | ||||
|     ``` | ||||
|     ss -p | ||||
|     ``` | ||||
|  | ||||
| @@ -833,19 +834,19 @@ References: https://www.commandlinux.com/man-page/man8/ss.8.html | ||||
| ### Query or control network driver and hardware settings | ||||
|  | ||||
| * Display ring buffer for a device (e.g. **eth0**) | ||||
|   * ``` | ||||
|     ``` | ||||
|     ethtool -g eth0 | ||||
|     ``` | ||||
| * Display driver information for a device (e.g. **eth0**) | ||||
|   * ``` | ||||
|     ``` | ||||
|     ethtool -i eth0 | ||||
|     ``` | ||||
| * Identify eth0 by sight, e.g. by causing LEDs to blink on the network port | ||||
|   * ``` | ||||
|     ``` | ||||
|     ethtool -p eth0 | ||||
|     ``` | ||||
| * Display network and driver statistics for a device (e.g. **eth0**) | ||||
|   * ``` | ||||
|     ``` | ||||
|     ethtool -S eth0 | ||||
|     ``` | ||||
|  | ||||
| @@ -866,21 +867,21 @@ cat /sys/class/net/<ethernet_device>/carrier | ||||
| ### Add IP address to hardware port (ethernet) | ||||
|  | ||||
| * Find ethernet port ID on both computers | ||||
|   * ``` | ||||
|     ``` | ||||
|     ip a | ||||
|     ``` | ||||
| * Add IP address (DHCO or static) | ||||
|   * Computer 1 | ||||
|     * ``` | ||||
|       ``` | ||||
|       ip addr add <Private_IP_Address_1>/24 dev <ethernet_interface_1> | ||||
|       ``` | ||||
|   * Computer 2 | ||||
|     * ``` | ||||
|       ``` | ||||
|       ip addr add <Private_IP_Address_2>/24 dev <ethernet_interface_2> | ||||
|       ``` | ||||
|  | ||||
| * [Ping](#test-the-network-connectivity-of-a-domain-or-an-ip-address-with-ping) the address to confirm connection | ||||
|   * ``` | ||||
|     ``` | ||||
|     ping <Private_IP_Address> | ||||
|     ``` | ||||
|  | ||||
| @@ -918,11 +919,11 @@ You can use the following template when you set an IP address manually: | ||||
| You can use the following template to add arguments when running a script: | ||||
|  | ||||
| * Option 1 | ||||
|   * ``` | ||||
|     ``` | ||||
|     ./example_script.sh arg1 arg2 | ||||
|     ``` | ||||
| * Option 2 | ||||
|   * ``` | ||||
|     ``` | ||||
|     sh example_script.sh "arg1" "arg2" | ||||
|     ``` | ||||
|  | ||||
| @@ -930,16 +931,16 @@ You can use the following template to add arguments when running a script: | ||||
|  | ||||
| * Write a script | ||||
|   * File: `example_script.sh` | ||||
|   * ```bash | ||||
|     ```bash | ||||
|     #!/bin/sh | ||||
|     echo $@ | ||||
|     ``` | ||||
| * Give permissions | ||||
|   * ```bash | ||||
|     ```bash | ||||
|     chmod +x ./example_script.sh | ||||
|     ``` | ||||
| * Run the script with arguments | ||||
|   * ```bash | ||||
|     ```bash | ||||
|     sh example_script.sh arg1 arg2 | ||||
|     ``` | ||||
|  | ||||
| @@ -947,7 +948,7 @@ You can use the following template to add arguments when running a script: | ||||
| ### Iterate over arguments | ||||
|  | ||||
| * Write the script | ||||
|   * ```bash | ||||
|     ```bash | ||||
|       # iterate_script.sh | ||||
|       #!/bin/bash  | ||||
|       for i; do  | ||||
| @@ -955,16 +956,16 @@ You can use the following template to add arguments when running a script: | ||||
|       done | ||||
|     ``` | ||||
| * Give permissions | ||||
|   * ``` | ||||
|     ``` | ||||
|     chmod +x ./iterate_script.sh | ||||
|     ``` | ||||
| * Run the script with arguments | ||||
|   * ``` | ||||
|     ``` | ||||
|     sh iterate_script.sh arg1 arg2 | ||||
|     ``` | ||||
|  | ||||
| * The following script is equivalent | ||||
|   * ```bash | ||||
|     ```bash | ||||
|       # iterate_script.sh | ||||
|       #/bin/bash  | ||||
|       for i in $*; do  | ||||
| @@ -977,7 +978,7 @@ You can use the following template to add arguments when running a script: | ||||
| ### Count lines in files given as arguments | ||||
|  | ||||
| * Write the script | ||||
|   * ```bash | ||||
|     ```bash | ||||
|     # count_lines.sh | ||||
|     #!/bin/bash | ||||
|      for i in $*; do | ||||
| @@ -986,11 +987,11 @@ You can use the following template to add arguments when running a script: | ||||
|     done | ||||
|     ``` | ||||
| * Give permissions | ||||
|   * ``` | ||||
|     ``` | ||||
|     chmod +x ./count_lines.sh | ||||
|     ``` | ||||
| * Run the script with arguments (files). Here we use the script itself as an example. | ||||
|   * ``` | ||||
|     ``` | ||||
|     sh count_lines.sh count_lines.sh | ||||
|     ``` | ||||
|  | ||||
| @@ -999,14 +1000,14 @@ You can use the following template to add arguments when running a script: | ||||
| ### Find path of a file | ||||
|  | ||||
| * Write the script | ||||
|   * ```bash | ||||
|     ```bash | ||||
|     # find.sh | ||||
|     #!/bin/bash | ||||
|  | ||||
|     find / -iname $1 2> /dev/null | ||||
|     ``` | ||||
| * Run the script | ||||
|   * ``` | ||||
|     ``` | ||||
|     sh find.sh <filename> | ||||
|     ``` | ||||
|  | ||||
| @@ -1015,13 +1016,13 @@ You can use the following template to add arguments when running a script: | ||||
| ### Print how many arguments are passed in a script | ||||
|  | ||||
| * Write the script | ||||
|   * ```bash | ||||
|     ```bash | ||||
|     # print_qty_args.sh | ||||
|     #!/bin/bash | ||||
|     echo This script was passed $# arguments | ||||
|     ``` | ||||
| * Run the script | ||||
|   * ``` | ||||
|     ``` | ||||
|     sh print_qty_args.sh <filename> | ||||
|     ``` | ||||
|  | ||||
| @@ -1050,7 +1051,7 @@ Note that the Terraform documentation also covers other methods to install Terra | ||||
|  | ||||
| * Option 1: | ||||
|   * Use the following command line: | ||||
|     * ``` | ||||
|       ``` | ||||
|       systemsetup -setremotelogin on | ||||
|       ``` | ||||
| * Option 2 | ||||
| @@ -1063,7 +1064,7 @@ Note that the Terraform documentation also covers other methods to install Terra | ||||
|  | ||||
| * Open **Finder** \> **Go** \> **Go to Folder** | ||||
| * Paste this path | ||||
|   * ``` | ||||
|     ``` | ||||
|     ~/Library/Caches | ||||
|     ``` | ||||
|  | ||||
| @@ -1087,15 +1088,15 @@ To install Chocolatey on Windows, we follow the [official Chocolatey website](ht | ||||
|  | ||||
| * Run PowerShell as Administrator | ||||
| * Check if **Get-ExecutionPolicy** is restricted | ||||
|   * ``` | ||||
|     ``` | ||||
|     Get-ExecutionPolicy | ||||
|     ``` | ||||
|   * If it is restricted, run the following command: | ||||
|     * ``` | ||||
|       ``` | ||||
|       Set-ExecutionPolicy AllSigned | ||||
|       ``` | ||||
| * Install Chocolatey | ||||
|   * ``` | ||||
|     ``` | ||||
|     Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1')) | ||||
|     ``` | ||||
| * Note: You might need to restart PowerShell to use Chocolatey | ||||
| @@ -1107,7 +1108,7 @@ To install Chocolatey on Windows, we follow the [official Chocolatey website](ht | ||||
| Once you've installed Chocolatey on Windows, installing Terraform is as simple as can be: | ||||
|  | ||||
| * Install Terraform with Chocolatey | ||||
|   * ``` | ||||
|     ``` | ||||
|     choco install terraform | ||||
|     ``` | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user