How to Uninstall a Program on Windows 10 from Command Prompt

  1. right click Command Prompt and select“Run as Administrator”. At the prompt, type the following command: wmic
  2. in wmic prompt, you can use below command to list apps you installed:
    product get name
  3. command to uninstall, don’t forget to confirm with Y:
    product where name=”program name” call uninstall
wmic:root\cli>product where name="Oracle VM VirtualBox 6.1.10" call uninstall
Execute (\\HANS-T430\ROOT\CIMV2:Win32_Product.IdentifyingNumber="{0359AF05-E674-4ED4-B9FB-B77918617667}",Name="Oracle VM VirtualBox 6.1.10",Vendor="Oracle Corporation",Version="6.1.10")->Uninstall() (Y/N/?)? Y
Method execution successful.
Out Parameters:
instance of __PARAMETERS
{
        ReturnValue = 1618;
};

NOTE: we can use PowerShell command to remove Win10 built-in apps, use GameServices as example:
Get-AppxPackage -AllUsers Microsoft.XboxGamingOverlay | Remove-AppxPackage
ref: https://www.majorgeeks.com/content/page/remove_windows_10_apps_using_powershell.html

use curl for API query, post and delete

  1. QUERY
    $ curl http://localhost:5000/student/
    $ curl http://localhost:5000/student/?page=1
    $ curl http://localhost:5000/student/?class=1&age=19

  2. UPDATE
    $ curl -X POST -d ‘{"name": "Lily", "age": 17, "class":1, "profile":"Likely"}’ -H "Content-Type: application/json" http://127.0.0.1:5000/student/
    {"age":17,"class":"1","id":8,"name":"Lily","profile":"Likely"}

$ curl -X PATCH -d ‘{"class":3}’ -H "Content-Type: application/json" http://127.0.0.1:5000/student/1
{"age":18,"class":"3","id":1,"name":"\u5f20\u4e09","profile":"\u64c5\u957f\u5b66\u4e60"}

  1. DELETE
    $ curl -X DELETE -H "Content-Type: application/json" http://127.0.0.1:5000/student/8

  2. OTHERS (meta and export)
    $ curl http://127.0.0.1:5000/student/meta
    $ curl -o student.csv http://127.0.0.1:5000/student/?export

Curl Cookbook: https://catonmat.net/cookbooks/curl

create a new repository on github and push files on the command line

  1. create a new repository on github first, like https://github.com/zhuby1973/play.git
  2. remove old git info on local:
    sudo rm -rf .git
  3. init and push files:
    git init
    git add .
    git commit -m "first commit"
    git remote add origin https://github.com/zhuby1973/play.git
    git push -u origin master
  4. some commands might help to check and verify:
    git remote -v
    git remote rm origin
    git remote set-url origin https://github.com/zhuby1973/play.git

install SaltStack on Ubuntu20

On Salt Master Server

  1. Run the following command to import the SaltStack repository key:
    wget -O – https://repo.saltstack.com/py3/ubuntu/20.04/amd64/latest/SALTSTACK-GPG-KEY.pub | sudo apt-key add –
  2. edit /etc/apt/sources.list.d/saltstack.list:
    deb [arch=amd64] http://repo.saltstack.com/py3/ubuntu/20.04/amd64/latest focal main
  3. Run sudo apt-get update
  4. Install the salt-master and other Salt components:
    apt -y install salt-api salt-cloud salt-master salt-ssh salt-syndic
  5. vi /etc/salt/master
    interface: 192.168.0.43 (Salt Master Server IP)
  6. systemctl restart salt-master.service
  7. root@ubunu2004:~# salt-key -F master
    Local Keys:
    master.pem: 12:0f:ba:d1:d3:cd:5c:e5:52:62:34:cd:ee:b6:51:d7:f1:30:59:79:57:fe:3f:9b:b7:79:f4:1a:42:f8:3b:bc
    master.pub: a8:87:3f:ea:f3:cd:b8:4d:6b:b9:45:d7:b2:7f:77:94:bc:a1:81:66:8e:06:46:38:77:82:65:7d:58:f6:cb:97
  8. open the FireWall
    ufw allow proto tcp from any to any port 4505,4506

on Salt Minion server

  1. do same step1-3 as master server
  2. apt -y install salt-minion
  3. edit /etc/hosts:
    192.168.0.43 saltmaster salt
  4. edit /etc/salt/minion to add master_finger(same as we generated master.pub):
    master_finger: ‘a8:87:3f:ea:f3:cd:b8:4d:6b:b9:45:d7:b2:7f:77:94:bc:a1:81:66:8e:06:46:38:77:82:65:7d:58:f6:cb:97’
  5. systemctl restart salt-minion
  6. you can run below commands to debug if there is any issues:
    salt-minion -l debug
    salt-call -l debug state.apply

    List and accept key on master server

    using the following command:
    root@ubunu2004:/etc/salt# salt-key -L
    Accepted Keys:
    Denied Keys:
    Unaccepted Keys:
    ubuntumac-minion01
    Rejected Keys:
    root@ubunu2004:/etc/salt# salt-key -A
    The following keys are going to be accepted:
    Unaccepted Keys:
    ubuntumac-minion01
    Proceed? [n/Y] y
    Key for minion ubuntumac-minion01 accepted.

    Verify the Salt commands

    root@ubunu2004:/etc/salt# salt ubuntumac-minion01 test.ping
    ubuntumac-minion01:
    True
    root@ubunu2004:/etc/salt# salt ‘‘ test.version
    ubuntumac-minion01:
    3001
    root@ubunu2004:/etc/salt# salt ‘
    ‘ disk.usage
    root@ubunu2004:/etc/salt# salt ‘*’ cmd.run ‘ls -l /etc’
    root@ubunu2004:/etc/salt# mkdir -p /srv/salt/nginx/
    root@ubunu2004:/etc/salt# touch /srv/salt/vimrc
    we have file_roots defined in /etc/salt/master:

    file_roots:
    base:
    - /srv/salt

    root@ubunu2004:/etc/salt# vi /srv/salt/nginx/init.sls

    
    nginx:
    pkg.installed: []
    service.running:
    - require:
      - pkg: nginx
root@ubunu2004:/srv/salt# salt '*' state.apply nginx

verify on ubuntumac-minion01:
root@ubuntumac:/etc/salt# which nginx
/usr/sbin/nginx

