Oxford University Computing Services. Getting Started with Unix

Similar documents
AN INTRODUCTION TO UNIX

CSCI 2132 Software Development. Lecture 4: Files and Directories

commandname flags arguments

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

UNIX Quick Reference

Chapter-3. Introduction to Unix: Fundamental Commands

Introduction to Linux Workshop 1

Getting Started with UNIX

Getting Started With UNIX Lab Exercises

Introduction to the Linux Command Line

INSE Lab 1 Introduction to UNIX Fall 2017

CS Fundamentals of Programming II Fall Very Basic UNIX

Mills HPC Tutorial Series. Linux Basics I

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.

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

CS246 Spring14 Programming Paradigm Notes on Linux

CS 215 Fundamentals of Programming II Spring 2019 Very Basic UNIX

A Brief Introduction to Unix

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

Outline. Structure of a UNIX command

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

Common UNIX Commands. Unix. User Interfaces. Unix Commands Winter COMP 1270 Computer Usage II 9-1. Using UNIX. Unix has a command line interface

ACS Unix (Winter Term, ) Page 92

CHAPTER 1 UNIX FOR NONPROGRAMMERS

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

Commands are in black

CISC 220 fall 2011, set 1: Linux basics

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

UNLV Computer Science Department CS 135 Lab Manual

Basic Survival UNIX.

Practical Session 0 Introduction to Linux

UNIX Quick Reference

THE HONG KONG POLYTECHNIC UNIVERSITY Department of Electronic and Information Engineering

Week 2 Lecture 3. Unix

Unix Tutorial Haverford Astronomy 2014/2015

Introduction to Linux

CS4350 Unix Programming. Outline

Operating Systems, Unix Files and Commands SEEM

Linux Essentials. Programming and Data Structures Lab M Tech CS First Year, First Semester

Introduction to Linux Basics

Unix Filesystem. January 26 th, 2004 Class Meeting 2

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

Physics REU Unix Tutorial

Introduction: What is Unix?

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

Scripting Languages Course 1. Diana Trandabăț

Introduction of Linux

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

Operating Systems. Copyleft 2005, Binnur Kurt

Introduction to Linux

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

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

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

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]

Unix Workshop Aug 2014

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

IMPORTANT: Logging Off LOGGING IN

Introduction to Unix: Fundamental Commands

Linux & Shell Programming 2014

CSC209H Lecture 1. Dan Zingaro. January 7, 2015

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

Using the Zoo Workstations

Std: XI CHAPTER-3 LINUX

UNLV Computer Science Department CS 135 Lab Manual

Introduction to Linux

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

UNIX File Hierarchy: Structure and Commands

This is Lab Worksheet 3 - not an Assignment

Tiny Instruction Manual for the Undergraduate Mathematics Unix Laboratory

Overview of the UNIX File System

Files and Directories

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

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

Part I. Introduction to Linux

Getting started with Hugs on Linux

Using UNIX. In this section we find out how to start and stop using a UNIX system and how to use some of its many commands.

The Directory Structure

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

Session 1: Accessing MUGrid and Command Line Basics

CENG 334 Computer Networks. Laboratory I Linux Tutorial

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

Perl and R Scripting for Biologists

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

Getting started with Hugs on Linux

1 Getting Started with Linux.

Linux File System and Basic Commands

5/20/2007. Touring Essential Programs

This section reviews UNIX file, directory, and system commands, and is organized as follows:

Files

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

Unix and C Program Development SEEM

Introduction to Linux

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

Overview of the UNIX File System. Navigating and Viewing Directories

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

Course 144 Supplementary Materials. UNIX Fundamentals

Lab Working with Linux Command Line

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

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

Linux Training. for New Users of Cluster. Georgia Advanced Computing Resource Center University of Georgia Suchitra Pakala

Transcription:

Oxford University Computing Services Getting Started with Unix Unix c3.1/2

