An Introduction to Unix

Similar documents
AMS 200: Working on Linux/Unix Machines

Introduction to the Linux Command Line

Linux/Cygwin Practice Computer Architecture

Outline. Structure of a UNIX command

Linux Tutorial. Ken-ichi Nomura. 3 rd Magics Materials Software Workshop. Gaithersburg Marriott Washingtonian Center November 11-13, 2018

Computer Systems and Architecture

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

Computer Systems and Architecture

Unix Workshop Aug 2014

Introduction to UNIX/Linux

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

Some useful UNIX Commands written down by Razor for newbies to get a start in UNIX

Introduction to UNIX command-line

Basic Shell Commands

Chapter-3. Introduction to Unix: Fundamental Commands

Introduction to Linux Environment. Yun-Wen Chen

AN INTRODUCTION TO UNIX

CS4350 Unix Programming. Outline

CSCI 2132 Software Development. Lecture 4: Files and Directories

Introduction to Linux. Fundamentals of Computer Science

Getting Started with UNIX

Mills HPC Tutorial Series. Linux Basics I

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]

Session 1: Accessing MUGrid and Command Line Basics

Physics REU Unix Tutorial

CS Fundamentals of Programming II Fall Very Basic UNIX

Linux at the Command Line Don Johnson of BU IS&T

CMSC 104 Lecture 2 by S Lupoli adapted by C Grasso

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

UoW HPC Quick Start. Information Technology Services University of Wollongong. ( Last updated on October 10, 2011)

Introduction of Linux

Getting Started With UNIX Lab Exercises

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

UNIX Quick Reference

Introduction. File System. Note. Achtung!

Using the Zoo Workstations

Unix/Linux Operating System. Introduction to Computational Statistics STAT 598G, Fall 2011

Connecting to ICS Server, Shell, Vim CS238P Operating Systems fall 18

Introduction to the UNIX command line

IMPORTANT: Logging Off LOGGING IN

Linux command line basics II: downloading data and controlling files. Yanbin Yin

CS 215 Fundamentals of Programming II Spring 2019 Very Basic UNIX

Goals for This Lecture:

Getting started with Hugs on Linux

Introduction to Linux (Part I) BUPT/QMUL 2018/03/14

Helpful Tips for Labs. CS140, Spring 2015

Linux Command Line Primer. By: Scott Marshall

Embedded Linux Systems. Bin Li Assistant Professor Dept. of Electrical, Computer and Biomedical Engineering University of Rhode Island

User Guide Version 2.0

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

COMS 6100 Class Notes 3

CHEM5302 Fall 2015: Introduction to Maestro and the command line

Introduction to Linux Part 1. Anita Orendt and Wim Cardoen Center for High Performance Computing 24 May 2017

Lezione 8. Shell command language Introduction. Sommario. Bioinformatica. Mauro Ceccanti e Alberto Paoluzzi

Brief Linux Presentation. July 10th, 2006 Elan Borenstein

Chapter 1 An Introduction to C++, Unix, SSH and Komodo Edit

CENG 334 Computer Networks. Laboratory I Linux Tutorial

Introduction to UNIX Command Line

UNIX Quick Reference

Lab 1 Introduction to UNIX and C

Introduction to Linux Organizing Files

Practical Session 0 Introduction to Linux

Virtual Machine. Linux flavor : Debian. Everything (except slides) preinstalled for you.

2. Basic Elements of Fortran

First of all, these notes will cover only a small subset of the available commands and utilities, and will cover most of those in a shallow fashion.

Part I. Introduction to Linux

Oxford University Computing Services. Getting Started with Unix

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

Lezione 8. Shell command language Introduction. Sommario. Bioinformatica. Esercitazione Introduzione al linguaggio di shell

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

Basic Unix Commands. CGS 3460, Lecture 6 Jan 23, 2006 Zhen Yang

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

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

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

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

Introduction: What is Unix?

Unix Introduction to UNIX

Linux Command Line Interface. December 27, 2017

CpSc 1111 Lab 1 Introduction to Unix Systems, Editors, and C

Introduction to Unix: Fundamental Commands

CS CS Tutorial 2 2 Winter 2018

INTRODUCTION TO BIOINFORMATICS

Introduction to Linux

Lab 2: Linux/Unix shell

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

