Skip to main content

1.1.1 Why Learn the Command Line

Command-line automation workflow diagram

The command line is where you give the computer precise text instructions. In AI projects, you will use it to enter a project folder, run Python, install packages, save Git commits, connect to servers, and start services.

Do not memorize commands first. First make one small loop work:

go to a folder -> run a command -> read the output -> fix the next step

Command Line vs Graphical Interface

NeedGUICLI
One-time actionEasy to clickAlso possible
Repeat the same actionEasy to forget a clickCopy and rerun the same command
Batch workSlowFast
Server workOften unavailableStandard method
Debugging evidenceHard to recordCommand and output can be saved

The key idea is not that the terminal looks professional. The key idea is that commands are repeatable evidence.

Run This First

Open a terminal in a practice folder and run:

pwd
mkdir ai-cli-practice
cd ai-cli-practice
python -c "from pathlib import Path; Path('hello_terminal.py').write_text('print(\"hello from terminal\")\\n', encoding='utf-8')"
python hello_terminal.py
ls

Expected signal:

hello from terminal
hello_terminal.py

If python does not work on Windows, try:

py hello_terminal.py

You have now completed the smallest terminal loop: see the current folder, create a folder, create a script, run it, and inspect the result.

Where AI Projects Use It

AI taskExample command
Install packagespython -m pip install pandas
Run a scriptpython train.py
Save codegit add . and git commit -m "message"
Start an APIuvicorn main:app --reload
Connect to a serverssh user@server
Build a deployable appdocker build -t my-ai-app .

You do not need all of these today. Just recognize that many later AI workflows start from the terminal.

Ten Commands to Recognize First

CommandMeaning
pwdShow the current folder
lsList files
cdChange folder
mkdirCreate a folder
cpCopy
mvMove or rename
rmRemove
pythonRun Python
gitSave and inspect code history
pip / condaInstall packages and manage environments

If It Fails

SymptomFirst check
command not foundIs the tool installed? Did you reopen the terminal after installing it?
python opens the wrong versionRun python --version and check the active environment
File not foundRun pwd and ls; you may be in the wrong folder
Permission deniedCheck whether the file or folder belongs to another user
Command is too long to retypePress the Up Arrow to bring back command history

Pass this page when you can explain what pwd, cd, ls, and python hello_terminal.py did in your own folder. The next page teaches the basic file operations more slowly.