another example to distribute a shell script:
```bash
install-cleanup-script:
 file:
 - managed
 - source: salt://cleanup-directories.sh
 - name: /usr/local/bin/cleanup-directories.sh
 - user: root
 - group: root
 - mode: 754

/var/www/vhost/production.website.com:
 file.directory:
   - user: root
   - group: root
   - mode: 755
   - makedirs: true

A more detailed example showing how to create a series of databases and users to access them using variables and "for" loops:

{% set DATABASE_PASS = 'our-db-password' %}
{% for DB in ['keystone','nova','cinder','glance','heat','neutron'] %}
{{ DB }}:
mysql_database:
 - present
 mysql_grants.present:
 - grant: all privileges
 - database: {{ DB }}.*
 - user: {{ DB }}
 - host: localhost
 mysql_user.present:
 - host: localhost
 - password: {{ DATABASE_PASS }}
 - connection_charset: utf8
{% endfor %}

https://repo.saltstack.com/#ubuntu
https://docs.saltstack.com/en/master/topics/tutorials/walkthrough.html
https://docs.saltstack.com/en/latest/topics/troubleshooting/minion.html

Bash String Manipulation

1. Identify String Length inside Bash Shell Script
${#string}
2. Extract a Substring from a Variable inside Bash Shell Script
${string:position:length}
3. Shortest Substring Match
Following syntax deletes the shortest match of $substring from front of $string
${string#substring}
Following syntax deletes the shortest match of $substring from back of $string
${string%substring}
Following sample shell script explains the above two shortest substring match concepts.
$ cat shortest.sh
filename="bash.string.txt"
echo ${filename#.}
echo ${filename%.
}
$ ./shortest.sh
After deletion of shortest match from front: string.txt
After deletion of shortest match from back: bash.string
4. Longest Substring Match
Following syntax deletes the longest match of $substring from front of $string
${string##substring}
Following syntax deletes the longest match of $substring from back of $string
${string%%substring}
Following sample shell script explains the above two longest substring match concepts.
$ cat longest.sh
filename="bash.string.txt"
echo "After deletion of longest match from front:" ${filename##.}
echo "After deletion of longest match from back:" ${filename%%.
}
$ ./longest.sh
After deletion of longest match from front: txt
After deletion of longest match from back: bash
5. Find and Replace String Values inside Bash Shell Script
Replace only first match
${string/pattern/replacement}
It matches the pattern in the variable $string, and replace only the first match of the pattern with the replacement.
$ cat firstmatch.sh
filename="bash.string.txt"
echo "After Replacement:" ${filename/str./operations.}
$ ./firstmatch.sh
After Replacement: bash.operations.txt
Replace all the matches
${string//pattern/replacement}
It replaces all the matches of pattern with replacement.
$ cat allmatch.sh
filename="Path of the bash is /bin/bash"
echo "After Replacement:" ${filename//bash/sh}
$ ./allmatch.sh
After Replacement: Path of the sh is /bin/sh
Replace beginning and end
${string/#pattern/replacement}
Following syntax replaces with the replacement string, only when the pattern matches beginning of the $string.
${string/%pattern/replacement}
Following syntax replaces with the replacement string, only when the pattern matches at the end of the given $string.
$ cat posmatch.sh
filename="/root/admin/monitoring/process.sh"
echo "Replaced at the beginning:" ${filename/#\/root/\/tmp}
echo "Replaced at the end": ${filename/%.
/.ksh}
$ ./posmatch.sh
Replaced at the beginning: /tmp/admin/monitoring/process.sh
Replaced at the end: /root/admin/monitoring/process.ksh
6. Check if Two Strings are Equal
VAR1="Linuxize"
VAR2="Linuxize"
if [ "$VAR1" = "$VAR2" ]; then
echo "Strings are equal."
else
echo "Strings are not equal."
fi
7. Check if a String Contains a Substring
VAR=’GNU/Linux is an operating system’
if [[ $VAR == "Linux" ]]; then
echo "It’s there."
fi
Copy
8. Check if a String is Empty
VAR=”
if [[ -z $VAR ]]; then
echo "String is empty."
fi

Bash scripting Tutorial

Writing Readable Bash Scripts

#!/bin/bash

set -u
set -e
set -o pipefail

function is-even {
    if [[ $(($1 % 2)) -gt 0 ]]
    then return 1
    else return 0
    fi
}

function epoch {
    date +"%s"
}

if is-even $(epoch)
then echo "Even epoch"
else echo "Odd epoch"
fi

===============================================
set -u will cause the script to fail if you’re trying to reference a variable that hasn’t been set. The default behavior will just evaluate the variable to the empty string.

set -e will cause the script to exit immediately if a command fails. The default behavior is to simply continue executing the remaining commands in the script.

set -o pipefail will cause a pipeline to fail if any of the commands in the pipeline failed. The default behavior is to only use the exit status of the last command.

Passing arguments to the bash script

#!/bin/bash
# use predefined variables to access passed arguments
#echo arguments to the shell
echo $1 $2 $3 ' -> echo $1 $2 $3'

# We can also store arguments from bash command line in special array
args=("$@")
#echo arguments to the shell
echo ${args[0]} ${args[1]} ${args[2]} ' -> args=("$@"); echo ${args[0]} ${args[1]} ${args[2]}'

#use $@ to print out all arguments at once
echo $@ ' -> echo $@'

# use $# variable to print out
# number of arguments passed to the bash script
echo Number of arguments passed: $# ' -> echo Number of arguments passed: $#' 

Reading User Input

#!/bin/bash
 
echo -e "Hi, please type the word: \c "
read  word
echo "The word you entered is: $word"
echo -e "Can you please enter two words? "
read word1 word2
echo "Here is your input: \"$word1\" \"$word2\""
echo -e "How do you feel about bash scripting? "
# read command now stores a reply into the default build-in variable $REPLY
read
echo "You said $REPLY, I'm glad to hear that! "
echo -e "What are your favorite colours ? "
# -a makes read command to read into an array
read -a colours
echo "My favorite colours are also ${colours[0]}, ${colours[1]} and ${colours[2]}:-)" 

Declare simple bash array

#!/bin/bash
#Declare array with 4 elements
ARRAY=( 'Debian Linux' 'Redhat Linux' Ubuntu Linux )
# get number of elements in the array
ELEMENTS=${#ARRAY[@]}

# echo each element in array 
# for loop
for (( i=0;i<$ELEMENTS;i++)); do
    echo ${ARRAY[${i}]}
done 

Read file into bash array

#!/bin/bash
# Declare array
declare -a ARRAY
# Link filedescriptor 10 with stdin
exec 10<&0
# stdin replaced with a file supplied as a first argument
exec < $1
let count=0

while read LINE; do

    ARRAY[$count]=$LINE
    ((count++))
done

echo Number of elements: ${#ARRAY[@]}
# echo array's content
echo ${ARRAY[@]}
# restore stdin from filedescriptor 10
# and close filedescriptor 10
exec 0<&10 10<&-

Bash if / else / fi statements

1. Simple Bash if/else statement
#!/bin/bash
directory="./BashScripting"

# bash check if directory exists
if [ -d $directory ]; then
	echo "Directory exists"
else 
	echo "Directory does not exists"
fi 

2. Nested if/else
#!/bin/bash
 
# Declare variable choice and assign value 4
choice=4
# Print to stdout
 echo "1. Bash"
 echo "2. Scripting"
 echo "3. Tutorial"
 echo -n "Please choose a word [1,2 or 3]? "
# Loop while the variable choice is equal 4
# bash while loop
while [ $choice -eq 4 ]; do
 
# read user input
read choice
# bash nested if/else
if [ $choice -eq 1 ] ; then
 
        echo "You have chosen word: Bash"

else                   

        if [ $choice -eq 2 ] ; then
                 echo "You have chosen word: Scripting"
        else
         
                if [ $choice -eq 3 ] ; then
                        echo "You have chosen word: Tutorial"
                else
                        echo "Please make a choice between 1-3 !"
                        echo "1. Bash"
                        echo "2. Scripting"
                        echo "3. Tutorial"
                        echo -n "Please choose a word [1,2 or 3]? "
                        choice=4
                fi   
        fi
fi
done 

Bash Comparisons

1. Arithmetic Comparisons
-lt	<
-gt	>
-le	<=
-ge	>=
-eq	==
-ne	!=
#!/bin/bash
# declare integers
NUM1=2
NUM2=2
if [ $NUM1 -eq $NUM2 ]; then
	echo "Both Values are equal"
else 
	echo "Values are NOT equal"
fi 

2. String Comparisons
=	equal
!=	not equal
<	less then
>	greater then
-n s1	string s1 is not empty
-z s1	string s1 is empty
#!/bin/bash
#Declare string S1
S1="Bash"
#Declare string S2
S2="Scripting"
if [ $S1 = $S2 ]; then
	echo "Both Strings are equal"
else 
	echo "Strings are NOT equal"
fi 

Bash File Testing

-b filename	Block special file
-c filename	Special character file
-d directoryname	Check for directory existence
-e filename	Check for file existence
-f filename	Check for regular file existence not a directory
-G filename	Check if file exists and is owned by effective group ID.
-g filename	true if file exists and is set-group-id.
-k filename	Sticky bit
-L filename	Symbolic link
-O filename	True if file exists and is owned by the effective user id.
-r filename	Check if file is a readable
-S filename	Check if file is socket
-s filename	Check if file is nonzero size
-u filename	Check if file set-ser-id bit is set
-w filename	Check if file is writable
-x filename	Check if file is executable
#!/bin/bash
file="./file"
if [ -e $file ]; then
	echo "File exists"
else 
	echo "File does not exists"
fi 

#!/bin/bash
 
while [ ! -e myfile ]; do
# Sleep until file does exists/is created
sleep 1
done 

Bash for/while/until loop

#!/bin/bash
# bash for loop
for f in $( ls /var/ ); do
	echo $f
done 

#!/bin/bash
COUNT=6
# bash while loop
while [ $COUNT -gt 0 ]; do
	echo Value of count is: $COUNT
	let COUNT=COUNT-1
done 

#!/bin/bash
COUNT=0
# bash until loop
until [ $COUNT -gt 5 ]; do
        echo Value of count is: $COUNT
        let COUNT=COUNT+1
done 

Bash Functions

!/bin/bash
# BASH FUNCTIONS CAN BE DECLARED IN ANY ORDER
function function_B {
        echo Function B.
}
function function_A {
        echo $1
}
function function_D {
        echo Function D.
}
function function_C {
        echo $1
}
# FUNCTION CALLS
# Pass parameter to function A
function_A "Function A."
function_B
# Pass parameter to function C
function_C "Function C."
function_D 

Bash Select

#!/bin/bash
 
PS3='Choose one word: ' 

# bash select
select word in "linux" "bash" "scripting" "tutorial" 
do
  echo "The word you have selected is: $word"
# Break, otherwise endless loop
  break  
done

exit 0 

Case statement conditional

#!/bin/bash
echo "What is your preferred programming / scripting language"
echo "1) bash"
echo "2) perl"
echo "3) phyton"
echo "4) c++"
echo "5) I do not know !"
read case;
#simple case bash structure
# note in this case $case is variable and does not have to
# be named case this is just an example
case $case in
    1) echo "You selected bash";;
    2) echo "You selected perl";;
    3) echo "You selected phyton";;
    4) echo "You selected c++";;
    5) exit
esac 

Bash quotes and quotations
Quotations and quotes are important part of bash and bash scripting. Here are some bash quotes and quotations basics.
Escaping Meta characters
Before we start with quotes and quotations we should know something about escaping meta characters. Escaping will suppress a special meaning of meta characters and therefore meta characters will be read by bash literally. To do this we need to use backslash “\” character. Example:

#!/bin/bash
 #Declare bash string variable
BASH_VAR="Bash Script"
# echo variable BASH_VAR
echo $BASH_VAR
#when meta character such us "$" is escaped with "\" it will be read literally
echo $BASH_VAR 
# backslash has also special meaning and it can be suppressed with yet another "\"
echo "\" 

Single quotes
Single quotes in bash will suppress special meaning of every meta characters. Therefore meta characters will be read literally. It is not possible to use another single quote within two single quotes not even if the single quote is escaped by backslash.

#!/bin/bash
 
 #Declare bash string variable
 BASH_VAR="Bash Script"
 
 # echo variable BASH_VAR
 echo $BASH_VAR
 
 # meta characters special meaning in bash is suppressed when  using single quotes 
 echo '$BASH_VAR  "$BASH_VAR"' 

Double Quotes
Double quotes in bash will suppress special meaning of every meta characters except “$”, “\” and “`”. Any other meta characters will be read literally. It is also possible to use single quote within double quotes. If we need to use double quotes within double quotes bash can read them literally when escaping them with “\”. Example:

