''Unix is user friendly -- It's just picky about who it's friends are...'' -- Unknown, seen in.sigs around the world.

Slides:



Advertisements
Similar presentations
Chapter 9: The TC Shell Everything you thought you knew is now wrong.
Advertisements

Chapter One The Essence of UNIX.
NETW-240 Shells Last Update Copyright Kenneth M. Chipps Ph.D. 1.
Chapter Seven Unix Shell Environments1 System Programming UNIX Shell Environments.
Git/Unix Lab March Version Control ●Keep track of changes to a project ●Serves as a backup ●Revert to previous version ●Work on the same files concurrently.
Introducing the Command Line CMSC 121 Introduction to UNIX Much of the material in these slides was taken from Dan Hood’s CMSC 121 Lecture Notes.
CS 497C – Introduction to UNIX Lecture 36: - Customizing the Environment Chin-Chih Chang
Guide To UNIX Using Linux Third Edition
Guide To UNIX Using Linux Third Edition
Introduction to Unix (CA263) Introduction to Shell Script Programming By Tariq Ibn Aziz.
1 UNIX essentials (hands-on) the directory tree running programs the shell (using the T-shell) → command line processing → special characters → command.
Linux Shell. 2 Linux Command-Line Interface ■ Linux shells: A shell is a command interpreter that allows you to type commands from the keyboard to interact.
Using Macs and Unix Nancy Griffeth January 6, 2014 Funding for this workshop was provided by the program “Computational Modeling and Analysis of Complex.
TOPIC 5.0 LINUX SHELLS.
Linux Shells Dr. Michael L. Collard 1.
"Two of the most famous products of Berkeley are LSD and Unix. I don't think that this is a coincidence.” Anonymous.
Welcome to CSE  Name: Di Cao   Classroom: DL357  Class Time: T 8:30am - 9:18am  Office.
UNIX command line. In this module you will learn: What is the computer shell What is the command line interface (or Terminal) What is the filesystem tree.
Chapter 9 Part II Linux Command Line Access to Linux Authenticated login using a Linux account is required to access a Linux system. The Linux prompt will.
Introduction to Shell Script Programming
– Introduction to the Shell 10/1/2015 Introduction to the Shell – Session Introduction to the Shell – Session 2 · Permissions · Users.
Chapter 6: Shell Programming
CENT 305 Information Systems Security Linux Introduction.
Shells. A program that is an interface between a user at a terminal and the computers resouces ▫The terminal may be real or an emulator The shell is.
Introduction to Unix – CS 21 Lecture 9. Lecture Overview Shell description Shell choices History Aliases Topic review.
1 UNIX essentials (hands-on) the directory tree running programs the shell → command line processing → special characters → command types → shell variables.
Session 2 Wharton Summer Tech Camp Basic Unix. Agenda Cover basic UNIX commands and useful functions.
UNIX/LINUX Shells Shell is an UNIX/LINUX command interpreter. Shell command can be internal or external. The code to execute an internal command is part.
Linux+ Guide to Linux Certification, Third Edition
UNIX/LINUX SHELLS.  “A Unix shell is a command-line interpreter or shell that provides a traditional user interface for the Unix operating system and.
Chapter 0 A “Quick-Start” into the UNIX Operating System.
Introduction to Unix Shell & Scripting with csh/tcsh  Brief Unix History  Unix Shell & Flavor  CSH/TCSH Scripts.
Unix/Linux cs3353. The Shell The shell is a program that acts as the interface between the user and the kernel. –The shell is fully programmable and will.
Lesson 2-Touring Essential Programs. Overview Development of UNIX and Linux. Commands to execute utilities. Communicating instructions to the shell. Navigating.
1 Applied CyberInfrastructure Concepts ISTA 420/520 Fall Nirav Merchant Bio Computing & iPlant Collaborative Eric Lyons.
ITR3 lecture 6: intoduction to UNIX Thomas Krichel
June 1, 1999Customizing the UNIX Environment1 Introduction to UNIX G. Customizing the UNIX Environment.
Unix Shell Environments February 23rd, 2004 Class Meeting 6.
UNIX shell environments CS 2204 Class meeting 6 *Notes by Doug Bowman and other members of the CS faculty at Virginia Tech. Copyright
User Environments Objectives –to provide appropriate environments for different types of users Contents –different login programs –user profiles –restricted.
UNIX shell environments CS 2204 Class meeting 4 Created by Doug Bowman, 2001 Modified by Mir Farooq Ali, 2002.
Introduction to Programming Using C An Introduction to Operating Systems.
UNIX Shell Dr. Tran, Van Hoai
Customizing the Shell Environment. UNIX Shells Two characteristics of shells –Interactive: prompts ($) and waits for your response/requests –Noninteractive:
Chapter Six Introduction to Shell Script Programming.
1 Day 18 Bash and the.files. 2 The.files ls shows you the files in your directory –Or at least most of them. –Some files are hidden. Try: ls –a –This.
CSCI 330 UNIX and Network Programming Unit III Shell, Part 1.
Module 1 - Introduction to Linux. Users must log-in Linux is case sensitive File and Directories naming conventions (No spaces!) Files and Directories.
Jozef Goetz, expanded by Jozef Goetz, 2006 Credits: Parts of the slides are based on slides created by textbook authors, Syed M. Sarwar, Robert.
Unix Advanced Shells Chapter 10. Unix Shells u Command Line Interpreter –once logged in, login gives control to a shell –it prompts for input, then parses,
1 CS3695 – Network Vulnerability Assessment & Risk Mitigation – Introduction to Unix & Linux.
Configuration your environment Many user-configurable Unix programs (such as your shell) read configuration files when they start up. These configuration.
Unix Lab Fall Shell Scripting ●Through the shell (LXTerminal) you can: ●Run programs. ●Interact with the file system. ●Change settings. ●Send/receive.
Introduction to LINUX command line Allegra Via IBBE, National Research Council, Italy Sapienza Università di Roma, Italy EMBO Practical Course on Computational.
INTRODUCTION TO SHELL SCRIPTING By Byamukama Frank
Information Technology Services Brett D. Estrade, LSU – High Performance Computing Phone:
Unix Scripting Session 1 March 6, 2008.
SUSE Linux Enterprise Desktop Administration
Introduction to Shells
Shell Features CSCI N321 – System and Network Administration
California State University Fresno
Andy Wang Object Oriented Programming in C++ COP 3330
The Linux Operating System
Shell Environments.
Chapter 1 The Essence of UNIX and Linux
UNIX and Shell Programming (06CS36)
Andy Wang Object Oriented Programming in C++ COP 3330
Linux Professor Sabol.
Unix Shell Environments
CMPSC 60: Week 5 Discussion
Presentation transcript:

