''Unix is user friendly -- PowerPoint Presentation

''Unix is user friendly -- PowerPoint Presentation

2016-07-11 59K 59 0 0

Description

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 . ID: 400563

Embed code:

Download this presentation



DownloadNote - The PPT/PDF document "''Unix is user friendly --" is the property of its rightful owner. Permission is granted to download and print the materials on this web site for personal, non-commercial use only, and to display it on your personal computer provided you do not modify the materials and that you retain all copyright notices contained in the materials. By downloading content from our website, you accept the terms of this agreement.

Presentations text content in ''Unix is user friendly --

Slide1

''Unix is user friendly --

It's just picky about who it's friends are...''

-- Unknown, seen in .sigs around the world

Slide2

Basics of the Unix/Linux Environment

Shells and Your Unix Environment

Slide3

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

Slide4

Common Shells

Bourne

Shell

Bourne Again

Shell

TENEXC shell

C Shell

KornShell

Slide5

sh

Bourne shell

the original Unix shell

Pro: Flexible and powerful scripting shell

Con: Not interactive or particularly user friendly

Slide6

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

Slide7

ksh

Korn

shell

derived from the Bourne shell so has a shared syntax

job control taken from the C shell

Slide8

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

Slide9

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

Slide10

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

Slide11

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

1139 11: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

Slide12

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

Slide13

What are your environment variables?

env

: prints the current environment variables to the screen

Slide14

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

Slide15

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/bin:/usr/sbin:/ceri/local/sbin:/gaia/home/stbisrat/bin:/usr/local/bin:/opt/Studio/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/bin/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

Slide16

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.

Slide17

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!

Slide18

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!

Slide19

To force your least squares

executable in the current (working) directory

to run

%./

ls

To force the

unix

ls

command to run

%/bin/

ls

Slide20

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/GMT4.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

Slide21

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

Slide22

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

141.225.156.223 52372 22

141.225.156.223 52372 141.225.157.75 22

Slide23

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.

Slide24

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

Slide25

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

Slide26

s

etenv

c

an

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

Slide27

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

Slide28

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)

Slide29

setenv PATH ${PATH}:/gaia/home/hdeshon/scriptssetenv LD_LIBRARY_PATH ${LD_LIBRARY_PATH}:/gaia/home/hdeshon/fftw-2.1.5/libsetenv PRINTER 3876_gradset filec #explicitly turns on file completionset noclobber #turns on no clobber, which keeps redirect > from #overwriting files unless the ! is specifiedset history=500 #keep the last 500 commands in the history listalias l 'ls -F'

.

cshrc

Slide30

PATH=/usr/local/sod-2.2.2/bin:$ANTELOPE/bin:$PATHexport PATH

.

bashrc

Slide31

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!

Slide32

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

Slide33

Aliases examples

alias

settitlebar

'echo -n "^[]2;$CWD^G"'

alias

cwdcmd

'set PROMPT="[${

USER}@`hostname

`] $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

Slide34

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

Slide35


About DocSlides
DocSlides allows users to easily upload and share presentations, PDF documents, and images.Share your documents with the world , watch,share and upload any time you want. How can you benefit from using DocSlides? DocSlides consists documents from individuals and organizations on topics ranging from technology and business to travel, health, and education. Find and search for what interests you, and learn from people and more. You can also download DocSlides to read or reference later.