Typographical Conventions Listed below are the typographical conventions used in this guide. Names of keys on the keyboard are enclosed in angle brackets; for example <Return> represents the Return key. Two key names enclosed in angle brackets and separated by a slash (for example, <Ctrl/Z>) indicate that the first key should be held down while the second is pressed; both keys can then be released together. Prompts or messages from the system are in lower-case bold characters in typewriter font. Characters typed in by the user are in lower-case non-bold characters in typewriter font. Items where the user has to supply a filename or number are given in lower-case italic characters in typewriter font. Where there is an optional parameter to a command, the characters of the parameter will be enclosed in square brackets, [ and ]. Where a command can optionally take a number of parameters of the same kind (for example, a list of filenames) separated by spaces, this possibility is indicated in the following way: % rm file1 [...]

Getting Started with Unix c3.1/2 Contents 1 Introduction 1 2 Command Shells 1 3 Command Structure 1 3.1 s of Commands 2 4 Online Help 3 5 The File System 3 5.1 s of Filenames 3 5.2 Wildcard Characters to Match Filenames 3 6 File Handling Commands 4 6.1 Directory Listings 4 6.2 Displaying and Printing Files 5 7 Copying, Renaming and Deleting Files 6 8 Redirecting Standard Input and Output 7 8.1 Redirecting Output (>) 7 8.2 Redirecting Input (<) 7 8.3 Pipelining 7 9 Working with Directories 8 9.1 Moving Around the File Structure 9 10 Background and Foreground Jobs 9 11 Exercises 10 November 1995 OUCS

References OUCS User Guides [1] c2.1getting Started on the DEC 5500 [2] c1.2getting Started on the Convex [3] r3.2 The Elm Mail Utility for Unix Machines [4] r3.3 The Pine Mail Utility for Unix Machines [5] e4.1getting Started with the Editor Emacs [6] c3.2further Use of Unix Author: Steve Jones, Jane Littlehales Revision History: c3.1/1 October 1992 Original publication c3.1/2 November 1995 Exercises added Oxford University Computing Services 1995 Although formal copyright is reserved, members of academic institutions may republish the material in this document subject to due acknowledgement of the source. OUCS November 1995

c3.1/2 1 Introduction 2 Command Shells Getting Started with Unix Unix is an operating system that runs on a full range of computers, from microcomputers up to very powerful supercomputers. It is not restricted to machines made by any specific manufacturer. Consequently, Unix is used on a great many computers. OUCS provide a general user service on Sable whilst the Convex vector processor [2] is used for specialised applications requiring great computer power. Many departments around the University have workstations and multi-user machines that use the Unix operating system. Unix is a very flexible operating system and this, coupled with its wide availability over a range of machines, is a big advantage. However, this also means that no two Unix machines will necessarily be set up identically. There will be differences in the way Unix machines operate, especially between the different flavours of Unix provided by different manufacturers. This Guide is intended as a general introduction to Unix and will describe features that should be common to all Unix systems. Two aspects that definitely vary between machines are the electronic mail system and the general text editor. For the OUCS machines these are described in [3], [4] and [5] respectively. The exercises assume you are attending the Getting Started on Unix course. This Guide does not explain specific methods for logging in to a Unix machine; the documentation for specific systems should be consulted for this information. The examples included here assume that login has been successful, and the general Unix prompt of % is used throughout. Unix provides the facility to work in different command environments, or shells. Two common examples of these are the C and Bourne shells, although many other different shells exist. The major reasons for choosing between shells are related to the running of command files and their associated command languages; there is very little difference to the basic commands. See [6] for further details of using shells. 3 Command Structure The basic structure of a Unix command is: command [-options,...] [arguments,...] where command is the name of the command. These are typically 2 or 3 characters long and are often very cryptic in their meaning. options are generally single characters which in some way modify the action of the command. There may be no options or there may be several acting on the same command. Options are preceded by a hyphen (-) character, but there is no consistent rule among Unix commands as to how options should be grouped. Some commands November 1995 1 OUCS

