Unix Primer - Basic Commands In the Unix Shell



Similar documents
Introduction to the UNIX Operating System and Open Windows Desktop Environment

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

University of Toronto

Introduction to Unix Tutorial

Introduction to Mac OS X

File Manager User Guide

Tutorial Guide to the IS Unix Service

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

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

Unix Sampler. PEOPLE whoami id who

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

Although Mac OS X is primarily known for its GUI, the under pinnings are all Unix. This

An Introduction to Using the Command Line Interface (CLI) to Work with Files and Directories

Command Line - Part 1

Running your first Linux Program

Unix the Bare Minimum

Thirty Useful Unix Commands

A UNIX/Linux in a nutshell

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

Command Line Crash Course For Unix

The Einstein Depot server

Hadoop Basics with InfoSphere BigInsights

Remote Access to Unix Machines

CS 103 Lab Linux and Virtual Machines

Getting Started with Command Prompts

A Crash Course on UNIX

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

SSH and Basic Commands

Computing Service G72. File Transfer Using SCP, SFTP or FTP. many leaflets can be found at:

Getting Started with the Cadence Software

Using SSH Secure Shell Client for FTP

Beyond Windows: Using the Linux Servers and the Grid

ICS 351: Today's plan

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

CMSC 216 UNIX tutorial Fall 2010

Linux Labs: mini survival guide

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

CGS 1550 File Transfer Project Revised 3/10/2005

Online Backup Client User Manual

New Lab Intro to KDE Terminal Konsole

QUICK START BASIC LINUX AND G++ COMMANDS. Prepared By: Pn. Azura Bt Ishak

Introduction to. UNIX Bob Booth December 2004 AP-UNIX2. University of Sheffield

The Virtual Desktop. User s Guide

Opening a Command Shell

Using SVN to Manage Source RTL

Miami University RedHawk Cluster Connecting to the Cluster Using Windows

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

Section 1: Ribbon Customization

FTP: Transferring Files to and from Home and UCS

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

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

Using Microsoft Expression Web to Upload Your Site

TIBCO Fulfillment Provisioning Session Layer for FTP Installation

Lab 0: Preparing your laptop for the course OS X

Contract Management System USER GUIDE. Individual Consultants Company Consultants

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

Adobe Dreamweaver Student Organizations Publishing Details Getting Started Basic Web Page Tutorial For Student Organizations at Dickinson College *

Unix Tools. Overview. Editors. Editors nedit vi Browsers/HTML Editors Mail Tools Utilities xv xman ftp

Sendspace Wizard Desktop Tool Step-By-Step Guide

State of Michigan Data Exchange Gateway. Web-Interface Users Guide

Introduction to the UNIX Operating System on IT Systems

Online Backup Client User Manual Mac OS

Online Backup Client User Manual Mac OS

Online Sharing User Manual

2 Advanced Session... Properties 3 Session profile... wizard. 5 Application... preferences. 3 ASCII / Binary... Transfer

User Guide Version 3.0

Contents. This document contains the following sections:

Using a login script for deployment of Kaspersky Network Agent to Mac OS X clients

MATLAB on EC2 Instructions Guide

Using WS_FTP. This tutorial explains how to use WS_FTP, a File Transfer Program for Microsoft Windows. INFORMATION SYSTEMS SERVICES.

How to Dump and Restore Postgres Plus (R) Databases Using pgadmin. A Postgres Evaluation Quick Tutorial From EnterpriseDB

File Transfer Examples. Running commands on other computers and transferring files between computers

File Protection Using Rsync User Guide

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

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

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

EMBnet Norway User introduction pack (instructions and services overview) George Magklaras Head Systems Engineer Version 3.

Exercises: FreeBSD: Apache and SSL: pre SANOG VI Workshop

Using Virtual Machines

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

Cloud Storage Quick Start Guide

Chapter 2 Text Processing with the Command Line Interface

FTP Manager. User Guide. July Welcome to AT&T Website Solutions SM

WS_FTP Professional 12

How to FTP (How to upload files on a web-server)

OWA User Guide. Table of Contents

Guide to the Configuration and Use of SFTP Clients for Uploading Digital Treatment Planning Data to ITC

A Crash Course in OS X D. Riley and M. Allen

Guide to the Configuration and Use of SFTP Clients for Uploading Digital Treatment Planning Data to IROC RI

Installation Guide Mac OS X Operating Systems

DEG Web User Guide State of Michigan Data Exchange Gateway Web

Extreme computing lab exercises Session one

Macintosh General Help

Content Author's Reference and Cookbook

Extreme computing lab exercises Session one

Cadence Verilog Tutorial Windows Vista with Cygwin X Emulation

Hadoop Installation MapReduce Examples Jake Karnes

Web File Management with SSH Secure Shell 3.2.3

Mapping ITS s File Server Folder to Mosaic Windows to Publish a Website

Lab 1 Beginning C Program

Transcription:

