Presentation is loading. Please wait.

Presentation is loading. Please wait.

Introduction to UNIX A User’s Perspective: Day 2 – Command Basics.

Similar presentations

Presentation on theme: "Introduction to UNIX A User’s Perspective: Day 2 – Command Basics."— Presentation transcript:

1 Introduction to UNIX A User’s Perspective: Day 2 – Command Basics

2 Review – UNIX Shells The basics of UNIX Shells – Types ksh & bash – Initialization/configuration scripts /etc/profile &.profile /etc/bash_rc &.bash_rc

3 Review – File System Everything is a file Paths Ownership & Permissions

4 Let’s Log into the Server A few changes – The server we will use: – The login utility: ssh Why the changes?

5 Review - Commands ls – LiSt cd – Change Directory pwd – Present Working Directory rm – ReMove mkdir – Make Directory mv – MoVe cp – CoPy touch – Create cat – conCATenate echo – Hello…lloo..llooo… ln – Link chmod – Change permissions chown – Change Ownership Shortcuts to your home directory – cd – cd ~ – cd ~user-name – cd $HOME

6 Command Exercise 1. pwd 2. ls -al 3. touch index.html 4. ls –al 5. mkdir –p public_html/test/page 6. cp -p index.html public_html/test/page 7. mv index.html public_html/test 8. cd public_html 9. echo “name Loves UNIX” > test/index.html 10. cd.. 11. echo “Mitch Loves UNIX” > test/page/index.html 12. ln –s test/index.html index.html 13. cat index.html 14. rm test/index.html 15. cat index.html 16. ln test/page/index.html test/index.html 17. cat index.html 18. echo “UNIX rules” >> test/page/index.html 19. cat index.html

7 What Did We Do?

8 Some Loose Ends CTRL-C – Terminate the current process CTRL-D – Close the connection immediately

9 What We Will Cover Today Extend our knowledge and use of commands Learn how to find help Standard I/O/E Redirection & Piping Customize our Shell account Begin to learn VI

10 Command Arguments Typically one or more file names the command will operate on

11 Switches!?! We don’t need no stink’in Switches Switches give us power/functionality Increase the functionality of a command Almost all commands have available switches Switches are denoted with a – (minus or hyphen)

12 Anatomy of a Command Command-name – Basic function Command-name arguments – Basic function performed on some file(s) Command-name –switches – Extended function Command-name –switches arguments – Extended function performed on some file(s)

13 Commands - Basic Function Single function ls, cp, mv, etc. – Minimal functionality – Minimal output

14 Commands – Directed Function Perform the command on a file – What can the file be? ls index.html rm /u/ux101is1/hdisk0

15 Commands – Extended Function Using switch(es) to refine the command output Usually provides more information Always deals with specific function of the base command

16 Commands – Directed Extended Function Refine the operation performed on a file(s) ls –ail index.html

17 Manual Pages – The UNIX Bible Everything you need to know… man pages – System resident manuals Available: – for most commands – on most UNIX systems – on the Web

18 Using man Syntax – man “command-name” – man –k “descriptor”

19 Anatomy of a man Page Purpose Syntax Description Details of switches Examples

20 Example cd ~ cd public_html ls –ailF cd test ls –ailF cd.. cp –h index.html.. cd.. ls –al rm index.html

21 What Should You Know? Basic Command Use How to use switches and arguments How to find help

22 Question? Anyone… anyone?

23 Redirection & Pipes Understanding UNIX Input and Output

24 What is Input? Information fed into a data processing system or computer (Merriam-Webster Dictionary) Data necessary to create some action or output. Text – ‘Joshua’ Keystroke combinations – CTRL -D

25 Input Sources Standard Input (stdin) Device – That part of the operating system controlling from where a program receives its input. – keyboard Any defined device capable of receiving input

26 What is Output? The information produced by a computer (Merriam-Webster Dictionary) Data created as a result of some action or input. Text – ‘Hello Joshua’ Pictures & Graphics –

27 Output Destinations Standard Output (stdout) Devices – That part of the operating system that controls where a program writes its output. – Monitor – Printer Any defined device capable of receiving output

28 Redirection Where? > the redirection operator – Allows for an output destination other then standard output (stdout). – Is a write only operation Can only redirect to regular files. # ls –al /usr > directory.lst

29 Pipes Keeping the Flow Going… | the pipe operator – Allows for the output (stdout) of one command to serve as the input (stdin) of another command – No write involved in the process Can only be used with commands ( executables ) # ls –al /usr/bin | grep ls

30 Putting it All Together What do we gain – Extended functionality – Increased control – Innovative solutions – An understanding of both input and output

31 IN CLASS DEMONSTRATION SIX Volunteers able to follow instructions – Hmmmm… A paper | B | C | D | E | F > Frontdesk

32 A Real World Example cp –p /u/ux101is1/tfile. ls –al tfile wc tfile sort tfile | wc sort tfile | uniq –c | wc sort tfile | uniq –c | sort –rn > tfile2 wc tfile wc tfile2 more tfile more tfile2

33 Running Processes Foreground – Ties up the command-prompt Loose control – Not really multi-tasking Background – Keep control of the command prompt Maintain control – Multi-tasking

34 What’s Running? ps –ef | grep ux ps aux | more ps –ef | grep “string”

35 Cron Jobs Scheduling jobs… – Minute Hour Day Month Day_of_the_Week Sunday = 0 * = Match all Examples: – 0,5,10,15,20,25,30,35,40,45,50,55 * * * * $HOME/ – 0 2 * * 4 /usr/sbin/acct/dodisk – 5 * * * * /usr/sbin/acct/ckpacct – 0 4 * * 1-6 /usr/sbin/acct/runacct 2>/var/adm/acct/nite/accterr

36 What Should You Know? – Basic Command Use – How to use switches and arguments – How to find help Understand Standard I/O/E Understand Redirection Understand Pipes How to use Redirection and Pipes Process management

37 Question? Anyone… anyone?

38 What Will Cover Tomorrow… Advanced UNIX commands VI

39 THANK YOU FOR ATTENDING Please fill out the Evaluation Form before leaving

Download ppt "Introduction to UNIX A User’s Perspective: Day 2 – Command Basics."

Similar presentations

Ads by Google