Getting Started with Unix c3.1/2 allow a list of options with just a single hyphen at the beginning of the list. Other commands require that each option is introduced by its own hyphen. Some options allow a value, often a filename, to be given following the option. Again, there is no consistent manner in which this is allowed, with some options requiring the value to be placed immediately following the option letter, while others expecting a space between the option letter and the value. arguments are values or items upon which the command is to operate. These are often filenames, and depending on the command there may be none or several arguments. Unix is case-sensitive throughout. The exact combination of upper and lower case letters used in a command, option or filename being important. For example, the options -p and -P in the same command will have different meanings. 3.1 s of Commands The following examples show the use of commands, options and arguments. More complete examples are given in following sections describing specific aspects of Unix. % date displays the current date % quota displays the current status of file usage and quota for the current username. % lpr filename prints the specified file on the default printer % lpr -Pqueue filename prints the specified file on the named printer queue. % passwd changes the password associated with the username, prompting for the existing password and then the new one. Different rules governing password format will exist on different systems; on the OUCS machines, for example, passwords must be at least six characters long and cannot be from a standard English dictionary. % logout will close the session. OUCS 2 November 1995

c3.1/2 4 Online Help Getting Started with Unix The main source of online documentation is the man command. This is an online Unix Reference Manual. The full syntax of any command may be seen by typing man command The reference manual entry for the specified command will be displayed on the screen, with the display pausing after each screenful. At this point the following actions can be taken: <Spacebar>display the next page <Return> display the next line /string display the next page containing string h give a full list of man sub-commands q quit from man and return to the command prompt The command 5 The File System man -k topic will give a list of other man pages that contain information about the specified topic. See man man for full details of the man command. Filenames may contain up to 255 characters, although a sensible limit (allowing for portability between different Unix systems) is 14 characters. Almost any character may be used within a filename, but it is recommended that only letters, numbers, dots (.), hyphens (-) and underscores (_) are used. Do not use hyphens at the beginning of a filename, and note that filenames beginning with a dot (.) are treated as special files (see section 6.1). The filename is simply a set of characters. There is no concept of the filetype or file extension as seen in other operating systems (VAX/VMS or MS-DOS for example), although certain commands will assume that files end in a particular sequence of characters. For example, the f77 Fortran compiler assumes that the source files end with.f. 5.1 s of Filenames The following are valid Unix filenames; each name refers to a different file. data1982 data.1982 addfil.f gordonmes GORDONMES gordonmes 5.2 Wildcard Characters to Match Filenames The following wildcard characters may be used when referring to groups of files. * matches any sequence of zero or more characters November 1995 3 OUCS

Getting Started with Unix c3.1/2? matches any single character [string] matches any of the characters in string s data* finds all files beginning with data *data* finds all files containing data data19?? finds all 8-character filenames beginning with data19 data198[268] finds data1982, data1986 and data1988 6 File Handling Commands 6.1 Directory Listings To obtain a list of all the files in a specified directory, use the ls command. % ls will list the names of all the files in the current working directory. The names will be listed in a series of columns, and in alphabetical order working down successive columns. The command can be restricted to reporting information about a single file or about a group of files by giving a filename or a wildcard specification as an argument. To obtain more information about individual files, use the -l option, which gives a longer listing, with one file per line. There are a number of hidden files that may be present in a directory; the -a option ensures that all these are shown on the listing. % ls -al drwxr-xr-x 5 fred 512 Jul 8 11:57. drwxr-xr-x21 root 512 Jun 26 09:24.. -rwxr-x--x 1 fred 397 Jul 5 10:30.cshrc -rwxr-x--x 1 fred 321 Jul 5 10:29.login -rwxr-x--x 1 fred 182 May 29 09:44.profile -rw-r--r-- 1 fred 2490 Jul 8 11:42 ALAN.TXT -rw-r--r-- 1 fred 3623 Jul 8 11:42 CATANP.TXT drwxr-x--x 2 fred 512 Jul 8 11:28 bin drwxr-xr-x 2 fred 512 Jul 8 11:53 data drwxr-xr-x 2 fred 512 Jul 8 11:33 plants -rw-r--r-- 1 fred 20 Jul 8 11:38 plantlist -rwxr-x--x 1 fred 241 Jul 8 11:35 try1 -rwxr-x--x 1 fred 321 Jul 8 11:35 try1~ OUCS 4 November 1995

