Chapter 3: The Command Line - your primary tool
In the previous chapter, you've logged in to LUMI. If you were successful, you saw LUMI's login wolf, a "Did you know?" fact, and a Command Line that looked similar to this:
Welcome to the Command Line Interface (CLI). The underlying program that actually reads and executes your commands here is known as the Shell.
Navigation without a mouse
When you use Windows or macOS, you see folders and icons. You double-click a folder to see what’s inside. On LUMI, those folders (called directories in the Command Line) and files are still there, but you are "navigating by description" rather than "navigating by sight."
Why do we use this for AI?
- Flexibility: Graphical interfaces are often just "wrappers" that sit on top of Command Line tools. By working directly in the Shell, you're removing the middleman. You gain the ability to use every piece of software in the LUMI ecosystem exactly how the developers intended, without being restricted by visual menu options.
- Automation: You can write a list of commands (a script) that LUMI can follow while you are asleep. You can't "script" a mouse click easily.
- Efficiency: LUMI is optimised for math and data processing. Displaying a fancy visual desktop for thousands of users would waste massive amounts of power that should be used for your AI models instead.
Command Line study materials
To learn about the Command Line and the commands to use it, we recommend reading Linux Command Line for beginners.
If you are more of a visual learner or if this is your first time learning about the Command Line, watch this video guide (Optional).
Practice
If you prefer a visual guide, you can watch this video walkthrough of the practice steps:
The best way to learn after having studied some theory is to practise. Log in to LUMI (see Chapter 2) and let's apply what you've learned in the guides in our Command Line Terminal on LUMI. Follow these step-by-step instructions:
-
Where am I? When you log into LUMI using
sshas we did in Chapter 2, you end up in your user's$HOMEfolder (this is the current "Working Directory"). Check it by running thepwd(print Working Directory) command:user@LUMI: ~pwdThe output (what is printed/shown on the screen) should be
/users/<username>. This is "where you are" now. -
Create a directory and name it "first_dir" using
mkdir(make directory):user@LUMI: ~mkdir first_dirIf it was successful,
mkdirhas no output (it won't print a "Success!" message, it will just drop you to a new, empty prompt). Check the result by listing all the files and directories in the current Working Directory:user@LUMI: ~lsYou should see your new directory there.
-
Move Inside. Change your Working Directory to the new directory using
cd(change directory):user@LUMI: ~cd first_dirNotice that the text at the beginning of your line has updated to include
~/first_dir>. This indicates that you are now inside the new folder. -
Create a Document. While in the new directory, create a new text file using
nano, a very simple text editor:user@LUMI: ~nano first_file.txtOnce the editor opens, follow these steps to add content and save it:
- First, type or paste some text into the editor (if pressing ctrl+V doesn't work, try ctrl+shift+V or right-click to paste).
- Then, save the file by pressing ctrl+S. To help you remember, "S" in this case stands for "save".
- Finally, exit the editor by pressing ctrl+X. "X" stands for "exit".
-
View the file:
user@LUMI: ~less first_file.txtPress q to exit the
lessviewer. -
Upload a file. Even though we are working in the Command Line, using the web interface is the simplest way to upload a small file from your machine (PC/laptop) to LUMI:
- Open www.lumi.csc.fi in your browser (don't close your Terminal!), log in and go to
Home directory. This is your$HOMEuser directory. There you should see ourfirst_dirfolder (do not click into it so your upload lands in$HOME, not insidefirst_dir). - Click "Upload" and select any image from your computer to upload directly to your
$HOMEdirectory. If you don't have one at hand, download a random image from the internet for this exercise.
- Open www.lumi.csc.fi in your browser (don't close your Terminal!), log in and go to
-
Navigate to the Parent Directory. Open your Terminal. Return to the "Parent Directory" of the current Working Directory:
user@LUMI: ~cd ..Now, when you're in your
$HOMEdirectory you should see the file that you uploaded there (Hint: uselsto check that it's there). -
Copy the uploaded image to the new directory using
cp(copy). Replace<your_image.png>with the actual name of your file (using its actual extension, like.jpgor.jpegif it's not a.png), and run:user@LUMI: ~cp <your_image.png> first_dirChange your Working Directory to
first_dirand list the files in it. Hint: look at steps 2 and 3. -
Rename the copied image. Let's rename it to
renamed_image.png(using your file's actual extension if it's not.png, likerenamed_image.jpg). We use themv(move) command for this, as renaming is essentially moving a file to the same location under a new name:user@LUMI: ~mv <your_image.png> renamed_image.png -
Delete the original image. Use
rm(remove) to delete the original image that we left in the Parent Directory:user@LUMI: ~rm ../<your_image.png>Make sure that the original image has been removed by navigating to the Parent Directory and listing the files there.
-
Clear the screen. If your Terminal is getting cluttered, you can clear all previous output to get a fresh screen. This just moves previous commands and outputs out of view (but doesn't remove or reverse anything):
user@LUMI: ~clear -
Disconnect. Great job! You can now disconnect from LUMI by pressing Ctrl+D. You will notice the Command Line prompt change back to your local computer's format (such as
username@your_computeron Mac/Linux, orC:\Users\Nameon Windows). This confirms you are safely back on your machine.
You can learn more about Linux Command Line on the Linux basics tutorial for CSC page. (Optional)
Your Command Line cheatsheet
| Command / Key | Action | Quick Note |
|---|---|---|
pwd | Print Working Directory | "Where am I right now?" |
ls | List | Show all files and folders here. |
mkdir <name> | Make Directory | Create a new folder. |
cd <name> | Change Directory | Enter a folder. |
cd .. | Navigate Up | Move up to the "parent" folder. |
nano <file> | Text Editor | Create or edit text files. |
less <file> | View File | Read a file without editing it (press q to exit). |
cp <old> <new> | Copy | Copy a file to a new location (or/and under a new name). |
mv <old> <new> | Move / Rename | Move a file or change its name. |
rm <file> | remove | Irreversibly delete a file |
clear | Clear | Clear the terminal screen (moves output out of view). |
TAB | Autocomplete | Type a few letters and hit Tab to finish the name. |
Ctrl + S | Save | Save changes in the nano editor. |
Ctrl + X | Exit | Close the nano editor. |
Ctrl + D | Disconnect | Logout from LUMI and return to your local machine. |
Summary checklist
- You know what a Command Line is and why it is used.
- You have learned the basics of the Command Line.
- You have practised learned commands on LUMI.
Knowledge check
Why do AI developers primarily use the Command Line Interface (CLI) instead of graphical desktops on a supercomputer?
Select all that apply.