Systems Programming and Computer Architecture ( ) Exercise Session 01 Data Lab

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

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

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

Getting Started. Running Utilities. Shells. Special Characters. Special Characters. Chapter 2 Unix Utilities for non-programmers

Unix L555. Dept. of Linguistics, Indiana University Fall Unix. Unix. Directories. Files. Useful Commands. Permissions. tar.

Getting started with Hugs on Linux

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

Development Environment & Linux Guide

Chapter 1 An Introduction to C++, Unix, SSH and Komodo Edit

Research. We make it happen. Unix Basics. User Support Group help-line: personal:

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

Short Read Sequencing Analysis Workshop

Introduction to UNIX command-line II

Transcription:

An Introduction to Unix Sylvia Plöckinger March 3, 2011 Sylvia Plöckinger () An Introduction to Unix March 3, 2011 1 / 29

General Information Find this file on: http://homepage.univie.ac.at/nigel.mitchell/numprac/ Sylvia Plöckinger () An Introduction to Unix March 3, 2011 2 / 29

Outline 1 Astro Lab 2 Unix Basics 3 Editors 4 Data Security (unet) 5 Tips for lazy users 6 Fortran - Part I Sylvia Plöckinger () An Introduction to Unix March 3, 2011 3 / 29

Astro Lab How to use the computers in the lab Documentation www.univie.ac.at/astro/internal/lab/ (Unet Login) Start up Enter UserID (student1-12) and password (keyboard or internal site). Applications System Terminal Get your data from your unet account (see Section Data Security ) Decompress your data > tar -xf dateiname.tar Start to work Sylvia Plöckinger () An Introduction to Unix March 3, 2011 4 / 29

Astro Lab How to use the computers in the lab Documentation www.univie.ac.at/astro/internal/lab/ (Unet Login) Close down Compress your data > tar -cvf dateiname.tar directory/ Put your data to your unet account with scp or sftp Quit the terminal with > exit Leave Logout Never shut down the computer! How to use the printer lpr -H <printserver> -P <printername> <filename> Sylvia Plöckinger () An Introduction to Unix March 3, 2011 5 / 29

Astro Lab How to use the lab computer from other maschines 1 Get a terminal (f.e. x11 (mac), cygwin (windows)) 2 Get an IP address within the firewall 3 ssh -Y <UserID>@lab<nr>.astro.univie.ac.at RSA key? Ad 1 (Windows) http://x.cygwin.com Install Cygwin/X now Install from Internet Choose a Server X11 xterm X11 terminal emulator Ad 1 (Mac) /Applications/Utilities/X11 Programme/Dienstprogramme/X11 If it is not there, install it from your Mac OS CD/DVD Sylvia Plöckinger () An Introduction to Unix March 3, 2011 6 / 29

Astro Lab How to use the lab computer from other maschines 1 Get a terminal (f.e. x11 (mac), cygwin (windows)) 2 Get an IP address within the firewall (www.univie.ac.at/zid/vpn) 3 ssh -Y<UserID>@lab<nr>.astro.univie.ac.at RSA key? Ad 2 www.univie.ac.at/zid/vpn Install the VPN Client for your system Connect with your unet accout Sylvia Plöckinger () An Introduction to Unix March 3, 2011 7 / 29

Unix Basics Unix Basics Login: > User-ID <Return> > Password <Return> Do not expect any symbols, when typing in your password! Logout: > exit <Return> or: > logout <Return> Special directories:. current directory.. one level up in the directory path home directory / root directory Different kind of paths: Absolute path (> pwd): /home/numast/mydir Path from home directory: ~/mydir/ Relative path:../mydir/ Sylvia Plöckinger () An Introduction to Unix March 3, 2011 8 / 29

Unix Basics Unix Commands In general > <command> [option(s)] <argument> Command examples Make Directory > mkdir newdir Exercise: What s the difference? > mkdir newdir/subdir/subdir2/ > mkdir -p newdir/subdir/subdir2/ > mkdir -vp newdir/subdir/subdir2/ Change directory > cd newdir > cd.. > cd../newdir > cd ~/newdir Sylvia Plöckinger () An Introduction to Unix March 3, 2011 9 / 29

