Command-Line Unixcduan/download/?file=unixcmd.pdf · WHAT ARE COMMANDS? Two ways to think about...

100
Command-Line Unix Charles Duan [email protected] FAS Computer Services March ,

Transcript of Command-Line Unixcduan/download/?file=unixcmd.pdf · WHAT ARE COMMANDS? Two ways to think about...

Page 1: Command-Line Unixcduan/download/?file=unixcmd.pdf · WHAT ARE COMMANDS? Two ways to think about commands: 1. Special les that contain programs 2. Something typed at the command prompt

Command-Line Unix

Charles Duan

[email protected]

FAS Computer Services

March ,

Page 2: Command-Line Unixcduan/download/?file=unixcmd.pdf · WHAT ARE COMMANDS? Two ways to think about commands: 1. Special les that contain programs 2. Something typed at the command prompt

COMMAND-LINE UNIX

• Files and the File System

• Commands and Aliases

• Modifying your Workspace

• Printing

Command-Line Unix Slide FAS Computer Services

Page 3: Command-Line Unixcduan/download/?file=unixcmd.pdf · WHAT ARE COMMANDS? Two ways to think about commands: 1. Special les that contain programs 2. Something typed at the command prompt

THE FIRST RULE

The most important thing to know about Unix:

Ask this guy

Command-Line Unix Slide FAS Computer Services

Page 4: Command-Line Unixcduan/download/?file=unixcmd.pdf · WHAT ARE COMMANDS? Two ways to think about commands: 1. Special les that contain programs 2. Something typed at the command prompt

THE FIRST RULE

The most important thing to know about Unix:

Ask this guy

Command-Line Unix Slide FAS Computer Services

Page 5: Command-Line Unixcduan/download/?file=unixcmd.pdf · WHAT ARE COMMANDS? Two ways to think about commands: 1. Special les that contain programs 2. Something typed at the command prompt

FILES AND THE FILE SYSTEM

• Directories

• Finding, viewing, arranging, editing

• File permissions

Command-Line Unix Slide FAS Computer Services

Page 6: Command-Line Unixcduan/download/?file=unixcmd.pdf · WHAT ARE COMMANDS? Two ways to think about commands: 1. Special les that contain programs 2. Something typed at the command prompt

DIRECTORIES

• Directories are hierarchical folders

• Commands: cd, mkdir, rmdir

• Home directories: ∼ and /home/x/y/xyzabc

• “Recursive” traversal: the –r option

Command-Line Unix Slide FAS Computer Services

Page 7: Command-Line Unixcduan/download/?file=unixcmd.pdf · WHAT ARE COMMANDS? Two ways to think about commands: 1. Special les that contain programs 2. Something typed at the command prompt

DIRECTORIES

• Directories are hierarchical folders

• Commands: cd, mkdir, rmdir

• Home directories: ∼ and /home/x/y/xyzabc

• “Recursive” traversal: the –r option

Command-Line Unix Slide FAS Computer Services

Page 8: Command-Line Unixcduan/download/?file=unixcmd.pdf · WHAT ARE COMMANDS? Two ways to think about commands: 1. Special les that contain programs 2. Something typed at the command prompt

DIRECTORIES

• Directories are hierarchical folders

• Commands: cd, mkdir, rmdir

• Home directories: ∼ and /home/x/y/xyzabc

• “Recursive” traversal: the –r option

Command-Line Unix Slide FAS Computer Services

Page 9: Command-Line Unixcduan/download/?file=unixcmd.pdf · WHAT ARE COMMANDS? Two ways to think about commands: 1. Special les that contain programs 2. Something typed at the command prompt

DIRECTORIES

• Directories are hierarchical folders

• Commands: cd, mkdir, rmdir

• Home directories: ∼ and /home/x/y/xyzabc

• “Recursive” traversal: the –r option

Command-Line Unix Slide FAS Computer Services

Page 10: Command-Line Unixcduan/download/?file=unixcmd.pdf · WHAT ARE COMMANDS? Two ways to think about commands: 1. Special les that contain programs 2. Something typed at the command prompt

DIRECTORIES

• Directories are hierarchical folders

• Commands: cd, mkdir, rmdir

• Home directories: ∼ and /home/x/y/xyzabc

• “Recursive” traversal: the –r option

Command-Line Unix Slide FAS Computer Services

Page 11: Command-Line Unixcduan/download/?file=unixcmd.pdf · WHAT ARE COMMANDS? Two ways to think about commands: 1. Special les that contain programs 2. Something typed at the command prompt

FINDING, VIEWING, ARRANGING, EDITING

• Finding: ls, find, grep, du

• Viewing: cat, less

• Arranging: mv, cp, rm

• Editing: pico, vi, vim

• Knowing a Unix text editor is absolutely necessary

Command-Line Unix Slide FAS Computer Services

Page 12: Command-Line Unixcduan/download/?file=unixcmd.pdf · WHAT ARE COMMANDS? Two ways to think about commands: 1. Special les that contain programs 2. Something typed at the command prompt

FINDING, VIEWING, ARRANGING, EDITING

• Finding: ls, find, grep, du

• Viewing: cat, less

• Arranging: mv, cp, rm

• Editing: pico, vi, vim

• Knowing a Unix text editor is absolutely necessary

Command-Line Unix Slide FAS Computer Services

Page 13: Command-Line Unixcduan/download/?file=unixcmd.pdf · WHAT ARE COMMANDS? Two ways to think about commands: 1. Special les that contain programs 2. Something typed at the command prompt

FINDING, VIEWING, ARRANGING, EDITING

• Finding: ls, find, grep, du

• Viewing: cat, less

• Arranging: mv, cp, rm

• Editing: pico, vi, vim

• Knowing a Unix text editor is absolutely necessary

Command-Line Unix Slide FAS Computer Services

Page 14: Command-Line Unixcduan/download/?file=unixcmd.pdf · WHAT ARE COMMANDS? Two ways to think about commands: 1. Special les that contain programs 2. Something typed at the command prompt

