BE CAREFUL! The Summer Research Student s Guide to UNIX

Similar documents
Using the Zoo Workstations

Physics REU Unix Tutorial

Introduction to Unix - Lab Exercise 0

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

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

Tutorial 1: Unix Basics

Getting Started With UNIX Lab Exercises

Part I. Introduction to Linux

Introduction. File System. Note. Achtung!

1 Installation (briefly)

Command Line Interface The basics

Mills HPC Tutorial Series. Linux Basics I

Unix Tutorial Haverford Astronomy 2014/2015

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

Chapter-3. Introduction to Unix: Fundamental Commands

Essential Linux Shell Commands

A Brief Introduction to the Linux Shell for Data Science

When you first log in, you will be placed in your home directory. To see what this directory is named, type:

Windows XP. A Quick Tour of Windows XP Features

Tiny Instruction Manual for the Undergraduate Mathematics Unix Laboratory

Linux Bootcamp Fall 2015

An Introduction to Unix

Introduction to Linux. Fundamentals of Computer Science

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

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

Using IRAF in Swain West 311

Linux Command Line Interface. December 27, 2017

Table Of Contents. 1. Zoo Information a. Logging in b. Transferring files 2. Unix Basics 3. Homework Commands

Introduction to Linux Workshop 1

Intro to Linux. this will open up a new terminal window for you is super convenient on the computers in the lab

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

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

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]

Basic Shell Commands

Unix/Linux Primer. Taras V. Pogorelov and Mike Hallock School of Chemical Sciences, University of Illinois

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.

Carnegie Mellon. Linux Boot Camp. Jack, Matthew, Nishad, Stanley 6 Sep 2016

acmteam/unix.pdf How to manage your account (user ID, password, shell); How to compile C, C++, and Java programs;

Using Microsoft Excel

STA 303 / 1002 Using SAS on CQUEST

CSE115 Lab exercises for week 1 of recitations Spring 2011

Introduction to UNIX command-line

Getting Started With Linux and Fortran Part 2

Bioinformatics? Reads, assembly, annotation, comparative genomics and a bit of phylogeny.

Shell Programming Overview

Excel Basics Rice Digital Media Commons Guide Written for Microsoft Excel 2010 Windows Edition by Eric Miller

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

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

For this class we are going to create a file in Microsoft Word. Open Word on the desktop.

COMS 6100 Class Notes 3

Helpful Tips for Labs. CS140, Spring 2015

XnView Image Viewer. a ZOOMERS guide

Introduction to the Linux Command Line

CMSC 201 Spring 2018 Lab 01 Hello World

Outline. Structure of a UNIX command

Refresher workshop in programming for polytechnic graduates General Java Program Compilation Guide

FILE MAINTENANCE COMMANDS

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

An introduction to Linux Part 4

Lab 1 Introduction to UNIX and C

HYPERSTUDIO TOOLS. THE GRAPHIC TOOL Use this tool to select graphics to edit. SPRAY PAINT CAN Scatter lots of tiny dots with this tool.

Introduction to Unix: Fundamental Commands

Python for Astronomers. Week 1- Basic Python

CSE 391 Lecture 3. bash shell continued: processes; multi-user systems; remote login; editors

Basic Unix and Matlab Logging in from another Unix machine, e.g. ECS lab Dells

CMSC 201 Spring 2017 Lab 01 Hello World

Adobe illustrator Introduction

Introduction to the UNIX command line

Microsoft Excel 2007

A Linux Virtual Machine for CS-2011 Projects

Lab Working with Linux Command Line

Introduction. SSH Secure Shell Client 1

Introduction: What is Unix?

213/513/613 Linux/Git Bootcamp. Cyrus, Eugene, Minji, Niko

In the fourth unit you will learn how to upload and add images and PDF files.

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

Guided Tour (Version 3.4) By Steven Castellucci

SolidWorks 2½D Parts

200" LFC Test and Checkout (Rev )

Introduction to remote command line Linux. Research Computing Team University of Birmingham

Editors in Unix come in two general flavours:

Practical Session 0 Introduction to Linux

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

Linux File System and Basic Commands

CSC111 Computer Science II

CHAPTER 1 COPYRIGHTED MATERIAL. Getting to Know AutoCAD. Opening a new drawing. Getting familiar with the AutoCAD and AutoCAD LT Graphics windows

The Directory Structure

Introduction to Linux Organizing Files

Getting Started With Linux and Fortran Part 3

CENG 334 Computer Networks. Laboratory I Linux Tutorial

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

