Command line utilities
Copyright (c) 2013-2020 UL HPC Team <firstname.lastname@example.org>
Using a command line text editor
Before the next section, you must learn to use a text editor in command line.
We can recommend
nano is very simple,
vim is complex but very powerful.
$ nano <path/filename>
- quit and save:
- highlight text:
- Cut the highlighted text:
There are 2 main modes:
- Edition mode: press
- Command mode: press
Here is a short list of useful commands:
- save and quit:
- quit and discard changes:
- search & replace:
- jump to line 100:
- highlight text:
- cut the highlighted text:
- cut one line:
Persistent Terminal Sessions using GNU Screen
GNU Screen is a tool to manage persistent terminal sessions. It becomes interesting since you will probably end at some moment with the following scenario:
you frequently program and run computations on the UL HPC platform i.e on a remote Linux/Unix computer, typically working in six different terminal logins to the access server from your office workstation, cranking up long-running computations that are still not finished and are outputting important information (calculation status or results), when you have 2 interactive jobs running... But it's time to catch the bus and/or the train to go back home.
Probably what you do in the above scenario is to
a. clear and shutdown all running terminal sessions
b. once at home when the kids are in bed, you're logging in again... And have to set up the whole environment again (six logins, 2 interactive jobs etc. )
c. repeat the following morning when you come back to the office.
Enter the long-existing and very simple, but totally indispensable GNU screen command. It has the ability to completely detach running processes from one terminal and reattach it intact (later) from a different terminal login.
Pre-requisite: screen configuration file
Otherwise, simply clone the ULHPC dotfile repository and make a symbolic link
~/.screenrc targeting the file
screen/screenrc of the repository.
You can start a screen session (i.e. creates a single window with a shell in it) with the
Its main command-lines options are listed below:
screen: start a new screen
screen -ls: does not start screen, but prints a list of
pid.tty.hoststrings identifying your current screen sessions.
screen -r: resumes a detached screen session
screen -x: attach to a not detached screen session. (Multi display mode i.e. when you and another user are trying to access the same session at the same time)
Once within a screen, you can invoke a screen command which consist of a "
CTRL + a" sequence followed by one other character. The main commands are:
CTRL + a c: (create) creates a new Screen window. The default Screen number is zero.
CTRL + a n: (next) switches to the next window.
CTRL + a p: (prev) switches to the previous window.
CTRL + a d: (detach) detaches from a Screen
CTRL + a A: (title) rename the current window
CTRL + a 0-9: switches between windows 0 through 9.
CTRL + a kor
CTRL + d: (kill) destroy the current window
CTRL + a ?: (help) display a list of all the command options available for Screen.