Welcome to your first CSCI 338 lab! The goal of today’s lab is to get you a little more comfortable doing “configuration things,” including working on the command line, configuring your command line environment, and working with command line code editors. You will complete the following tasks:
I have curated a list of useful resources on the course resources page. Please see the “Command Line” and “Code Editors” sections.
When a step has Mac and Windows labels, use the line for your OS and skip the other. Shared steps have no OS label.
Windows every terminal step in this lab is in WSL, not PowerShell. Your home folder is ~ (something like /home/yourname). That is not the same as C:\Users\....
Mac use the Terminal app. Your home folder is also ~.
1. Set-Up
Install VS Code if it isn’t already installed on your machine.
Windowsfollow these instructions to install WSL and a Linux distribution (Windows Subsystem for Linux). Read / watch them carefully — if you skip steps, you will likely have to rebuild your Linux distro. When you’re done, open a WSL terminal and type pwd. You should see a path like /home/yourname.
Create a directory called csci338 in your home folder (cd then mkdir csci338).
Mac you can put csci338 somewhere else if you want, but not in Downloads.
Before moving on
VS Code is installed
ls shows a csci338 folder
2. VS Code Exercises
2.1. Install VS Code Extensions
Please install the following VS Code Extensions:
Live Server (by Ritwick Dey)
Prettier (by Prettier; should have the blue “verified” badge)
Prettier ESLint (by Rebecca Vest)
To install VS Code Extensions:
From within VS Code, open the extensions window by clicking the extensions icon (looks like 4 squares on the left-hand bar).
Search for the extension name using the search textbox.
When you find the extension, install it.
2.2. Configuration Tasks
Configuring Prettier
Configure “Format on Save” using Prettier by modifying the settings.json file (a configuration file used to customize your VS Code Editor). To find settings.json, type Mac Shift + CMD + P or Windows Shift + CTRL + P and then type settings.json in the search textbox that appears. Then, add the following code to settings.json within the curly braces. Note that in JSON, each key-value pair must be separated by a comma or else there will be syntax errors:
Then Command Palette → Developer: Reload Window. Run the same script with on when you want AI back.
3. Complete the Command Line Exercises
Please complete the following command line exercises with the help of the Command Line Reference that has been compiled for you. Feel free to collaborate with your classmates!
3.1 Open a Terminal
Mac open the Terminal app
Windows open WSL
3.2. Navigation
Figure out which directory you’re in (pwd).
Windowsexplorer.exe . from WSL opens File Explorer at your current WSL folder.
Navigate to the folder where you plan to save your coursework (cd). Pro-tips:
If any of your folder names have spaces, surround the path with quotes
Use the tab key to autocomplete the path
Use the up and down keys to revive old commands
Use the history command to see the commands you’ve issued in the past
3.3. Create
Navigate to the csci338 directory you made in Part 1.
Create a directory called lab01 within csci338 (mkdir).
Navigate into the lab01 directory you just made.
Create a new file called index.html (touch).
Create another new file called style.css (touch).
Copy the Google homepage locally: curl https://www.google.com > google-home.html
If you did everything correctly, you should have a directory structure that looks like this:
Verify that the new files exist in your current directory (ls).
List all of the files and folders in your home (ls ~).
List all of the files and folders in your home directory including hidden files (ls -la ~).
List files recursively with tree. If tree is not installed:
Windowssudo apt-get update then sudo apt-get install tree
Macbrew install tree
Then try:
tree ~ -La 1
tree ~ -La 2
tree ~ with no -L can print a huge list; skip it if it is slow.
3.5. Read
Read the contents of the google-home.html file you just created (cat).
Inspect the file using some of the other read commands (less, head, tail, wc).
Pro-tip: For less, use the space bar to scroll down and q to quit.
3.6. Write
Append the sentence “Hello World” to index.html: echo "Hello World" >> index.html
Do it again.
Read the contents of index.html (cat). You should see “Hello World” twice.
Now replace the contents of index.html with “Goodbye”: echo "Goodbye" > index.html
Read the contents of index.html (cat). You should see only “Goodbye”.
You can also use >> and > to write to a new file: echo 'Yo yo' > new.txt
Read new.txt (cat).
Now remove it (rm new.txt).
Notice the difference: >> appends; > overwrites.
3.7. Move & Copy
From lab01, practice on files you just create:
touch notes.txt
mkdir practice_folder
touch practice_folder/inside.txt
Copy a file: cp notes.txt notes-copy.txt
Rename a file: mv notes-copy.txt notes-renamed.txt
Copy a directory and all subdirectories: cp -r practice_folder practice_folder_copy
Move a file into a folder: mv notes-renamed.txt practice_folder/
3.8. Search
Use grep to search files for strings / text.
Find the word “Goodbye” in your current directory or any descendants: grep "Goodbye" ./ -r
Same search, case insensitive: grep "goodbye" ./ -ri
Same search anywhere in your home directory: grep "goodbye" ~ -ri
3.9. Make a bash script
You can also combine multiple commands into a bash script (use the .sh extension). Let’s make a bash script that sets up a basic web app in your current directory.
Create a script called start-web-prj.sh
Add the following lines of code to the script:
#!/bin/bash# Prompt the user for the folder nameread -p "Enter the folder name: " DIR_NAME
# 1. Create a new directory if it doesn't already existif [ -d "$DIR_NAME" ]; thenecho"Directory '$DIR_NAME' already exists. Exiting."exit 1
elsemkdir"$DIR_NAME"echo"Directory '$DIR_NAME' created."fi# 2. Navigate into itcd"$DIR_NAME" || { echo"Failed to navigate into $DIR_NAME. Exiting."; exit 1; }
# 3. Create a new starter index.html fileecho'''
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="styles.css" />
<title>Hello World</title>
</head>
<body>
<h1>Hello World</h1>
<p>Your starter file.</p>
</body>
</html>
''' > index.html
echo"index.html created."# 4. Create a new starter styles.css fileecho'''
body * {
box-sizing: border-box;
}
body {
font-family: Arial, sans-serif;
}
''' > styles.css
echo"styles.css created."# 5. Navigate back to the original directorycd ..
When you’re done, execute the script from lab01:
bash ./start-web-prj.sh
When it asks for a folder name, type my_new_folder and press Enter.
Take a look at what was created: tree .
Now open the HTML file in a browser. Then, open the current folder in VS Code:
code .
Mac if that didn’t work, see this Stack Overflow post (Command Palette → Shell Command: Install ‘code’ command in PATH).
Before moving on
code . opens VS Code
Folders match the tree below (extra files from 3.7 are fine)
In Linux-style operating systems, you can create shortcuts, aliases, and customizations by editing your shell config file. We’ll make an alias so that typing 338 takes you to your csci338 directory.
Print the path you want the alias to open (cd ~/csci338 then pwd) and copy it.
See which shell you use: echo $SHELL
zsh (usual on Mac): you will edit ~/.zshrc
bash (usual on WSL): you will edit ~/.bashrc
Open that file and add one line at the bottom, using your path from step 1:
alias 338='cd /paste/your/path/here'
Save the file, then reload it: source ~/.zshrc or source ~/.bashrc (whichever you edited).
Test: cd ~ then 338 then pwd. You should be in csci338.
Using either vim or emacs, open a file from the command line, edit it, save it, and exit.
Vim (from lab01):
vim notes.txt
Press i (insert mode)
Type a short sentence
Press Esc
Type :wq and press Enter (write and quit)
Then cat notes.txt to confirm your sentence is there.
Before moving on
cat notes.txt shows the sentence I typed
6. Configure Java in VS Code
We will be practicing programming in this class in multiple languages, including in Java. In this section, you’re going to ensure that you can compile your Java code from the command line.
From the command line, check for the Java compiler: javac --version
If javac is not installed, expand the instructions for your OS below, follow them, then reopen your terminal and re-run javac --version to confirm.
Windows Windows / WSL: install the JDK
In WSL, run:
sudo apt update
sudo apt install default-jdk
Then close and reopen your WSL terminal.
Mac Mac: install the JDK
If you’ve taken a Java course before, you may already have a JDK installed that just isn’t on your PATH. Check with:
/usr/libexec/java_home -V
If this lists one or more JDKs, add the default one to your PATH by adding this line to the bottom of ~/.zshrc:
export PATH="$(/usr/libexec/java_home)/bin:$PATH"
Then run source ~/.zshrc and open a new Terminal tab/window.
If it says no Java runtime is installed, install one using one of these options, then reopen Terminal:
Oracle JDK (recommended): download the macOS installer for JDK 25 (LTS) from Oracle’s JDK downloads page (pick the .dmg matching your chip — Apple Silicon or Intel) and run it.
Homebrew (if you already use it):
brew install openjdk
Then follow the “Next steps” that brew prints (it gives you a command to link javac onto your PATH).
Once you’ve verified that the Java runtime environment has been installed and configured (javac --version gives you a message and not an error) create a ReadinessCheck.java file inside of your lab01 folder, and paste in the following code:
publicclassReadinessCheck {
publicstaticvoidmain(String[] args) {
System.out.println("Java is ready");
}
}
Then, compile and run this file (be sure to run these commands from the same directory your file’s in):
# compile your Java program:
javac ReadinessCheck.java
# run the resulting bytecode (*.class file) via the JVM runtime:
java ReadinessCheck
Before moving on
The terminal prints Java is ready
What do I turn in?
Under Lab 1 on Canvas, paste the command line history from today’s lab (history). If the dump is huge, the last ~80–100 lines that include this lab is enough.
What to study / have done after completing this lab…
If you are a Windows user, make sure your WSL is installed and configured
Make sure your VS Code editor is set up. If Copilot or other AI tools keep popping up, turn them off.
Make sure you know some basic shell commands, and specifically how to navigate, search, create, delete, copy, read, and move files.