c3.1/2 Getting Started with Unix The above example shows that you can combine two options (-a and -l) together on the command line. Each output line shows, in sequence, the access modes, link count, owner, size (in characters), date and time of last modification and finally the filename for each file. The files beginning with a full stop (.) are special or hidden files that are only shown with the use of the -a option. The two top files are special files referring respectively to the current directory (.) and the parent directory (..). The remaining hidden files in this example (.cshrc,.login and.profile) are initialisation files that are responsible for setting a number of options and environmental variables for the session. The access modes for each file consist of 10 characters. A d in the first position indicates that the file is a directory file (as in bin, data and plants above for example). The remaining nine characters are three sets of three access codes. Each set can have r (for read), w (for write) and x (for execute) permission granted, the three sets referring to the owner of the file, the group to which the owner belongs and the world respectively. On the OUCS machines, a group consists of all users from the same department while the world refers to all registered users. These access modes can be altered using the chmod command. 6.2 Displaying and Printing Files To display the contents of a file on the screen use the cat command. % cat plantlist If the file is long, you may wish to scroll the display up a screenful at a time to allow you to read it. To do this, use the more program. % more plantlist The display will pause at the end of each screenful, at which point the same series of sub-commands described above for the man command may be used. To print a file use the lpr command. % lpr plantlist will cause the file plantlist to be printed on the default printer attached to the system. For the OUCS machines, files are printed by default on the central lineprinter in the computer room at 13 Banbury Road. For details of how to print on any OUCS printer from Sable or the Convex, see [1] and [2]. November 1995 5 OUCS

Getting Started with Unix 7 Copying, Renaming and Deleting Files c3.1/2 To copy a file, use the command cp file1 file2 This will make a copy of file1, giving it the name file2. There is no concept of version numbers in Unix, and if file2 already exists, its contents will be OVERWRITTEN with the contents of file1, thus destroying what was originally in file2. The option -i may be used to cause the machine to prompt for confirmation before overwriting the output file. s % cp plantslist plantsback will make a copy of the file plantslist, calling the copy plantsback. % cp -i try1 try2 Overwrite try2? will copy the file try1 to try2, confirming that the file should be overwritten. The cp command leaves the original file (file1) intact. If you simply wish to change the name of a file, use the mv command. To change the name of a file (move it) use the command mv file1 file2 This renames file1 to be called file2. As with cp, if file2 already exists, its contents will be OVERWRITTEN and lost. Again, there is an option -i to cause the machine to confirm that the second file should be overwritten if it already exists. % mv newdata olddata To delete a file (or files), use the rm command rm file1 [...] The rm command can take a number of filenames as parameters, with each file being deleted in turn. By default the files will simply be deleted with no confirmation; the option -i may be used to cause the machine to ask for each file whether it should be deleted or not. OUCS 6 November 1995

c3.1/2 Getting Started with Unix % rm -i data* This will cause any file beginning with the characters data to be deleted, with confirmation being sought for each file. These three commands, cp, mv, rm have all been implemented on the OUCS Sable with the -i option set by default. 8 Redirecting Standard Input and Output Unix has the concept of a standard input (that is, where the input for a command comes from) and a standard output (that is, where the results of a command will go to). By default, both of these are the terminal; the keyboard for the standard input and the screen for the standard output. It is possible to redirect either or both of the standard input and output, using the redirection symbols < and >. 8.1 Redirecting Output (>) This is probably the more commonly used of the two redirection symbols, and can be used to store the results of a command that would normally be displayed on the terminal screen, in a file. % ls > mydir 8.2 Redirecting Input (<) 8.3 Pipelining The ls command produces a list of files in the current directory. The redirection symbol places this list into the file named mydir. This redirection allows a program that normally takes its input from the terminal keyboard to take it instead from a file. % maple < run1 This would use the file run1 as the input to the Maple program. Pipelining is the redirection of the output from one command to the input for another. The pipeline symbol is the vertical bar ( ). November 1995 7 OUCS

