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



Similar documents
A Crash Course on UNIX

AN INTRODUCTION TO UNIX

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

Unix the Bare Minimum

Tutorial Guide to the IS Unix Service

ICS 351: Today's plan

Command Line - Part 1

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

A UNIX/Linux in a nutshell

Running your first Linux Program

An Introduction to the Linux Command Shell For Beginners

Introduction to Mac OS X

Command Line Crash Course For Unix

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

Hands-On UNIX Exercise:

University of Toronto

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

A Brief Introduction to the Use of Shell Variables

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

Windows PowerShell Essentials

Open Source Computational Fluid Dynamics

UNIX, Shell Scripting and Perl Introduction

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

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

Extending Remote Desktop for Large Installations. Distributed Package Installs

INASP: Effective Network Management Workshops

CS 103 Lab Linux and Virtual Machines

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

Creating a Java application using Perfect Developer and the Java Develo...

Tutorial 0A Programming on the command line

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

Answers to Even- Numbered Exercises

Lecture 4: Writing shell scripts

Unix Sampler. PEOPLE whoami id who

Introduction to Unix Tutorial

CMSC 216 UNIX tutorial Fall 2010

HP-UX Essentials and Shell Programming Course Summary

Introduction to Operating Systems

UNIX Intro and Basic C shell Scripting

Setting up PostgreSQL

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

Basic Linux & Package Management. Original slides from GTFO Security

The Linux Operating System and Linux-Related Issues

Instructions for Accessing the Advanced Computing Facility Supercomputing Cluster at the University of Kansas

Introduction. Chapter 1

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

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

Single Node Hadoop Cluster Setup

CPSC 226 Lab Nine Fall 2015

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

BioSense 2.0. User Community Extension Project. Getting Started With The Data Lockers. Information Contributed by:

INSTALLING KAAZING WEBSOCKET GATEWAY - HTML5 EDITION ON AN AMAZON EC2 CLOUD SERVER

Code Estimation Tools Directions for a Services Engagement

USEFUL UNIX COMMANDS

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

Adafruit's Raspberry Pi Lesson 6. Using SSH

TEL2821/IS2150: INTRODUCTION TO SECURITY Lab: Operating Systems and Access Control

DS-5 ARM. Using the Debugger. Version 5.7. Copyright 2010, 2011 ARM. All rights reserved. ARM DUI 0446G (ID092311)

TNM093 Practical Data Visualization and Virtual Reality Laboratory Platform

Linux System Administration on Red Hat

Linux für bwgrid. Sabine Richling, Heinz Kredel. Universitätsrechenzentrum Heidelberg Rechenzentrum Universität Mannheim. 27.

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

Unix Scripts and Job Scheduling

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

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

Introduction to Shell Programming

CS 2112 Lab: Version Control

Editing Locally and Using SFTP: the FileZilla-Sublime-Terminal Flow

Version Control with Subversion and Xcode

This presentation explains how to monitor memory consumption of DataStage processes during run time.

Agenda. Using HPC Wales 2

L01 Introduction to the Unix OS

Hadoop Basics with InfoSphere BigInsights

Advanced Bash Scripting. Joshua Malone

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

Advanced UNIX Techniques Lee Ann Lee Revised by Wendy Kajiyama

Thirty Useful Unix Commands

TCH Forecaster Installation Instructions

Secure Shell Demon setup under Windows XP / Windows Server 2003

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

The latest update can be found on the Bruker FTP servers:

Rev C. DBDS Backup and Restore Procedures For System Release 2.2 Through 4.3

1001ICT Introduction To Programming Lecture Notes

Linux Labs: mini survival guide

Git - Working with Remote Repositories

Beginners Shell Scripting for Batch Jobs

Using Subversion in Computer Science

Remote Access to Unix Machines

LAMP Quickstart for Red Hat Enterprise Linux 4

INF 111 / CSE 121. Homework 4: Subversion Due Tuesday, July 14, 2009

Getting biocomputing software to run: How to use the UNIX/Linux Operating System just the basics

CLC Server Command Line Tools USER MANUAL

How to configure the DBxtra Report Web Service on IIS (Internet Information Server)

Navigating the Rescue Mode for Linux

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

SSH and Basic Commands

PHP Debugging. Draft: March 19, Christopher Vickery

Installing Sun's VirtualBox on Windows XP and setting up an Ubuntu VM

How To Use The Librepo Software On A Linux Computer (For Free)

PROGRAMMING FOR BIOLOGISTS. BIOL 6297 Monday, Wednesday 10 am -12 pm

Transcription:

