Introduction to the basics of UNIX

Similar documents
Introduction: What is Unix?

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

Introduction to Linux

Getting started with Hugs on Linux

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

Mills HPC Tutorial Series. Linux Basics I

CENG393 Computer Networks Labwork 1

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

AN INTRODUCTION TO UNIX

CSCI 2132 Software Development. Lecture 4: Files and Directories

CS Fundamentals of Programming II Fall Very Basic UNIX

Week 2 Lecture 3. Unix

CHEM5302 Fall 2015: Introduction to Maestro and the command line

Chapter Two. Lesson A. Objectives. Exploring the UNIX File System and File Security. Understanding Files and Directories

CMSC 104 Lecture 2 by S Lupoli adapted by C Grasso

Outline. Structure of a UNIX command

1 Getting Started with Linux.

Operating Systems. Copyleft 2005, Binnur Kurt

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

Introduction to Linux

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

Getting started with Hugs on Linux

Unix Introduction to UNIX

Introduction to the Linux Command Line

Introduction to UNIX I: Command Line 1 / 21

Introduction to Linux Workshop 1

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

Introduction to Linux Basics

Unix File System. Class Meeting 2. * Notes adapted by Joy Mukherjee from previous work by other members of the CS faculty at Virginia Tech

Essential Linux Shell Commands

Getting Started with UNIX

Introduction to the UNIX command line

Perl and R Scripting for Biologists

A Brief Introduction to Unix

CSC209. Software Tools and Systems Programming.

Introduction to Cygwin Operating Environment

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

Unit 10. Linux Operating System

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

AMS 200: Working on Linux/Unix Machines

Chapter-3. Introduction to Unix: Fundamental Commands

Lecture 01: welcome and intro what LSD and Unix have in common

Intro to Linux & Command Line

Introduction. File System. Note. Achtung!

Linux Shell Script. J. K. Mandal

CS 215 Fundamentals of Programming II Spring 2019 Very Basic UNIX

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

Lab Working with Linux Command Line

CISC 220 fall 2011, set 1: Linux basics

CS4350 Unix Programming. Outline

Files and Directories

Introduction to Linux

Introduction to Linux

Lecture 3. Unix. Question? b. The world s best restaurant. c. Being in the top three happiest countries in the world.

Unix background. COMP9021, Session 2, Using the Terminal application, open an x-term window. You type your commands in an x-term window.

Files

Unit 13. Linux Operating System Debugging Programs

Introduction to Linux Environment. Yun-Wen Chen

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

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

Unix Tutorial Haverford Astronomy 2014/2015

Introduction to Unix. Jin-Soo Kim Computer Systems Laboratory Sungkyunkwan University

Practical Computing-II. Programming in the Linux Environment. 0. An Introduction. B.W.Gore. March 20, 2015

CHAPTER 1 UNIX FOR NONPROGRAMMERS

Examples: Directory pathname: File pathname: /home/username/ics124/assignments/ /home/username/ops224/assignments/assn1.txt

CS 261 Recitation 1 Compiling C on UNIX

Introduction to Linux

Scripting Languages Course 1. Diana Trandabăț

Unix Workshop Aug 2014

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

Oxford University Computing Services. Getting Started with Unix

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

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

INSE Lab 1 Introduction to UNIX Fall 2017

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

STA 303 / 1002 Using SAS on CQUEST

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

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

Open Source Computational Fluid Dynamics

Introduction to Unix: Fundamental Commands

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

Lecture 1. A. Sahu and S. V. Rao. Indian Institute of Technology Guwahati

Working with Basic Linux. Daniel Balagué

Unix basics exercise MBV-INFX410

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

CS1101: Lecture 5 Basic File Manipulation II

CENG 334 Computer Networks. Laboratory I Linux Tutorial

CSN08101 Digital Forensics. Module Leader: Dr Gordon Russell Lecturers: Robert Ludwiniak

IBM AIX Basic Operations V5.

CHEM 5412 Spring 2017: Introduction to Maestro and Linux Command Line

Getting Started With UNIX Lab Exercises

Introduction to Unix. University of Massachusetts Medical School. October, 2014

Short Read Sequencing Analysis Workshop

Unix Essentials. BaRC Hot Topics Bioinformatics and Research Computing Whitehead Institute October 12 th

Beyond this course. Machine code. Readings: CP:AMA 2.1, 15.4

Linux Command Line Primer. By: Scott Marshall

User Guide Version 2.0

Quick Start Guide. by Burak Himmetoglu. Supercomputing Consultant. Enterprise Technology Services & Center for Scientific Computing

Introduction to Linux Spring 2014, Section 02, Lecture 3 Jason Tang

Linux environment. Graphical interface X-window + window manager. Text interface terminal + shell

Transcription:

Introduction to the basics of UNIX Joachim Hein Centre for Mathematical Sciences Lund University Outline 1 Operating system UNIX 2 Interacting with UNIX Manipulating files and directories Editing files: emacs Basic scripting UNIX variables 3 Summary Introduction to UNIX UNIX and UNIX-like operating systems widely for scientific computation platforms Started in 1969 at AT&T Bell Labs Large number of UNIX flavours, including: Various flavours of LINUX AIX by IBM Solaris by Oracle (formerly Sun) Mac OS X by Apple HP-UX by HP To the user of a system the difference between these flavours of UNIX are typically small This lecture: Basic introduction into using UNIX