''Unix is user friendly -- It's just picky about who it's friends are...'' -- Unknown, seen in.sigs around the world

Basics of the Unix/Linux Environment Shells and Your Unix Environment

What is a shell? Traditional user interface with the unix operating system…it interprets your typing A scripting program that controls the syntax at the command line interface Just as there are many flavors of unix and unix-like systems, there are many types of shells

Common Shells sh bash ksh csh tcsh Bourne Shell Bourne Again Shell TENEX C shell C Shell Korn Shell

sh Bourne shell the original Unix shell Pro: Flexible and powerful scripting shell Con: Not interactive or particularly user friendly

csh C shell designed for the BSD Unix system syntax closely follows C programming Pro: easy for C programmers to learn and comes with many interactive features such as file completion and aliases Con: not as flexible or powerful a scripting language

ksh Korn shell derived from the Bourne shell so has a shared syntax job control taken from the C shell

bash Bourne-Again shell Combines the “best” of sh, ksh, and csh Default shell on Linux and Mac OSX operating systems Pro: Flexible and powerful scripting language with all the interactive features of csh plus command completion This shell is great for complicated GMT scripts

tcsh TENEX C shell Default shell of the CERI unix environment Pro: User friendly on the command line & it is what your CERI account environment is set up to use Con: It is not as suitable for long and involved scripts It is perfectly good for most daily geophysics work on the command line & most faculty here use it on a daily basis so there are many experts around

What is my shell? env $SHELL will echo your current login shell to the screen to switch your shell in a single terminal window, simply type the name of the preferred shell the command line also usually indicates which shell family you are using $ -- bash, sh, or ksh > or % -- csh, tcsh

Useful features of tcsh & bash file completion: you can key the tab button to complete the name of a long file history: list the previous commands entered during the active session % history :19 ls | more | tail -n5 >> directory.list up and down arrow keys: allow you to move up and down through previous commands right and left arrow keys: allow you to edit command lines without starting from scratch !XXX: reruns the command labeled XXX in the history list % !1139 ls | more | tail -n5 >> directory.list

The Unix Environment Mitch has set up the basic CERI environment so that everyone can access the standard geophysics packages available on the Sun system But what does this mean? your environment is composed of a number of environment variables which provide important information to the operating system since you generally want the computer to behave the same way everyday, these environment variables are setup in configuration files accessed at login

What are your environment variables? env: prints the current environment variables to the screen

HOME & SHELL HOME: this environment variable controls what other unix commands consider your base or home directory this is how “%cd “ knows which directory to go to % echo $HOME /gaia/home/hdeshon SHELL: this variable stores your default shell % echo $SHELL /usr/bin/tcsh *these environment variables should not be changed by the user

PATH PATH: tells the shell where to find applications and/or executable files %echo $PATH /gaia/smeagol/local/passcal.2006/bin:/gaia/smeagol/local/gmt/GMT4.2. 1/bin:/opt/local/bin:/opt/local/sbin:/opt/csw/bin:/opt/csw/sbin:/ceri/local/bi n:/usr/sbin:/ceri/local/sbin:/gaia/home/stbisrat/bin:/usr/local/bin:/opt/Stu dio/SUNWspro/bin:/opt/Studio/SUNWspro/prod/bin:/opt/sfw/bin:/usr/bin: /usr/dt/bin:/usr/openwin/bin:/bin:/usr/ucb:/usr/ccs/bin:/usr/local/teTeX/bi n/sparc-sun-solaris2.8:/gaia/smeagol/local/bin The : is used to separate each full path name When a command is called from the command line, the shell will search through this list of paths, in order, until it finds the first instance

