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

Similar documents
Lab Working with Linux Command Line

Unix Tutorial Haverford Astronomy 2014/2015

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

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

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

Introduction to the UNIX command line

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

Introduction: What is Unix?

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

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

The Directory Structure

Operating System Interaction via bash

LAB #7 Linux Tutorial

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

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

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

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

CENG 334 Computer Networks. Laboratory I Linux Tutorial

CS 300 Data Structures

Introduction of Linux

Introduction. File System. Note. Achtung!

Perl and R Scripting for Biologists

Linux Command Line Primer. By: Scott Marshall

CHEM5302 Fall 2015: Introduction to Maestro and the command line

Python for Astronomers. Week 1- Basic Python

Scripting Languages Course 1. Diana Trandabăț

Tutorial 1: Unix Basics

Mills HPC Tutorial Series. Linux Basics I

INSE Lab 1 Introduction to UNIX Fall 2017

Computer Architecture Lab 1 (Starting with Linux)

Introduction to Linux

Chapter 4. Unix Tutorial. Unix Shell

User Guide Version 2.0

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

Session 1: Accessing MUGrid and Command Line Basics

1 Getting Started with Linux.

CISC 220 fall 2011, set 1: Linux basics

Linux File System and Basic Commands

CSCI 2132 Software Development. Lecture 4: Files and Directories

LAB 0: LINUX COMMAND LINE AND SVN

Outline. Structure of a UNIX command

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

TNM093 Practical Data Visualization and Virtual Reality Laboratory Platform

UNIT 9 Introduction to Linux and Ubuntu

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

CMSC 104 Lecture 2 by S Lupoli adapted by C Grasso

Overview of the UNIX File System

Brief Linux Presentation. July 10th, 2006 Elan Borenstein

Using Commands. Introduction to Unix. May 24, 2008 Rabat, Morocco. Hervey Allen

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

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

Overview of the UNIX File System. Navigating and Viewing Directories

Introduction to Linux

Getting Started with UNIX

Introduction to the Linux Command Line

Introduction to Linux

Introduction to the basics of UNIX

Introduction to Linux Part 1. Anita Orendt and Wim Cardoen Center for High Performance Computing 24 May 2017

Unit 10. Linux Operating System

CS CS Tutorial 2 2 Winter 2018

UNIX Tutorial One

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

Computer Systems and Architecture

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

Linux Operating System Environment Computadors Grau en Ciència i Enginyeria de Dades Q2

Using the Zoo Workstations

Warmup. A programmer s wife tells him, Would you mind going to the store and picking up a loaf of bread? Also, if they have eggs, get a dozen.

Introduction to Linux

Chap2: Operating-System Structures

Short Read Sequencing Analysis Workshop

Introduction to Linux. Fundamentals of Computer Science

GNU/Linux Course Lesson 1. Puria Nafisi

EKT332 COMPUTER NETWORK

Physics REU Unix Tutorial

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

Introduction to Linux Workshop 1

CSE 390a Lecture 1. introduction to Linux/Unix environment

C++ Programming on Linux

Part I. UNIX Workshop Series: Quick-Start

CENG393 Computer Networks Labwork 1

Introduction to UNIX command-line

COSC UNIX. Textbook. Grading Scheme

THE HONG KONG POLYTECHNIC UNIVERSITY Department of Electronic and Information Engineering

Introduction to Unix: Fundamental Commands

Basic Survival UNIX.

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

Introduction to Unix - Lab Exercise 0

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

CSE115 Lab exercises for week 1 of recitations Spring 2011

The Command Line. Matthew Bender. September 10, CMSC Command Line Workshop. Matthew Bender (2015) The Command Line September 10, / 25

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.

Getting Started with Command Prompts

Command Line Interface The basics

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

Getting Started With UNIX Lab Exercises

UNIX COMMANDS AND SHELLS. UNIX Programming 2015 Fall by Euiseong Seo

Introduction to Cygwin Operating Environment

Linux/Cygwin Practice Computer Architecture

Transcription:

Introduction to the Unix command line History Many contemporary computer operating systems, like Microsoft Windows and Mac OS X, offer primarily (but not exclusively) graphical user interfaces. The user interacts with files and programs by pointing and clicking with a mouse. Unix, which is a considerably older operating system than Windows or OS X, also offers a graphical user interface (more than one, actually), but Unix originally presented a command line interface, in which the user interacts with the operating system by typing commands at a text prompt and reading textual output from programs. The command line interface is alive and well in Unix today, and many Unix users consider it the most powerful and efficient system for basic operations like navigating through directories and handling files. Terminology In this document, we use the term Unix to refer to a family of operating systems. The look and feel of the graphical interfaces of these systems, as well as the file system layout, may differ significantly from one system to the next, but they all have their (conceptual) roots in the original Unix developed at Bell Labs. This family of operating systems includes Linux (also called GNU/Linux) distributions like Debian, Red Hat, and Ubuntu, as well as Sun Solaris. Mac OS X is a curious case; many of its users never touch the command line interface, but all the commands described below are all available in OS X. Many entertaining arguments about whether OS X is a true Unix can be found in programmer internet forums. Microsoft Windows offers a different command line interface than Unix, but a program called Cygwin provides a Unix interface for Windows. We also use the abbreviation OS to mean operating system. Opening a Terminal In a modern Unix OS (that is, one with a graphical user interface) the command line interface is accessed through a program called a Terminal. Below we show how to run a terminal program in some of the more popular graphical Unix environments, including GNOME and KDE, available in most Linux distributions, as well as Mac OS X. GNOME In the GNOME desktop, click the Applications menu (typically in the upper left corner); in the Accessories menu, choose Terminal. 1 / 13

