system or read a good Unix book from the DESY library (e.g. Mark Sobell, APractical Guide to



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

Thirty Useful Unix Commands

Unix Sampler. PEOPLE whoami id who

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

USEFUL UNIX COMMANDS

Tutorial 0A Programming on the command line

Introduction to Mac OS X

Hands-On UNIX Exercise:

ICS 351: Today's plan

Command Line Crash Course For Unix

UNIX Tutorial for Beginners

Introduction to the UNIX Operating System on IT Systems

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

Fundamentals of UNIX Lab Networking Commands (Estimated time: 45 min.)

Birmingham Environment for Academic Research. Introduction to Linux Quick Reference Guide. Research Computing Team V1.0

Command Line - Part 1

Introduction to Unix Tutorial

HP-UX Essentials and Shell Programming Course Summary

RECOVER ( 8 ) Maintenance Procedures RECOVER ( 8 )

An Introduction to the Linux Command Shell For Beginners

Tutorial Guide to the IS Unix Service

AN INTRODUCTION TO UNIX

A UNIX/Linux in a nutshell

Some basic unix commands

An A-Z Index of the Apple OS X command line (TERMINAL) The tcsh command shell of Darwin (the open source core of OSX)

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

University of Toronto

CS 103 Lab Linux and Virtual Machines

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

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

A Crash Course on UNIX

Extreme computing lab exercises Session one

Beginners Shell Scripting for Batch Jobs

Introduction to the UNIX Operating System and Open Windows Desktop Environment

CS10110 Introduction to personal computer equipment

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

Basic Linux and Unix commands, editing and transfering files

Setting up PostgreSQL

Unix Scripts and Job Scheduling

Debian and Windows Shared Printing mini HOWTO

Open Source Computational Fluid Dynamics

INASP: Effective Network Management Workshops

Progress Database Overview

Linux System Administration. System Administration Tasks

Introduction to Operating Systems

Linux System Administration on Red Hat

List of FTP commands for the Microsoft command-line FTP client

Training Day : Linux

LECTURE-7. Introduction to DOS. Introduction to UNIX/LINUX OS. Introduction to Windows. Topics:

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

CMSC 216 UNIX tutorial Fall 2010

UNIX: Introduction to TELNET and FTP on UNIX

UNIX Comes to the Rescue: A Comparison between UNIX SAS and PC SAS

File Manager User Guide

IBM WebSphere Application Server Version 7.0

File Transfer Protocol. What is Anonymous FTP? What is FTP?

WS_FTP Professional 12

Introduction to Linux and Cluster Basics for the CCR General Computing Cluster

Secure File Transfer Installation. Sender Recipient Attached FIles Pages Date. Development Internal/External None 11 6/23/08

Lab 1: Introduction to the network lab

Worksheet 3: Distributed File Systems

LSN 10 Linux Overview

Syntax: cd <Path> Or cd $<Custom/Standard Top Name>_TOP (In CAPS)

24/08/2004. Introductory User Guide

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

SFTP SHELL SCRIPT USER GUIDE

TNM093 Practical Data Visualization and Virtual Reality Laboratory Platform

CPSC 2800 Linux Hands-on Lab #7 on Linux Utilities. Project 7-1

1 Intro 1. 2 man - Accessing On-Line Manual Pages 1. 3 pwd - Print the Working Directory 2. 4 cd - Changing Directory 2

UNIX Basics. Ian Darwin TCP Informatics January, Presented from a Mac using Apple s Keynote presentation software

CO Web Server Administration and Security. By: Szymon Machajewski

Kernel. What is an Operating System? Systems Software and Application Software. The core of an OS is called kernel, which. Module 9: Operating Systems

Unix/Linux Forensics 1

Beyond Windows: Using the Linux Servers and the Grid

Higher National Unit Specification. General information for centres. Multi User Operating Systems. Unit code: DH3A 34

WebSphere Application Server security auditing

Installation Guide for WebSphere Application Server (WAS) and its Fix Packs on AIX V5.3L

DOS Command Reference

Backing Up TestTrack Native Project Databases

Grid Engine Basics. Table of Contents. Grid Engine Basics Version 1. (Formerly: Sun Grid Engine)

SSH and Basic Commands

CLC Server Command Line Tools USER MANUAL

Hadoop Basics with InfoSphere BigInsights

Tracking Network Changes Using Change Audit

WinSCP PuTTY as an alternative to F-Secure July 11, 2006

The Einstein Depot server

1 Basic commands. 2 Terminology. CS61B, Fall 2009 Simple UNIX Commands P. N. Hilfinger

Downloading Files using FTP

Unix Primer - Basic Commands In the Unix Shell

PageR Enterprise Monitored Objects - AS/400-5

Partek Flow Installation Guide

DS License Server V6R2013x

CSIL MiniCourses. Introduction To Unix (I) John Lekberg Sean Hogan Cannon Matthews Graham Smith. Updated on:

Transcription:

Introduction to Unix at DESY There are only a few commands that you have to know in order to get started on Unix. These will be presented in this introduction. For a more detailed description of the syntax of the commands and the available options, you can consult the help les (so called manual pages) on the computer system or read a good Unix book from the DESY library (e.g. Mark Sobell, APractical Guide to Unix System V or W. Abrahams and B.R. Larson, Unix for the Impatient). Unix commands sometimes have cryptic names and a very strict calling sequence for their options and parameters. The commands are case sensitive, as are the le names on the system, but most of the Unix commands are all lower case letters. Options are usually preceded by a{(minus) sign, or sometimes by a + (plus) sign. The general syntax is: command {options parameters but of course there are exceptions. Most commands allow more than one option. These options can either be put individually on the command line (e.g. cmd -1-2 -3...) or combined to a single option string (e.g. cmd -123..). File and Directory Names Unix has a tree like le and directory structure, where you can address any le or directory with its absolute path name starting at the le system root (denoted by /), or with a name relative toyour current position in the le tree. Examples:. the dot denotes the current working directory.. two dots denote the directory above the current one /usr/local/bin/xrsh is an absolute path name for the command le xrsh subdir is the name of a subdirectory below the current one../otherdir is a directory parallel to the current one your home directory username home directory of another user.controlle name of a control le in the current directory (e.g. for mail, editors, etc) usually these "dot les" are found in the home directory Manipulate Files Wildcards (? single character, * word) are very useful in handling les. Be very careful when you use wildcards with the copy, move, or remove command. Unix will delete or overwrite existing les without warning. cat name head name tail name less name cp name newname mv name newname rm name le name nd path-name expression locate name ln name newname list le with name name list rst 10 lines of le (option -number, e.g. head -20 for rst 20 lines) list last 10 lines of le (option -number, e.g. tail -20 for last 20 lines) tail -f continuously lists the end of a le list le page by page (other pagers are more, pg) copy le to new name or new directory move le to new name or new directory remove le (option -i will prompt you before deletion) analyze le type and contents nd a le in the le tree (relatively slow) locate a le in the le tree (fast, based on a periodically updated list) link an existing le with name name to a new location/name newname Introduction to Unix at DESY 1

Manipulate Directories mkdir name rmdir name cd name pwd ls name create a directory with name name remove the (empty) directory with name name change to working directory with name name print (=list) name of the current working directory list contents of the directory with the name name if name is omitted, the current working directory is listed. (options -l long detailed listing, -a lists also dot les) e.g. ls -al will list all les in the current directory in the long form Editors There is a large variety of editors on Unix. The basic editor vi is cryptic to learn but very powerful, while other editors, like pico, are very easy to learn but have only a limited number of commands. The editor that is recommended because of its widespread usage on all kinds of Unix platforms and VMS is emacs. vi pico emacs xedit ted standard Unix editor (see USG/93/01) an easy to use editor (see USG/93/02) the recommended editor (see emacs reference card and USG/93/07) an X based editor a Motif style editor Shells The interaction between the user and the Unix system is controlled by a program called shell. There are two basic families of shells, the Bourne shell and the C shell family. High level shells are recommended for interactive work, while shell scripts should be written in a low level shell (sh). At DESY the following shells are supported: sh ksh zsh csh tcsh basic Bourne shell Korn shell, which is a Bourne shell with additions Z shell, which is a Bourne shell with more additions basic C shell C shell with many additions Printing All PostScript printers at DESY are accessible from all computer platforms. The print request is spooled via central print servers which recognise various formats (e.g. text, PostScript, dvi, metales, etc.) and print them accordingly. lp name lpr name lpdest lpq (lpstat) lprm (cancel) print le (on System V Unix systems) options: -dprinter, -nnumber-of-copies, -odesy-option e.g. lp -dr02ps3 -n5 -oc name will print 5 copies of the le name on r02ps3 in a compressed format print le (on BSD Unix systems) options: -Pprinter e.g. lpr -Pr02ps3 lename will print on r02ps3 list all printer destinations (DESY command) list jobs on the print queue submitted by lpr (lp) remove job from the print queue submitted by lpr (lp) Introduction to Unix at DESY 2

Manipulate Variables The behaviour of programs and of the shell is controlled by variables or environment variables. Variables in the Bourne shell family have upper case names while variables in the C shell family have lower case names. Variables are only valid for the current shell, while the values of environment variables are accessible on all subshells. echo $VAR list value of variable VAR (remember: variable names are case sensitive) VAR=value set variable VAR (in Bourne shell family ) set var=value set variable var (in C shell family) export VAR export value of variable VAR to the environment (in Bourne shell family ) setenv var value export value of variable var to the environment (in C shell family) set list values of all local variables env list values of all environment variables Command Execution Commands can be executed in the foreground or the background. In foreground execution, input is read from the keyboard and output is written to the screen. If the command does not need input, the keyboard is locked until the command execution is nished. To avoid the keyboard locking, commands can be placed in the background for execution. This is achieved by appending an ampersand (&) to the end of the command. Examples: ls -al mosaic & will be executed in the foreground will be executed in the background Whenever a command is executed, the system will start a process and assign a unique process id (pid) to it. For commands which are executed in the background, a job number will be assigned in addition. Background commands can be monitored on all but the Bourne shell with the following commands: jobs get a list of all background commands, where the returned lines mean: [job-number] process-id status command-name stop %n stop job with job number n, can be restarted with bg %n kill %n kill job with job number n notify %n request notication from job n if status changes fg %n move job n to the foreground and restart if necessary All processes can be manipulated with the following commands: ps ps -ef ps -aux kill pid ctrl-z bg list all processes started from your current window produce a full listing of all processes on the (System V) machine produce a full listing of all processes on the (BSD) machine kill command with process id pid stop current foreground command move current stopped foreground process to the background and restart Note: background does not imply batch. All jobs for H1/ZEUS should be started using the NQS batch system. Redirection and Piping In Unix, the output of a command is usually written to the screen and the input usually given from the keyboard. Error messages are printed to a le called standard error (usually the screen). These standard le assignments can be redirected to or from any other le by the usage of a less-than-sign Introduction to Unix at DESY 3

(<) or a greater-than-sign (>) preceded by a 1 (optional) for standard output and 2 for standard error. On csh and tcsh the standard error cannot be redirected independently of the standard output. cmd <le-in >le-out cmd >>le-out cmd 1>le-out 2>error cmd >&le-out-err will get its input from le-in and write its output to le le-out will append the output to an existing le le-out will write output to a le with the name le-out and error messages to a le with the name error will write output and error messages to a le with the name le-out-err Instead of redirecting the output to a le, it could also be redirected to the input stream of another command. This is called piping and the piping symbol is a vertical bar (j). It is quite often used for listing the output page-by-page or executing search commands, e.g. ps -ef j grep string news X11 j less will look for a string in the list of all processes will list the news item about X11 page-by-page How to Get Help The standard way to get help on a Unix machine is with the so called manual pages. If the manual page for a command is installed on a system, you will get this manual page by typing: man name-of-the-command The disadvantage of the man command is that you need the exact spelling of the command name in order to read the corresponding manual page. If you don't know the name of the command you are looking for, some machines allow for an index-driven search for the manual page: apropos keyword man -k keyword xman info xinfo insight will produce a list of manual pages containing this keyword will produce a list of manual pages containing this keyword an X-based manual browser tool (click on help-button to get help) description for GNU products an X-based description for GNU products a Motif interface to the SGI documentation Network Access On the network there are two types of host: those who have a trusted relationship to each other and those who do not. The system administrator of a host will establish a trusted relationship only if all userids on the related hosts are unique. With the help of the.rhosts le you yourself can establish a trusted relationship between single users on single hosts. The.rhosts le should only be writeable by the user (i.e. the le should have the protection -rw-r--r--). The entries in this le consist of hostname username pairs. telnet hostname create an interactive connection to a remote host rlogin hostname create an interactive connection to a trusted host 3270 hostname create an interactive connection to an IBM host xrsh hostname create a connection to a trusted host with full X access ftp hostname copy les from or to a remote host rcp le1 le2 copy les from or to a trusted host, the lenames on other hosts can be specied as userid@host:lename or host:lename Introduction to Unix at DESY 4

Miscellaneous Commands chmod rights le passwd who nger user@host last grep string le di le1 le2 cmp le1 le2 sort cut uc df du [-k] tar cpio (un)compress which name wc talk user@host Text Formatting and Displaying latex xdvi dvips a2ps ghostview change access rights (whoright) of les or directories, e.g. chmod g+x lename will add execution right for members of the same group change your password list all logged in users on local machine list information about users on local or remote machines display last login information of users on the system nd a string or regular pattern in a le display dierences between two text les display dierences between two binary les sort les in lexical/numerical order skipping elds/characters cut out columns, characters, etc from a le uncosyfy NEWLIB members which have been copied with ftp from the IBM display free space on disk display space used by directories and les [in kilobytes] tape le archiver (les with name name.tar) copy le archives in and out compress or uncompress les (les with name name.z) display the full path name for the command with name name count lines, words, and characters in a le talk to another user on a remote host run LaT E X display dvi les on an X-terminal create a PostScript le from a dvi le convert ASCII text to PostScript for printing (good for manual pages) the command will send the PostScript output directly to the printer e.g. man a2ps j a2ps will print the manual pages for a2ps display PostScript les on an X-terminal Electronic Mail and Information Services There is a wide variety ofmailinterfaces on Unix. The standard mail or mailx are not recommended. Instead try using one of the programs mentioned in the following table: pine elm mh xmh mmh vm a simple e-mail program using the pico editor a wide spread electronic mail program another mail message handling system an X based mail interface to mh a Motif style interface to mh a mail interface for emacs Important system messages are displayed when you log on to the system. This message-of-today can be reviewed with the command less /etc/motd. Other more long-term system news are kept in the local news system, while information which should be accessible on more than one computer is posted to one of the DESY newsgroups. These newsgroups are readable from mosaic and any of the many newsreaders, and to post messages you have to invoke one of the newsreaders listed below. None of the newsreader, however, is completely satisfactory. We recommened tin if you are a rst time user or mosaic if you only want to read newsgroups. Introduction to Unix at DESY 5

less /etc/motd news mosaic tin xrn mxrn gnus display message-of-today display system news a Motif style document browsing program, netnews reader, information source, phonebook interface,... (see USG/93/06) a netnews interface for VT style terminals an X based newsreader a Motif style newsreader a netnews interface for emacs Programming C and fortran programs can easily be maintained and run under Unix. To run a program you just type the name of the executable. The program is compiled and linked with the same command: cc progname CC progname f77 progname C compiler, e.g. cc myprog.c compiles the C program myprog.c and creates an executable named a.out C++ compiler fortran 77 compiler, e.g. f77-omyprog myprog.f -L/cern/pro/lib -lpacklib compiles and links a fortran program myprog.f with the CERN packlib and creates an executable with the name myprog Some compiler options are used frequently, others are machine dependent. In the next table some of the most common options are listed: -o name change the name of the executable from a.out to name -static allocate local variables statically and set value to zero -Olevel set the optimize level -g create additional symbol table for debugging -c just compile and produce an object le with the ending.o -lname use the library libname.a for linking -L dir directory where the libname.a libraries are kept (on HP only available for fort77 compiler, not for f77) the cernlibs are in /cern/pro/lib or /usr/local/cern/pro/lib the naglib is in /usr/local/naglib Other options can be found by consulting the corresponding manual pages for the compiler. If you have to maintain a larger program which consists of many subroutines and header les (some of which may be dependent oneach other), you might want to put down the creation rules for the program executable in a le called makele and keep your object codes in a private library. make ar option library les dbx gdb cvd maintain, update, and regenerate groups of programs see man make and USG documentation (USG/93/11) archive objectlesinlibrary, options are: t - table of contents of archive r - replace le in archive d - delete le from archive e.g. ar r libmylib.a sub.o will replace subroutine sub.o in libary mylib a debugger a GNU debugger a debugger with Motif interface To use any of the debuggers your program needs to be compiled with the -g option. Note that this will enlarge the size of the executable. Introduction to Unix at DESY 6