Chapter 8 ssh and the command line | PSY6422 Data management and visualization (2023)

Chapter 8 ssh and the command line | PSY6422 Data management and visualization (1)

Before this course, install theUni-VPNand confirm that it works [estimated time: 5-10 minutes]

In this class, we will introduce the idea of ​​the command line, executing commands without the normal graphical user interface (GUI) and accessing remote computers via ssh (Secure Shell).

8.1start terminal

On Windows or Mac, search for "terminal" in the launcher. You should see a small black box (called a "Command Prompt" in Windows) with a cursor. On Windows, you can also typecmd.exein the search field in the lower left corner.

Chapter 8 ssh and the command line | PSY6422 Data management and visualization (2)

Note that the cursor appears after some information indicating the file path and/or the identity of the computer. Just as RStudio has a working directory, a place to load or save files, so does the command line. This is very important, as many command line statements only work if they are the right place.

8.2Change folder ("browse directory tree")

Get the content of the current directory withdirectory(without Windows) ols(sin Mac).

You will get a list of contents, some of them are folders, some are files. Can you identify what is what?

You can change to a subfolder withCD folder name. With you can move up/down the roadCD ..

(Video) Intro and Tools, 3Sept2020, Data Analytics (CS301Fall2020)

You can get the current pathCD(Windows) tuPeople with disabilities(Mac)

This allows you to browse all the files stored on your computer. It's cumbersome and annoying compared to the normal GUI method, but it's more fundamental to the "under the hood" operation of computers, and this way of interacting with computers is necessary in some situations (including frequent access to remote computers). .

Remember that, like in RStudio, you can use TAB to complete commands.


Computers connected to a network have an address, known asIP adress, which are always four numbers separated by periods. Are you used to dealing with domain names, but these names exist for human convenience. Like the command line for individual computers, IP addresses are closer to how computer networks work.

Copy this IP into your browser and see which website it takes you to:

Your computer is also connected to the Internet, so it has an IP address. You can find out by typingipconfig(Windows) tuifconfig(Mac) from the command line. (You can also google "what's my IP", but that won't work for what we're going to do.) This command should provide a lot of information. Look up the IP addresses. If you are at home you can see one with the first two If you are on campus, you should see an IP in the format "". All computers on the university network have IP addresses that start with the same number.

Now start the college VPN and find your IP again. If you're off campus, this should change, so you now have an IP starting with 172. Remember this number, we'll use it later.


Computers communicate with each other in many different ways, but you are probably most familiar with web pages: the "World Wide Web" (www) that is served throughprotocolo http.

One of the easiest ways for two computers to communicate isRingThis is just a tool to check if two computers can send and receive messages. The content of the message is not important, just check that both are connected to the network.

You can ping an IP or a website. Try it on the command line


(Video) DevOps for Data Science: The Terminal & Connecting Securely with SSH (do4ds01 6 7)

You should receive a series of lines telling you how long it took your computer, in milliseconds, to receive a message to and from this site. Try somewhere further away.

ping East Coast), orping continental)

But we can also ping individual computers. "sharc" is one ofhigh performance computing(HPC) in Sheffield. You can only talk to him if you are within the university network (ie you have to be on campus or activate your VPN). To try


If you have your VPN enabled correctly it will work.

8.5Remote access via SSH

If two computers are connected, you can access one remotely with a command called ssh. take the form

ssh user@ip_machine

Tom will set up a machine for you to try this out in class. If it's successful, you should see something like this.

Chapter 8 ssh and the command line | PSY6422 Data management and visualization (3)

The terminal is similar, but the commands you run will now be executed on that remote computer. It is also possible that you have changed your operating system so that instead of using Mac or Windows commands, you need to use commands that work on the remote computer. Many HPC machines and web servers are Linux machines (including the one we'll connect to in class).

8.6Find files, run files, copy files

This section assumes that you are working on a remote Linux machine.

(Video) Data Science at the Command Line: Introduction (dscl01 1)

Let's use the commandThinkto search for R scripts on this remote machine. The use of * here is called a "wildcard".

find -name '*.R'

We can run R on the remote machine, but it can't run RStudio (because the terminal doesn't display graphics, just text). Running software without the GUI is called headless running software.


Starts an interactive R console. stop meq()

But we can also run the script without starting R (so the script runs and exits, leaving us back in the terminal. You can navigate to the containing folder and run it.


You can also pass the script to R by providing the full path

Rscript home/neo/Escritorio/toyscript.R

Find out how long the script takes to run by typing putTempoBefore

tempo Rscript toyscript.R

Now there is no point in running a simple R script remotely, but if you have a large amount of data, it might be useful to run your analysis on a more powerful remote machine (or many remote machines that allow parallel processing).

Let's copy this script from the remote machine to our home machine. For that you need thescpcommand and know your username and IP address. The path where the file will be saved comes after the colon:

(Video) Firewall Training

scp toyscript.R user@your_ip:/path/to/Desktop/toyscript.R

scp works on Linux or Mac, but not on Windows.


We often feed additional switches (sometimes called "switches") to command line tools. then the commandspeakspeak words out loud

say hi"

we can read themTalk Documentationto see what options are available. Let's adjust the pitch and speed.

espeak -p 8 "Hello, but with extra seriousness"

espeak -s 230 "Hello my name is fast"


These exercises must be completed during the week following the class, since the remote device is not permanently on. See in Slack the IP, username and password for remote access

  • Enter the remote IP in a browser; this will display a website served by the remote computer
  • remote access via ssh
  • Locate the index.html file
    • Note: It is located in /var/www/html
  • Copy to your local computer using scp
  • edit it with a text editor and save it to your local computer
  • copy back to server
  • Look again at the IP address in a browser to see if it has changed (remember to press refresh/F5/clear cache).

8.8Check list

  • Identify and open a terminal window
  • Navigate the directory tree using command line instructions
  • find your ip address
  • Ping an IP or website
  • Find files, run programs, on remote computers
    • Pass options to command line tools using options
  • Copy files to/from remote machines with scp



1. CIS30B Unit 12 Lecture: Elasticity Stack
(Kasey Nguyen)
2. Intro to CISL HPC for New Users
(NCAR Computational and Information Systems Laboratory (CISL))
3. Visualization and Graphics Tutorial 1/7: matplotlib, Vi.
(quirk meze)
4. LIVE MSI Tutorial: Intro to MSI 9/7/17
5. 1 3 no code low code ai ml
(Pragmatic AI Labs)
6. AWS CLI Tutorial 9- How to Connect to AWS Ubuntu EC2 Machine with SSH
(KGP Talkie)
Top Articles
Latest Posts
Article information

Author: Prof. An Powlowski

Last Updated: 06/06/2023

Views: 6227

Rating: 4.3 / 5 (44 voted)

Reviews: 83% of readers found this page helpful

Author information

Name: Prof. An Powlowski

Birthday: 1992-09-29

Address: Apt. 994 8891 Orval Hill, Brittnyburgh, AZ 41023-0398

Phone: +26417467956738

Job: District Marketing Strategist

Hobby: Embroidery, Bodybuilding, Motor sports, Amateur radio, Wood carving, Whittling, Air sports

Introduction: My name is Prof. An Powlowski, I am a charming, helpful, attractive, good, graceful, thoughtful, vast person who loves writing and wants to share my knowledge and understanding with you.