KDE In the KDE desktop, click the main menu (with K superimposed over a gear), typically in the lower left corner; in the System menu, choose Konsole (the KDE terminal program). 2 / 13

Mac OS X In a Finder window, choose the Utilities folder. 3 / 13

In the Utilities folder, select the Terminal application. 4 / 13

A new window The steps listed above should produce a new window on the screen, with a prompt and possibly a cursor. The prompt might be a simple character, like $ or %, or it might be the name of the computer and a number showing how many commands have been entered, like coates[1]. Regardless of the color of the window or cursor or the wording of the prompt, this terminal window is a Unix command line interface. Shell The prompt in a terminal window is the output of a program called the shell. The shell is the Unix command interpreter. (It is actually a separate program from the terminal window program, but the shell starts automatically when a terminal window opens and exits when the terminal window closes). Unix offers several different shells, but for most of what we cover in this document, the differences between the shells are negligible. The shell reads the characters typed next to the prompt in the terminal, until the user hits either the Enter key or the Return key. After Enter or Return, the shell interprets all the input characters as a command, runs the command, returns any text output from the command to be displayed in the terminal, and, finally, displays a new prompt, waiting for the next command. File names and directories Since most of the commands below involve files and directories, we should consider the rules for naming files and directories. Unix file names may contain letters (a-z, A-Z), numbers (0-9), and a few other characters, like the dot (.) and underscore (_). Certain characters should not be used in a file name, like slash (/), asterisk (*), ampersand (&), percent (%), and space ( ). These characters have special meaning in the Unix file system, or to the shell, and should be avoided in file names. Files whose names begin with a dot (.) are handled specially by some of the commands considered below. Unix files live in directories, which are analogous to folders in Microsoft Windows. A directory is simply a collection of files. All directories exist in a hierarchy, which begins at the root directory, which is denoted by a slash (/). The full path of a file indicates its position in the directory hierarchy. For example, the full paths /file1 and /file2 refer to two separate files, file1 and file2, which both reside in the root directory (hence the / in the full path). The full path always begins with /. As another example, consider the full paths /dir1/file1 and /dir1/dir2/file2. These paths refer, again, to two separate files, but in this case the files exist in different directories. The first file, file1 lives in the directory dir1, which lives in the root directory /. The second file, file2, lives in the directory dir2, which is a subdirectory of dir1. Note that the slash (/) separates directory names in the full path, as well as representing the root directory. Directory names follow the same rules as file names. 5 / 13

Basic commands This section introduces the basic Unix command line utilities, programs designed to do one specific task. The example images show a grey terminal window with black text and a prompt of the form coates[n], where N is the number of commands which have been entered already. ls list files Perhaps the most basic of all Unix commands, ls lists the files in a directory. If no argument is given to ls, as in this example 6 / 13

certain files in the current directory are shown. Which files are shown and which are not shown? Read on ls -a Files whose name begins with dot (.) are not shown by default in the output of ls. Such files are called hidden files or dot files. To see the hidden files in a directory, use the -a argument to ls. This example shows the additional output from ls, listing the hidden files which were not reported by the first invocation of ls. 7 / 13

Two entries always appear in the output of ls -a, even in empty directories which contain no files:. and.., which are shortcuts to the current directory and the parent directory, respectively. ls -F Some of the results listed in the output of ls are subdirectories, while others are simply files. In order to distinguish between files and directories we can use the -F argument (also called a flag) to ls. Arguments can be grouped together. For example, ls -a -F and ls -F -a both list all files, including hidden files, and add a trailing slash (/) to directory names. The order of arguments (e.g. -a -F vs -F -a) does not matter. 8 / 13

ls path The ls command also accepts a directory argument. This example shows a listing of the files in specific subdirectories of the current directory. Note that the -F flag adds a trailing slash (/) to the names of directories. The shortcut.. can be used to see the files in the parent directory. 9 / 13

In the parent directory listing we can see the name of the current directory (bhaley, in this case) because the current directory is a subdirectory of the parent directory. pwd print working directory The pwd command shows the full path of the current (working) directory. In the example above we saw the name of the current directory in the listing of the contents of the parent directory. In this example we see the full path of the current directory, bhaley. 10 / 13

The name of the parent directory, then, is u101. cd change directory The cd command changes the current (working) directory. In this example we use the parent directory shortcut.. as the argument to cd, which changes the working directory one level up in the directory hierarchy. This can be seen by the output of the pwd commands before and after the cd command. If no argument is passed to cd, the working directory reverts back to the user s home directory. The home directory is where a Unix shell begins by default. 11 / 13

A tilde (~) is used as a shortcut to the home directory; thus cd and cd ~ will both change the working directory to the home directory and the path ~/mydir/myfile indicates a file myfile in a subdirectory mydir of the home directory. mkdir create new directory cp copy mv move (rename) rm remove (delete) rmdir remove directory clear clear screen cat display file man manual Slightly more advanced topics grep search pipe output 12 / 13

Powered by TCPDF (www.tcpdf.org) INTRODUCTION TO THE UNIX COMMAND LINE <<, >> redirect *,? wildcards ssh remote access Links Other useful Topics Software Development Using Subversion, a source code version management system Other websites Unix cheat sheet short summaries of key commands Unix tutorial 13 / 13