AN INTRODUCTION TO UNIX



Similar documents
Hands-On UNIX Exercise:

Basic C Shell. helpdesk@stat.rice.edu. 11th August 2003

Command Line - Part 1

ICS 351: Today's plan

A Crash Course on UNIX

HP-UX Essentials and Shell Programming Course Summary

Unix Scripts and Job Scheduling

INASP: Effective Network Management Workshops

Unix Shell Scripts. Contents. 1 Introduction. Norman Matloff. July 30, Introduction 1. 2 Invoking Shell Scripts 2

Cisco Networking Academy Program Curriculum Scope & Sequence. Fundamentals of UNIX version 2.0 (July, 2002)

Unix Sampler. PEOPLE whoami id who

Thirty Useful Unix Commands

The Linux Operating System and Linux-Related Issues

Linux command line. An introduction to the Linux command line for genomics. Susan Fairley

Extending Remote Desktop for Large Installations. Distributed Package Installs

Linux Overview. Local facilities. Linux commands. The vi (gvim) editor

Cloud Server powered by Mac OS X. Getting Started Guide. Cloud Server. powered by Mac OS X. AKJZNAzsqknsxxkjnsjx Getting Started Guide Page 1

Unix Guide. Logo Reproduction. School of Computing & Information Systems. Colours red and black on white backgroun

Tutorial Guide to the IS Unix Service

Command-Line Operations : The Shell. Don't fear the command line...

Shell Scripts (1) For example: #!/bin/sh If they do not, the user's current shell will be used. Any Unix command can go in a shell script

Using SSH Secure Shell Client for FTP

CONNECTING TO DEPARTMENT OF COMPUTER SCIENCE SERVERS BOTH FROM ON AND OFF CAMPUS USING TUNNELING, PuTTY, AND VNC Client Utilities

Lecture 18 Regular Expressions

CS 2112 Lab: Version Control

Introduction to Mac OS X

UNIX Tutorial for Beginners

Tutorial 0A Programming on the command line

Parallels. for your Linux or Windows Server. Small Business Panel. Getting Started Guide. Parallels Small Business Panel // Linux & Windows Server

Unix the Bare Minimum

UNIX, Shell Scripting and Perl Introduction

Microsoft Access 3: Understanding and Creating Queries

A UNIX/Linux in a nutshell

Basic Linux and Unix commands, editing and transfering files

Setting Up VNC, SSH Tunnels, and RDP

WS_FTP Professional 12

SSH Connections MACs the MAC XTerm application can be used to create an ssh connection, no utility is needed.

Fred Hantelmann LINUX. Start-up Guide. A self-contained introduction. With 57 Figures. Springer

A Tool must be configured to allow for CMISSync, see below for more information.

JBackpack Manual. Version Abstract

Linux Syslog Messages in IBM Director

Windows PowerShell Essentials

WinSCP Tutorial 01/28/09: Y. Liow

CS10110 Introduction to personal computer equipment

USEFUL UNIX COMMANDS

grep, awk and sed three VERY useful command-line utilities Matt Probert, Uni of York grep = global regular expression print

PHP Debugging. Draft: March 19, Christopher Vickery

Introduction to UNIX and SFTP

HPCC - Hrothgar Getting Started User Guide

An Introduction to the Linux Command Shell For Beginners

WinSCP for Windows: Using SFTP to upload files to a server

MFCF Grad Session 2015

Using WinSCP to Transfer Data with Florida SHOTS

Using sftp in Informatica PowerCenter

Parallels Plesk Panel 11 for your Linux server

CASHNet Secure File Transfer Instructions

UNIX - Command-Line Survival Guide

CMSC 216 UNIX tutorial Fall 2010

Getting Started With Your Virtual Dedicated Server. Getting Started Guide

PuTTY/Cygwin Tutorial. By Ben Meister Written for CS 23, Winter 2007

VIP Quick Reference Card

Lab 1: Introduction to C, ASCII ART and the Linux Command Line Environment

