1 / 16

Unix Comp-145

Unix Comp-145. Chapter 2. Objectives. Unix Commands The Path Flexibility of Command Usage Access and Manipulate Files Command Classification Using man Several simple commands . UNIX Commands. who (lists who is on system) date (date and time)

marlee
Download Presentation

Unix Comp-145

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Unix Comp-145 Chapter 2 BROOKDALE COMMUNITY COLLEGE

  2. Objectives Unix Commands The Path Flexibility of Command Usage Access and Manipulate Files Command Classification Using man Several simple commands BROOKDALE COMMUNITY COLLEGE

  3. UNIX Commands who (lists who is on system) date (date and time) man (manual page for the specified command) info - like man organized hierarchically passwd (change passwd) script - logs all interaction in a file clear - clear screen tty - terminal id stty - terminal options exit – Terminate session

  4. UNIX Commands Generally, commands are executable disk files (C programs) Commands execute like any other program (remember chp 1) UNIX supports commands written in any language (ie Java) Files do not need extension Shell (exception) automatically invoked once you log in

  5. Types of Commands Internal command of the shell which could be a built-in (like cd, pwd, etc.) an alias defined by the user that invokes the disk or External program on disk which could be a binary executable (written in C, C++). a script file (like a shell or perl script). internal version in a specific manner.

  6. The PATH • A shell variable (or environment variable) • Specifies a list of directories to search. • Shell looks at PATH only when • Command is not used with a pathname • Also not a shell built-in. • Command can still be executed if not in PATH by • Using a pathname. • Modifying PATH to include the directory containing the command. BROOKDALE COMMUNITY COLLEGE

  7. The PATH (Contd) • PATH can be modified in an absolute or relative manner: • PATH=/usr/bin:. (Absolute) • PATH=$PATH:/usr/local/bin (Relative) • Modified setting is lost after user has logged out unless saved in a startup file. BROOKDALE COMMUNITY COLLEGE

  8. Flexibility of Command Usage • Run multiple commands by specifying them in the same line: • date ; echo $PATH • Split a command into multiple lines: • $ echo “Hello • > Dolly” • Save command output in a file: • date > foo • date | cut -d” “ -f2 BROOKDALE COMMUNITY COLLEGE

  9. Flexibility of Command Usage (Cont’d) • Use output of one command as input of another: • date | cut -d” “ -f2 • Run a command in the background with &: • ls -lRa / > $HOME/ls-lRa.txt & BROOKDALE COMMUNITY COLLEGE

  10. Access and Manipulate Files • ls - List directory content • mv – Move file to another location or name • cp - Create a copy of the named file in the current or different directory • mkdir – Create a new directory as a child of the current directory • rm – Remove the named file • rmdir – Remove the named directory BROOKDALE COMMUNITY COLLEGE

  11. Command Classification: A Different Approach • Utilities that are generally used in standalone mode (vi, stty, bc). • Commands that do useful work but produce no output (mkdir, cp, rm). • Commands that produce output which may need further processing • (date, who, ls, tty, man, info). • Commands specially designed to accept output of other commands as their input and vice versa (grep, sort, head, prt). BROOKDALE COMMUNITY COLLEGE

  12. Using man • Displays documentation of commands, configuration files, system • calls and library functions. • Organized in a number of sections. Commands are found in Section 1. • May need to use section number when entry exists in multiple sections • (e.g. man passwdand man -s 5 passwd). BROOKDALE COMMUNITY COLLEGE

  13. Using man (Cont’d) • man documentation not available for most internal commands of the shell. • Use manman first to know how man should be used. BROOKDALE COMMUNITY COLLEGE

  14. Understanding a man Page • Example: wc Syntax/Synopsis • wc [ -c | -m | -C ] [ -lw ] [ file ... ] • Most useful information available in SYNOPSIS and DESCRIPTION. • When options grouped in [ ] without a |, one or more of them can be used. • (-l, -w and -lware valid.) BROOKDALE COMMUNITY COLLEGE

  15. Understanding a man Page • The | signifies an OR condition. (e.g., Only one of -c, -m or -C can be used.) • The ... means that multiple occurrences of the preceding item are possible. • (wc can be used with multiple files.) • EXIT STATUS indicates values returned on error. BROOKDALE COMMUNITY COLLEGE

  16. Several simple commands Example: prtSyntax/Synopsis prt [ -c| -m | -C ] [ -lw ] [ file ... ] Example: edSyntax/Synopsis ed[ file ... ] Example: lsSyntax/Synopsis ls [-OPTION] [fileName | substring] OPTION: -x= multi-column outut -F= prefix executables with *, directories with / and symbolic links with @ -a= shows all file names beginning with. Or .. -l= show long list -d= shows only dir names See pg 66 for complete options list. BROOKDALE COMMUNITY COLLEGE

More Related