FINDING, VIEWING, ARRANGING, EDITING

• Finding: ls, find, grep, du

• Viewing: cat, less

• Arranging: mv, cp, rm

• Editing: pico, vi, vim

• Knowing a Unix text editor is absolutely necessary

Command-Line Unix Slide FAS Computer Services

Page 15: Command-Line Unixcduan/download/?file=unixcmd.pdf · WHAT ARE COMMANDS? Two ways to think about commands: 1. Special les that contain programs 2. Something typed at the command prompt

FINDING, VIEWING, ARRANGING, EDITING

• Finding: ls, find, grep, du

• Viewing: cat, less

• Arranging: mv, cp, rm

• Editing: pico, vi, vim

• Knowing a Unix text editor is absolutely necessary

Command-Line Unix Slide FAS Computer Services

Page 16: Command-Line Unixcduan/download/?file=unixcmd.pdf · WHAT ARE COMMANDS? Two ways to think about commands: 1. Special les that contain programs 2. Something typed at the command prompt

FINDING, VIEWING, ARRANGING, EDITING

• Finding: ls, find, grep, du

• Viewing: cat, less

• Arranging: mv, cp, rm

• Editing: pico, vi, vim

• Knowing a Unix text editor is absolutely necessary

Command-Line Unix Slide FAS Computer Services

Page 17: Command-Line Unixcduan/download/?file=unixcmd.pdf · WHAT ARE COMMANDS? Two ways to think about commands: 1. Special les that contain programs 2. Something typed at the command prompt

FILE PERMISSIONS

• File permissions let other users access your files

• Where are they useful?

– Web pages

– Group projects

– Finger: .plan file

• Can be tricky to use—ask someone!

Command-Line Unix Slide FAS Computer Services

Page 18: Command-Line Unixcduan/download/?file=unixcmd.pdf · WHAT ARE COMMANDS? Two ways to think about commands: 1. Special les that contain programs 2. Something typed at the command prompt

FILE PERMISSIONS

• File permissions let other users access your files

• Where are they useful?

– Web pages

– Group projects

– Finger: .plan file

• Can be tricky to use—ask someone!

Command-Line Unix Slide FAS Computer Services

Page 19: Command-Line Unixcduan/download/?file=unixcmd.pdf · WHAT ARE COMMANDS? Two ways to think about commands: 1. Special les that contain programs 2. Something typed at the command prompt

FILE PERMISSIONS

• File permissions let other users access your files

• Where are they useful?

– Web pages

– Group projects

– Finger: .plan file

• Can be tricky to use—ask someone!

Command-Line Unix Slide FAS Computer Services

Page 20: Command-Line Unixcduan/download/?file=unixcmd.pdf · WHAT ARE COMMANDS? Two ways to think about commands: 1. Special les that contain programs 2. Something typed at the command prompt

FILE PERMISSIONS

• File permissions let other users access your files

• Where are they useful?

– Web pages

– Group projects

– Finger: .plan file

• Can be tricky to use—ask someone!

Command-Line Unix Slide FAS Computer Services

Page 21: Command-Line Unixcduan/download/?file=unixcmd.pdf · WHAT ARE COMMANDS? Two ways to think about commands: 1. Special les that contain programs 2. Something typed at the command prompt

FILE PERMISSIONS

• File permissions let other users access your files

• Where are they useful?

– Web pages

– Group projects

– Finger: .plan file

• Can be tricky to use—ask someone!

Command-Line Unix Slide FAS Computer Services

Page 22: Command-Line Unixcduan/download/?file=unixcmd.pdf · WHAT ARE COMMANDS? Two ways to think about commands: 1. Special les that contain programs 2. Something typed at the command prompt

FILE PERMISSIONS

• File permissions let other users access your files

• Where are they useful?

– Web pages

– Group projects

– Finger: .plan file

• Can be tricky to use—ask someone!

Command-Line Unix Slide FAS Computer Services

Page 23: Command-Line Unixcduan/download/?file=unixcmd.pdf · WHAT ARE COMMANDS? Two ways to think about commands: 1. Special les that contain programs 2. Something typed at the command prompt

FILE PERMISSIONS

• File permissions let other users access your files

• Where are they useful?

– Web pages

– Group projects

– Finger: .plan file

• Can be tricky to use—ask someone!

Command-Line Unix Slide FAS Computer Services

Page 24: Command-Line Unixcduan/download/?file=unixcmd.pdf · WHAT ARE COMMANDS? Two ways to think about commands: 1. Special les that contain programs 2. Something typed at the command prompt

COMMANDS AND ALIASES

• What are commands?

• Finding programs/the PATH variable

• Command aliases

• Where to get help

Command-Line Unix Slide FAS Computer Services

Page 25: Command-Line Unixcduan/download/?file=unixcmd.pdf · WHAT ARE COMMANDS? Two ways to think about commands: 1. Special les that contain programs 2. Something typed at the command prompt

WHAT ARE COMMANDS?

• Two ways to think about commands:

. Special files that contain programs

. Something typed at the command prompt

• Not always the same! (But they usually are)

• Some general Unix command categories

– File system

– Processing text files (sorting, searching, etc.)

– Network/Internet (e-mail, IM, diagnostics)

Command-Line Unix Slide FAS Computer Services

Page 26: Command-Line Unixcduan/download/?file=unixcmd.pdf · WHAT ARE COMMANDS? Two ways to think about commands: 1. Special les that contain programs 2. Something typed at the command prompt

WHAT ARE COMMANDS?

• Two ways to think about commands:

. Special files that contain programs

. Something typed at the command prompt

• Not always the same! (But they usually are)

• Some general Unix command categories

– File system

– Processing text files (sorting, searching, etc.)

– Network/Internet (e-mail, IM, diagnostics)

Command-Line Unix Slide FAS Computer Services

Page 27: Command-Line Unixcduan/download/?file=unixcmd.pdf · WHAT ARE COMMANDS? Two ways to think about commands: 1. Special les that contain programs 2. Something typed at the command prompt

WHAT ARE COMMANDS?

• Two ways to think about commands:

. Special files that contain programs

. Something typed at the command prompt

• Not always the same! (But they usually are)

• Some general Unix command categories

– File system

– Processing text files (sorting, searching, etc.)

– Network/Internet (e-mail, IM, diagnostics)

Command-Line Unix Slide FAS Computer Services

Page 28: Command-Line Unixcduan/download/?file=unixcmd.pdf · WHAT ARE COMMANDS? Two ways to think about commands: 1. Special les that contain programs 2. Something typed at the command prompt

WHAT ARE COMMANDS?

• Two ways to think about commands:

. Special files that contain programs

. Something typed at the command prompt

• Not always the same! (But they usually are)

• Some general Unix command categories

– File system

– Processing text files (sorting, searching, etc.)

– Network/Internet (e-mail, IM, diagnostics)

Command-Line Unix Slide FAS Computer Services

Page 29: Command-Line Unixcduan/download/?file=unixcmd.pdf · WHAT ARE COMMANDS? Two ways to think about commands: 1. Special les that contain programs 2. Something typed at the command prompt

WHAT ARE COMMANDS?

• Two ways to think about commands:

. Special files that contain programs

. Something typed at the command prompt

• Not always the same! (But they usually are)

• Some general Unix command categories

– File system

– Processing text files (sorting, searching, etc.)

– Network/Internet (e-mail, IM, diagnostics)

Command-Line Unix Slide FAS Computer Services

Page 30: Command-Line Unixcduan/download/?file=unixcmd.pdf · WHAT ARE COMMANDS? Two ways to think about commands: 1. Special les that contain programs 2. Something typed at the command prompt

WHAT ARE COMMANDS?

• Two ways to think about commands:

. Special files that contain programs

. Something typed at the command prompt

• Not always the same! (But they usually are)

• Some general Unix command categories

– File system

– Processing text files (sorting, searching, etc.)

– Network/Internet (e-mail, IM, diagnostics)

Command-Line Unix Slide FAS Computer Services

Page 31: Command-Line Unixcduan/download/?file=unixcmd.pdf · WHAT ARE COMMANDS? Two ways to think about commands: 1. Special les that contain programs 2. Something typed at the command prompt

WHAT ARE COMMANDS?

• Two ways to think about commands:

. Special files that contain programs

. Something typed at the command prompt

• Not always the same! (But they usually are)

• Some general Unix command categories

– File system

– Processing text files (sorting, searching, etc.)

– Network/Internet (e-mail, IM, diagnostics)

Command-Line Unix Slide FAS Computer Services

Page 32: Command-Line Unixcduan/download/?file=unixcmd.pdf · WHAT ARE COMMANDS? Two ways to think about commands: 1. Special les that contain programs 2. Something typed at the command prompt

WHAT ARE COMMANDS?

• Two ways to think about commands:

. Special files that contain programs

. Something typed at the command prompt

• Not always the same! (But they usually are)

• Some general Unix command categories

– File system

– Processing text files (sorting, searching, etc.)

– Network/Internet (e-mail, IM, diagnostics)

Command-Line Unix Slide FAS Computer Services

Page 33: Command-Line Unixcduan/download/?file=unixcmd.pdf · WHAT ARE COMMANDS? Two ways to think about commands: 1. Special les that contain programs 2. Something typed at the command prompt

WHAT ARE COMMANDS?

• Two ways to think about commands:

. Special files that contain programs

. Something typed at the command prompt

• Not always the same! (But they usually are)

• Some general Unix command categories

– File system

– Processing text files (sorting, searching, etc.)

– Network/Internet (e-mail, IM, diagnostics)

Command-Line Unix Slide FAS Computer Services

Page 34: Command-Line Unixcduan/download/?file=unixcmd.pdf · WHAT ARE COMMANDS? Two ways to think about commands: 1. Special les that contain programs 2. Something typed at the command prompt

FINDING PROGRAMS

• Typing the full path for a command

– /usr/local/bin/ls

– ./dining

• But if you just type the command name without the path,

what do you run?

• The which command:

% which ls

/usr/local/bin/ls

• How do you specify which command to use?

Command-Line Unix Slide FAS Computer Services

Page 35: Command-Line Unixcduan/download/?file=unixcmd.pdf · WHAT ARE COMMANDS? Two ways to think about commands: 1. Special les that contain programs 2. Something typed at the command prompt

FINDING PROGRAMS

• Typing the full path for a command

– /usr/local/bin/ls

– ./dining

• But if you just type the command name without the path,

what do you run?

• The which command:

% which ls

/usr/local/bin/ls

• How do you specify which command to use?

Command-Line Unix Slide FAS Computer Services

Page 36: Command-Line Unixcduan/download/?file=unixcmd.pdf · WHAT ARE COMMANDS? Two ways to think about commands: 1. Special les that contain programs 2. Something typed at the command prompt

FINDING PROGRAMS

• Typing the full path for a command

– /usr/local/bin/ls

– ./dining

• But if you just type the command name without the path,

what do you run?

• The which command:

% which ls

/usr/local/bin/ls

• How do you specify which command to use?

Command-Line Unix Slide FAS Computer Services

Page 37: Command-Line Unixcduan/download/?file=unixcmd.pdf · WHAT ARE COMMANDS? Two ways to think about commands: 1. Special les that contain programs 2. Something typed at the command prompt

FINDING PROGRAMS

• Typing the full path for a command

– /usr/local/bin/ls

– ./dining

• But if you just type the command name without the path,

what do you run?

• The which command:

% which ls

/usr/local/bin/ls

• How do you specify which command to use?

Command-Line Unix Slide FAS Computer Services

Page 38: Command-Line Unixcduan/download/?file=unixcmd.pdf · WHAT ARE COMMANDS? Two ways to think about commands: 1. Special les that contain programs 2. Something typed at the command prompt

FINDING PROGRAMS

• Typing the full path for a command

– /usr/local/bin/ls

– ./dining

• But if you just type the command name without the path,

what do you run?

• The which command:

% which ls

/usr/local/bin/ls

• How do you specify which command to use?

Command-Line Unix Slide FAS Computer Services

Page 39: Command-Line Unixcduan/download/?file=unixcmd.pdf · WHAT ARE COMMANDS? Two ways to think about commands: 1. Special les that contain programs 2. Something typed at the command prompt

FINDING PROGRAMS

• Typing the full path for a command

– /usr/local/bin/ls

– ./dining

• But if you just type the command name without the path,

what do you run?

• The which command:

% which ls

/usr/local/bin/ls

• How do you specify which command to use?

Command-Line Unix Slide FAS Computer Services

Page 40: Command-Line Unixcduan/download/?file=unixcmd.pdf · WHAT ARE COMMANDS? Two ways to think about commands: 1. Special les that contain programs 2. Something typed at the command prompt

FINDING PROGRAMS

• Typing the full path for a command

– /usr/local/bin/ls

– ./dining

• But if you just type the command name without the path,

what do you run?

• The which command:

% which ls

/usr/local/bin/ls

• How do you specify which command to use?

Command-Line Unix Slide FAS Computer Services

Page 41: Command-Line Unixcduan/download/?file=unixcmd.pdf · WHAT ARE COMMANDS? Two ways to think about commands: 1. Special les that contain programs 2. Something typed at the command prompt

FINDING PROGRAMS

• Typing the full path for a command

– /usr/local/bin/ls

– ./dining

• But if you just type the command name without the path,

what do you run?

• The which command:

% which ls

/usr/local/bin/ls

• How do you specify which command to use?

Command-Line Unix Slide FAS Computer Services

Page 42: Command-Line Unixcduan/download/?file=unixcmd.pdf · WHAT ARE COMMANDS? Two ways to think about commands: 1. Special les that contain programs 2. Something typed at the command prompt

FINDING PROGRAMS

• Typing the full path for a command

– /usr/local/bin/ls

– ./dining

• But if you just type the command name without the path,

what do you run?

• The which command:

% which ls

/usr/local/bin/ls

• How do you specify which command to use?

Command-Line Unix Slide FAS Computer Services

Page 43: Command-Line Unixcduan/download/?file=unixcmd.pdf · WHAT ARE COMMANDS? Two ways to think about commands: 1. Special les that contain programs 2. Something typed at the command prompt

THE PATH VARIABLE

PATH is a colon-separated list of directories

Say there are /bin/ls, /usr/bin/ls, /home/l/i/lib/bin/ls and

PATH is /bin:/usr/bin

% echo $PATH

/bin:/usr/bin

% which ls

/bin/ls

% setenv PATH /home/l/i/lib51/bin:{$PATH}% which ls

/home/l/i/lib51/bin/ls

Command-Line Unix Slide FAS Computer Services

Page 44: Command-Line Unixcduan/download/?file=unixcmd.pdf · WHAT ARE COMMANDS? Two ways to think about commands: 1. Special les that contain programs 2. Something typed at the command prompt

THE PATH VARIABLE

PATH is a colon-separated list of directories

Say there are /bin/ls, /usr/bin/ls, /home/l/i/lib/bin/ls and

PATH is /bin:/usr/bin

% echo $PATH

/bin:/usr/bin

% which ls

/bin/ls

% setenv PATH /home/l/i/lib51/bin:{$PATH}% which ls

/home/l/i/lib51/bin/ls

Command-Line Unix Slide FAS Computer Services

Page 45: Command-Line Unixcduan/download/?file=unixcmd.pdf · WHAT ARE COMMANDS? Two ways to think about commands: 1. Special les that contain programs 2. Something typed at the command prompt

THE PATH VARIABLE

PATH is a colon-separated list of directories

Say there are /bin/ls, /usr/bin/ls, /home/l/i/lib/bin/ls and

PATH is /bin:/usr/bin

% echo $PATH

/bin:/usr/bin

% which ls

/bin/ls

% setenv PATH /home/l/i/lib51/bin:{$PATH}% which ls

/home/l/i/lib51/bin/ls

Command-Line Unix Slide FAS Computer Services

Page 46: Command-Line Unixcduan/download/?file=unixcmd.pdf · WHAT ARE COMMANDS? Two ways to think about commands: 1. Special les that contain programs 2. Something typed at the command prompt

THE PATH VARIABLE

PATH is a colon-separated list of directories

Say there are /bin/ls, /usr/bin/ls, /home/l/i/lib/bin/ls and

PATH is /bin:/usr/bin

% echo $PATH

/bin:/usr/bin

% which ls

/bin/ls

% setenv PATH /home/l/i/lib51/bin:{$PATH}% which ls

/home/l/i/lib51/bin/ls

Command-Line Unix Slide FAS Computer Services

Page 47: Command-Line Unixcduan/download/?file=unixcmd.pdf · WHAT ARE COMMANDS? Two ways to think about commands: 1. Special les that contain programs 2. Something typed at the command prompt

THE PATH VARIABLE

PATH is a colon-separated list of directories

Say there are /bin/ls, /usr/bin/ls, /home/l/i/lib/bin/ls and

PATH is /bin:/usr/bin

% echo $PATH

/bin:/usr/bin

% which ls

/bin/ls

% setenv PATH /home/l/i/lib51/bin:{$PATH}% which ls

/home/l/i/lib51/bin/ls

Command-Line Unix Slide FAS Computer Services

Page 48: Command-Line Unixcduan/download/?file=unixcmd.pdf · WHAT ARE COMMANDS? Two ways to think about commands: 1. Special les that contain programs 2. Something typed at the command prompt

THE PATH VARIABLE

PATH is a colon-separated list of directories

Say there are /bin/ls, /usr/bin/ls, /home/l/i/lib/bin/ls and

PATH is /bin:/usr/bin

% echo $PATH

/bin:/usr/bin

% which ls

/bin/ls

% setenv PATH /home/l/i/lib51/bin:{$PATH}% which ls

/home/l/i/lib51/bin/ls

Command-Line Unix Slide FAS Computer Services

Page 49: Command-Line Unixcduan/download/?file=unixcmd.pdf · WHAT ARE COMMANDS? Two ways to think about commands: 1. Special les that contain programs 2. Something typed at the command prompt

THE PATH VARIABLE (CONTINUED)

Two things to note:

. Searches are done in order, and the first one found is

selected

. Make sure to always include the old PATH in the new

PATH

Alternate specification:

% set path = (/home/l/i/lib51/bin $path)

Command-Line Unix Slide FAS Computer Services

Page 50: Command-Line Unixcduan/download/?file=unixcmd.pdf · WHAT ARE COMMANDS? Two ways to think about commands: 1. Special les that contain programs 2. Something typed at the command prompt

THE PATH VARIABLE (CONTINUED)

Two things to note:

. Searches are done in order, and the first one found is

selected

. Make sure to always include the old PATH in the new

PATH

Alternate specification:

% set path = (/home/l/i/lib51/bin $path)

Command-Line Unix Slide FAS Computer Services

Page 51: Command-Line Unixcduan/download/?file=unixcmd.pdf · WHAT ARE COMMANDS? Two ways to think about commands: 1. Special les that contain programs 2. Something typed at the command prompt

THE PATH VARIABLE (CONTINUED)

Two things to note:

. Searches are done in order, and the first one found is

selected

. Make sure to always include the old PATH in the new

PATH

Alternate specification:

% set path = (/home/l/i/lib51/bin $path)

Command-Line Unix Slide FAS Computer Services

Page 52: Command-Line Unixcduan/download/?file=unixcmd.pdf · WHAT ARE COMMANDS? Two ways to think about commands: 1. Special les that contain programs 2. Something typed at the command prompt

THE PATH VARIABLE (CONTINUED)

Two things to note:

. Searches are done in order, and the first one found is

selected

. Make sure to always include the old PATH in the new

PATH

Alternate specification:

% set path = (/home/l/i/lib51/bin $path)

Command-Line Unix Slide FAS Computer Services

Page 53: Command-Line Unixcduan/download/?file=unixcmd.pdf · WHAT ARE COMMANDS? Two ways to think about commands: 1. Special les that contain programs 2. Something typed at the command prompt

COMMAND ALIASES

Aliases are “command nicknames”

Created by adding to the .aliases file

Example:

alias sb sudo budget

Now, typing sb will run sudo budget

To use, either run source .aliases or logout and login again

Command-Line Unix Slide FAS Computer Services

Page 54: Command-Line Unixcduan/download/?file=unixcmd.pdf · WHAT ARE COMMANDS? Two ways to think about commands: 1. Special les that contain programs 2. Something typed at the command prompt

COMMAND ALIASES

Aliases are “command nicknames”

Created by adding to the .aliases file

Example:

alias sb sudo budget

Now, typing sb will run sudo budget

To use, either run source .aliases or logout and login again

Command-Line Unix Slide FAS Computer Services

Page 55: Command-Line Unixcduan/download/?file=unixcmd.pdf · WHAT ARE COMMANDS? Two ways to think about commands: 1. Special les that contain programs 2. Something typed at the command prompt

COMMAND ALIASES

Aliases are “command nicknames”

Created by adding to the .aliases file

Example:

alias sb sudo budget

Now, typing sb will run sudo budget

To use, either run source .aliases or logout and login again

Command-Line Unix Slide FAS Computer Services

Page 56: Command-Line Unixcduan/download/?file=unixcmd.pdf · WHAT ARE COMMANDS? Two ways to think about commands: 1. Special les that contain programs 2. Something typed at the command prompt

COMMAND ALIASES

Aliases are “command nicknames”

Created by adding to the .aliases file

Example:

alias sb sudo budget

Now, typing sb will run sudo budget

To use, either run source .aliases or logout and login again

Command-Line Unix Slide FAS Computer Services

Page 57: Command-Line Unixcduan/download/?file=unixcmd.pdf · WHAT ARE COMMANDS? Two ways to think about commands: 1. Special les that contain programs 2. Something typed at the command prompt

COMMAND ALIASES

Aliases are “command nicknames”

Created by adding to the .aliases file

Example:

alias sb sudo budget

Now, typing sb will run sudo budget

To use, either run source .aliases or logout and login again

Command-Line Unix Slide FAS Computer Services

Page 58: Command-Line Unixcduan/download/?file=unixcmd.pdf · WHAT ARE COMMANDS? Two ways to think about commands: 1. Special les that contain programs 2. Something typed at the command prompt

WHERE TO GET HELP

• The man command

• The apropos command

• The Internet

• Refer to Slide

Command-Line Unix Slide FAS Computer Services

Page 59: Command-Line Unixcduan/download/?file=unixcmd.pdf · WHAT ARE COMMANDS? Two ways to think about commands: 1. Special les that contain programs 2. Something typed at the command prompt

WHERE TO GET HELP

• The man command

• The apropos command

• The Internet

• Refer to Slide

Command-Line Unix Slide FAS Computer Services

Page 60: Command-Line Unixcduan/download/?file=unixcmd.pdf · WHAT ARE COMMANDS? Two ways to think about commands: 1. Special les that contain programs 2. Something typed at the command prompt

WHERE TO GET HELP

• The man command

• The apropos command

• The Internet

• Refer to Slide

Command-Line Unix Slide FAS Computer Services

Page 61: Command-Line Unixcduan/download/?file=unixcmd.pdf · WHAT ARE COMMANDS? Two ways to think about commands: 1. Special les that contain programs 2. Something typed at the command prompt

WHERE TO GET HELP

• The man command

• The apropos command

• The Internet

• Refer to Slide

Command-Line Unix Slide FAS Computer Services

Page 62: Command-Line Unixcduan/download/?file=unixcmd.pdf · WHAT ARE COMMANDS? Two ways to think about commands: 1. Special les that contain programs 2. Something typed at the command prompt

WHERE TO GET HELP

• The man command

• The apropos command

• The Internet

• Refer to Slide

Command-Line Unix Slide FAS Computer Services

Page 63: Command-Line Unixcduan/download/?file=unixcmd.pdf · WHAT ARE COMMANDS? Two ways to think about commands: 1. Special les that contain programs 2. Something typed at the command prompt

MODIFYING YOUR WORKSPACE

• Login/logout settings

• Shell settings

Command-Line Unix Slide FAS Computer Services

Page 64: Command-Line Unixcduan/download/?file=unixcmd.pdf · WHAT ARE COMMANDS? Two ways to think about commands: 1. Special les that contain programs 2. Something typed at the command prompt

LOGIN/LOGOUT SETTINGS

• .cshrc and .login files run on login

– Only the .login should print out anything

• .logout runs on logout

• All of these are text files containing commands, one per line

• To test, type source .login (or the appropriate file)

Command-Line Unix Slide FAS Computer Services

Page 65: Command-Line Unixcduan/download/?file=unixcmd.pdf · WHAT ARE COMMANDS? Two ways to think about commands: 1. Special les that contain programs 2. Something typed at the command prompt

LOGIN/LOGOUT SETTINGS

• .cshrc and .login files run on login

– Only the .login should print out anything

• .logout runs on logout

• All of these are text files containing commands, one per line

• To test, type source .login (or the appropriate file)

Command-Line Unix Slide FAS Computer Services

Page 66: Command-Line Unixcduan/download/?file=unixcmd.pdf · WHAT ARE COMMANDS? Two ways to think about commands: 1. Special les that contain programs 2. Something typed at the command prompt

LOGIN/LOGOUT SETTINGS

• .cshrc and .login files run on login

– Only the .login should print out anything

• .logout runs on logout

• All of these are text files containing commands, one per line

• To test, type source .login (or the appropriate file)

Command-Line Unix Slide FAS Computer Services

Page 67: Command-Line Unixcduan/download/?file=unixcmd.pdf · WHAT ARE COMMANDS? Two ways to think about commands: 1. Special les that contain programs 2. Something typed at the command prompt

LOGIN/LOGOUT SETTINGS

• .cshrc and .login files run on login

– Only the .login should print out anything

• .logout runs on logout

• All of these are text files containing commands, one per line

• To test, type source .login (or the appropriate file)

Command-Line Unix Slide FAS Computer Services

Page 68: Command-Line Unixcduan/download/?file=unixcmd.pdf · WHAT ARE COMMANDS? Two ways to think about commands: 1. Special les that contain programs 2. Something typed at the command prompt

LOGIN/LOGOUT SETTINGS

• .cshrc and .login files run on login

– Only the .login should print out anything

• .logout runs on logout

• All of these are text files containing commands, one per line

• To test, type source .login (or the appropriate file)

Command-Line Unix Slide FAS Computer Services

Page 69: Command-Line Unixcduan/download/?file=unixcmd.pdf · WHAT ARE COMMANDS? Two ways to think about commands: 1. Special les that contain programs 2. Something typed at the command prompt

LOGIN/LOGOUT SETTINGS

• .cshrc and .login files run on login

– Only the .login should print out anything

• .logout runs on logout

• All of these are text files containing commands, one per line

• To test, type source .login (or the appropriate file)

Command-Line Unix Slide FAS Computer Services

Page 70: Command-Line Unixcduan/download/?file=unixcmd.pdf · WHAT ARE COMMANDS? Two ways to think about commands: 1. Special les that contain programs 2. Something typed at the command prompt

CHANGING YOUR PROMPT

Put this in your .cshrc file:

set prompt = ...

set prompt = Sample prompt

"prompt%" prompt%

"[%M:\!] %˜> " [ice:] ∼>"%M: %B%t%b %˜: " is: :am ∼:

Many more options—read man tcsh

Command-Line Unix Slide FAS Computer Services

Page 71: Command-Line Unixcduan/download/?file=unixcmd.pdf · WHAT ARE COMMANDS? Two ways to think about commands: 1. Special les that contain programs 2. Something typed at the command prompt

CHANGING YOUR PROMPT

Put this in your .cshrc file:

set prompt = ...

set prompt = Sample prompt

"prompt%" prompt%

"[%M:\!] %˜> " [ice:] ∼>"%M: %B%t%b %˜: " is: :am ∼:

Many more options—read man tcsh

Command-Line Unix Slide FAS Computer Services

Page 72: Command-Line Unixcduan/download/?file=unixcmd.pdf · WHAT ARE COMMANDS? Two ways to think about commands: 1. Special les that contain programs 2. Something typed at the command prompt

CHANGING YOUR PROMPT

Put this in your .cshrc file:

set prompt = ...

set prompt = Sample prompt

"prompt%" prompt%

"[%M:\!] %˜> " [ice:] ∼>"%M: %B%t%b %˜: " is: :am ∼:

Many more options—read man tcsh

Command-Line Unix Slide FAS Computer Services

Page 73: Command-Line Unixcduan/download/?file=unixcmd.pdf · WHAT ARE COMMANDS? Two ways to think about commands: 1. Special les that contain programs 2. Something typed at the command prompt

CHANGING YOUR PROMPT

Put this in your .cshrc file:

set prompt = ...

set prompt = Sample prompt

"prompt%" prompt%

"[%M:\!] %˜> " [ice:] ∼>

"%M: %B%t%b %˜: " is: :am ∼:

Many more options—read man tcsh

Command-Line Unix Slide FAS Computer Services

Page 74: Command-Line Unixcduan/download/?file=unixcmd.pdf · WHAT ARE COMMANDS? Two ways to think about commands: 1. Special les that contain programs 2. Something typed at the command prompt

CHANGING YOUR PROMPT

Put this in your .cshrc file:

set prompt = ...

set prompt = Sample prompt

"prompt%" prompt%

"[%M:\!] %˜> " [ice:] ∼>"%M: %B%t%b %˜: " is: :am ∼:

Many more options—read man tcsh

Command-Line Unix Slide FAS Computer Services

Page 75: Command-Line Unixcduan/download/?file=unixcmd.pdf · WHAT ARE COMMANDS? Two ways to think about commands: 1. Special les that contain programs 2. Something typed at the command prompt

CHANGING YOUR PROMPT

Put this in your .cshrc file:

set prompt = ...

set prompt = Sample prompt

"prompt%" prompt%

"[%M:\!] %˜> " [ice:] ∼>"%M: %B%t%b %˜: " is: :am ∼:

Many more options—read man tcsh

Command-Line Unix Slide FAS Computer Services

Page 76: Command-Line Unixcduan/download/?file=unixcmd.pdf · WHAT ARE COMMANDS? Two ways to think about commands: 1. Special les that contain programs 2. Something typed at the command prompt

PRINTING

• Viewing printing status

• Printable files

• Printing files

Command-Line Unix Slide FAS Computer Services

Page 77: Command-Line Unixcduan/download/?file=unixcmd.pdf · WHAT ARE COMMANDS? Two ways to think about commands: 1. Special les that contain programs 2. Something typed at the command prompt

VIEWING PRINTING STATUS

• echo $printers to list printers

• lpq –P[printer name] to show active print jobs

• You can put a space between the –P and the printer name

Command-Line Unix Slide FAS Computer Services

Page 78: Command-Line Unixcduan/download/?file=unixcmd.pdf · WHAT ARE COMMANDS? Two ways to think about commands: 1. Special les that contain programs 2. Something typed at the command prompt

VIEWING PRINTING STATUS

• echo $printers to list printers

• lpq –P[printer name] to show active print jobs

• You can put a space between the –P and the printer name

Command-Line Unix Slide FAS Computer Services

Page 79: Command-Line Unixcduan/download/?file=unixcmd.pdf · WHAT ARE COMMANDS? Two ways to think about commands: 1. Special les that contain programs 2. Something typed at the command prompt

VIEWING PRINTING STATUS

• echo $printers to list printers

• lpq –P[printer name] to show active print jobs

• You can put a space between the –P and the printer name

Command-Line Unix Slide FAS Computer Services

Page 80: Command-Line Unixcduan/download/?file=unixcmd.pdf · WHAT ARE COMMANDS? Two ways to think about commands: 1. Special les that contain programs 2. Something typed at the command prompt

VIEWING PRINTING STATUS

• echo $printers to list printers

• lpq –P[printer name] to show active print jobs

• You can put a space between the –P and the printer name

Command-Line Unix Slide FAS Computer Services

Page 81: Command-Line Unixcduan/download/?file=unixcmd.pdf · WHAT ARE COMMANDS? Two ways to think about commands: 1. Special les that contain programs 2. Something typed at the command prompt

PRINTABLE FILES

Plain text Contain only printable characters

• Check with less

Postscript A “page description language”

• Files start with

“%!PS-Adobe-.” (or . or .)

• Again, check with less or head

Don’t print any other type of file!

Command-Line Unix Slide FAS Computer Services

Page 82: Command-Line Unixcduan/download/?file=unixcmd.pdf · WHAT ARE COMMANDS? Two ways to think about commands: 1. Special les that contain programs 2. Something typed at the command prompt

PRINTABLE FILES

Plain text Contain only printable characters

• Check with less

Postscript A “page description language”

• Files start with

“%!PS-Adobe-.” (or . or .)

• Again, check with less or head

Don’t print any other type of file!

Command-Line Unix Slide FAS Computer Services

Page 83: Command-Line Unixcduan/download/?file=unixcmd.pdf · WHAT ARE COMMANDS? Two ways to think about commands: 1. Special les that contain programs 2. Something typed at the command prompt

PRINTABLE FILES

Plain text Contain only printable characters

• Check with less

Postscript A “page description language”

• Files start with

“%!PS-Adobe-.” (or . or .)

• Again, check with less or head

Don’t print any other type of file!

Command-Line Unix Slide FAS Computer Services

Page 84: Command-Line Unixcduan/download/?file=unixcmd.pdf · WHAT ARE COMMANDS? Two ways to think about commands: 1. Special les that contain programs 2. Something typed at the command prompt

PRINTABLE FILES

Plain text Contain only printable characters

• Check with less

Postscript A “page description language”

• Files start with

“%!PS-Adobe-.” (or . or .)

• Again, check with less or head

Don’t print any other type of file!

Command-Line Unix Slide FAS Computer Services

Page 85: Command-Line Unixcduan/download/?file=unixcmd.pdf · WHAT ARE COMMANDS? Two ways to think about commands: 1. Special les that contain programs 2. Something typed at the command prompt

PRINTABLE FILES

Plain text Contain only printable characters

• Check with less

Postscript A “page description language”

• Files start with

“%!PS-Adobe-.” (or . or .)

• Again, check with less or head

Don’t print any other type of file!

Command-Line Unix Slide FAS Computer Services

Page 86: Command-Line Unixcduan/download/?file=unixcmd.pdf · WHAT ARE COMMANDS? Two ways to think about commands: 1. Special les that contain programs 2. Something typed at the command prompt

PRINTABLE FILES

Plain text Contain only printable characters

• Check with less

Postscript A “page description language”

• Files start with

“%!PS-Adobe-.” (or . or .)

• Again, check with less or head

Don’t print any other type of file!

Command-Line Unix Slide FAS Computer Services

Page 87: Command-Line Unixcduan/download/?file=unixcmd.pdf · WHAT ARE COMMANDS? Two ways to think about commands: 1. Special les that contain programs 2. Something typed at the command prompt

PRINTABLE FILES

Plain text Contain only printable characters

• Check with less

Postscript A “page description language”

• Files start with

“%!PS-Adobe-.” (or . or .)

• Again, check with less or head

Don’t print any other type of file!

Command-Line Unix Slide FAS Computer Services

Page 88: Command-Line Unixcduan/download/?file=unixcmd.pdf · WHAT ARE COMMANDS? Two ways to think about commands: 1. Special les that contain programs 2. Something typed at the command prompt

PRINTING FILES

Command Plain text Postscript PDF

enscript Yes No No

lpr Yes Yes No

Both commands are of syntax

[command] –P[printer] [files]

Without the –P option you will print to scb

Command-Line Unix Slide FAS Computer Services

Page 89: Command-Line Unixcduan/download/?file=unixcmd.pdf · WHAT ARE COMMANDS? Two ways to think about commands: 1. Special les that contain programs 2. Something typed at the command prompt

PRINTING FILES

Command Plain text Postscript PDF

enscript Yes No No

lpr Yes Yes No

Both commands are of syntax

[command] –P[printer] [files]

Without the –P option you will print to scb

Command-Line Unix Slide FAS Computer Services

Page 90: Command-Line Unixcduan/download/?file=unixcmd.pdf · WHAT ARE COMMANDS? Two ways to think about commands: 1. Special les that contain programs 2. Something typed at the command prompt

PRINTING FILES

Command Plain text Postscript PDF

enscript

Yes No No

lpr Yes Yes No

Both commands are of syntax

[command] –P[printer] [files]

Without the –P option you will print to scb

Command-Line Unix Slide FAS Computer Services

Page 91: Command-Line Unixcduan/download/?file=unixcmd.pdf · WHAT ARE COMMANDS? Two ways to think about commands: 1. Special les that contain programs 2. Something typed at the command prompt

PRINTING FILES

Command Plain text Postscript PDF

enscript Yes

No No

lpr Yes Yes No

Both commands are of syntax

[command] –P[printer] [files]

Without the –P option you will print to scb

Command-Line Unix Slide FAS Computer Services

Page 92: Command-Line Unixcduan/download/?file=unixcmd.pdf · WHAT ARE COMMANDS? Two ways to think about commands: 1. Special les that contain programs 2. Something typed at the command prompt

PRINTING FILES

Command Plain text Postscript PDF

enscript Yes No

No

lpr Yes Yes No

Both commands are of syntax

[command] –P[printer] [files]

Without the –P option you will print to scb

Command-Line Unix Slide FAS Computer Services

Page 93: Command-Line Unixcduan/download/?file=unixcmd.pdf · WHAT ARE COMMANDS? Two ways to think about commands: 1. Special les that contain programs 2. Something typed at the command prompt

PRINTING FILES

Command Plain text Postscript PDF

enscript Yes No No

lpr Yes Yes No

Both commands are of syntax

[command] –P[printer] [files]

Without the –P option you will print to scb

Command-Line Unix Slide FAS Computer Services

Page 94: Command-Line Unixcduan/download/?file=unixcmd.pdf · WHAT ARE COMMANDS? Two ways to think about commands: 1. Special les that contain programs 2. Something typed at the command prompt

PRINTING FILES

Command Plain text Postscript PDF

enscript Yes No No

lpr

Yes Yes No

Both commands are of syntax

[command] –P[printer] [files]

Without the –P option you will print to scb

Command-Line Unix Slide FAS Computer Services

Page 95: Command-Line Unixcduan/download/?file=unixcmd.pdf · WHAT ARE COMMANDS? Two ways to think about commands: 1. Special les that contain programs 2. Something typed at the command prompt

PRINTING FILES

Command Plain text Postscript PDF

enscript Yes No No

lpr Yes

Yes No

Both commands are of syntax

[command] –P[printer] [files]

Without the –P option you will print to scb

Command-Line Unix Slide FAS Computer Services

Page 96: Command-Line Unixcduan/download/?file=unixcmd.pdf · WHAT ARE COMMANDS? Two ways to think about commands: 1. Special les that contain programs 2. Something typed at the command prompt

PRINTING FILES

Command Plain text Postscript PDF

enscript Yes No No

lpr Yes Yes

No

Both commands are of syntax

[command] –P[printer] [files]

Without the –P option you will print to scb

Command-Line Unix Slide FAS Computer Services

Page 97: Command-Line Unixcduan/download/?file=unixcmd.pdf · WHAT ARE COMMANDS? Two ways to think about commands: 1. Special les that contain programs 2. Something typed at the command prompt

PRINTING FILES

Command Plain text Postscript PDF

enscript Yes No No

lpr Yes Yes No

Both commands are of syntax

[command] –P[printer] [files]

Without the –P option you will print to scb

Command-Line Unix Slide FAS Computer Services

Page 98: Command-Line Unixcduan/download/?file=unixcmd.pdf · WHAT ARE COMMANDS? Two ways to think about commands: 1. Special les that contain programs 2. Something typed at the command prompt

PRINTING FILES

Command Plain text Postscript PDF

enscript Yes No No

lpr Yes Yes No

Both commands are of syntax

[command] –P[printer] [files]

Without the –P option you will print to scb

Command-Line Unix Slide FAS Computer Services

Page 99: Command-Line Unixcduan/download/?file=unixcmd.pdf · WHAT ARE COMMANDS? Two ways to think about commands: 1. Special les that contain programs 2. Something typed at the command prompt

PRINTING FILES

Command Plain text Postscript PDF

enscript Yes No No

lpr Yes Yes No

Both commands are of syntax

[command] –P[printer] [files]

Without the –P option you will print to scb

Command-Line Unix Slide FAS Computer Services

Page 100: Command-Line Unixcduan/download/?file=unixcmd.pdf · WHAT ARE COMMANDS? Two ways to think about commands: 1. Special les that contain programs 2. Something typed at the command prompt

Thank you!