Unix Primer - Basic Commands In the Unix Shell If you have no experience with the Unix command shell, it will be best to work through this primer. The last section summarizes the basic file manipulation commands. Unix Shell The shell is a command programming language that provides an interface to the UNIX operating system. The remainder of this tutorial presents basic commands to use within the UNIX shell. Directories The shell should start you in your home directory. This is your individual space on the UNIX system for your files. You can find out the name of your current working directory by typing: /Users/username (The '%' designates your command line prompt, and you should type the letters 'p', 'w', 'd', and then "enter" - always conclude each command by pressing the "enter" key. The response that follows on the next line will be the name of your home directory, where the name following the last slash should be your username.) The directory structure can be conceptualized as an inverted tree. No matter where in the directory structure you are, you can always get back to your home directory by typing: % cd (without specifying a directory name). From your home directory, create a new subdirectory named "primer" for working through this tutorial: % mkdir primer You can remove an empty subdirectory with the following command (but don't do this right now): % rmdir primer (Note: if you do remove "primer", please create it again.) Now change to the "primer" subdirectory, making it your current working directory: % cd primer Files Files live within directories. You can see a list of the files in your "primer" directory (which should be your current working directory) by typing:

Since you just created the directory, nothing will be listed because the directory is empty. Create your file using the pico text editor: % pico The pico editor fills the entire console window. You can type text and move the cursor around with the arrow keys; the bottom of the screen presents the commands available. Type the sentence: "My file." Then press "^O" (hold the left "control" key while pressing 'O') and "enter" to save the file, then "^X" (hold the left "control" key while pressing 'X') to exit pico. Now when you list your files, you will see file "" listed: You can view a text file with the following command: % cat My file. ("cat" is short for concatenate - you can use this to display multiple files together on the screen.) If you have a file that is longer than your 24-line console window, use instead "more" to list one page at a time or "less" to scroll the file down and up with the arrow keys. Don't use these programs to try to display binary (non-text) files on your console - the attempt to print the non-printable control characters might alter your console settings and render the console unusable. Copy file "" using the following command: % cp 2nd By doing this you have created a new file named "2nd" which is a duplicate of file "". The file listing reveals: 2nd Now rename the file "2nd" to "second": % mv 2nd second Listing the files still shows two files because you haven't created a new file, just changed an existing file's name: second If you "cat" the second file, you'll see the same sentence as in your file: % cat second My file. "mv" will allow you to move files, not just rename them. Perform the following commands: % mkdir sub % mv second sub sub

second sub This creates a new subdirectory named "sub", moves "second" into "sub", then lists the contents of both directories. You can list even more information about files by using the "-l" option with "ls": -l -rw-r--r-- 1 username group 15 May 22 16:26 drwxr-xr-x 2 username group 512 May 22 17:11 sub (where "username" will be your username and "group" will be your group name). Among other things, this lists the creation date and time, file access permissions, and file size in bytes. The letter 'd' (the character on the line) indicates the directory names. Next perform the following commands: % cd sub /Users/username/primer/sub -l -rw-r--r-- 1 username group 15 May 22 16:55 second % cd.. /Users/username/primer This changes your current working directory to the "sub" subdirectory under "primer", lists the files there, then changes you back up a level. The ".." always refers to the parent directory of the given subdirectory. Finally, clean up the duplicate files by removing the "second" file and the "sub" subdirectory: % rm sub/second % rmdir sub -l -rw-r--r-- 1 username group 15 May 22 16:26 This shows that you can refer to a file in a different directory using the relative path name to the file (you can also use the absolute path name to the file - something like "/Users/username/primer/sub/second", depending on your home directory). You can also include the ".." within the path name (for instance, you could have referred to the file as "../primer/sub/second"). Other Useful Commands The current date and time are printed with the following command: % date Thu May 22 17:39:04 CDT 2003 Remote login to another machine can be accomplished using the "ssh" command: % ssh -l myname host where "myname" will be your username on the remote system (possibly identical to your username on this system) and "host" is the name (or IP address) of the machine you are logging into. Note that

"ssh" is secure unlike older programs such as "telnet". Transfer files between machines using "scp". For example, to copy file "myfile" from the remote machine named "host", the command would be: % scp myname@host:myfile. (The "." refers to your current working directory, meaning that the destination for "myfile" is your current directory.) If you are running X11, you should be able to start some applications from the command line, for example: % matlab & (The '&' character tells the console to run Matlab in the background - this way you immediately get a new prompt without having to quit Matlab.) In OS X, you can open file using the command "open". This command will open the file with the application corresponding to the file type. For example % open README.pdf will open the file README.pdf using Preview. You can also open applications using the -a flag % open -a Safari or open a file using TextEdit with the -e flag % open -e mytext.txt Online Help You can get online help from the "man" pages ("man" is short for "manual"). The information is terse, but generally comprehensive, so it provides a nice reminder if you have forgotten the syntax of a particular command or need to know the full list of options. Use the "-k" option to provide a list of commands that pertain to a particular topic. For instance, try: % man -k "copy files" (and make sure to include the quotation marks). One of the commands listed should be the "cp" file copy command. Display the man page for "cp" by typing: % man cp Logging Out It is very important to log out of your account whenever you are done using it, especially if you are on a public machine. To close a shell window in a graphical environment, you can type:

% exit Logging out from a graphical environment will require clicking on the appropriate icon. Logging out of a remote session can be done by either using the "exit" command or by typing: % logout Summary Of Basic Shell Commands % pico myfile text edit file "myfile" list files in current directory -l long format listing % cat myfile view contents of text file "myfile" % more myfile paged viewing of text file "myfile" % less myfile scroll through text file "myfile" % cp srcfile destfile copy file "srcfile" to new file "destfile" % mv oldname newname rename (or move) file "oldname" to "newname" % rm myfile remove file "myfile" % mkdir subdir make new directory "subdir" % cd subdir change current working directory to "subdir" % rmdir subdir remove (empty) directory "subdir" display current working directory % date display current date and time of day % ssh -l myname host remote shell login of username "myname" to "host" % scp myname@host:myfile. remote copy of file "myfile" to current directory % netscape & start Netscape web browser (in background) % man -k "topic" search manual pages for "topic" % man command display man page for "command" % exit exit a terminal window % logout logout of a console session