Terminal#

Why would you want to use the terminal?#

A terminal is a text input and output environment. A shell is the primary interface that users see when they log in, whose primary purpose is to start other programs.

A typing-based interface is often called a command-line interface, or CLI, to distinguish it from a graphical user interface, or GUI. The heart of a CLI is a read-evaluate-print loop, or REPL: when the user types a command and then presses the Enter (or Return) key, the computer reads it, executes it, and prints its output.

Shell is the standard way to interact with a supercomputer. It is worth learning the basics and getting comfortable with the “black box”, to make efficient use of the resources.

The terms terminal, command line and shell are often used interchangeably, even though they mean slightly different things.

Basic Linux commands#

Do you remember how you edited some files in the web interface? Let’s do the same thing again; only now from the command line:

Exploring files#

  1. Download a file into this new folder. Use the command wget for downloading from a URL:

wget https://raw.githubusercontent.com/csc-training/csc-env-eff/master/part-1/prerequisites/my-first-file.txt
  1. Check what kind of file you got and what size it is using the ls command with some extra options:

ls -l         # option l is for long format
  1. Use the less command to check what the contents of the file look like:

less my-first-file.txt
  1. To exit the less view of the file, hit q.

  2. Make a copy of this file:

cp my-first-file.txt $USER-second-file.txt    
ls -l
less $USER-second-file.txt                    
  1. Remove the file we originally downloaded (leave your own copy).

rm my-first-file.txt
ls -l

Moving files

If you don’t want to have duplicate files you can use mv to ‘move/rename’ the file. The syntax is the same: mv /path/to/source/oldname /path/to/destination/newname.

Re-executing commands from history

If you remember a part of a command that you have used recently you can search for it with the command history | grep string. This will show all your used commands that have included the string string (replace this with the pattern you are searching for).