420 likes | 569 Views
Introduction to UNIX. A User’s Perspective: Day 2 – Command Basics. Review – UNIX Shells. The basics of UNIX Shells Types ksh & bash Initialization/configuration scripts /etc/profile & .profile /etc/bash_rc & .bash_rc. Review – File System. Everything is a file Paths
E N D
Introduction to UNIX A User’s Perspective: Day 2 – Command Basics
Review – UNIX Shells • The basics of UNIX Shells • Types • ksh & bash • Initialization/configuration scripts • /etc/profile & .profile • /etc/bash_rc & .bash_rc
Review – File System • Everything is a file • Paths • Ownership & Permissions
Let’s Log into the Server • A few changes • The server we will use: • 137.99.110.55 • spf1n5.ucc.uconn.edu • The login utility: • ssh • Why the changes?
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 Review - Commands
pwd ls -al touch index.html ls –al mkdir –p public_html/test/page cp -p index.html public_html/test/page mv index.html public_html/test cd public_html echo “name Loves UNIX” > test/index.html cd .. echo “Mitch Loves UNIX” > test/page/index.html ln –s test/index.html index.html cat index.html rm test/index.html cat index.html ln test/page/index.html test/index.html cat index.html echo “UNIX rules” >> test/page/index.html cat index.html Command Exercise
Some Loose Ends • CTRL-C • Terminate the current process • CTRL-D • Close the connection immediately
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
Command Arguments • Typically one or more file names the command will operate on
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)
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)
Commands - Basic Function • Single function • ls, cp, mv, etc. • Minimal functionality • Minimal output
Commands – Directed Function • Perform the command on a file • What can the file be? • ls index.html • rm /u/ux101is1/hdisk0
Commands – Extended Function • Using switch(es) to refine the command output • Usually provides more information • Always deals with specific function of the base command
Commands – Directed Extended Function • Refine the operation performed on a file(s) • ls –ail index.html
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 • http://www.linuxcentral.com/linux/man-pages/
Using man • Syntax • man “command-name” • man –k “descriptor”
Anatomy of a man Page • Purpose • Syntax • Description • Details of switches • Examples
Example • cd ~ • cd public_html • ls –ailF • cd test • ls –ailF • cd .. • cp –h index.html .. • cd .. • ls –al • rm index.html
What Should You Know? • Basic Command Use • How to use switches and arguments • How to find help
Question? • Anyone… anyone?
Redirection & Pipes Understanding UNIX Input and Output
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
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
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
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
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
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
Putting it All Together • What do we gain • Extended functionality • Increased control • Innovative solutions • An understanding of both input and output
IN CLASS DEMONSTRATION • SIX Volunteers able to follow instructions • Hmmmm… • A paper | B | C | D | E | F > Frontdesk
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
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
What’s Running? • ps –ef | grep ux • ps aux | more • ps –ef | grep “string”
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/automation.pl • 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
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
Question? • Anyone… anyone?
What Will Cover Tomorrow… • Advanced UNIX commands • VI
THANK YOU FOR ATTENDING • Please fill out the Evaluation Form before leaving