dev to main periodic update #71

Merged
mik-tf merged 35 commits from development into main 2024-05-14 17:28:54 +00:00
Showing only changes of commit c54a6ab037 - Show all commits

View File

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