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

Similar documents
Unix Tutorial Haverford Astronomy 2014/2015

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

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

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

The Directory Structure

Mills HPC Tutorial Series. Linux Basics I

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

Physics REU Unix Tutorial

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

INSE Lab 1 Introduction to UNIX Fall 2017

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

Crash Course in Unix. For more info check out the Unix man pages -orhttp:// -or- Unix in a Nutshell (an O Reilly book).

Essential Linux Shell Commands

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

Command Line Interface The basics

Operating System Interaction via bash

Part I. UNIX Workshop Series: Quick-Start

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

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

Parts of this tutorial has been adapted from M. Stonebank s UNIX Tutorial for Beginners (

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.

Using the Zoo Workstations

Scripting Languages Course 1. Diana Trandabăț

UNIX Tutorial One

Unix Basics. Systems Programming Concepts

Week 2 Lecture 3. Unix

CSCI 2132 Software Development. Lecture 4: Files and Directories

Lab Working with Linux Command Line

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

Introduction to the Linux Command Line

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

Getting Started With UNIX Lab Exercises

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

5/8/2012. Creating and Changing Directories Chapter 7

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.

Oxford University Computing Services. Getting Started with Unix

Basic Survival UNIX.

Outline. Structure of a UNIX command

Chapter-3. Introduction to Unix: Fundamental Commands

Introduction to Unix - Lab Exercise 0

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

Chapter 4. Unix Tutorial. Unix Shell

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

This is Lab Worksheet 3 - not an Assignment

Perl and R Scripting for Biologists

Lab 2: Linux/Unix shell

UNIX Tutorial Two

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

Introduction to Linux Workshop 1

1 Getting Started with Linux.

Linux Command Line Primer. By: Scott Marshall

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

Files

Introduction to Linux

THE HONG KONG POLYTECHNIC UNIVERSITY Department of Electronic and Information Engineering

Filesystem and common commands

CSC 112 Lab 1: Introduction to Unix and C++ Fall 2009

Computer Architecture Lab 1 (Starting with Linux)

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

LAB #7 Linux Tutorial

Working With Unix. Scott A. Handley* September 15, *Adapted from UNIX introduction material created by Dr. Julian Catchen

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

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

Tutorial 1: Unix Basics

Introduction to Linux and Supercomputers

Getting Started with UNIX

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

Tiny Instruction Manual for the Undergraduate Mathematics Unix Laboratory

CMSC 104 Lecture 2 by S Lupoli adapted by C Grasso

Introduction to Linux. Fundamentals of Computer Science

unix intro Documentation

Introduction to UNIX Shell Exercises

Std: XI CHAPTER-3 LINUX

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]

Overview of the UNIX File System. Navigating and Viewing Directories

Introduction to the UNIX command line

Linux Bootcamp Fall 2015

CSE 390a Lecture 2. Exploring Shell Commands, Streams, Redirection, and Processes

Session 1: Accessing MUGrid and Command Line Basics

A Brief Introduction to Unix

Linux Command Line Interface. December 27, 2017

Overview of the UNIX File System

DATA 301 Introduction to Data Analytics Command Line. Dr. Ramon Lawrence University of British Columbia Okanagan

Why learn the Command Line? The command line is the text interface to the computer. DATA 301 Introduction to Data Analytics Command Line

CSE 390a Lecture 2. Exploring Shell Commands, Streams, and Redirection

CHAPTER 1 UNIX FOR NONPROGRAMMERS

Introduction. File System. Note. Achtung!

UNLV Computer Science Department CS 135 Lab Manual

Introduction to Unix: Fundamental Commands

Computer Systems and Architecture

COSC UNIX. Textbook. Grading Scheme

Linux File System and Basic Commands

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.

Unit 10. Linux Operating System

Introduction: What is Unix?

Helpful Tips for Labs. CS140, Spring 2015

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

Practical Session 0 Introduction to Linux

PDS Lab Section 16 Autumn Tutorial 1. Unix Commands pwd The pwd command displays the full pathname of the current directory.

Introduction to the Linux Command Line January Presentation Topics

Transcription:

Unix tutorial Thanks to Michael Wood-Vasey (UPitt) and Beth Willman (Haverford) for providing Unix tutorials on which this is based. Terminal windows You will use terminal windows to enter and execute commands to the operating system. To open up a terminal window on a Mac machine, click on "Applications" in the menu bar at the top of your screen, and enter the "Accessories" submenu. Select "Terminal" from this submenu. You can use the menubar on the terminal window itself to open more than one terminal window, either by using tabs or by opening separate windows. Directory Structure The directory architecture used by Unix is a hierarchical tree structure, much like what you may have used in a Windows or other computing environment. When you first log onto a Unix system, you land in your home directory. Instead of clicking on folders, you navigate through the directory structure by changing directories using the command cd at the prompt in your terminal window. The directory that you are currently sitting in at a prompt is your working directory. The top of the tree is the root directory, designated with a slash sign (/). Directory names build on the root directory, with a slash designating a new branch in the directory structure. For example, the full (absolute) path name for my home directory would be /home/mgeha/. Directories can also have relative path names, which are interpreted as starting from the present working directory. If we were in the /home/ directory, the relative path name to my home directory would be mgeha. Listing the Contents of a Directory The command ls is used to list the contents of a directory. Under Unix, files, directories and even devices are treated as philosophically equal, so a directory could contain any one of these types of items. The ls command can be invoked with a variety of options, which modify its action. Under Unix, command options are preceded by a hyphen. A few of the more useful forms of ls include: ls ls l ls p ls t lists all filenames, including directories generates a full listing, including dates, sizes, etc distinguishes between directories and regular files lists contents by date of their creation, latest first. Try each of these ls commands in order and notice the way they indicate your home directory s contents. You can combine different options when executing a Unix command, for example: ls lt

