Part I. Introduction to Linux

Similar documents
Tutorial 1: Unix Basics

Getting Started With UNIX Lab Exercises

Unix Tutorial Haverford Astronomy 2014/2015

CENG 334 Computer Networks. Laboratory I Linux Tutorial

Introduction to Unix - Lab Exercise 0

Using LINUX a BCMB/CHEM 8190 Tutorial Updated (1/17/12)

Using the Zoo Workstations

CS Fundamentals of Programming II Fall Very Basic UNIX

Parallel Programming Pre-Assignment. Setting up the Software Environment

AN INTRODUCTION TO UNIX

Chapter-3. Introduction to Unix: Fundamental Commands

Operating Systems. Copyleft 2005, Binnur Kurt

Linux Operating System Environment Computadors Grau en Ciència i Enginyeria de Dades Q2

Operating Systems 3. Operating Systems. Content. What is an Operating System? What is an Operating System? Resource Abstraction and Sharing

Getting Started with UNIX

Helsinki 19 Jan Practical course in genome bioinformatics DAY 0

Lab 1 Introduction to UNIX and C

Getting Started with Fedora

This lab exercise is to be submitted at the end of the lab session! passwd [That is the command to change your current password to a new one]

Guided Tour (Version 3.3) By Steven Castellucci as Modified by Brandon Haworth

Linux/Unix Filesystems

Introduction to Unix: Fundamental Commands

Session 1: Accessing MUGrid and Command Line Basics

Lab Working with Linux Command Line

An Introductory Tutorial on UNIX

Lab #8: Introduction to UNIX and GMT

When talking about how to launch commands and other things that is to be typed into the terminal, the following syntax is used:

Practical Session 0 Introduction to Linux

Introduction to Unix and Linux. Workshop 1: Directories and Files

STA 303 / 1002 Using SAS on CQUEST

EKT332 COMPUTER NETWORK

CS 2400 Laboratory Assignment #1: Exercises in Compilation and the UNIX Programming Environment (100 pts.)

Brief Linux Presentation. July 10th, 2006 Elan Borenstein

UNIX Quick Reference

CSE115 Lab exercises for week 1 of recitations Spring 2011

Perl and R Scripting for Biologists

Laboratory 1 Semester 1 11/12

CSE 303 Lecture 2. Introduction to bash shell. read Linux Pocket Guide pp , 58-59, 60, 65-70, 71-72, 77-80

CS 215 Fundamentals of Programming II Spring 2019 Very Basic UNIX

CHEM5302 Fall 2015: Introduction to Maestro and the command line

History. Terminology. Opening a Terminal. Introduction to the Unix command line GNOME

Tiny Instruction Manual for the Undergraduate Mathematics Unix Laboratory

INSE Lab 1 Introduction to UNIX Fall 2017

Unix/Linux Basics. Cpt S 223, Fall 2007 Copyright: Washington State University

EECS Software Tools. Lab 2 Tutorial: Introduction to UNIX/Linux. Tilemachos Pechlivanoglou

commandname flags arguments

Using UNIX. -rwxr--r-- 1 root sys Sep 5 14:15 good_program

Operating Systems and Using Linux. Topics What is an Operating System? Linux Overview Frequently Used Linux Commands

Guided Tour (Version 3.4) By Steven Castellucci

Lab Assignment #1. University of Pittsburgh Department of Electrical and Computer Engineering

Using WestGrid from the desktop Oct on Access Grid

CSCE 212H, Spring 2008, Matthews Lab Assignment 1: Representation of Integers Assigned: January 17 Due: January 22

Linux hep.wisc.edu

Due: February 26, 2014, 7.30 PM

Linux File System and Basic Commands

Semester 2, 2018: Lab 1

Unix File System. Learning command-line navigation of the file system is essential for efficient system usage

CS CS Tutorial 2 2 Winter 2018

Introduction. SSH Secure Shell Client 1

COSC UNIX. Textbook. Grading Scheme

Introduction to the Linux Command Line

Oxford University Computing Services. Getting Started with Unix

Introduction to Linux. Woo-Yeong Jeong Computer Systems Laboratory Sungkyunkwan University

Unix tutorial. Thanks to Michael Wood-Vasey (UPitt) and Beth Willman (Haverford) for providing Unix tutorials on which this is based.

Introduction p. 1 Who Should Read This Book? p. 1 What You Need to Know Before Reading This Book p. 2 How This Book Is Organized p.

Introduction to UNIX. Logging in. Basic System Architecture 10/7/10. most systems have graphical login on Linux machines

Commands are in black

Linux Survival Guide

BIOINFORMATICS POST-DIPLOMA PROGRAM SUBJECT OUTLINE Subject Title: OPERATING SYSTEMS AND PROJECT MANAGEMENT Subject Code: BIF713 Subject Description:

JCCC Virtual Labs. Click the link for more information on installing on that device type. Windows PC/laptop Apple imac or MacBook ipad Android Linux

Introduction to Linux

This is Lab Worksheet 3 - not an Assignment

The Directory Structure

Additional laboratory

Contents. Note: pay attention to where you are. Note: Plaintext version. Note: pay attention to where you are... 1 Note: Plaintext version...

Appendix B WORKSHOP. SYS-ED/ Computer Education Techniques, Inc.

UNIX Essentials Featuring Solaris 10 Op System

Copyright. Trademarks Attachmate Corporation. All rights reserved. USA Patents Pending. WRQ ReflectionVisual Basic User Guide

Introduction to Unix The Windows User perspective. Wes Frisby Kyle Horne Todd Johansen

BE CAREFUL! The Summer Research Student s Guide to UNIX

CSCI 161: Introduction to Programming I Lab 1a: Programming Environment: Linux and Eclipse

CSE Linux VM. For Microsoft Windows. Based on opensuse Leap 42.2

Introduction to Linux. Fundamentals of Computer Science

In this exercise you will practice working with HDFS, the Hadoop. You will use the HDFS command line tool and the Hue File Browser

Week Overview. Unix file system File types and file naming Basic file system commands: pwd,cd,ls,mkdir,rmdir,mv,cp,rm man pages

Helpful Tips for Labs. CS140, Spring 2015

Mills HPC Tutorial Series. Linux Basics I

WEBppliance for Windows User Administrator's Help

Section 2 Getting Started

Exercise sheet 1 To be corrected in tutorials in the week from 23/10/2017 to 27/10/2017

CSE 391 Lecture 1. introduction to Linux/Unix environment

Scripting Languages Course 1. Diana Trandabăț

Cmpt 101 Lab 1 - Outline

Linux Kung Fu. Ross Ventresca UBNetDef, Fall 2017

Lab 1 Introduction to UNIX and C

Your desktop or laptop computer consists of several hardware components:

AMS 200: Working on Linux/Unix Machines

CSE 391 Lecture 1. introduction to Linux/Unix environment

1. Open VirtualBox and start your linux VM. Boot the machine and log in with the user account you created in Lab #1. Open the Terminal application.

Getting Started With Linux and Fortran Part 2

Transcription:

Part I Introduction to Linux 7

Chapter 1 Linux operating system Goal-of-the-Day Familiarisation with basic Linux commands and creation of data plots. 1.1 What is Linux? All astronomical data processing is done with the help of computers. Each of you have been assigned a private area on a disk, which will be your working environment. Interaction with astronomical data and software in your account is done by means of an operating system. The operating system that we will use during this lab course is called Linux. This open source operating system is extremely versatile and as such is the operating system most commonly used by the astronomical community. Each one of you already has a Linux account; you will have to login by specifying your Keele username and password. Within Windows we will use a virtual environment that simulates all the properties of Linux and allows us to use astronomical software Exercise 1.1 (a) Start or re-start your computer and login to your Keele student account; (b) In the Physics folder in your Desktop, start-up Scientific Linux VM. Select Scientific Linux from the menu and press Start. Follow any on-screen instructions as necessary; (c) Once the Virtual box has launched, login using your usual name and password; wait until various icons appear on the left-hand side of the working environment. The Linux operating system sets up the screen with a variety of tools. Commonly-used tasks are grouped together in the toolbar at the top of the screen. There is also a menu of tools which are activated by a click of the right mouse-button. However, the majority of the tasks we are going to perform require detailed instructions to be provided. These commands will be implemented via a designated window on the screen, called a shell or terminal, using the command line. The shell window displays in the corner an abbreviated combination of username and diskname, followed by a prompt, where commands are typed. It may be necessary to first activate the window by clicking with the left mouse-button anywhere within the window. The window features quite a few extras. The size and position of the window can be manipulated by using the left or right mouse-button on the rim of the window. Terminating the window can be achieved by typing the command exit, using the quit 9

10 CHAPTER 1. LINUX OPERATING SYSTEM option from the session menu on the window, or clicking the little button displaying a cross in the top-right corner of the window. However this last option does not cleanly terminate tasks and can cause problems. Exercise 1.1 (b) Start a shell/terminal window by right-clicking on the mouse and selecting Open in terminal or click on terminal icon on top left tab; (c) Move and manipulate the window to familiarise yourself with it; (d) Terminate the window. 1.2 Internet The development of the World Wide Web has had a massive impact on modern research including Astronomy and Astrophysics. It allows astronomers amongst other things to easily access information and vast data archives, to remotely control the operation of telescopes and to quickly and effectively react to interesting astronomical events like gamma-ray bursts or supernova explosions. WewillalsousetheWebtoaccess materialrequiredforthislab. Weuseaweb-browser called Firefox. The website dedicated to this lab is at www.astro.keele.ac.uk/astrolab where you find the lab scripts, downloadable data archive and the results from the lab sessions. File contents can be saved on your local disk by right-clicking on the mouse (beware of where exactly on the disk the data will be saved to). Exercise 1.2 (a) Proceed to the data archive on the lab webpage and download the file called gnuplot. 1.3 Files and directories Linux requires users to be mindful of the structure under which information is kept on the disk. Coherent data structures called files are generally stored under a directory structure on the disk. A file s location is given by its path. In reality, the directory structure of a disk is a virtual one, and the path does not directly correspond to a physical location on the disk: it is merely a (very useful) way of book keeping. The command pwd when typed in a shell displays the path to the current directory. The command ls lists the contents of the current directory, comprising a number of files and/or sub-directories. The contents of the sub-directory can be viewed by typing ls followed by the name of the sub-directory (separated by a blank space). Sub-directories can be created or removed (if empty) with the commands mkdir and rmdir, respectively, followed by the name of the sub-directory. To change location to the sub-directory, use the command cd followed by the name of the sub-directory. Type cd.. to change one directory level back. By default the outcome of a particular command will be displayed on screen. This output can however also be written into a file by adding > [filename] after the command. The command man followed by a command name can be used to get help on the syntax and options of a particular command. Be mindful that syntax is important in Linux, for instance blank spaces separate commands and the required arguments but are not recognised in a directory path. Previously typed commands can be recovered using the keyboard arrows or using the left and middle mouse buttons.

1.4. DATA TRANSFER AND DATA MANAGEMENT 11 Exercise 1.3 (a) Open a shell window; (b) What is the full path of the current directory? (c) What are the contents of the current directory? (d) Create a sub-directory called plots within our home directory/users/students/username (not in the Desktop directory). Files may be moved or copied from one directory into another(sub-)directory by means of the commands mv and cp respectively. The way these are used (syntax) is: mv (or cp) [filename] [destination directory]/[destination filename] the square brackets are not typed. If the destination filename is the same as the original filename, then it may be replaced by a dot (.). If the destination directory is the same, then only the filename needs to be specified. The command mv moves the file from the original directory to the destination directory by changing its path. Hence, mv may lead to the loss of data if a mistake is made. The alternative, cp copies the file to the destination directory, leaving the original file intact. The original file (or any file, for that matter) may be removed with the command rm [filename]. Exercise 1.3 (e) Copy the file gnuplot.gpi from its original directory to directory plots; (f) Change to directory plots. 1.4 Data transfer and data management Another way of transporting electronic data through the Internet is via File Transfer Protocol, by typing ftp within a shell window. To open a connection, type open, followed by the address of the FTP site. The address consists of four numbers or a combination of words (alias). Once the connection is established, you will need to log-in to the FTP site. Often, data archives provide the opportunity to use the FTP service anonymously, in which case you type anonymous when prompted for your username, and as a password you type your e-mail address. You may use commands like ls and cd. Before starting the transfer, type binary to ensure that the transfer mode is binary as most data are stored in binary format to reduce their size on the disk. A file may be retrieved with the command get, followed by the filename. Multiple files may be retrieved by the single command mget, in which case a wildcard (the symbol *) may replace part or all of the filename. For each file, you will be asked whether or not to transfer that particular file (answer with yes or no ). You may type prompt to toggle between being prompted and not being prompted for each file to be downloaded. To terminate the FTP session, type bye. Exercise 1.4 (a) In the directory plots, open an anonymous FTP connection to ftp.astro.keele.ac.uk; (b) Change to directory /pub/astrolab; (c) Retrieve all files which names start with gnu ; (d) Exit the FTP connection. When working with large amounts of data, it is not only good practice to maintain

12 CHAPTER 1. LINUX OPERATING SYSTEM a tidy and logical directory structure, but also to keep track of the size of the data compared to the maximum capacity of the disk. The command df lists the available disk units, together with their capacity and use in units of kilo-byte (1024 bytes). The command du -k * lists all files in the current and linked directories, together with their size in units of kilo-byte. The more elaborate ls -l displays a wealth of information about the files in the current directory, amongst which are the file name, date of creation, size in units of byte, owner, and a 10-digit code summarising certain privileges to handle the file. If running out of disk space, use ls -a to check amongst the hidden files (preceded by a leading dot) for any files that were meant to be temporary and which may be removed. Exercise 1.4 (e) What is the total size of the contents of the directory plots in kilo-byte? (f) How does this compare with the maximum capacity of the corresponding disk? (g) And with the free space remaining on the disk? 1.5 Editing files The contents of a file can be examined by typing the command more [filename]. If the contents exceed the height of the window, the return key and the spacebar can be used to scroll through them, whilst any other key will quit from the command. The command wc -l displays the number of lines in a file. A convenient way of examining the contents of a file, which at the same time allows you to modify these contents, is by means of a text editor. There are many different editor tools around, and many of these look like the editor that we will introduce here: nedit. You can start up the editor by typing nedit, which allows you to open an existing file or to create and write a new file, or by typing nedit [filename], which opens the specified file and creates it if it did not already exist. It is often convenient for tools that use separate display windows to be run in the background, to keep the original window available for other uses. This is done by trailing the command with the symbol & (e.g. type nedit &). Exercise 1.5 (a) Open the file gnuxample.dat using the text editor. What does the first line read? Delete this line; (b) Save the modified file as gnumod.dat, and exit from the editor; (c) Check that the file gnumod.dat has one line less than the file gnuxample.dat. 1.6 Graphs with gnuplot Amongst the many tools for plotting data in graphs, we here introduce gnuplot. It is command-line based, and can be entered by typing gnuplot. The commands may also be written within a file, which can then be invoked from within gnuplot by typing load [filename], or fed directly into gnuplot by typing gnuplot [filename]. This makes it much easier to repeat a graph, or to design a different but similar graph. Help can be obtained from within gnuplot by typing help. Also, the files that you have retrieved via FTP include the gnuplot manual in two different formats: as an html document, that can be viewed with Firefox, or as a PostScript (.ps) file. Within Unix, PostScript is a

1.6. GRAPHS WITH GNUPLOT 13 commonly used format for figures. These may be modified using any type of text editor, and can be viewed with a tool called Ghostview by typing the command gv followed by the file name. An almost identical but slightly more versatile version of PostScript is encapsulated PostScript (.eps). Exercise 1.6 (a) View the gnuplot.html manual with Firefox; (Hint: in this case, the address is a concatenation of the path and the filename.) (b) View the gnuplot.ps manual with Ghostview. The file gnuplot.gpi is an example of a set of commands that make a graph of the data in gnumod.dat. It has a lot of comment lines describing the various commands and a variety of plot options like plot symbols, labels, plot ranges etc. Close examination of this file, in combination with the gnuplot help, should suffice to get you started designing your own graphs. Exercise 1.6 (c) Make yourself familiar with gnuplot by studying the information described in the file gnuplot.gpi. This file can be edited and loaded, or alternatively similar commands can be typed from within gnuplot to produce plots. By default gnuplot will produce plots in a graphic window on the screen. Gnuplot can also be made to produce an (encapsulated) PostScript file if the output device is set accordingly with the gnuplot command set terminal postscript, and the output filename is then specified with the gnuplot command set output [filename].eps. This PostScript file can be sent to the printer with the Unix command lpr [filename].eps. If there is no (or a wrong) default name for the printer, one may have to accompany the printing command with the option -P[printer name]. Exercise 1.6 (d) Generate a personally customised graph, as a PostScript file; (e) Send the PostScript file with the graph to the printer. Toreturntodisplayingoutputonthescreen, typeset outputtoclosethefile, followed by set terminal X11. Feel free to experiment with gnuplot. IMPORTANT: Do not forget at the end of each astrolab session to log out from your account. On the System tab at the top left of the working environment select shut down. This shuts down the VirtualBox Linux environment and returns to the Windows workspace. Logout from Windows as usual.

14 CHAPTER 1. LINUX OPERATING SYSTEM