Unix Basics Unix Commands Command examples List > ls [-la -h] > ls [-la -h] *.txt > ls [-la -h] /home/ Case sensitive! Copy a file > cp newfile.txt../newdir/. Move / rename a file > mv newfile.txt../newfile2.txt Remove a file or directory > rm newfile.txt > rm -r newdir removes newdir with all files and subdirectories > rm -rv newdir > rmdir newdir removes only empty directories Be very careful! No messages like: Are you sure? <Return> Really?. No recycle bin! Be even more careful, when using a wildcard * helpful option -i. Sylvia Plöckinger () An Introduction to Unix March 3, 2011 10 / 29

Unix Basics Unix Commands Output in files: > ls -la -h > list.txt >./a.out > output.dat Disk usage (free memory): du [-h -s] df -h df -h /home Output page by page: > ls -la -h more > more test.dat Search for...... files: > locate newfile.dat... commands: > whereis ls... within files: > grep [-i -l -v] atest *.dat... yourself: > whoami Learn more about every command: > man <command> (quit man with q ) Sylvia Plöckinger () An Introduction to Unix March 3, 2011 11 / 29

Unix Basics Emergency Exit Kill Jobs Foreground jobs: [Ctrl] + c Get your process ID: > top (quit top with q ) > kill <PID> > kill -9 <PID> Contact us or Mr. Fischer (system administrator) Sylvia Plöckinger () An Introduction to Unix March 3, 2011 12 / 29

Editors The Vi Editor Start Vi: > vi > vi newfile.dat Start insert mode a or i Quit insert mode [Esc] Delete [Esc] x current character [Esc] dd current line Go to line nr. <nr> [Esc] :<nr> Go to the last line [Esc] G Copy a line [Esc] Y Paste the copied line [Esc] P Save file: [Esc] :w [Esc] :w newfile2.dat Save file and quit vi: [Esc] ZZ [Esc] :wq [Esc] :x Quit Vi without saving: [Esc] :q [Esc] :q! Sylvia Plöckinger () An Introduction to Unix March 3, 2011 13 / 29

Editors Vi - A brief instruction (www.fehcom.de/pub/viref.pdf) Sylvia Plöckinger () An Introduction to Unix March 3, 2011 14 / 29

Editors Vi - A brief instruction (www.fehcom.de/pub/viref.pdf) Sylvia Plöckinger () An Introduction to Unix March 3, 2011 15 / 29

Editors The Emacs Editor Start Emacs: > emacs > emacs newfile.dat Open file in buffer [Ctrl]-x [Ctrl]-s Go to beginning of line [Ctrl]-a Go to end of line [Ctrl]-e Save file: [Ctrl]-x [Ctrl]-s Quit Emacs: [Ctrl]-x [Ctrl]-c Sylvia Plöckinger () An Introduction to Unix March 3, 2011 16 / 29

Editors The XEmacs Editor Start Emacs: > xemacs > xemacs newfile.dat & Advantage: Very user-friendly Nice GUI - with lots of buttons to click on Sylvia Plöckinger () An Introduction to Unix March 3, 2011 17 / 29

Data Security (unet) Data Security Do not use the lab computers to store your data! Use your unet filespace! Sylvia Plöckinger () An Introduction to Unix March 3, 2011 18 / 29

Data Security (unet) How to use the unet filespace Login ssh -Y a<matrikelnr.>@unet.univie.ac.at Unet password Type in s to use the Unix shell Logout Type > exit to quit the shell Type q to close the unet-connection Secure Copy Copy files from lab1-12 to unet with secure copy (scp) instead of cp. scp <UserID>@lab<nr>.astro.univie.ac.at:Numast/testing.dat Numast/. From unet to lab1-12: scp testing.dat <UserID>@lab<nr>.astro.univie.ac.at:Numast/. Sylvia Plöckinger () An Introduction to Unix March 3, 2011 19 / 29

Data Security (unet) How to use the unet filespace SSH File Transfer Protocol (SFTP) Example: You are logged in on one of the lab machines and want to put/get data on/from your unet account: > sftp a<matrikelnr.>@unet.univie.ac.at > put Numast/testfile.dat > get testfile.dat > exit Question: What is the target/source directory? Local directory (ssh -Y <UserID>@lab<nr>.astro...) lls lcd lpwd lmkdir Remote directory (sftp a<mnr.>@unet.univie.ac.at) ls cd pwd mkdir Sylvia Plöckinger () An Introduction to Unix March 3, 2011 20 / 29

