1 / 34

Unix File System

Unix File System. Stores Files Text, Programs, Images, etc. Made up of Many Files User, Unix System, Unix Commands. Top most directory in Unix. Home Directory. Directory containing all home directories. Unix File System. Unix File System. Home Directory

dash
Download Presentation

Unix File System

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 File System • Stores Files • Text, Programs, Images, etc. • Made up of Many Files • User, Unix System, Unix Commands

  2. Top most directory in Unix Home Directory Directory containing all home directories Unix File System

  3. Unix File System • Home Directory • Personal Directory to store files • Usually the Directory Name = login ID • Current Directory after successful login Home directories for: rdefe, jsmith and djones

  4. Unix File System • What Can You Do? • Create New Files & Directories • Organize Files • Locate Files Based on a Directory Structure • Change to a New Directory

  5. Unix File System • File & Directory Naming Guidelines • Don’t Use Meta Characters • / \ “ ` * ; ? { } ( ) [ ] ~ ! $ < > | & # • Do Use • a-z A-Z • 0-9 • . _ - • Remember Unix is Case Sensitive!

  6. Unix File System • File & Directory Name Examples • feb1998, 178987, my_data, my.data.new • mbox, Mbox, mboX, MBOX, mBox • prog1..2 • .profile

  7. Unix Commands • ls • List Files & Directories $ ls 198 A aa.bb.cc.dd bin datefile etc mail mbox mbox.old unix $

  8. Unix Commands • ls -p • -pShow Directories $ ls -p 198 A aa.bb.cc.dd bin/ datefile etc/ mail/ mbox mbox.old unix/ $

  9. Unix Commands • ls [directory1] [directory2] ... • List the contents of a directory $ ls -p 198 A aa.bb.cc.dd bin/ datefile etc/ mail/ mbox mbox.old unix/ $ $ ls unix awk.data awk.prg bgraph cpy homework2 homework3 unix2test $

  10. Unix Commands • ls -s • -sShow File Size in Blocks • Block Sizes • 512 bytes • 1024 bytes • 2048 bytes $ ls -s total 19 1 198 1 A 1 aa.bb.cc.dd 1 bin 1 datefile 1 etc 1 mail 2 mbox 1 unix

  11. Unix Commands • ls -l • -lLong Listing $ ls -l total 19 -rw-r--r-- 1 rdefe unix 53 Sep 12 21:46 198 -rw-r--r-- 1 rdefe unix 62 Sep 12 21:47 A drwxr-xr-x 2 rdefe unix 96 Sep 4 20:58 bin drwxr-xr-x 3 rdefe unix 80 Aug 29 20:54 db drwxr-xr-x 2 rdefe unix 64 Aug 29 20:54 etc drwxr-xr-x 2 rdefe unix 32 Sep 2 1992 mail -rw------- 1 rdefe unix 984 Sep 12 21:44 mbox drwxr-xr-x 2 rdefe unix 144 Aug 29 20:54 unix $

  12. Unix Commands • ls -a • -a List All Files $ ls -a . .. .profile .sh_history 198 A bin datefile db etc mbox unix $ Include Files That Begin with a ‘.’ Files that begin with a ‘.’ are usually configuration files

  13. Unix Commands • ls -r • -rReverse Sort • ls -R • -R List Contents of Subdirectories $ ls -r unix mbox mail etc db datefile bin A 198 $ • List files in each subdirectory. • Subdirectories with Subdirectories will also be listed…and so on...

  14. Unix Commands • ls -l -t or ls -lt • -tSort On Modification Time $ ls -lt total 19 -rw-r--r-- 1 rdefe unix 62 Sep 12 21:47 A -rw-r--r-- 1 rdefe unix 53 Sep 12 21:46 198 -rw------- 1 rdefe unix 984 Sep 12 21:44 mbox drwxr-xr-x 2 rdefe unix 96 Sep 4 20:58 bin drwxr-xr-x 2 rdefe unix 64 Aug 29 20:54 etc drwxr-xr-x 2 rdefe unix 144 Aug 29 20:54 unix drwxr-xr-x 3 rdefe unix 80 Aug 29 20:54 db drwxr-xr-x 2 rdefe unix 32 Sep 2 1992 mail $

  15. Unix Commands • ls -l -t -r or ls -ltr • -trReverse Sort On Modification Time $ ls -ltr total 19 drwxr-xr-x 2 rdefe unix 32 Sep 2 1992 mail drwxr-xr-x 3 rdefe unix 80 Aug 29 20:54 db drwxr-xr-x 2 rdefe unix 144 Aug 29 20:54 unix drwxr-xr-x 2 rdefe unix 64 Aug 29 20:54 etc drwxr-xr-x 2 rdefe unix 96 Sep 4 20:58 bin -rw------- 1 rdefe unix 984 Sep 12 21:44 mbox -rw-r--r-- 1 rdefe unix 53 Sep 12 21:46 198 -rw-r--r-- 1 rdefe unix 62 Sep 12 21:47 A $

  16. Unix Commands • ls -[ltrRa] [Filename1] [Filename2] … • UnixCommandOptionsArguments $ ls -lt unix $

  17. Unix Commands • cat [Filename1] [Filename2] … • Concatenate Files • Display Files to the Screen • Ctrl-s Pause Screen • Ctrl-q Unpause Screen $ cat sample.file This is a sample file that i'll use to demo how the pr command is used. The pr command is useful in formatting various types of text files. $

  18. Unix Commands • more [Filename1] [Filename2] … • Display Files to the screen one page at a time $ more largefile This is a sample file that i'll use to demo how the pr command is used. The pr command is useful in formatting various types of text files. --More--(16%) • Spacebar (next page) • b (previous page) • Enter Key (next line) • q (Quit & return to unix) • /string (search for string) • :n (next file) • :p (previous file)

  19. $ pr sample.file 98-05-22 23:07 sample.file Page 1 This is a sample file that i'll use to demo how the pr command is used. ... Ideal solution would be to combine the lpr & pr to achieve formatted printed output Unix Commands • lpr [Filename1] [Filename2] … • Send Files to a Unix Printer • No Formatting (page numbers, etc.) $ lpr prog1 mbox $

  20. Unix Redirection • Redirecting Input • A Command Requiring Input Can Receive it’s Input From a File $ mail rdefe < mesg $

  21. Unix Redirection • Redirecting Input $ mail rdefe < mesg $ Command that requires input Command < File File used to provide input (instead of typing it!)

  22. $ pr data > data.pr $ lpr data.pr 1 Is the same as $ pr data | lpr 2 $ cal 3 1993 > year Using arguments with redirection Using arguments & options with redirection 3 $ ls -l data > stuff Redirection Examples

  23. 4 $ pr data > lpr 5 $ cat text let > mesg 6 $ pr f1 f2 > f1 1 Create the file f1 Erases f1 if it already exists 2 pr f1 and f2, redirect to f1 Redirection Examples

  24. * is a Meta Char that matches anything $ rm p* $ Unix Commands • rm [Filename1] [Filename2] … • remove files $ rm prog1 mbox $ $ rm * $ • Caution • Unix Assumes You Know What Your Doing • Be Sure You Know What Your Deleting • No Undelete!

  25. Unix Commands • vi [Filename] • Full Screen, Visual Editor • Changes Displayed As They Are Made • Edits A Copy of the File • Changes Must Be Saved $ vi mesg • emacs • http://www.gnu.org/software/emacs/emacs.html

  26. Unix Commands Vi Modes • Command Mode • Start in command mode • Every Key Performs an Editing Command • Insert Mode • Perform Text Entry/Input Insert Mode Command Command Mode Insert Mode ESC Key

  27. Welcome to UNIX This is an example of a text file in vi ~ ~ ~ $ vi mesg Sample vi Edit Session • Start in Command Mode • Press akey for Append After Cursor Command • Enter text (Input Mode) • Press ESC key (Command Mode) • Press :wq followed by Enter key to Save & Exit Wnewtextelcome to UNIX This is an example of a text file in vi ~ ~ :wq $

  28. k h l j Cursor Positioning • Moving the Cursor in Command Mode Key Command wForward One Word b Backward One Word Cntrl-d Scroll Down Cntrl-u Scroll Up Enter Down One Line G Go To Last Line 5G Go To Line 5

  29. Wnewtextelcome to UNIX This is an example of a text file in vi ~ ~ aAppend After Cursor Welcome to UNIXnewtext This is an example of a text file in vi ~ ~ AAppend at End of Line newtextWelcome to UNIX This is an example of a text file in vi ~ ~ iInsert Before Cursor newtextWelcome to UNIX This is an example of a text file in vi ~ ~ IInsert at Beginning of Line newtext Welcome to UNIX This is an example of a text file in vi ~ ~ OOpen New Line Above Cursor o Open New Line Below Cursor R Replace Text (typeover) r Replace One Char Text Input Mode vi Text Input Mode Commands

  30. xDelete One Char X Delete Char Before Cursor Welcome to UNIX This is an example of a text file in vi ~ ~ This is an example of a text file in vi ~ ~ ddDelete One Line Deleting Text • Proceed Any Command with a Number to multiply effect • 4x Delete 4 chars • 5dd Delete 5 lines • 3dw Delete 3 words

  31. xDelete One Char u Undo Last Change Welcome to UIX This is an example of a text file in vi ~ ~ WELcome to UIX 123 This is an example of a text file in vi ~ ~ UUndo All Changes on Line Undo Changes Welcome to UNIX This is an example of a text file in vi ~ ~ Welcome to UNIX This is an example of a text file in vi ~ ~

  32. Saving Your Changes • Command Mode • ZZ Save & Exit vi • :wq Save & Exit vi • :w data Save to a file data • :q! Quit Without Saving Changes • Vi reference Card • http://vh224401.truman.edu/~dbindner/mirror/vi-ref.pdf

  33. Other Goodies... • /string Forward Search for `string` • ?string Backward Search for `string` • n Repeat Search • N Repeat Search in reverse direction • Ctrl-G Display Current Location in File • J Join two lines together • http://www.thomer.com/thomer/vi/vi.html

  34. That’s All ...

More Related