CENG393 Computer Networks Labwork 1

XnView 1.9. a ZOOMERS guide. Introduction...2 Browser Mode... 5 Image View Mode...15 Printing Image Editing...28 Configuration...

A new clients guide to: Activating a new Studio 3.0 Account Creating a Photo Album Starting a Project Submitting a Project Publishing Tips

Unix basics exercise MBV-INFX410

Working with Basic Linux. Daniel Balagué

SolidWorks Intro Part 1b

Introduction to Linux Environment. Yun-Wen Chen

Introduction to Linux for BlueBEAR. January

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

Transcription:

BE CAREFUL! The Summer Research Student s Guide to UNIX Luke Leisman adapted from Andrew Butler June 2011 This is a guide designed to help summer researchers navigate the complexities of using a unix/linux machine, along with several key programs useful in doing astronomy and physics research. The guide contains the following: 1. Basic unix commands a. navigation b. manipulating files (saving/moving/copying/renaming files) c. displaying information about the system/files d. opening other terminals e. opening programs f. other helpful commands 2. More advanced unix commands 3. Guides to the following programs/languages/software: a. DS9 (imaging software)

b. EMACS (programming/text editing) c. IDL (astronomy programming language, similar to Python) d. IRAF (collection of tool for working with astronomical data) e. LATEX (excellent paper writing/formatting software) f. OOFFICE (Microsoft office for linux/unix, text/powerpoint/spreadsheet editing) I. Basic unix/linux commands ** a few Important Tips: 1.) UNIX doesn t like spaces in filenames! 2.) UNIX is case sensitive. 3.) If you don t feel like completely typing in the name of a directory or filename, just hit the tab key, and as long as there is nothing else in the folder that starts with the same string of characters that you already have typed in, UNIX will complete the typing for you. If it won t tab complete for you, type in more characters in the folder or filename until it deviates from everything else, then hit the tab key. 4.) If you don t feel like typing anything to copy something, just highlight the text you want copied, and then hit the middle mouse button in the terminal or program that you want the text copied into, and the text will automatically appear. 5.) If you want to use the same command or part of the command you just used, hit the up arrow key and it will reappear. In fact, if you keep hitting the up arrow, all of the commands you entered before that will reappear. Essentially, UNIX keeps a history of all the commands you entered since logging in, and these commands are accessed by hitting the up arrow key 1. 6.) Be sure to type an "&" after opening anything that will pop up a new window, otherwise you will lose your command prompt!! Example: "emacs somefile.txt &" opens somefile.txt in a new emacs window, and returns the command prompt 7). google is an excellent resource for learning about computers and computing. Google "linux help" or "unix help" or "ubuntu help" for lots of helpful info. http://www.unixguide.net/linux/linuxshortcuts.shtml has a nice list of some helpful commands as well. A. Navigation between directories Command: Meaning: cd cd new_directory cd.. cd changes to the home directory moves you from your current directory into [new_directory] Example: cd research/records moves you into the folder records, assuming records is contained in the folder research moves you into the folder up one level Example: if you re in the folder research, which is contained in the folder summer_2007, cd.. will bring you into summer_2007 Moves you into the previous directory 1 One should note that UNIX encourages lazy behavior. The authors of this guide are not responsible for consequences of such behavior.

ls ls l ls lrt pwd lists the files in a directory shows details of each file Shows the details of each file with the most recently created first; shows the most recently created files along with their details Shows which folder you are currently in Helpful note: ~ signifies the home directory Example: cd ~/help moves you to the directory help in the home directory B. Manipulating files and directories 1. Basic Manipulation cp filename directory cp filename newfilename mv filename directory copies filename into directory Example: cp log research places a copy of the file log into the folder research copies filename into newfilename Example: cp log log_old copies the file log and saves it as log_old moves [filename] into [directory] Example: mv log research moves the file log into the folder research Example: mv research/records/log.. moves log into the folder up one level mv filename newfilename renames filename to newfilename Example: mv log log_old renames the file log to log_old rm filename mkdir new_directory rmdir directory rm R directory Deletes the file called filename makes a folder called new_directory deletes the folder called directory (directory must be empty first) deletes a folder and its entire contents ( R stands for recursive) 2. Unpacking Downloaded Files gunzip filename.gz unzips gz files tar zxvf [filename] unpacks file.tar files Helpful notes:. signifies the current directory Example: mv ~/help/ilovelinux.txt. moves Ilovelinux.txt from ~/help to your current directory See advanced commands for manipulating multiple files that contain the same sequence of characters C. Displaying Information about the System and Files

df shows hard disk space df h more filename less filename whoami grep somestring more */*fits shows hard disk space with abbreviations convenient for humans (thus the h ), like G for gigabyte and M for megabyte shows the contents of filename (use space to scroll by much at a time and enter to scroll by a line at a time; type q to quit) same as above but allows one to scroll up (use up arrow key) tells you which user you currently are searches directories to view all fits files in subdirectories Note: * is a wildcard, and can be very helpful when searching directories. For more info see advanced commands. D. opening other terminals Sometimes it is inconvenient/impossible to run programs from the command terminal. From within the command terminal it is possible to open up other terminals. Here are the commands/terminals we most often use: xterm & xgterm & sb Opens a new terminal which we use for running idl opens a terminal which we use to run iraf adds a scroll bar to the new terminal so one can scroll up to view previous information. Example: xgterm sb opens xgterm window with a scroll bar E. program commands 1.) To open a program, type the program name (or alias), then the filename to open a given file in the program. Example: emacs logsummer2011.txt & 2.)***remember to type an & after opening anything that will pop up a new window, otherwise you will lose your command prompt!! 3.) To close a program usually type exit/ logout, or something of that nature, depending on the program. If all else fails, use ctrl c to quit a program. 4.) Here are a few of the commands for opening some of the main programs we use on Cecelia: acroread opens adobe reader ds9 opens image editing software emacs opens text editor firefox opens internet browser. ggv use to view.ps files kview one way to view jpeg files latex use for formating papers ooffice like microsoft office

2. A selection of more advanced unix/linux commands A. Setting up symbolic links Sometimes it is useful to have a special kind of file called a symbolic link stored in a directory. No data is actually stored in this file, rather opening this file links to data stored in another file elsewhere. ln s path/file.txt path2/link.txt creates a symbolic link at path2/link.txt to path.file.txt B. setting up an alias which [command] unalias [command] alias [command] [command] i shows the alias [command] is associated with (the most common alias is one in which the command asks you if you really want to do something) Example: which rm shows what alias rm is associated with. If it displays /bin/rm, then it is not aliased at all. It will delete whatever you want to delete without question (most of the time not a good situation to be in!). If it displays rm: aliased to rm i, then if you use the rm command, it will ask you if you really want to delete whatever you have attempted to delete. makes [command] not aliased to anything associates the are you sure? mentality mentioned above to [command]. Example: alias rm rm i makes it so that when you attempt to delete something, rm will ask you if you are sure you want to do that. In the case of mv or cp, it will ask you if you want to overwrite a file if that file happens to have the same filename of the file you want to move, rename, or copy C. Manipulating multiple files that contain the same sequence of characters The key to moving multiple files with similar parts is to use the wildcard symbol * to replace any parts of the names that do not match. mv *[string]* [directory] moves files that contain [string] anywhere in the filename into another directory Example: mv *dark* dark moves all files that contain dark anywhere in the filename into the folder dark mv [string]* [directory]: moves files that start with [string] in the filename into another directory

Example: mv bias00* bias moves all files that start with bias00 in the filename into the folder bias mv *[string] [directory]: moves files that end with [string] in the filename into another directory Example: mv *flat15 flat moves all files that end with flat15 in the filename into the folder flat mv [string1]*[string2] [directory]: moves files that start with [string1] and end in [string2] in the filename into another directory Example: mv image*.fits images moves all files that start with image and end in.fits in the filename into the folder images mv *[string1]*[string2]* [directory]: moves files that contain [string1] and [string2] anywhere in the filename into another directory Example: mv *image*.fits* images moves all files that contain image and.fits anywhere in the filename (but in that order) into the folder images Note: this technique doesn t work with mv or cp if you re using them to rename files because you can t rename multiple files to have the same filename. This same format works with cp (if you re using it for copying files into different directories) and rm (you obviously don t need to specify a directory with this command). other operations passwd: allows you to change your password (beware: it won t let you use easy passwords!) ls > making lists 3. Guides to helpful programs DS9 opening images: select File then Open then navigate to your image and open it. To make it easier on the eye, select Color then Invert Color Map so that you see black galaxies on a white background. To bring up the histogram, select Scale then Scale Parameters. right clicking the mouse also adjusts contrast. In the upper right, you'll see two snapshots. One shows the whole image, with a blue box to indicate the part of the image displayed in the large lower frame. Move the blue box around, and use zoom to view all parts of your image. The other snapshot shows a close up around your cursor position, File: Edit: View: Frame:

Bin: Zoom: Color: Region: WCS: Analysis: EMACS 1. introduction Emacs is a text editor which is useful for programming, logging, and viewing text and csv files. Most basic commands, such as save as, copy, paste, etc., can be seen by viewing the drop down menus at the top of the emacs window, abbreviate where C = ctrl, and M = alt esc Otherwise, here is a pretty nice list: ctrl a moves to beginning of line ctrl e moves to end of line ctrl k kills a whole line ctrl g unhighlights ctrl g quits out of command line below ctrl space marks set (marks the beginning of a highlighted region) ctrl w cuts highlighted region ctrl y pastes highlighted region alt u makes the word after where the cursor is CAPS alt q might realign your text at least in a latex file... 2. find and replace Emacs is especially useful for editing long lists of data. Macros and find and replace commands facilitate this. To use find and replace in emacs: first type: alt shift 5 [old phrase] enter [new phrase] then: space or `y' to replace one match! to replace all remaining matches with no more questions additionally, you can type: delete or `n' to skip to next, RET or `q' to exit, period to replace one match and exit Comma to replace but not move point immediately C r to enter recursive edit (C M c to get out again) C w to delete match and recursive edit C l to clear the screen, redisplay, and offer same replacement again ^ to move point back to previous match,

E to edit the replacement string 3. Macros Macros are basically a sequence of commands that the user defines which can be run over and over again. Setting up the macro: 1.) Place cursor where you want to edit the text. 2.) Type ctrl x ( (the dash means hold down ctrl while typing x). At the bottom of the emacs window, it should say Defining keyboard macro. 3.) Edit the text the way you want each line to appear, and then arrow down to the next line and stop on the spot you started at on the first line. 4.) Type ctrl x ). At the bottom of the emacs window, it should say Keyboard macro defined. Using the macro: 1.) Place the cursor where you want each line to be edited. 2.) Type ctrl x e (this executes the macro once). 3.) Type esc [# of times you want the macro to run] ctrl x e. Example: esc 54 ctrl x e runs whatever macro you defined 54 times IDL 2.run in an xterm window $ in front to do a unix command 3. Type idl to log in 4. command,[stuff about command] format 5. script can be run in both the command line and a txt document 6. keeping track of what things are is key #'s verses strings verses float verses real etc. '1234' gives a string 1234. gives a float 1234 gives an integer **some useful commands: help, [some variable] gives the number and the data type! print, [some variable] gives just the number 7.writing script: write in comment lines and command lines: comments have ; in front the computer just reads the commands, the comments help you read it start by defining variables you want to list all the things you might want to change this way I can plug in something different & the whole code will run fine 8. "verbs"

mrdfits( ) reads the fits file tv draws the fits file tvcircle,radius,120,150 plots a circle on the file curval gives the pixel value where ever you hover your cursor IRAF logging in... open in an xgterm window by typing xgterm & xgterm sb & gives a scrollbar with the xgterm window cd to iraf cl logs in in help commandname gives manual of what commandname does epar commandname edits parameters on commandname ctrl d to leave epar :go to run command from epar imputs... you need.fits endings for iraf to read.fits files to make a long list of imputs, make a text file, 1 imput per line,and enter the text file name on the imput line with a @ sign: @comimputs.txt OOFFICE an early version of microsoft office, works very similar to excel and word help tab tells you more LATEX This is the program we use to format papers for publication. Most of it can be figured out from just looking at the syntax of previous publications. A few helpful notes, none the less: general running latex strategy: run latex (just type latex [filename.tex] in the command terminal) run bibtex (type bibtex [filename])

run latex run latex you can otherwise just type the filename without extension and it is smart about choosing the extension. so latex paper1.tex can be latex paper1 and xdvi paper1.dvi & can be xdvi paper1 & to make the latex file: latex [filename] to view the latex file: xdvi [filename] to print the latex file: dvips Psb157 paper.dvi Specific symbols have specific meanings in latex. Thus, if you want to type them in the text, you have to use the escape character, a backslash ( "\") to remove their special meaning. Thus: make sure each & in your text is a \& make sure each _ id a or \_ % is the comment symbol. To actually type % in the text type \% citations: ~dhaarsma/help/bibtex.in.aastex.help lists all the different commands for citations: a few key ones: \citep{author99a} (Author 1999) \citep{smith94a,jones95b,chen84a} (Smith 1994, Jones et al 1995, Chen 1984) \cite{author99a} Author (1999) \citet{author99a} Author (1999) \citealp{author99a} Author 1999