Getting Started with Unix c3.1/2 % ls -al more This would pass the output from the ls command into the more command, causing the display to be shown a screenful at a time. 9 Working with Directories Unix filestore is divided into a tree of directories and sub-directories. At the very top level (or bottom level depending on how you look at it) is the root directory, represented by the / character. Below this are a number of system directories (such as /bin, /lib, /dev) together with the directories for user files. Users can sub-divide their own directory into a number of sub-directories, so that they may group their files according to the different areas of their work. / usr bin lib u1 u2 Fred bin data plants Figure 1 Directory Tree results1 So, the main login directory (the home directory) for the user fred who has been allocated to the u1 directory would be /u1/fred. The full filename for fred's file results1 in the subdirectory plants would be /u1/fred/plants/results1. Assuming the user fred was working in the default, home directory, then only plants/results1 need be used to refer to the file. The mkdir and rmdir commands should be used to create and delete directories respectively. See the relevant man entries for these commands. OUCS 8 November 1995

c3.1/2 Getting Started with Unix 9.1 Moving Around the File Structure The pwd command will display the setting of the current working directory. This is the directory where files will be read from or written to if no other directory path information is given on filenames. To change the current working directory, use the cd command. This takes one argument, the directory path where you wish to work. The cd command on its own will move back to your home directory, while cd.. will move back up one level in the directory tree. A tilde (~) can be used as a shorthand for a home directory. For example, if /fred is the home directory, cd ~/progs will move to /fred/progs. A tilde followed immediately by a username will be expanded to that user's home directory. 10 Background and Foreground Jobs The C-shell environment (one of the more commonly provided shells) provides facilities for manipulating jobs and sessions. The default shell on the OUCS Unix system is the TC shell which is very similar to the C shell but with enhanced features. Normally, when a command is given it is executed immediately and it is not possible to give other commands until it has been completed. This mode of working is referred to as running jobs in the foreground. It is also possible to run a job in the background, that is, to cause the command to be executed as a separate process, leaving the terminal free for other work. To start a background job, place an ampersand character at the end of the command line before pressing <Return>. % maple < run1 > run1out & This will cause the Maple program, using the data file run1, to be run as a background job, placing the results into the file run1out. A job that is currently running in the foreground may be suspended and then sent to the background. To suspend, or stop, a foreground job, press <Ctrl/Z>; this temporarily stops the job from running and returns to the normal system prompt. The suspended job may then be re-started in the background by typing bg, or brought to the foreground by typing fg. % maple < run2 <Ctrl/Z> % bg % These commands run a Maple program, taking its input from the file run2. This job is then suspended, then started again but this time in the background for completion. November 1995 9 OUCS

Getting Started with Unix c3.1/2 There are commands for listing all the jobs, foreground, stopped and background, that are currently running, and for killing jobs. See the man entries for csh and kill for further details. 11 Exercises Exercise 1 : Connecting to Sable (1) Switch on the computer. (2) Type sable then press the <Return> key. (3) You will be asked for your username at the login: prompt. Type unix** where ** is the number you have been allocated for the course. (4) The password will be given to you by the lecturer. Type this at the password: prompt. (5) If you have logged in successfully, you should see the sable% prompt. Exercise 2 : Simple Commands (1) Find out the current date and time with the date and time commands. Date gives the current date and time while time gives the command execution time. (2) Examine the current quota for your course username by typing quota Exercise 3 : Accessing Help (1) On Sable, there are two help systems, the man pages as described above and Help on using Sable which is an OUCS system. To access the Help on using Sable information, type help and press <Return>. (2) Read the instructions at the bottom of the screen to see how to use the information system. (3) Move around the options on the screen using the arrow keys. Various words will be highlighted as you move. Pressing <Return> when the item you want is highlighted will take you to the page of information on that topic. (4) Browse through the headings available under General Help on Unix. OUCS 10 November 1995