How does PATH work? If you are working a program to do least squares analysis and decide to call it “ls,” what will happen when you enter the command “ls”? It depends on your PATH variable. When the shell goes looking through your path for an executable file named “ls”, it will run the first one it finds.

If the directory containing your least squares program (executable file), “ls”, is in your path Before the directory containing the Unix list command, “ls”, it will run your program and you will not be able (at least simply) to get a listing of your directory!

If the directory containing your least squares program, “ls”, is in your path AFTER the directory containing the Unix list command, “ls”, it will run the Unix ls command and you will not be able (at least simply) to run your program!

To force your least squares executable in the current (working) directory to run %./ls To force the unix ls command to run %/bin/ls

MANPATH MANPATH: tells the shell where to find the manual pages read using the man command %echo $MANPATH /gaia/smeagol/local/passcal.2006/man:/gaia:smeagol/local/gmt/G MT4.2.1/man:/opt/local/man:/ceri/local/man:/usr/dt/man:/usr/man: /usr/openwin/share/man:/usr/local/man:/opt/SUNWspro/man:/opt/ sfw/man:/usr/local/teTeX/man:/gaia/smeagol/local/man:/opt/csw/ man If you do a man on a command and the shell can’t find a manual page (and you are sure the man page exists), this environment variable may not be set correctly

HOST & REMOTEHOST HOST: the name of the machine you are currently logged into REMOTEHOST: the name of the machine you are sitting in front of, if different % echo $HOST $REMOTEHOST enigma sailfish2.ceri.memphis.edu

SSH Related Variables SSH_CLIENT: the IP (internet protocol) address of the HOST machine SSH_CONNECTION: the IP address of the HOST machine and the REMOTEHOST machine % echo $SSH_CLIENT $SSH_CONNECTION

Modifying your current shell environment If you mess up modifying the environment in your current window – you may “break” your current window (shell). This is generally not a problem on the sun, mac, etc. The environment is local to that window/shell. Just close it and open another window.

set set: sets csh shell variables A typical tcsh set command is %set history=100 This would save the last 100 commands on the history list. The bash equivalent is simply %history=100

setenv setenv: the csh command to change environment settings. % setenv PATH {$PATH}:/gaia/home/hdeshon/scripts this adds the directory ‘~/scripts’ to the end of the environment variable PATH within the active window The bash equivalent is simply %PATH=$PATH:/gaia/home/hdeshon/scripts

setenv can be run on the command line, from within a local configuration file (.cshrc or.login), or in a shell script. When run without specifying an environment variable, it will print all environment variables to the screen

Making your own environment variables Anytime you want a global definition of something, you can create your own global environment variable %setenv LATESTRTVEL rtvel4_9305_5bv19

Modifying your default environment It will get old changing everything to the way you want it each time you log in/open a new window/start a new shell. And this being Unix, there is a (easy) way to set up your own personal environment. The setup of your personal environment (personal changes/preferences for how you want the shell to work for you) is stored in shell configuration files, aka dot files.cshrc or.bashrc There is also a file.login, but it is not likely you will have to change it (it get’s used when you log in, not each time you start a shell)

setenv PATH ${PATH}:/gaia/home/hdeshon/scripts setenv LD_LIBRARY_PATH ${LD_LIBRARY_PATH}:/gaia/home/hdeshon/fftw /lib setenv PRINTER 3876_grad set filec#explicitly turns on file completion set noclobber#turns on no clobber, which keeps redirect > from #overwriting files unless the ! is specified set history=500#keep the last 500 commands in the history list alias l 'ls -F'. cshrc

PATH=/usr/local/sod-2.2.2/bin:$ANTELOPE/bin:$PATH export PATH. bashrc

some warnings If you need to modify your environment configuration file (.cshrc,.bashrc), do so with care Always leave two terminal windows open (prior to making any changes) in case you mess your file up so completely and break your active window, you have another window open to delete the offending file Always backup the file you before modifying it!

Aliases alias: creates a pseudonym or nickname for a common command or series of commands Anything you find yourself typing repeatedly can be set to an alias Anything you find yourself frequently mis-typing can be set to an alias unalias: unset the alias alias and unalias can be run within a terminal window for short-term usage or set in your configuration files for long-term usage

Aliases examples alias settitlebar 'echo -n "^[]2;$CWD^G"' alias cwdcmd 'set $CWD% "' alias cd 'chdir \!* && cwdcmd && settitlebar’ alias howmuch 'du -sk.’ alias h 'history’ alias m more alias mroe more alias l 'ls -F' alias c clear alias src source

Source source: executes configuration files If you change your configuration file, you will need to execute the changes in all open terminal windows for the changes to take effect. They automatically will take effect when new terminal windows are opened. %nedit ~/.cshrc you’ve used NEdit to make file changes %source ~/.cshrc