• No results found

Editing Files on Remote File Systems

N/A
N/A
Protected

Academic year: 2021

Share "Editing Files on Remote File Systems"

Copied!
31
0
0

Loading.... (view fulltext now)

Full text

(1)

Editing Files on Remote File Systems

Terminal Intro (Vol 2)

Paul E. Johnson1 2

1Department of Political Science

2Center for Research Methods and Data Analysis, University of Kansas

(2)

Outline

1 Editing Without a Mouse!

Emacs nano vi

2 Edit Here, Transfer There

3 Use Emacs to Open Remote files

4 Remote Desktop or Remote Applications

(3)

Outline

1 Editing Without a Mouse!

Emacs nano vi

2 Edit Here, Transfer There

3 Use Emacs to Open Remote files

(4)

Working in a Straight-Jacket

Some systems allow no Graphical User Interface (GUI). 3 common alternatives

Emacs: most difficult, most powerful vi: somewhat difficult, less powerful

nano: an old email editor easy, but almost unpowerful

(5)
(6)

Emacs No X? Challenging!

Emacs was originally designed for this environment Interact with the minibuffer in the very bottom of the terminal display

Keystroke combinations to memorize C: Control Key

M: Meta Key, usually Alt on modern systems

When they say “Emacs has a steep learning curve”, this is what they are talking about. Life without a mouse or pull down menus.

(7)

To Exit from Emacs (if accidentally stuck in there)

If you are in a terminal, and can’t figure how to get out To Exit:

Type: C-x C-c

If you goof that up and you feel stuck, Hit C-g C-g is “get out of trouble” in Emacs.

(8)

Terminal: Login, use “nano”

nano is an adaptation of “pico”, the editor for “pine” email (1990s).

Arrow keys move cursor

Control key reminders at bottom

(9)

X11 Mouse Secret and Nano

Usual “Cut” and “Paste” (C-x, C-v) don’t work , usually Some systems allow an old-fashioned X11 style cut and paste.

Hi-light with left mouse button

Do not touch any keys, or mouse buttons Move mouse pointer to target position, and hit

the middle mouse button, or

both buttons at once if you don’t have a middle button, or

(10)

vi: Editor of Unix Gods who Don’t Prefer Emacs

All Unix/Linux systems I have ever seen have “vi” This requires some practice, but I prefer it for editing config files because

Fast with big text files.

vi never damages text (doesn’t “word wrap”, etc).

(11)

Start vi, see what happens

How to run the editor. You choose either $ v i s o m e f i l e . t x t

or

$ vim s o m e f i l e . t x t

“vim” is “VI improved, a newer variant”

On many modern systems, vi and vim will launch same editor

Ignore your mouse. Navigate with “up arrow” and “down arrow”

(12)

vi: Splash Screen at Startup

(13)

vi: Practice

vi always begins in “VIEW” mode. Can move cursor

Can delete text (Try “x” or “dd)

Touch letter “i” to go into “INSERT” mode. Look at bottom left of terminal.

Type! You are “stuck” in the “INSERT” mode.

To stop typing, hit “Escape” (Esc) key. You are back in the “VIEW” mode. No more inserts until you hit the letter “i”

(14)

vi: Save and Close

To save:

Reminder: Exit INSERT if necessary (Hit the Escape (Esc) key)

: The Colon key puts “focus” at bottom of terminal, you should see a prompt when you do that

To quit, type:

wq to save and quit

q! quit without saving

(15)

vi: Just a few other things

Did you goof up? There is UNDO If in INSERT mode, hit Esc

u is for “undo”. It should reverse your actions one at a time.

If you accidentally get into “recording” mode (happens to me all the time), bail out with

(16)

vi: Keystrokes to remember

x ## deletes the character at the cursor

i ## begins INSERT mode at the cursor

dd ## d twice deletes the current line

E s c 33 dd ## deletes 33 lines (Esc nn is repeat following )

/ w h a t e v e r ## search for whatever

: n ## goes to line n in file. Example :55

line 55

G ## goes to bottom of file

Cut-and-paste might work: Try highlight with left mouse drag, and paste with middle-click mouse (only if vi is in “insert mode”).

(17)

Outline

1 Editing Without a Mouse!

Emacs nano vi