#!/bin/bash
 
#Declare bash string variable
BASH_VAR="Bash Script"

# echo variable BASH_VAR
echo $BASH_VAR

# meta characters and its special meaning in bash is 
# suppressed when using double quotes except "$", "\" and "`"

echo "It's $BASH_VAR  and \"$BASH_VAR\" using backticks: `date`" 

Arithmetic Operations

echo '### Bash Arithmetic Expansion ###'
# There are two formats for arithmetic expansion: $[ expression ] 
# and $(( expression #)) its your choice which you use

echo 4 + 5 = $((4 + 5))
echo 7 - 7 = $[ 7 - 7 ]
echo 4 x 6 = $((3 * 2))
echo 6 / 3 = $((6 / 3))
echo 8 % 7 = $((8 % 7))
echo 2 ^ 8 = $[ 2 ** 8 ]


echo '### Declare ###'

echo -e "Please enter two numbers \c"
# read user input
read num1 num2
declare -i result
result=$num1+$num2
echo "Result is:$result "

# bash convert binary number 10001
result=2#10001
echo $result

# bash convert octal number 16
result=8#16
echo $result

# bash convert hex number 0xE6A
result=16#E6A
echo $result 

Round floating point number:
#!/bin/bash
# get floating point number
floating_point_number=3.3446
echo $floating_point_number
# round floating point number with bash
for bash_rounded_number in $(printf %.0f $floating_point_number); do
echo "Rounded number with bash:" $bash_rounded_number
done 

