User Tools

Site Tools


cluster-linux

This is an old revision of the document!


CLUSTER MANUAL

Linux Quickstart

What's on this page:

  1. New on Linux systems?
  2. Common Commands
  3. Text editing in command line

1. New on Linux systems?

This page contains some tips on how to get started using the psychp01 cluster if you are not too familiar with Linux/Unix. The information is intended for both users that are new to psychp01 and for users that are new to Linux/UNIX-like operating systems. Please consult the rest of the user guide for information that is not covered in this chapter.

Please also visit this MIT course on basics shell commands and command line environment.

SSH

On a terminal, you can use ssh to login to psychp01. Check the Access to psychp01 through Command Line in this documentation to learn more about ssh.

File Transfer Clients

To transfer any file or data you wish to use to the cluster, you can use file transfer clients, such as scp or sftp. For more info, see Transferring files to/from psychp01.

Running jobs on the cluster

You must execute your jobs by submitting them to the batch system using bash files. There is a dedicated section on bash files and batch system in our user guide that explains how to use the batch system. The pages explain how to write job scripts, and how to submit, manage, and monitor jobs. It is not allowed to run long or large memory jobs interactively (i.e., directly from the command line).

2. Common Commands

Provide the full path name of the directory you are currently in:

pwd

Change the current working directory:

cd

List the files and directories which are located in the directory you are currently in:

ls

Searches through one or more directory trees of a file system, locates files based on some user-specified criteria and applies a user-specified action on each matched file:

find

Find specific files, you can use the -name and -type arguments:

find . -name 'my*' -type f

The above command searches in the current directory (.) and below it, for files and directories with names starting with my. “-type f” limits the results of the above search to only regular files, therefore excluding directories, special files, pipes, symbolic links, etc. my* is enclosed in single quotes (apostrophes) as otherwise the shell would replace it with the list of files in the current directory starting with “my”.

Find a certain expression in one or more files:

grep

For example, to find the string apple in the fruitlist.txt text file, type:

grep apple fruitlist.txt

Create new directory:

mkdir

Remove a file. Use with caution:

rm

Remove a directory. Use with caution:

rmdir

Move or rename a file or directory:

mv

Edit text files in command line (for more details, see below Text editing in command line):

vi

or

vim

View (but do not change) the contents of a text file one screen at a time, or, when combined with other commands (see below Text editing in command line) view the result of the command one screen at a time. Useful if a command prints several screens of information on your screen so quickly, that you don’t manage to read the first lines before they are gone.

less

and

more

Use the “pipe” or “vertical bar” to group two or more commands together:

|

For example, list files in the current directory (ls), retain only the lines of ls output containing the string “key” (grep), and view the result in a scrolling page (less), type:

ls -l | grep key | less    

A complete listing of the defined variables and their meanings can be obtained by typing:

printenv

You can define (and redefine) your own variables by typing:

export VARIABLE=VALUE

If you know the UNIX-command that you would like to use but not the exact syntax, consult the manual pages on the system to get a brief overview. Use man + command for this. For example, to get the right options to display the contents of a directory, use:

man ls

To choose the desired options for showing the current status of processes, use

man ps

3. Text editing in command line

A popular tool for editing files (e.g., your code) on Linux/UNIX-based systems is vi. Unfortunately, the commands within both vi editor are quite cryptic for beginners. It is probably wise to spend some time understanding the basic editing commands before starting to program the machine.

For quick help, use:

man vi

or

man vim

Suppose you want to check the progress of your analyses. Suppose that you defined in your bash file that SLURM is supposed to output the status of your analyses in a text file (see here) named job_out.txt stored in your analyses folder in your home directory /home/gbellucci. To quickly check the status of your analyses, you would first establish an ssh connection with the cluster, then cd to your analyses folder and type vim job_out.txt, like that:

ssh gbellucci@psychp01.rhul.ac.uk
gbellucci@psychp01.rhul.ac.uk's password:
gbellucci@psychp01:~$ cd /home/gbellucci/analyses
gbellucci@psychp01:~$ vim job_out.txt

This would open the file in your command window. You can scroll and check the status of your analyses. To exit just type:

:q

Every file opened with vim will be in a non-writable state. To write in your opened file, press

i

On the bottom left of your command line, you will see the word INSERT appear, like that:

  1. -INSERT–

Modify your file as you wish. When done, press ESC on your keyboard. This will make the word INSERT disappear. You are again back to a non-writable state. To save and exit, type:

:wq

Where w stands for “write” and q for “quit”. If you change your mind and decide to exit without saving your changes, just type

:q!

This will not write your changes and force an exit (that's why the !) from vim.

Discussion

Enter your comment. Wiki syntax is allowed:
 
cluster-linux.1715084356.txt.gz · Last modified: 2024/05/07 12:19 by gabriele

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki