Transcript Slide 1

Your UNIX: The Ultimate Guide
second edition
UNIX Commands
• Major part of the of learning UNIX is to master the essential command set.
• When you run a command, the __________ is loaded in __________, and
the __________ starts executing the instructions contained in the program.
• UNIX is case sensitive; command names are generally in lower case
• The command names are seldom __________ characters long.
• __________ is the most special command!
Das
© 2006 The McGraw-Hill Companies, Inc. All rights reserved.
Your UNIX: The Ultimate Guide
second edition
UNIX Commands
• The PATH: Locating Commands
• __________ maintains the environment variable in its own
environment.
• apache[kkhan:16] echo $PATH
/net/core/export/home/cs/001/k/kkhan/bin:/usr/local/bin:/usr/bin:/u
sr/ccs/bin:/usr/ucb:/usr/dt/bin:/usr/openwin/bin:/opt/bin:/usr/xpg4/
bin:
Das
© 2006 The McGraw-Hill Companies, Inc. All rights reserved.
Your UNIX: The Ultimate Guide
second edition
UNIX Commands
• apache[kkhan:18] netscape
Error: Can't open display:
You have not accepted the Binary Software Evalution Agreement. Exiting
• Where is the Command?
• 3 commands in UNIX that provides clues to the location of another
command.
• which, whereis, and type
• which
• which abandons the search the moment it locates the file name
grep.
• _________ does not require the utility
Das
© 2006 The McGraw-Hill Companies, Inc. All rights reserved.
Your UNIX: The Ultimate Guide
second edition
UNIX Commands
• apache[kkhan:21] which grep
/usr/bin/grep
• whereis
• Unlike which, which confines its search to the directories in the
PATH, whereis looks up a larger list.
• It finds 2 versions of ls on this Solaris system.
• __________ does not support it.
• apache[kkhan:23] whereis ls
ls: /usr/bin/ls /usr/ucb/ls /usr/man/man1/ls.1 /usr/man/man1b/ls.1b
Das
© 2006 The McGraw-Hill Companies, Inc. All rights reserved.
Your UNIX: The Ultimate Guide
second edition
UNIX Commands
• All UNIX commands are not files; some are built into the
__________
• apache[kkhan:33] which echo
/usr/bin/echo
The information output by which is only half true; type is more
authentic; the ambiguity, however, only arises when the command is
also a builtin command in the SHELL. Shell will ignore the disk
version in preference to the builtin command. However, we can
override this preferential behavior. HOW?
• apache[kkhan:27] type echo
echo is a shell builtin
.
Das
© 2006 The McGraw-Hill Companies, Inc. All rights reserved.
Your UNIX: The Ultimate Guide
second edition
UNIX Commands
• The UNIX Command structure:
• apache[kkhan:43] ls -l -t foo foo.sh
-rw------- 1 kkhan
-rw------- 1 kkhan
cs
cs
5 Jan 14 18:40 foo.sh
5 Jan 14 18:37 foo
• command line: ls -l -t foo foo.sh <Enter to execute>
• command Arguments – separated by whitespace
• Arguments
• beginning with hyphen (-) are called options
• options change the default behavior of the command
Das
© 2006 The McGraw-Hill Companies, Inc. All rights reserved.
Your UNIX: The Ultimate Guide
second edition
UNIX Commands
• ls – covered in detail in chapter 4
• bash-2.05$ ls -l -a –t OR
• bash-2.05$ ls -lat
• There are some characters in the command line that are not really
arguments – for example, |, <, and <. Covered in chapter 7
• apache[kkhan:66] who > foo
Das
© 2006 The McGraw-Hill Companies, Inc. All rights reserved.
Your UNIX: The Ultimate Guide
second edition
UNIX Commands
• UNIX provides a full-duplex terminal
• separate channels for input/output
• users do not have to wait for a command to complete
before typing the next one; just continue typing even if the
output of the previous command clutters the display
• who ; ls not – 2 commands separated by a metacharacter ;
• apache[kkhan:72] echo "This is
>a three-line
>text message"
This is
a three-line
text message
Das
© 2006 The McGraw-Hill Companies, Inc. All rights reserved.
Your UNIX: The Ultimate Guide
second edition
UNIX Commands
• the same command in c-shell
• apache{kkhan}10: echo "This is\
a three-line\
text message"
This is
a three-line
text message
• When you encounter > or ?
• due to absence of matching quotes
• you can interrupt with Ctrl-c or Ctrl-u
Das
© 2006 The McGraw-Hill Companies, Inc. All rights reserved.
Your UNIX: The Ultimate Guide
second edition
UNIX Commands
• Command output need not always be seen on the terminal.
• apache[kkhan:79] who > userlist.txt
• apache[kkhan:80] who | wc –l
• print the line count
• - m: print the character count
Das
© 2006 The McGraw-Hill Companies, Inc. All rights reserved.
Your UNIX: The Ultimate Guide
second edition
UNIX Command
• man: On-Line Help
• the most complete and authoritative guide to UNIX system
• also available of the internet
• to view wc command
• apache[kkhan:80] man wc
Das
© 2006 The McGraw-Hill Companies, Inc. All rights reserved.
Your UNIX: The Ultimate Guide
second edition
UNIX Commands
Reformatting page. Please Wait... done
User Commands
wc(1)
NAME
wc - display a count of lines, words and characters in a
file
SYNOPSIS
wc [-c | -m | -C] [-lw] [file...]
DESCRIPTION
The wc utility reads one or more input files and, by
default, writes the number of newline characters, words and
bytes contained in each input file to the standard output.
The utility also writes a total count for all named files,
if more than one input file is specified.
wc considers a word to be a non-zero-length string of characters delimited by white space (for example, SPACE, TAB).
See iswspace(3C) or isspace(3C).
--More--(23%)
Das
© 2006 The McGraw-Hill Companies, Inc. All rights reserved.
Your UNIX: The Ultimate Guide
second edition
UNIX Commands
• man –k and man –f
• man - k who
• displays manual without stopping
• searches the keyword in all the manuals available
• man -f grep
• displays a one line header from the NAME section
• Pages are traditionally referred to using the notation
“name(section”); the same page name may appear in more than
one section of the manual. For example, exit(1), exit(2)
• grep
grep (1)
- search a file for a pattern
Das
© 2006 The McGraw-Hill Companies, Inc. All rights reserved.
Your UNIX: The Ultimate Guide
second edition
UNIX Commands
• printf: Alternative to echo
• Like echo, it exists as an external command
• except Bash has it built in
• unlike echo, you must use \n – escape sequence
• {csblade310:~} printf "Testing"
Testing{csblade310:~} printf "Testing\n"
Testing
• {csblade310:~} printf "My current shell is %s\n" $SHELL
My current shell is /bin/ksh
Das
© 2006 The McGraw-Hill Companies, Inc. All rights reserved.
Your UNIX: The Ultimate Guide
second edition
UNIX Command
• script – Recording Your Session
• Virtually unknown to many users
• lets you “record” your login session in a file
• not included in the ___________ standard
• keeps the log of your activities
Das
© 2006 The McGraw-Hill Companies, Inc. All rights reserved.
Your UNIX: The Ultimate Guide
second edition
UNIX Command
{csblade310:~} script
Script started, file is typescript
$ ls
Mail
foo
public_html userlist.txt
PUTTY.RND foo.sh
typescript
$ echo $SHELL
/bin/ksh
$ exit
Script done, file is typescript
{csblade310:~} cat typescript
Script started on Wed Jan 23 18:21:26 2008
$ ls
Mail
foo
public_html userlist.txt
PUTTY.RND foo.sh
typescript
$ echo $SHELL
/bin/ksh
$ exit
script done on Wed Jan 23 18:21:40 2008
Das
© 2006 The McGraw-Hill Companies, Inc. All rights reserved.
Your UNIX: The Ultimate Guide
second edition
UNIX Command
• passwd: Changing Your Password
• {csblade310:~} passwd
passwd: Changing password for kkhan
Enter existing login password:
• uname: Machine’s Name and Operating System
{csblade310:~} uname
SunOS
• uname -r: The Current Release
5.10
• uname -n: The machine name
csblade310.utdallas.edu
Das
© 2006 The McGraw-Hill Companies, Inc. All rights reserved.
Your UNIX: The Ultimate Guide
second edition
UNIX Command
• who: Know the Users
• who am I
• date
• date +%m - month
• date +%h – month name
• stty: When Things Go Wrong
Das
© 2006 The McGraw-Hill Companies, Inc. All rights reserved.
Your UNIX: The Ultimate Guide
second edition
UNIX Command
{csblade310:~} stty -a
speed 9600 baud;
rows = 24; columns = 80; ypixels = 370; xpixels = 730;
csdata ?
eucw 1:0:0:0, scrw 1:0:0:0
intr = ^c; quit = ^\; erase = ^h; kill = ^u;
eof = ^d; eol = <undef>; eol2 = <undef>; swtch = <undef>;
start = ^q; stop = ^s; susp = ^z; dsusp = ^y;
rprnt = ^r; flush = ^o; werase = ^w; lnext = ^v;
-parenb -parodd cs8 -cstopb hupcl cread -clocal -loblk -crtscts -crtsxoff -parext
-ignbrk -brkint -ignpar -parmrk -inpck -istrip -inlcr -igncr icrnl -iuclc
ixon -ixany ixoff -imaxbel
isig icanon -xcase echo echoe echok -echonl -noflsh
-tostop echoctl -echoprt echoke -defecho -flusho -pendin iexten
opost -olcuc onlcr -ocrnl -onocr -onlret -ofill -ofdel
Das
© 2006 The McGraw-Hill Companies, Inc. All rights reserved.