bash script search string and delete the line above

we search a string "test" in file.txt file, then delete its line above.
 hans@testvm:~ $ cat ./del_line_above.sh
#!/bin/bash
line_number="$(grep -n 'test' file.txt| cut -d: -f1)"
line_number_above="$((line_number - 1))"
sed "${line_number_above}d" file.txt

 hans@testvm:~ $ cat file.txt
aadsfasfda
line 1
line 2
line 3
line 4
test
java
hans@testvm:~ $ ./del_line_above.sh
aadsfasfda
line 1
line 2
line 3
test
java

How to Install PHP7.4 and phpMyAdmin on Ubuntu 20.04

Step 1 – Install Apache2 and PHP 7.4
sudo apt install apache2 wget unzip
sudo apt install software-properties-common
sudo add-apt-repository ppa:ondrej/php
sudo apt update
sudo apt install -y php7.4
sudo apt install php7.4-mysql php7.4-curl php7.4-json php7.4-cgi php7.4-xsl
sudo apt install php7.4-zip php7.4-mbstring
sudo systemctl enable apache2
sudo systemctl start apache2
Step 2 – Install phpMyAdmin on Ubuntu 20.04
wget https://files.phpmyadmin.net/phpMyAdmin/5.0.2/phpMyAdmin-5.0.2-all-languages.zip
unzip phpMyAdmin-5.0.2-all-languages.zip
sudo mkdir /usr/share/phpmyadmin
sudo mv phpMyAdmin-5.0.2-all-languages/* /usr/share/phpmyadmin
sudo mkdir /usr/share/phpmyadmin/tmp
sudo chown -R www-data:www-data /usr/share/phpmyadmin
sudo chmod 777 /usr/share/phpmyadmin/tmp
Step 3 – Configure phpMyAdmin
sudo vi /etc/apache2/conf-available/phpmyadmin.conf:

Alias /phpmyadmin /usr/share/phpmyadmin
Alias /phpMyAdmin /usr/share/phpmyadmin

<Directory /usr/share/phpmyadmin/>
   AddDefaultCharset UTF-8
   <IfModule mod_authz_core.c>
      <RequireAny>
      Require all granted
     </RequireAny>
   </IfModule>
</Directory>

<Directory /usr/share/phpmyadmin/setup/>
   <IfModule mod_authz_core.c>
     <RequireAny>
       Require all granted
     </RequireAny>
   </IfModule>
</Directory>

sudo a2enconf phpmyadmin
you will see the link in /etc/apache2/conf-enabled
sudo systemctl restart apache2
Step 4 – Adjusting FirewallD
sudo firewall-cmd –permanent –add-service=http
sudo firewall-cmd –reload
Step 5 – Access phpMyAdmin
http://your-server-ip-domain/phpmyadmin
Log in with the username and password used to access MySQL on the command line.

Make a bootable USB drive to install Windows 10

1. Make a bootable USB drive with the Windows utility program DiskPart

If you dare to do the necessary work by hand, you can simply use the cmd.exe application, better known as “Command Prompt”, to create a bootable USB drive on all operating systems from Windows Vista (including Windows 10). This goes as follows:

Plug the USB drive into your computer’s USB port.
Search for the “cmd” application in the Windows start menu, right-click on the item, and select “Run as administrator” from the context menu. This opens a small window with white text on a black background.
Type the command “diskpart” and confirm your input with the enter key (you’ll also do this after every other entered command). This starts the storage device manager.
Enter the command “list disk” to display all available storage devices.
You can recognize your USB by its storage capacity, and it’s usually listed as “disk 1”. In the system partition, “disk 0” is usually your PC, so a hard drive or solid state drive in your computer.
Based on the assumption that your USB has the label “disk 1”, enter the command “sel disk 1” to select it (or the corresponding “disk 2”, etc.).
Enter then command “clean” to delete all files from the USB.
Enter the command “create partition primary” to create a main partition.
Enter the command “list par” and select the newly created main partition with “sel par 1”.
Activate the partition with the command “active”.
Format the USB with the command “format fs=FAT32 label=“WINDOWSUSB” quick override” (in place of “WINDOWS USB” you can also choose another label, so long as it doesn’t contain any spaces or special characters. The drive will later be displayed under this name if you plug into a running Windows computer). Formatting may take a while. You can track its progress in the percentage bar.
As soon as the process is finished, enter the command “assign” to automatically assign a drive letter (for example “G:”) to your USB.
Enter “exit” to close DiskPart, and then “exit” again to close the command prompt.

To finish the process, you just have to copy the Windows ISO file to a bootable USB stick. This is done with a basic drag-and-drop. If you’re using an installation disc, you can also drag all setup files from there onto your drive (use the folder options to display all of the hidden files first). That’s all possible in the command prompt as well. For a source media with the drive letter “D:” and a USB drive with the letter “G:”, the corresponding command would look as follows: “xcopy D:*. G:*. /S /E /F” (all of the spaces are intentional).

2. create Bootable USB with Rufus

Rufus is widely considered to be the fastest and most reliable tool for the creation of a bootable USB. It also supports UEFI (“Unified Extensible Firmware Interface”), a new mainboard firmware that replaced the old BIOS and can already be found on almost all newer computers. From Windows 8, it’s also possible to install “Windows2Go” as a portable operating system on an external storage device with Rufus.

Operation of the tool is simple:
Open the program with a double-click
Select your USB drive in “Device”
Select “Create a bootable disk using” and the option “ISO Image”
Right-click on the CD-ROM symbol and select the ISO file
Under “New volume label”, you can enter whatever name you like for your USB drive
You’ll receive the warning “ALL DATA ON THIS DEVICE WILL BE DESTROYED”, which you can confidently confirm with “OK”– at this point, you’ve ideally already saved any important files from the USB drive
Click on “Start”
As soon as the green bar is full, click on “Finish”
Eject your bootable USB drive with “Safely eject hardware”

3. Create Windows 10 installation media

https://www.microsoft.com/en-ca/software-download/windows10

click "Download tool now"
then select "Using the tool to create installation media (USB flash drive) to install Windows 10 on a different PC"

4. after bootable USB created, you need change your computer BIOS settings to make it startup from USB first!

reboot and start Windows 10 installation!