Miami University RedHawk Cluster Connecting to the Cluster Using Windows

University of Toronto

University of Hull Department of Computer Science. Wrestling with Python Week 01 Playing with Python

Introduction to Operating Systems

Computational Mathematics with Python

Simple. Control Panel. for your Linux Server. Getting Started Guide. Simple Control Panel // Linux Server

Getting Started With Your Virtual Dedicated Server. Getting Started Guide

Getting Started Guide. Getting Started With Your Dedicated Server. Setting up and hosting a domain on your Linux Dedicated Server using Plesk 8.0.

UNIX / Linux commands Basic level. Magali COTTEVIEILLE - September 2009

Introduction to the UNIX Operating System and Open Windows Desktop Environment

Partitioning. Files on the Hard Drive. Administration of Operating Systems DO2003. Partition = Binder with index. Write file = Insert document

Module Title: Advanced Systems Administration 2

Worksheet 3: Distributed File Systems

How to upload large files to a JTAC Case

Connecting to Remote Desktop Windows Users

Tera Term Telnet. Introduction

sftp - secure file transfer program - how to transfer files to and from nrs-labs

Introduction to Shell Programming

Advanced Bash Scripting. Joshua Malone

Agenda. Using HPC Wales 2

Git - Working with Remote Repositories

Introduction to Unix Tutorial

L04 C Shell Scripting - Part 2

Lecture 4: Writing shell scripts

Setting Up the Site Licenses

Editing Files on Remote File Systems

System Resources. To keep your system in optimum shape, you need to be CHAPTER 16. System-Monitoring Tools IN THIS CHAPTER. Console-Based Monitoring

TS-800. Configuring SSH Client Software in UNIX and Windows Environments for Use with the SFTP Access Method in SAS 9.2, SAS 9.3, and SAS 9.

Lab 1 Beginning C Program

Computational Mathematics with Python

Computational Mathematics with Python

CS Unix Tools & Scripting Lecture 9 Shell Scripting

Accessing the FTP Server - User Manual

Transcription:

AN INTRODUCTION TO UNIX Paul Johnson School of Mathematics September 24, 2010

OUTLINE 1 SHELL SCRIPTS Shells 2 COMMAND LINE Command Line Input/Output 3 JOBS Processes Job Control 4 NETWORKING Working From Home File Synchronisation 5 SUMMARY

OUTLINE 1 SHELL SCRIPTS Shells 2 COMMAND LINE Command Line Input/Output 3 JOBS Processes Job Control 4 NETWORKING Working From Home File Synchronisation 5 SUMMARY

OUTLINE 1 SHELL SCRIPTS Shells 2 COMMAND LINE Command Line Input/Output 3 JOBS Processes Job Control 4 NETWORKING Working From Home File Synchronisation 5 SUMMARY

OUTLINE 1 SHELL SCRIPTS Shells 2 COMMAND LINE Command Line Input/Output 3 JOBS Processes Job Control 4 NETWORKING Working From Home File Synchronisation 5 SUMMARY

OUTLINE 1 SHELL SCRIPTS Shells 2 COMMAND LINE Command Line Input/Output 3 JOBS Processes Job Control 4 NETWORKING Working From Home File Synchronisation 5 SUMMARY

SHELLS A shell is a command interpreter. It translates the commands you type into instructions to the main operating system Advantage of a shell is that it can make life a lot easier with wildcards, filename completion and history mechanisms The shell can also be used as a programming language to write shell scripts Many different shells Bourne C Korn Bash Only going to cover the tcsh (default) shell. Use the ypchsh command to change your default shell.

SHELLS A shell is a command interpreter. It translates the commands you type into instructions to the main operating system Advantage of a shell is that it can make life a lot easier with wildcards, filename completion and history mechanisms The shell can also be used as a programming language to write shell scripts Many different shells Bourne C Korn Bash Only going to cover the tcsh (default) shell. Use the ypchsh command to change your default shell.

