Editing files on Fox
Several command-line options exist for editing files on Fox.
Emacs
We highly recommend using the text mode when using Emacs, e.g.,
$ emacs -nw
If you wish to use the graphical user interface, then we recommend to run Emacs on your local computer and open the file remotely. For this you do not need to copy the files from the cluster to your local computer, you simply open them as you would open a remote web page in your browser. The procedure uses an Emacs package called TRAMP (Transparent Remote (file) Access, Multiple Protocol). See their web page https://www.gnu.org/software/tramp/ for more details:
- In order for TRAMP to recognize and handle the Two Factor Authentication prompt on Fox, add the following to your Emacs init file before
(require 'tramp)
and any other TRAMP configuration you might have:
(add-to-list 'password-word-equivalents "One-Time_Code")
- Open emacs on your laptop/machine
- C-x C-f (Ctrl+x, then Ctrl+f (or Mac equivalent), then you will get a “find file” prompt)
- /ssh:username@fox.educloud.no:pathname (note the leading slash)
- You may get the following message “Offending key for IP in …. Are you sure you want to continue connecting (yes/no)?“ type yes and enter
- Depending on the network state you might see the message “Waiting for prompt from remote shell” for few seconds to a minute, before the connection opens.
For example if your user name is “newuser” and if you want to open a file called “myfile.txt”, located in your home area on Fox, you would use the following: /ssh:newuser@fox.educloud.no:/cluster/home/newuser/myfile.txt
If you specify a directory name, you can browse the remote file system until you have found the file you wish to open.
(Thanks to Koen van Greevenbroek for input on TRAMP and two factor authentication)
Nano
Opening files on nano can be done with:
$ nano <filename>
You are ready to start editing right away.
To save press Ctrl
and O
. To quit, use Ctrl-X
.
You may wish to open a file in read-only mode, use the -v
(for “view”) option:
$ nano -v <filename>
Vim
Opening files on vim can be done with:
$ vim <filename>
If editing a file, first press i
to enter “insert” mode. Press the Escape
key to exit insert mode.
To save your changes, use a colon, then ‘w’: :w
To quit, type: :q
These commands can be combined to save and quit the editor :wq
.
To quit without saving changes, use :q!
instead of :q
You may wish to open a file in read-only mode, use the -M
option:
$ vim -M <filename>
This will disable you from modifying the file.
CC Attribution: This page is maintained by the University of Oslo IT FFU-BT group. It has either been modified from, or is a derivative of, "Editing files" by NRIS under CC-BY-4.0. Changes: Added additional sections "Nano" and "Vim" and updated "Emacs" with bullet point addressing compatibility between TRAMP and TFA on Fox.