2 Edit Here, Transfer There

3 Use Emacs to Open Remote files

(18)

File Transfer Programs

Most Unix/Linux remote systems will allow a “secure shell” based file transfer

In Windows, try one of the two-pane file transfer programs, such as WinSCP or Filezilla

The “portable” version of WinSCP works fine: https://winscp.net/eng/docs/guide_install WinSCP is my favorite because, in SCP mode, it can alter file permissions on the remote system.

Command line file transfer fast, efficient, if your PC has it. Try “scp” or the more powerful “rsync” programs.

(19)

Mount remote file system as if it were a local hard

drive

The “CIFS” protocol (older name “SMB” or “Samba”) is a Unix service that mimics a Windows file server.

Your PC may have, or can get, “client programs” that can attach the CIFS share.

Problem: You need to know the names of the shares offered on the target system

The Linux HOME directory on ACF is not currently mountable by CIFS.

(20)

Try a CIFS mounted share

Windows Explorer, try this: 1 Find “Computer” or “My

Computer”

2 Choose “Map Network Drive” 3 Name your “share” on the

host. On ACF at KU, try \\ t r a n s f e r . a c f . k u . e d u \

crmda

Linux or Macintosh file managers allow similar Try

smb : / /

t r a n s f e r . a c f . k u . e d u / crmda

(21)

In Linux, I use "sshfs"

$ m k d i r mount.crmda

$ s s h f s t r a n s f e r . a c f . k u . e d u : / crmda mount.crmda

Also works in Nautilus file manager at URL “ssh://transfer.acf.ku.edu/crmda”

Additional freedom to mount my HOME directory $ m k d i r mount.home

(22)

The Desktop might have this built in

File Manager may handle this as well: the URL “ssh://transfer.acf.ku.edu/crmda”

Disconnect

$ f u s e r m o u n t −u mount.home

(23)

The Danger in "Mounted" file systems

The PC might “freeze” if the network fails: the OS does not respond gracefully when a mounted device disappears. IMPORTANT: disconnect before “suspending” a laptop

Computer will go into a panic when it wakes up and can’t find drives that were mounted

(24)

Outline

1 Editing Without a Mouse!

Emacs nano vi

2 Edit Here, Transfer There

3 Use Emacs to Open Remote files

4 Remote Desktop or Remote Applications

(25)

Emacs “tramp” mode

Launch Emacs with a remote file name

$ emacs / u s e r @ s y s t e m : p a t h−t o−m a t e r i a l−o r−f i l e n a m e Examples $ emacs / p a u l j o h n @ t r a n s f e r . a c f . k u . e d u : f i l e . t x t $ emacs / p a u l j o h n @ t r a n s f e r . a c f . k u . e d u : / crmda / u s e r s / p a u l j o h n / f i l e . t x t $ emacs / p a u l j o h n @ t r a n s f e r . a c f . k u . e d u : / crmda / w o r k g r o u p s / W i n S t a t U p d a t e s / f i l e . t x t

(26)

Emacs “tramp” mode (cont.)

(27)

If Emacs is already running, do

C−x C−f

the minibuffer should prompt you with “Find file: ~/”. Replace “~/” with

(28)

Use File Transfer Program’s Edit emulator

WinSCP or Filezilla (or similar) have “edit” right click options.

“transparently” downloads file “edits” in your system

Save “transparently” transfers file back to remote system.

Configuration may take some effort, since the file transfer program has to be informed of what editor in “your PC” is supposed to open the file that comes from (and goes back) “over there”.

(29)

Outline

1 Editing Without a Mouse!

Emacs nano vi

2 Edit Here, Transfer There

3 Use Emacs to Open Remote files

(30)

Relay A Whole Remote Workscreen

The login node of a cluster system might allow a “remote desktop” experience.

ACF at KU currently offers the “NoMachine” remote desktop. Documentation is ample in

http://crmda.ku.edu/computing

Other systems may offer desktops like VNC or Vine

(31)

X11 can display individual programs I

This requires an X11 “server” on your PC In a Macintosh system,

install the Xcode package, open a terminal $ s s h −X l o g i n 2 . a c f . k u . e d u $ q x l o g i n $ emacs & $ g e d i t & $ n a u t i l u s −−no−desktop &

References

Related documents