If you’ve ever worked with a coding agent, you’ve noticed that when they ask you for permission to do things, or simply report on what they are doing, they’ll not just summarize their task but they’ll show you the commands that they will be or are running. The way that one changes files, moves files around, updates the computer’s configuration, launch programs, or send and receive network information is done via commands. Agents don’t have hands for dragging and dropping. Text-based commands is the way your computer can do anything. Agents rely on it, but you should develop this valuable skill as well. It’s far more general and powerful than graphical interfaces alone, and besides the GUIs use commands “under the hood”. It is empowering to know what’s going on. And you do want to understand exactly what your agents are doing, right?
Basic commands Files and Folders Navigating the file system Creating folders Moving folders Creating files Moving files Deleting files Editing files The Python REPL
If you are using Windows, install Git for Windows. Then launch the program called Git Bash. You will be using Git Bash rather than PowerShell throughout the course.
If you are using macOS, you might already have the program called Terminal on your task bar. Launch it if so; if not, hit ⌘-Space and type in terminal. If you have any other operating system, make sure it has a Unix-like shell (chances are if this is you, you have a niche OS and already know what you are doing 😀).
Vocab learning time: The terminal is a visual program providing a CLI (command line interface) on which commands are issued on the command line. The commands are executed by an internal program called a shell. Don’t worry too much about the distinctions for now: in practice, people mix up these terms all the time.
Now let’s try out some commands. We’ll do these together and explain everything during class.
datedfwhoamiecho The command line is funhostnamepsclearHere are some commands that don’t work on Windows (even with Git Bash). If you have macOS, try them, If you are Windows user, look over the shoulder of a classmate with a Mac as they try these out:
calcal 2025cal 1752host www.google.comgrep qi /usr/share/dict/wordsgrep 'a.*e.*i.*o.*u' /usr/share/dict/wordsgrep 'a.*e.*i.*o.*u' /usr/share/dict/words | wc -lHow many commands are there?Hundreds at least. The number is actually unlimited because you can install new software that comes with additional commands, and you can write your own commands!
There are nice online resources listing built-in commands for the Mac and built in commands for Linux-like systems. If you are running Git Bash, enter the command:
ls -1F /bin | grep '\*$' | grep -v '\.dll\*$' | sed 's/\*$\|\.exe\*$//g' | columnto see a list of the basic commands it provides.
Now, we’ll do these super important commands that manage your computer’s file system (and we’ll discuss what’s happening during class):
pwdlsls -lls -acd /lscdpwdcd ..pwdcdmkdir cmsi1010cd cmsi1010mkdir lab01 lab02cd lab02Now after these commands, assuming your name is Jessica, the current folder, a.k.a. current directory is something like /Users/jessica/cmsi1010/lab02 on a Mac, /home/jessica/cmsi1010/lab02 on Linux, or /c/Users/jessica/cmsi1010/lab02 on Git Bash under Windows. Because different systems put user folders in different places, there’s a cool convention: the folder named ~ refers to your home folder! So we can say, whatever system we’re on, you can always refer to this folder as ~/cmsi1010/lab02.
Is it “folder” or ”directory”?No one cares. Pick which one you like better. “Directory” is the OG term, which is why
cdgot its name: it means “change directory.” Ditto formkdir.
Now let’s practice: We’re going to fetch a zip file of completely messed up folders and files, unzip it, and use find . to see not only the files in your current folder but those in all of the subfolders.
curl -L https://github.com/rtoal/cmsi-1010-classroom/raw/refs/heads/main/labs/places.zip -o places.zipls (to make sure you got the zip file)unzip -t places.zip (to see what is in the zip; the -t stands for “test”)unzip places.zip (does the unzipping, creating new files)find .(shows everything in the current folder and its subfolders)Ah, so similar to how ~ is your home folder, . is your current folder. (It’s the one that you are “in” right now, set via the cd command we learned about above, remember?)
Here is what your folder structure for this class should look like at this point:
cmsi1010
├── lab01
└── lab02
├── places.zip
└── world
├── africa
│ ├── ghana
│ └── italy
├── asia
│ ├── china
│ ├── iceland
│ │ └── matsya-narayana.jpg
│ └── spain
│ └── spanish-steps.jpg
├── europe
│ ├── egypt
│ ├── india
│ │ └── bahia-palace.jpg
│ └── palau
└── oceania
├── morocco
└── zambia
└── victoria-falls.jpg
WAIT THIS IS REALLY MESSED UP! We’re going to get these in order using only the command line. Practice matters! Here are the first few commands:
cd world
mv africa/italy europe
mv europe/egypt africa
mv oceania/zambia africa
mv asia/spain/spanish-steps.jpg europe/italy
. is the current folder for more interesting practice. Let’s make India be our current folder (it’s okay that it’s still not in the right place; we’ll get things right eventually):cd europe/india
.. is the name of the current folder’s parent folder. Here’s the magic:mv bahia-palace.jpg ../../oceania/morocco
. so we do this:mv ../../asia/iceland/matsya-narayana.jpg .
pwd
cd ..
mv ../asia/iceland .
So we got pretty far along ourselves, but now your job is to figure out the commands to do each of the following. As you do these things, keep a record of the commands you entered. (Remember, you are currently “in” Europe. You can stay there or move back up to the world folder. Your choice!
find . to check everything out.Congratulations! Your lab02/world folder should now look great.
Let’s practice adding new folders. From the world folder:
mkdir north-americamkdir north-america/méxico north-america/barbadosmkdir oceania/kiribatiOH! Just realized something: that zip file is still there, isn’t it. Let’s get rid of it:
rm places.zipYou are getting good manipulating the structure of the file system and for creating folders. How about creating a file? We weren’t doing files in the previous lab, so let’s create a file in the lab01 folder for a triangle program. First we use cd to get into our class folder, then touch to create the file:
cd ~/cmsi1010touch lab01/triangle.pyHow do you know the file got created? Try these commands, which we will explain in class:
lsls -lcat lab01/triangle.pyThe point is, the new file is empty. It has a size of zero bytes. How do we get content into it? Agents use the echo command, but even for the most command line savvy humans, for a file with multiple lines, a text editor is better.
The most popular these days for programmers is Visual Studio Code, or VSCode for short. Install it. Then launch it.
Within VSCode, open a “workspace” at the cmsi1010 folder. Note how easy it is to expand and collapse the folders in your workspace: VSCode gives you a really nice view of your files. Everything you do in this course can be done within this workspace.
You can also run VSCode from the command lineOptionally, do some research to find out how to run VSCode from the command line. If you are able to set things up to do so, go to your cmsi1010 folder (remember,
cdgets you there), then run the command:code .That can be quite convenient.
Once open, find your simple_triangles.py file in the VSCode file explorer. Next, edit that file as follows, and don’t forget to save it:
def print_triangle(character, lines): for count in range(1, lines + 1): print(character * count) print_triangle(character="@", lines=8) print_triangle(character="&", lines=13) print_triangle(character="o", lines=5)
If you haven’t edited files beforeIt won’t be so bad! It’s not unlike other tools you used to compose emails or documents. When you create and save files, they are created not in an online account, but directly on your computer’s file system.
Oh, and if you are new to “saving” files, you will get used to that eventually. We will explain what that means in class, too.
Once you have saved that file, go back into the Terminal (or Git Bash) and go to the lab01 folder (use cd to get there), where we will try to run this program. To do so, we’ll need a Python runner installed on our machine. It might already be there. To see if it is, type:
python3 --versionIf you see something like command not found: python3 then try:
python --versionYou should get a response like Python 3.13.2. If you have anything less than Python 3.13, then you need to install Python on your machine. It is recommended you install Python from the official Python downloads page. After downloading, run either python3 --version or python --version (whichever one works). If you can’t get either to work, get help during class.
And now, we can run a program:
python3 simple_triangles.pyor,
python simple_triangles.pyIt would be nice if the world would standardize on the name of the Python command, but alas.
One last item. The python (or python3) command will run a Python program if you give it the name of a file, but if you just enter python or python3 with no argument, you will drop into a little command line environment in which you can execute bits of Python. This environment is called the Python shell, or the Python REPL. Its prompt is >>>. Try it out now. Inside the Python environment, here are some suggested commands. (The last one, exit() is a good one to know!)
>>> 10 * 5
50
>>> 3 ** 21 + 5
10460353208
>>> "Hello" + ", " + "World"
'Hello, World'
>>> type(3)
<class 'int'>
>>> type(3.14)
<class 'float'>
>>> type("Hello")
<class 'str'>
>>> type([1, 2, 3])
<class 'list'>
>>> exit()
Exiting the Python InterpreterOne of these ways should work: entering
quit, enteringquit(), enteringexit, enteringexit(), the keychord Control-D. If desperate, the keychord Control-C might also work, as does closing the Terminal Window in which the shell is running. Don’t just give up and turn off the computer. Become fluent in this stuff, even if it takes a lot of practice.
Tired of moving back and forth between the Terminal and VSCode applications? You can open an integrated terminal right inside VSCode! Just go to the menu and select Terminal > New Terminal. There are ways to use multiple terminals in the terminal window. Ask a friend or AI assistant how.
If you are a Windows user, you will need to make sure that you set the terminal program to Git Bash rather than PowerShell or Command Prompt. The course staff can help you if require assistance.
It’s good to be able to use either the Terminal program or the integrated terminal in VSCode. It’s also fine to have your own preference, too.
Now it’s your turn. Here are some ideas for you to extend the activities above:
mv command to move a file or folder into a different folder. But you can also use mv to rename a file. Find out how to do this, and practice with this command.tree is not required, but it is really cool to have.)Keep up the momentum with these recommended reads and activities:
We’ve covered:
date, df, echo, whoami, hostname, ps, clearpwd, ls, cd, mkdir, curl, unzip, find, rm, touch, cat/ (root folder), ~ (home folder), . (current folder), .. (parent folder)Here are some questions useful for your spaced repetition learning. Many of the answers are not found on this page. Some will have popped up in lecture. Others will require you to do your own research.
curlunzipunzip -t/~...pwdcd ~/cmsi1010cd ..lsfind .mkdirtouchrmmvmv animals/dog caninesmv best bestiecatls -lpython3 or python, it dependsexit(), quit(), or by using the keychord Control-D