The UNIX terminal Traditional interaction with a UNIX system: Prompt in terminal Graphical user interfaces are modern alternative, but Not everything you need to do can be done via gui Prompt available on any UNIX system Prompt faster to access a remote computer (e.g. in the US) Just type the commands at the prompt Rem: There is also a DOS prompt on a windows system UNIX command A typical UNIX command looks as follows: command arg1 arg2 arg3 Arguments can be optional or mandatory Examples for UNIX commands: ls mkdir src grep -i input io.c gcc -O3 -c solver.c Getting help on a command To get help on a UNIX command, study the man-pages Example: man gcc Produces the manual page for the gcc command

Directory structure The directory structure of a user fred might look like: fred Simax Epen src obj README doc comp.c io.c simax.c comp.o io.o simax.o ch1.txt ch2.txt comp.h io.h : file The home directory of fred contains: directories and/or files - the directories contain: sub-directories and/or files : directory Basic UNIX usage requires manipulation of your directories and files Listing files and directories To list the files and directories in your present directory, simply type ls There are a number of important options to ls -l Long listing, incl. owner, size, dates, time -t Sort by time -r Reverse the order of the listing -a List all objects objects starting with. are hidden You can also given a file/directory as argument to ls: ls -l input.c Gives the details of the file input.c Example listing Example output for a long time reversed listing on a Linux system: guldin:~/courses/scicompmath/slides> ls -ltr total 55 -rw-r--r-- 1 joachim matte 168 Jun 2 14:40 slidetemplate.tex -rw-r--r-- 1 joachim matte 5025 Jun 3 16:25 LU.JPG -rw-r--r-- 1 joachim matte 48096 Jun 3 16:25 logoonly.pdf drwxr-xr-x 2 joachim matte 512 Jun 3 16:25 CVS/ drwxr-xr-x 4 joachim matte 512 Jun 3 19:37 IntroUnix/ Meaning of key columns: ---------- ------- ----- ----- ------------ ----------------- permission owner group size modif. time object name

Navigating the directory tree Use cd to change the directory Examples: cd src change into the sub-directory: src cd testcode/src change into the sub-sub-directory: testcode/src cd.. move into the parent directory (one level up) cd change in your home directory cd /usr/bin/latex change into the directory: /usr/bin/latex Rem: Leading / gives absolute path, otherwise relative Creating and removing directories mkdir mydir creates a sub-directory mydir in the present directory rmdir olddir removes the sub-directory olddir (needs to be empty) from the present directory Copying and deleting files Use cp to copy a file Different location: cp results.txt Textfiles/. Copies the file results.txt from present directory into the subidrectory Textfiles and keeps the name Different name: cp results.txt results_old.txt Different name in different directory: cp results.txt Archieve/results_old.txt Use rm to delete (remove) a file: Deleting the file oldfile.c rm oldfile.c Depending on setup, this might remove the file without asking any questions!!!

Viewing files One can view the contents of a text file (e.g. listing.txt, program.c, routine.h) with more more program.c Compare two files using diff diff filea.c fileb.c Sample output from diff showing line 13 from first and second file: 13c13 < double result = sq(avec[0]); --- > double result = scalarprod(avec,bvec); Editing files To write and modify C-code you need a text editor There are many text editors available for UNIX vi this is very popular with system administrators pico/nano a simple, easy to use editor emacs extremely powerful many more Use what works best for you you need the job done Next: a quick introduction to emacs Text editor: emacs Emacs has special modes for different types of files Typically switched automatically based on extension Modes include: C-source, Fortran-source, L A TEX-source, UNIX-scripts Emacs is easiest when using the graphical window You normally just type in the main window Full mouse support (change of writing postion, buttons, pull down menues,...) On a remote machine, the graphical window might not open (e.g. no X-connection) or might be slow Run emacs in your terminal window Typically faster Emacs in your terminal can be forced by calling emacs -nw Downside: reduced functionallity

Starting emacs Depending on the installation, emacs can often be started from the graphical user interface of the UNIX system Emacs can also be started from the UNIX prompt Starting emacs form terminal to run in graphical window: emacs programsource.c & Starts emacs and loads file programsource.c into it The & ensures the prompt is not blocked, to e.g. compile and run programs Starting emacs from terminal to run in terminal: emacs -nw programsource.c Starts emacs and loads file programsource.c into it The -nw forces the terminal mode The EMACS graphical window EMACS in a terminal

Controlling Emacs Just type your text (e.g. C-code) in the main window Emacs can be controlled for special action (e.g. storing, reading, finishing,...) Mouse clicks (button, pull down) Writing command in the last line of the window (M-x to get there) Keyboard shortcuts (very fast for things you use regular) Resources Build in tutorials and build in help Reference card for shortcuts (M denotes ESC and C denotes ctrl)