WILDCARDS Wildcards are special characters than can be used to make life easier The most used is * which replaces any string ls * lists all files ls *.txt lists all files ending in.txt rm a*.txt deletes all files starting with a and ending in.txt e.g. andrew.text, awfully_boring.txt, another_long_file.txt

WILDCARDS Wildcards are special characters than can be used to make life easier The most used is * which replaces any string ls * lists all files ls *.txt lists all files ending in.txt rm a*.txt deletes all files starting with a and ending in.txt e.g. andrew.text, awfully_boring.txt, another_long_file.txt? will replace only a single character rm a?.txt will only delete files of the form ab.txt or ac.txt, not andrew.txt

WILDCARDS Wildcards are special characters than can be used to make life easier The most used is * which replaces any string ls * lists all files ls *.txt lists all files ending in.txt rm a*.txt deletes all files starting with a and ending in.txt e.g. andrew.text, awfully_boring.txt, another_long_file.txt [ ] encloses a choice of values ls [ab]*.txt will list files that start with a or b and end in.txt The hyphen denotes a range e.g. rm [a-z].txt will remove any of the files a.txt, b.txt, c.txt, etc Warning the only sensible ranges are 0-9, a-z, A-Z or subsets thereof (unless you happen to be conversant in the numerical order of ASCII symbols)

WILDCARDS Wildcards are special characters than can be used to make life easier The most used is * which replaces any string ls * lists all files ls *.txt lists all files ending in.txt rm a*.txt deletes all files starting with a and ending in.txt e.g. andrew.text, awfully_boring.txt, another_long_file.txt A caret ˆ as the first character in square brackets acts as a logical not ls [ˆ e]* lists all files that don t start with e.

QUOTING What do you do if you have a filename containing a wildcard? Quoting (or escaping) removes the special nature of wildcard characters Backslash, \, single quotes,, or double quotes,, are used to quote characters For example to delete a file with a space in it rm strange file rm strange file rm strange\ file Or with a star rm file* rm file* rm file\* There are subtle differences between quotes, safest are single or strong quotes May need to quote when passing arguments to commands

EDITING THE COMMAND LINE (SHELL DEPENDENT) You ve probably been editing the command line without realising it! Many emacs (or vi) editing commands are available on the command line Arrow keys move left, right, CTL-t transposes two letters, CTL-a moves to start of line, etc history will display a numbered list of previous commands Up and down arrows move through the history list

EDITING THE COMMAND LINE (SHELL DEPENDENT) You ve probably been editing the command line without realising it! Many emacs (or vi) editing commands are available on the command line Arrow keys move left, right, CTL-t transposes two letters, CTL-a moves to start of line, etc history will display a numbered list of previous commands Up and down arrows move through the history list

EDITING THE COMMAND LINE (SHELL DEPENDENT) You ve probably been editing the command line without realising it! Many emacs (or vi) editing commands are available on the command line!n Repeat command n!! Repeat last command!string Repeat last command starting with string!?string[?] Repeat last command containing string!n:m mth word of nth command!$ last word of last command!n:s/old/new/ Repeat nth command substituting old for new

COMPLETION The TAB key will attempt to fill in commands a filenames for you (In tcsh need to type set autolist first) It works on the command line, in emacs and various other programs For example, if there are three files: file1, file2 & file3 typing ls f and then TAB will expand the f to file and then beep. Pressing TAB again should present a list of possible further choices It also works with commands e.g. type l and then hit TAB twice. You should see a list of all commands that start with l

I/O REDIRECTION By default input comes from the keyboard and output goes to the screen Standard input is terminated by CTL-d Standard input can be redirected using < cat < file will list the contents of file on the screen. Standard output can be redirected using > ls > ls.txt will send a file listing to the file ls.txt cat file1 file2 > file3 will concatenate add the contents of file1 and file2 and put the result in file3 cat file4 >> file3 will append file4 to the end of file3

