• No results found

FEEG Applied Programming 6 - Working Remotely on Linux Server

N/A
N/A
Protected

Academic year: 2021

Share "FEEG Applied Programming 6 - Working Remotely on Linux Server"

Copied!
25
0
0

Loading.... (view fulltext now)

Full text

(1)

FEEG6002 - Applied Programming 6 - Working

Remotely on Linux Server

Sam Sinayoko

2015-11-06

(2)

Outline

Learning Outcomes

Introduction

Connecting to Linux server

Transfering files to Linux server

Text editors

Sending emails on remote server

(3)

Outline

Learning Outcomes

Introduction

Connecting to Linux server Transfering files to Linux server Text editors

Sending emails on remote server Summary

(4)

Learning outcomes

After studying this lecture you should be able to: I Connect to a remote linux server with SSH

I via PuTTY on Windows

I via the terminal on Linux / OSX

I Display remote graphical applications on your local screen via X forwarding

I Edit files on the linux server using nano or emacs I Sending files on the linux server using Firefox

I text editors

(5)

Outline

Learning Outcomes

Introduction

Connecting to Linux server Transfering files to Linux server Text editors

Sending emails on remote server Summary

(6)

Introduction

Why remote servers?

I Websites

I Supercomputers: Iridis 4, Hector, Archer. I Cloud computing:

I pay for what you use (computing time, memory etc)

I work anywhere

I Amazon AWS, Microsoft Azure

I CD-Adapco: CFD software usable in the cloud

I Wakari.io: http://www.wakari.io

I Sage: http://cloud.sagemath.com

Why Linux / Unix

I The most common OS on servers.

(7)

Outline

Learning Outcomes Introduction

Connecting to Linux server

Transfering files to Linux server Text editors

Sending emails on remote server Summary

(8)

Connecting to Linux server

Linux / OS X terminal

ssh -X [email protected]

where LOGIN is your username on the server. You can only connect to a server where you have an account, and ssh will ask for your password.

The -X option forwards graphical applications to the local display. See slide XX.

Windows

(9)

Connecting to Linux server

Example

hostname # display local host name

ssh -X [email protected] hostname

landade # <- the local server hostname [email protected]’s password:

Last login: Fri Nov 7 12:43:11 2014 from srv00470.soton.ac.uk

---System: Red Hat Enterprise Linux Server release 6.5 (Santiago)

Server: srv00470.soton.ac.uk Service: SES Teaching Server Status: Production

Purpose: SES Teaching Server

---srv00470 # <- the remote server hostname

(10)

X server

> ssh -X

I Start X server locally before running "ssh -X"

I "ssh -X" connects the remote server to the local X server. I This allows to display remote GUI applications. You can try

I [login@feeg6002]$ xterm &

I [login@geeg6002]$ emacs &

I [login@feeg6002]$ firefox &

(11)

Job control

Job control1

If you forget the "&", you can do "Ctrl-Z" to suspend the program. This will display a job number on the screen (say, [1]) and freeze the app, but it will free the terminal. To de-freeze the application, run

bg 1

to put it in the background. If you run

fg 1

you will put the application back in the foreground. The bg and fg commands are especially useful when using non-graphical programs in the terminal such as nano or emacs. These programs take over the shell but can be put in the

background temporarily with "Ctrl-Z" to bring back the shell, and later brought back a little later with fg. This avoids having to quit and restart commands constantly.

1

Seehttp://software-carpentry.org/v4/shell/job.htmlfor more

(12)

Installing an X server on the local machine

Installing an X server on the local machine

I Linux: nothing to do (the X server is always running) I OS X: may need to download and install X-Quartz (free)

http://xquartz.macosforge.org/trac

I Windows:

I Exceed (commercial): available on university computers.

I Xming (free): http://sourceforge.net/projects/xming/

(13)

Outline

Learning Outcomes Introduction

Connecting to Linux server

Transfering files to Linux server

Text editors

Sending emails on remote server Summary

(14)

University Computer

I Your filestore directory on the remote server

(/home/LOGIN/filestore) contains a folder mydocuments in sync with your Windows "My Documents" folder.

I You can put files in that folder to make them visible on Windows

emacs program.c

# (edit the program and save)

mv file.c /home/LOGIN/filestore/mydocuments

(15)

Transfering files to Linux server

The scp command

Works like cp but can copy file to/from remote server securely. I Copying file to home directory on remote server

# copy file to remote home directory

scp file.c [email protected]: *Don’t forget the trailing colon ":"*.

I One can give the remote path to

# copy file to remote home directory

scp file.c [email protected]:/remote/path/

(16)

Transfering files to Linux server

GUI programs

I Use one of the many GUI programs for transfering files to remote server:

I Windows: WinSCPhttp://winscp.net/eng/index.php

I OS X: Finder, muCommander

http://www.mucommander.com/

I Linux: Krusaderhttp://www.krusader.org/

(17)

Outline

Learning Outcomes Introduction

Connecting to Linux server Transfering files to Linux server

Text editors

Sending emails on remote server Summary

(18)

Text editors

Non-GUI text editors on server

I Nanohttp://www.nano-editor.org/

I Run with nano

I ^X (exit) means Ctrl+X

I Vim http://www.vim.org/

I Run with vim

I Modal editor: press "I" to start insert mode and "ESC" to get

back to command mode.

I Command mode is for moving around: try h,j,k,l keys, ":help

tutor" to start tutorial and ":q" to quit.

I Run non-GUI Emacs with "emacs -nw" (combine with "Ctrl-Z" to suspend, and "fg 1" to use again) GUI text editors on server

I Emacs: http://www.gnu.org/software/emacs/

(19)

Emacs intro

Basics

I Use the GUI and the menus to get started.

I In Emacs, "C-" means "Ctrl+" and "M-" means "Alt+". I Emacs prints information and reads information in the

mini-buffer at the bottom of the screen.

I Use "M-x COMMAND" to run a command if you know its name. Use TAB for completion.

C-x C-f open or create file C-x C-s save file

M-x compile compile file (type the command you need the first time). M-x eshell run the code in eshell

M-x cua-mode make Ctrl-C and Ctrl=V work like on windows

(20)

Emacs buffers

I Emacs can run multiple files and programs (like the emacs terminal eshell) simultaneously.

I Each file or program is displayed in its own buffer. Switch buffer with C-x b:

C-x b display a different buffer in current window I The window can also be split to display multiple buffers

simultaneously

C-x 2 Split buffer horizontally C-x 3 Split buffer vertically C-x 1 Maximize the buffer

(21)

Getting help in Emacs

In Emacs

C-h t Start the Emacs tutorial C-h r Start the emacs manual

Online

I Official website: http://www.gnu.org/software/emacs/

I Getting help: http://www.emacswiki.org/

I Blog: http://masteringemacs.org/

(22)

Outline

Learning Outcomes Introduction

Connecting to Linux server Transfering files to Linux server Text editors

Sending emails on remote server

(23)

Sending emails on remote server

firefox

Run Firefox on remote remote server with command firefox &

and use Outlook Web Access to write and attach email

Note: Sometimes firefox detects if it is already running on the local computer, and switches to that application instead of starting a remote one. If that happens Close your local copy of firefox and try again (or run firefox locally with the -no-remote option).

(24)

Outline

Learning Outcomes Introduction

Connecting to Linux server Transfering files to Linux server Text editors

Sending emails on remote server

(25)

Summary

I Start X Server on local machine if needed

I Use "ssh -X [email protected]" to connect to remote server on the command line

I or with PuTTY on Windows

I Start coding with your prefered text editor on the server (Emacs , Nano, or Vi).

References

Related documents

1 Este trabajo forma parte de una investigación más amplia desarrollada en el marco de mi tesis doctoral titulada “La seguridad interna como ‘teatro de

The discrete-time ISM based SMC achieves accurate control performance for both the sliding mode and state regulation, meanwhile eliminates the reaching phase and avoids

 Live lobster is the most important product for retail markets  Live lobster represents only 20% of restaurant lobster sales. volume; 80% of volume is tails

• Bespoke hand-made Eucalyptus cabinetry with integrated lighting, including drawer units, shoe racks, tall hanging, shirt hanging, shelving and floor-to-ceiling mirror.

Experiences with embedding data analysis methods into the library field can be categorised into five areas: the use of data analysis and visualisation to provide insights into

It is based on three steps: a splitting step which splits events in order to allow the incremental and local resolution of non-determinism, a mapping step which introduces

Using RFID technology and Web databases to track and record maintenance schedules and carry out inspections of equipment in the field ensures only equipment that has been

We have put a number of different solutions into place with Internexus in three cities around the UK, including high speed internet connection and managed voice services for