Basic C Shell helpdesk@stat.rice.edu 11th August 2003 This is a very brief guide to how to use cshell to speed up your use of Unix commands. Googling C Shell Tutorial can lead you to more detailed information. Change Your Shell To tcsh Open a terminal, if you can not use left/right arrow to edit your commands, you are NOT using tcsh. To formally check it, type command If you see echo $shell /usr/local/bin/tcsh you are using tcsh. Otherwise, enter command: Enter passwd -r nis -e /usr/local/bin/tcsh when prompted. The new setting will be effective after around 10 minutes. For the purpose of this tutorial, use command tcsh to start an instance of tcsh. 1. Check you shell and set it to tcsh if necessary. 2. If necessary, use tcsh command to enter tcsh. Note that you can use exit command to exit this shell. 1

A Tour of C Shell Features.cshrc All the features of cshell can be set in.cshrc. This is a plain text file located under you home directory. It will be loaded and executed whenever you open a shell window. After you edit this file (with any text editor of your choice), use source ~/.cshrc command to activate the change. 1. Open.cshrc with emacs. (Or vi if you prefer). Try to understand each line of it. Change $path $path contains a list of directories to be searched when running programs or shell scripts. For example, the command Splus is in /usr/local/bin. If /usr/local/bin is not in your $path, you will have to enter the full path name /usr/local/bin/splus to start Splus, rather than simply Splus. Usually, we set $path in ~/.cshrc, which will be executed whenever a new shell is started. The syntax of setting $path is: set path = ( $path /home/helpdesk/bin ~/bin.) To check the content of your current $path, use command echo $path Note that ~ means your home directory,. means current directory. The above set path command add /home/helpdesk/bin ~/bin and. to your $path. 1. check you $path. 2. Add /home/helpdesk/bin to your $path by editing.cshrc file. 3. source.cshrc to activate the change. 4. check your $path again. Command Line Editing Tcsh records up to $history your previous commands. You can set $history in your.cshrc file as follows set history=50 Then, history command will list all your previous commands and 2

!27 will execute command 27.!! is used to repeat your alst command. You can also use the arrow keys to navigate the command history and edit the command line. It is also very important to know how to use the middle button of your mouse. Try to select your previous command with the left button and paste it with your middle button. Command Line Completion The <TAB> key is very useful in tcsh. Whenever you press <tab>, tcsh will try to complete your command, file or directory name. That is to say, you can enter xt<tab> instead of xterm if xterm is the only command in your searching path that begin with xt. This is especially useful if you have very long file/directory names. 1. enter the following commands, try to use your mouse, arrrow and tab keys to simplify the task. (a) cat.cshrc have a look at.cshrc file. Try to use tab key. (b) more.cshrc try to use mousr copy and paste, (You might not be able to use this function if you are using windows++xwin32+ssh.) or up/down arrow keys. Standard Input/Output, Pipe You need to understand some basics about standard input/output of Unix commands. Briefly, Unix programs usually read from their standard input, like the keyboard, output to their standard output, like the terminal. We can redirect their standard input/output in the following ways: 1. Redirect standard output to a file: cat a.c b.c > sum.c 2. Add the standard output to another file cat c.c >> sum.c 3. Redirect standard input from a file: cat < a.c 4. Use the output of the first program as the input of another program: (pipe) cat a.c more 3

Alias Alias, as its name implies, maps a (shorter) name to another (long) name. It can be used to give shortcuts to existing commands, create new commands or even overwrite existing commands. For example, command alias ll ls -l maps ll to ls -l so that ls -l will be called whenever ll is entered as a command. It is perfectly all right to use command alias ls ls -l to alias ls to ls -l. The result of this alias is to add a default option -l to the ls command. This trick is most frequently used on the dangerous rm command, alias rm rm -i since the default rm command removes files without warning. Alias can also handle parameters. Here I only demonstrate the simplest case where you use \!* as the parameters. For example: alias mcd mkdir -p \!*; cd \!* When you call mcd stat it will be expanded to mkdir stat; cd stat Can you mak the following aliases? You can use unalias command to disable an alias. 1. findjob: list all running jobs and then find jobs that match a string (use ps -ef, pipe and grep). 2. ssh7: ssh to stat007.stat.rice.edu. 3. emacs: Add an & at the end of emacs command automatically. 4. rxvt: set default foreground, background to rxvt command. (Use -fg green -bg black options.) 4

Other Useful Features cdpath set cdpath = (~ ~/public html ~/stat ) and you can use cd stat410 to change your current directory to /stat/stat410 even when you are not under ~/stat. prompt set prompt= %n@%m:%~ % will set your prompt to username@machine name: current directory %. Control Structure You do need to understand more about variables, expressions before you can use control structure or write a shell script. Here are two very simple examples about how they can be used: 1. Configure for different platforms: if ( $OS = Linux ) then source.rc.linux else source.rc.unix endif 2. Using loops to process multiple files: foreach file in (*) move $file $file.bak end Starting from the above basics, you can learn: C Shell Script: automate a sequence of jobs Make: Similar to shell script but have multiple objects Perl: deal with texts to simplify every routine of your Unix life. helpdesk@stat.rice.edu $Date: 2003/07/17 02:49:21 $ $Revision: 1.1 $ 5