I/O REDIRECTION By default input comes from the keyboard and output goes to the screen Standard input is terminated by CTL-d Standard input can be redirected using < cat < file will list the contents of file on the screen. Standard output can be redirected using > ls > ls.txt will send a file listing to the file ls.txt cat file1 file2 > file3 will concatenate add the contents of file1 and file2 and put the result in file3 cat file4 >> file3 will append file4 to the end of file3

I/O REDIRECTION By default input comes from the keyboard and output goes to the screen Standard input is terminated by CTL-d Standard input can be redirected using < cat < file will list the contents of file on the screen. Standard output can be redirected using > ls > ls.txt will send a file listing to the file ls.txt cat file1 file2 > file3 will concatenate add the contents of file1 and file2 and put the result in file3 cat file4 >> file3 will append file4 to the end of file3

I/O REDIRECTION By default input comes from the keyboard and output goes to the screen Standard input is terminated by CTL-d Standard input can be redirected using < cat < file will list the contents of file on the screen. Standard output can be redirected using > ls > ls.txt will send a file listing to the file ls.txt cat file1 file2 > file3 will concatenate add the contents of file1 and file2 and put the result in file3 cat file4 >> file3 will append file4 to the end of file3

PIPES A Pipe passes the output of one command to the input of the next For example consider the two stage process ls -l > ls.txt more ls.txt ls -l more sends the output of the directory listing to the more command (which stops the listing flying off the screen) Pipes can be stacked together (called a pipeline) ls -l sort more sorts the line entries alphabetically before passing the output to more

PROCESSES A process is (basically) any running program Every process is assigned a unique(ish) number or PID To suspend the current process use CTL-z To quit the current process use CTL-c (Remember this if nothing else) ps will list currently running processes PID TTY TIME CMD 5958 pts/0 00:00:00 bash 6045 pts/0 00:00:00 ps kill PID will kill the process PID kill -9 PID means really kill the process!

JOB CONTROL Programs (or jobs) may be run in the foreground or background Running in the foreground prevents you from doing anything (in the shell from which you launch the program) until the program is finished. Any foreground processes will be killed if you logout (quit the shell) Background jobs will continue to run after you logout and will return control of the shell to you To run a job in the background simply type command & For safety you should also use the nohup command if you are planning to logout nohup command &

JOB CONTROL II If you have a foreground job that you want to move to the background type CTL-z (to stop the job) and then bg which moves the job into the background The fg command can be used to move background jobs back into the foreground Use the jobs command to check on currently running jobs If you want to kill a background job you must find the PID using ps and use the kill command

JOB PRIORITY Each job is assigned a priority number If you are planning on running a long job (longer than 5 minutes) you must use the nice command to alter the priority Thus the whole command for a job running overnight would be nohup nice +19 program &

WORKING FROM HOME The school has a unix RDP server running on the address 130.88.16.43. Access can be from any RDP client on any operating system. You can quickly access a terminal command line with ssh to run jobs. External access to unix at vummath.ma.man.ac.uk and orac.ma.man.ac.uk Standard networking commands (on unix) are ssh machine sftp machine rdesktop RDPserver gives a remote shell on another machine (Encrypted) allows remote file transfer allows remote desktop use

FILE SYNCHRONISATION To transfer files from your central account, use a web browser with the address: https://pdrives.manchester.ac.uk To transfer files from your unix account to a windows machine, use the free file transfer program winscp: http://winscp.net For file synchronisation between your home desktop/laptop and university unix account, try the free sync program unison: http://www.cis.upenn.edu/ bcpierce/unison/

FINAL THOUGHTS Basic knowledge Login and logout Change your password Send and receive e-mail Edit and print files Average knowledge Use directories to organise your files Move about the filesystem confidently Use a few simple wildcards and history Monitor running processes

FINAL THOUGHTS Basic knowledge Login and logout Change your password Send and receive e-mail Edit and print files Average knowledge Use directories to organise your files Move about the filesystem confidently Use a few simple wildcards and history Monitor running processes