This is an old revision of the document!
Working on the command line - part 1
After logging in into the system you will have been presented by a command line prompt. Like:
username@habrok:~ █
This line shows first your username and after the @ symbol the name of the system you are connected to. After the colon the current location in the file system is shown. In the example this is ~, which is a short notation for your private home directory. More on this later.
The last item is the black square. This is the prompt, where you can start typing commands.
Why a command line?
Before delving into the command line commands it is a good idea to explain some advantages the command line offers over having a graphical user interface.
But first be aware that many actions that you can do on the command line for manipulating files can also be done through graphical oriented file managers, like MobaXterm, WinSCP or FileZilla, and the web portal to Hábrók.
Advantages of a command line interface:
- A command line interface uses just a little network bandwidth, making it possible to use these at remote locations.
- Command line tools can be easily combined to make them more powerful.
- It allows for repeating tasks in an easy and efficient way.
- Commands can be copied and combined into a script to create more complex workflows, that can easily be run many times.
- It is easy to capture and store output of programs into files, which can be parsed by other tools, or studied later.
In summary the main advantage is that a command line interface allows for an easy automation of tasks. It also offers extreme flexibility, as users can write their own scripts to run their special workflows. These are also the main reasons it is used as the main interface to computer clusters.
Graphical user interfaces certainly have their place, and normally are easier to use. But a graphical user interface limits you to the capabilities it supports. It also makes it much harder to repeat a task many times.
The welcome messages
Above the prompt there will have been a welcome message. This message will contain useful information that the CIT wants the Hábrók users to know about. A full example looks like:
Welcome to the Hábrók HPC cluster Login Node (( \\``. \_`.``-. ( `.`.` `._ `._`-. `._ \`--. ,' `. `--._ `. .`. `--.--- `. ` `. `.-- `; .`._ :- : ;. `.__,.,__ __ `\ : ,-( ';o`>. `-.`: ,' `._ .: (,-`, \ ; ;. ,: ,"`-._>-: ;,' `---.,---. `>'" "-` ,' "":::::".. `-. `;"'_, (\`\ _ `:::::::::::'" `---. -hrr- `-(_,' -'),)\`. _ .::::"' `----._,-"") \_,': `.-' `-----' `--;-. `. ``.`--.____/ `-^--' \(-. `.``-.`-=:-.__) ` `.`.`._`.-._`--.) `-^---^--.`-- Use the following commands to adjust your environment: 'module avail' - show available modules 'module add <module>' - adds a module to your environment for this session ------------------------------------------------------------------------------------------- | | | Do not run long, heavy jobs on the login node; only use it for simple and short tasks! | | The interactive node, hn-interactive.hpc.rug.nl, can be used for testing your program. | | | ------------------------------------------------------------------------------------------- Updates: Planned Maintenance: - None. Also see our status page: https://status.hpc.rug.nl
The message has four parts:
- Welcome message with hawk art.
- Useful information for the users, like explaining the important module command and to be careful running heavy computations on certain nodes.
- Updates on the system status, which may be useful for you.
- Maintenance plans you should be aware of.
File system structure
Before continuing with the command line interface it is good to first discuss the file system structure as used on Linux systems like Hábrók.
A graphical overview of the folder/directory structure is shown in the following figure:
The root of the file system hierarchy is at /
. This is different from Windows where the file system starts with drive letters like C:
or `X:
.
Within the root of the file system there are several directories, which can have subdirectories. There are system ones like bin/
for holding system tools and programs, and etc/
which is used for storing files with all kinds of settings.
Another difference between Linux and Windows is that directories are separated by the forward slash /
, whereas Windows uses the backslash \
. So where a Windows path might look like:
C:\Users\p-number1\programs\analyse.exe
A similar path on a Linux system would look like:
/home/p-number1/programs/analyse.x
home directory
On a Linux system each user has a home directory. On Hábrók these are located in home/
in the root of the file system.
When you log in into the system your command line prompt will start in this home directory. And any files you refer to, without giving a full path will refer to files within the home directory.
Full versus relative paths
If you refer to a file, without starting at the root of the file system using /
, the path + filename combination will refer to a point starting in the current directory. If you want to refer to another location in the file system hierarchy you will have to give the full path. A full path starts with /
, which is the root of the file system. An example is:
/data/p-number1/exp_1/series.csv
If you want to refer to a location within the current directory, you can use relative paths like:
sources/analyse.c
In this case we assumed that the command line prompt was in the home directory /home/p-number1
.
Special pointers
There are two special pointers that can be used to point to locations in a relative path, these are:
.
points to the current directory. This is mainly useful when referring to programs that are not in standard locations. In order to execute such a program it has to made clear in which precise location they are. When the program or script is in the current directory./
can be used to point to this, like./myscript.sh
...
points to the directory one level higher in the hierarchy. So when being in the directorysources
in the example structure..
would refer to the home direcory/home/p-number1
.
As mentioned before, another useful pointer is ~
, which points to your home directory. So, if you want to refer to a file in your home directory, you can use the notation ~/myfile.txt
instead of /home/p-number/myfile.txt
.
Next section: Working on the command line - part 2