c3.1/2 Getting Started with Unix Exercise 4 : Changing your Password (1) The password rules on Sable can be quite complicated. Details about them and how to change your password can be found by typing help (as above), then selecting Getting Started on Sable and Passwords. If you are already in Help, type M for the Main Menu and confirm that is where you want to go then select Getting Started on Sable. (2) Read through the information given. (3) When you have read it, quit from the help system by typing q and confirming that you wish to quit. (4) Type passwd and follow the instructions to change your password to one of your choice, remembering the rules and guidelines given in the help system. Make sure it is something you will remember in case you need to login again later in the session! Exercise 5 : Using the Man Pages (1) Look up the man page on the ls command. What does the ls option -x do? (2) Find out what sub-commands are available while browsing the man pages by typing h (3) When you have finished reading the information, type q to return to the sable% prompt. Alternatively, browse to the end of the information, press any key and the sable% prompt will reappear. (4) Look up the page for mv then use man -k rename to list all the pages on the topic of renaming files and directories. Is mv one of the pages listed? (5) Type man quota to find out about the quota command. Search for the next page containing the word group by typing /group then pressing <Return>. Exercise 6 : Manipulating Files (1) List all the files in your current (home) directory with ls. (2) Try typing ls -l to see the difference. This will give more information on the files. How many directories do you have? (3) List the files using ls -a to see the hidden files and finally with ls -la to see all information on all the files. November 1995 11 OUCS

Getting Started with Unix c3.1/2 (4) List full details for everything beginning with v using the ls -l v* command. (5) Type ls verse[134] to list a selection of the files whose name begins with verse Exercise 7 : Creating a File (1) Create a file called intro using the pico editor by typing pico intro and type the following text into it: Two files in your main (home) directory are executed automatically on login. One,.cshrc, contains C-shell setup material, that is set commands to define various shell variables and alias commands to provide alternative names for commands. In fact, this file is executed whenever you begin a (new) C-shell, including at the start of a batch job. (2) Save the file and leave pico with <Ctrl/x>. Confirm you want to save the file and press <Return> to accept the filename. Exercise 8 : Displaying and Printing Files (1) Display this file on the screen with the cat intro command. (2) Use cat convexdoc to display the file convexdoc on the screen. (3) Display convexdoc again but this time use more convexdoc to see it a page at a time. (4) Print convexdoc on the userarea lineprinter. Exercise 9 : Copying, Renaming and Deleting Files (1) Use cp verse1 poem to copy the file called verse1 to poem. (2) Copy convexdoc to poem. Poem already exists and you do not want to overwrite it so type n, when asked to confirm your actions, to cancel the copy. (3) Rename poem as rhyme with the mv command. (4) Now copy convexdoc to poem again. This time there is no file called poem to be overwritten. (5) Type rm v* to delete all files starting with v. Only confirm deletion of verse1. OUCS 12 November 1995

c3.1/2 Getting Started with Unix (6) Rename rhyme as verse1 and delete poem. You should now have all the same files as when you started! Check with ls. Exercise 10 : Redirecting Input and Output (1) List your home directory to the file dirlist with the ls > dirlist command. Use pico to check the contents of dirlist. (2) The finger command can be used to obtain brief details about people who have usernames on a particular machine. Type finger chris more to list the people called Chris a page at a time. Exercise 11 : Working with Directories (1) Create a subdirectory called coursestuff under your home directory with the mkdir command. (2) Change directory to coursestuff and list its contents. (3) Copy the files intro and convexdoc to this directory. As they are in your home directory and you are currently in the coursestuff directory, you will need to use cp ~/intro.(full stop). The full stop means here. That is, copy this file to the current directory and keep its name. (4) Create another new directory under coursestuff called newfiles (5) Change directory to newfiles and check the path with the pwd command. (6) Type cd then pwd to move back to your home directory and check its path. (7) From your home directory, move the file intro from the coursestuff directory to the newfiles directory and rename it as first. The command will be: mv ~/coursestuff/intro ~/coursestuff/newfiles/first (8) Type ls ~/coursestuff/newfiles to check. (9) Now, change directory to coursestuff and copy convexdoc to newfiles, renaming it as convexinfo. Type cp convexdoc newfiles/convexinfo. When moving or copying files the pathnames can often be simplified depending on which directory you start from. (10) From the coursestuff directory, type rmdir newfiles to delete the directory. As it is not empty, you will not be able to. (11) Change directory to newfiles, check its contents, which should be first and convexinfo, and delete them with rm * November 1995 13 OUCS

Getting Started with Unix c3.1/2 (12) Use cd.. to go back down the directory structure to coursestuff and delete the newfiles directory. This time it will succeed. OUCS 14 November 1995