Creating Directories Create a new directory in which you will work by using the command mkdir. You can call this directory anything you d like, but avoid whitespaces and try to name it something that makes sense, like A255. mkdir A255 Now list the contents of your current working directory to verify that your new directory has been created. Directories can be deleted with the rmdir command. Changing Directories Learn where you are in the directory structure by typing pwd which is an abbreviation for print working directory. The cd command moves you around in the directory structure, and takes an argument that is the desired destination directory. The argument can be either a relative or an absolute pathname. Type cd yournewdirectory to enter the directory that you ve just created and the system will move your current working directory to /home/yourname/yournewdirectory. Unix provides some useful shortcuts for navigating directories. A single dot,., always refers to the current directory. Double dots,.. refer to the parent directory. You can therefore move into the directory /home/mgeha from /home/mgeha/a255_data by simply typing: cd.. You can always get back to your home directory by typing cd with no arguments. Copying Files The command cp is used to copy files: cp source destination so for example I could make a backup copy of the file foo.txt by typing cp foo.txt foo.bak

Viewing and editing the contents of a file The tasks cat file and more file print the contents of a simple text file to the terminal window. The cat task scrolls the entire thing past with no pauses. The more task more allows you to page through the file, using the spacebar to move one screenful and the Enter key to move down one line at a time. There are a number of ways to edit text files. I use the program emacs. Other options are vi or textedit. We will discuss the pro/cons of these options in class. You open up a file to edit with emacs by typing: emacs myfile You can do this whether or not the file yet exists. Its better if you open a file using emacs by typing: emacs myfile & The & will run emacs in the background of your terminal, freeing up your terminal prompt for you to execute commands. Go to the directory that you created for this class. Use emacs to create a file in which you will keep notes. Write a couple of notes, and save and close the file. Edit your.bashrc File I want you to add an alias to the.bashrc file in your home directory that will help prevent you from accidentally deleting files that you want. Add the line: alias rm= rm -i to your.bashrc file. Save and quit this file. Filenames and Wildcards Files in the current working directory can be referred to simply by their filename. In general, however, the name of a file includes its full pathname, such as /home/mgeha/foo.txt where the last element, foo.txt, is the file name. Unix allows you to select a subset of the objects of interest. For example, to obtain a listing of all files that end in.doc, you would type

ls *.doc You could also move all files that fit a particular pattern with mv../*.doc. Redirection One of the most useful aspects of Unix is the ability to redirect streams of information, input and output to and from files and processes. The symbols >, < and >> are used to accomplish this. For example, to send the listing of all the files in the current directory into a file called foo, one would type ls > foo This has the feature that if a file called foo existed already, it would be overwritten with the new information. You could instead append the directory listing to a pre-existing file called foo by using ls >> foo Online help under Unix The on-line documentation for Unix can be accessed through man pages, short for manual. If you remember the relevant work, you can type man k keyword Which will produce a listing of all the man pages that pertain to that topic. You can then type man foo to get specific information on the topic foo. For more detailed information you can use the info command, e.g., info foo. A Multi-tasking and Multi-user operating system Unix is somewhat different from most typical personal computer operating systems. For one thing, multiple users can be logged in at once. Also, the computer can be running multiple tasks at the same time. A single CPU can only execute one instruction at a time, but it rapidly switches between tasks so they appear to be running simultaneously. You can determine who s logged onto a system by typing who. You can see what processes are running (and what resources they are consuming) by typing top. Type q to quit the top process.

You should think of the Unix system as taking input from one or more files (which includes the keyboard, as it treats devices as a kind of file). This information can then be passed through one or more processes to produce an output file. Rather than having to store intermediate results in temporary files you can pipe the results from one process into the input stream of another process. This is one of the really powerful aspects of Unix, but it takes a while to embrace this perspective. An example might help. The output of the ls command can be piped into the more command using the pipe symbol, which is a vertical bar: ls l more mini Unix Survival Guide cd name cd.. cd ~ cd pwd ls ps mkdir name rm i file rmdir directory changes directory to name (relative or absolute path) changes directory up one level changes to home directory (with no argument) changes to home directory print current working directory (i.e. where am I?) lists contents of current directory lists processes running on the machine creates a directory called name deletes file, but asks first. deletes directory, but it must be empty first more file types the contents of file to the screen, one page at a time cp file1 file2 makes a copy of file1 called file2 > file sends output stream to file, overwriting if it exists >> file appends output stream to end of file task1 task2 pipes the output of task1 into task2 man topic produces help listing on topic. info topic produces help listing on topic Troubleshooting If you find that the cursor has gone away, with no indication of ever returning, try the old standby CTRL-c. This means hold down the Ctrl key and hit c. This ought to kill the hung process. If this fails, try CTRL-z, where you hit z instead of c. This suspends, rather than kills, the hung process but still might let you recover.