Tips for lazy users Tips for lazy users Command completion: [Tab] or [Tab] [Tab] Search the shell history: [Ctrl] + r (quit the search with [Esc]) Create your own commands in the ~/.bashrc: > vi ~/.bashrc alias l="ls -la -h" alias..="cd.." alias...="cd../.." alias rm="rm -i" alias myfolder="cd /folder1/folder2/folder3/myfolder/" Look at your alias with > alias Do not remove any other line from the.bashrc! Sylvia Plöckinger () An Introduction to Unix March 3, 2011 21 / 29

Fortran - Part I Very, very basic Fortran 90 Program Structure PROGRAM <program-name> IMPLICIT NONE [declaration part] [execution part] Run the program > vi myprogram.f90 > gfortran myprogram.f90 Find a file a.out in your current directory >./a.out END PROGRAM <program-name> Sylvia Plöckinger () An Introduction to Unix March 3, 2011 22 / 29

Fortran - Part I A Fortran90 variable name (identifier) has less than 31 characters can consist of letters, digits or underscores, (first one must be a letter) is case insensitive (name = Name = NAME = NaMe) Variable Types: Integer 1000, -359, 0, 97338 Double Precision (F77) 1.89d0, 1985.d0, 5,44d7, -2.978d-15 Complex (2.887,-3.654) Real 2.384, -7.0987, 1.67e-8, -186.e3 Logical.true.,.false. Character test, hello, Sylvia Plöckinger () An Introduction to Unix March 3, 2011 23 / 29

Fortran - Part I Variable Declaration Declaration Part - Example Program Structure PROGRAM <program-name> IMPLICIT NONE [declaration part] [execution part] END PROGRAM <program-name> integer (kind=4) :: i, j, k, count (F90) real (kind=8) :: a, b, x (F90) logical :: hello =.true. character (len=11) :: message = "hello world" double precision :: dp1 (F77) Sylvia Plöckinger () An Introduction to Unix March 3, 2011 24 / 29

Fortran - Part I Execution Part Mathematical Operators Arithmetic ** * / + Relational < <= > >= == = / (F90).lt..le..gt..gt..eq..ne. (F77) Logical.not..and..or..eqv..neqv. Function Result Function Result ABS(x) absolute value ASIN(x) arc sine of x SQRT(x) square root ACOS(x) arc cosine of x SIN(x) sine of x (radian) ATAN(x) arc tangent of x COS(x) cosine of x (radian) EXP(x) e x TAN(x) tangent of x (radian) LOG(x) logarithm of x (e) LOG10(x) logarithm of x (10) Sylvia Plöckinger () An Introduction to Unix March 3, 2011 25 / 29

Fortran - Part I Execution Part Read Purpose: Read data from keyboard or file Use: read(<unit>, <format>) <var> read (*,*) a, b, c Write Purpose: Write data on the screen or in a file Use: write(<unit>, <format>) <var> write (*,*) a, b, c Every read (*,*) or write (*,*) starts a new line! <unit> stands for a number between 1 and 99 and has to be unique within the programme Sylvia Plöckinger () An Introduction to Unix March 3, 2011 26 / 29

Fortran - Part I Write data to file Open the file: open (<unit>, file ="dir/ filename", status = "unknown") Write data: write (<unit>, <format>) var1, var2 Close file: close (<unit>) <status> : NEW, OLD, SCRATCH or UNKNOWN <format> : statement label (100-999) write (*,100)a, b, c, d 100 format (E12.4,1X,F8.4,1X,1P,I8.7) a string that contains the format information character (len=40) :: str = "(E12.4,1X,F8.4,1X,1P,I8.7)" write (*,str)a, b, c, d the format statement itself write (*,"(E12.4,1X,F8.4,1X,1P,I8.7)")a, b, c, d Sylvia Plöckinger () An Introduction to Unix March 3, 2011 27 / 29

Fortran - Part I Do Loops in a Nutshell DO x = 1, 10, 2 f x = x*x + 10. write (*,*) x, f x ENDDO x=1 DO f x = x*x + 10. write (*,*) x, f x IF (x > 10) EXIT x = x+2 ENDDO Sylvia Plöckinger () An Introduction to Unix March 3, 2011 28 / 29

Fortran - Part I Get started! Sylvia Plöckinger () An Introduction to Unix March 3, 2011 29 / 29