How to Install Magento 2 using command line?

Install Magento 2 using command line using below command:

magento setup:install --base-url=localhost/magento2/ \
--db-host=DB_HOST --db-name=DB_NAME --db-user=DB_USER --db-password=DB_PASSWORD \
--admin-firstname=FIRST_NAME --admin-lastname=LAST_NAME --admin-email=YOUR_EMAIL \
--admin-user=USER_NAME --admin-password=PASSWORD --language=en_US \
--currency=USD --timezone=America/Chicago --use-rewrites=1 \
--search-engine=elasticsearch7 --elasticsearch-host=ELASTIC_SEARCH_HOST_NAME \
--elasticsearch-port=9200

Checkout video instructions: