intro unix/linux 11


Published on

user files: locate | print | archive

Published in: Technology
  • Be the first to comment

  • Be the first to like this

No Downloads
Total Views
On Slideshare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide

intro unix/linux 11

  1. 1. Lesson 11-Locating, Printing, and Archiving User Files
  2. 2. Overview <ul><li>Creating a long file. </li></ul><ul><li>Splitting long files. </li></ul><ul><li>Locating files with find. </li></ul><ul><li>Printing a file. </li></ul><ul><li>Archiving files. </li></ul>
  3. 3. Creating a Long File <ul><li>The “ls –R ~” command is used to list all the files contained in the user’s home directory. </li></ul><ul><li>The “cut –c range of characters ~/file name” command is used to read a particular number of characters from each line in a file. </li></ul><ul><li>The “cat –n file name” command is used to add numbers to the left of all lines in a copy of the file. </li></ul>
  4. 4. Splitting Long Files <ul><li>The “split” utility is used to read a long file and break up the contents into a series of small files of specified size. </li></ul><ul><li>Each small file has an extension starting with “aa” and going through the alphabet as far as needed to hold a copy of the whole file. </li></ul>
  5. 5. Splitting Long Files Splitting Long Files into Pieces
  6. 6. Splitting Long Files <ul><li>Reassembling the files: </li></ul><ul><ul><li>The “cat filename*” command is used to read all the small files and output data that matches the original long file. </li></ul></ul><ul><ul><li>The last part of the file names, such as “aa”, “ab”, etc., is in ASCII order. </li></ul></ul><ul><ul><li>The ASCII order is used by the shell for the filenames when it replaces the * in the command line. </li></ul></ul>
  7. 7. Locating File with Find <ul><li>The “find” utility is used to locate a particular file in several directories. </li></ul><ul><li>The find utility displays the output and any error message that is appropriate. </li></ul><ul><li>The pathnames of files and information about directories that cannot be examined because of their assigned permissions are also displayed by the find utility. </li></ul>
  8. 8. Locating File with Find <ul><li>The command to be given is “find ~ -name filename –print”. </li></ul><ul><li>The “~” specifies the target starting point directory. </li></ul><ul><li>The “–print” specifies that the full pathname of each occurrence of the file(s) matching the selection criterion should be output to the screen. </li></ul>
  9. 9. Locating File with Find <ul><li>Locating files by owner. </li></ul><ul><li>Locating and acting on files by owner. </li></ul><ul><li>Locating additional options. </li></ul><ul><li>Acting on all files in a directory tree. </li></ul>
  10. 10. Locating Files by Owner <ul><li>The “ls –ld /directory name/$USER” command is used to determine if the user has a directory with the same name as the login name in a particular directory. </li></ul><ul><li>The “find” utility can also be used to identify files owned by a particular user. </li></ul><ul><li>The output of the find utility can be redirected to a file or a printer. </li></ul>
  11. 11. Locating Files by Owner Command Line Interpretation find Utility
  12. 12. Locating and Acting on Files by Owner <ul><li>The find utility can also be used to remove located files, change file permissions, or employ any shell file-manipulation command. </li></ul><ul><li>The “-exec” option is used with the utility to execute any command utilizing the file names that are selected. </li></ul>
  13. 13. Locating and Acting on Files by Owner Using the find Utility to Locate Files by Owner
  14. 14. Locating Additional Options Additional Options
  15. 15. Acting on all Files in a Directory Tree <ul><li>The find utility can be used as an agent to go through the directory tree recursively and execute another utility on all files. </li></ul><ul><li>The utility shows a user to search through the specified directory trees, based on a variety of criteria, and perform actions on the located files. </li></ul>
  16. 16. Printing a File <ul><li>Printing the output of a pipeline. </li></ul><ul><li>Printing multiple copies. </li></ul><ul><li>Adding a title line to the banner page. </li></ul><ul><li>Checking the status of print jobs. </li></ul><ul><li>Canceling a print request. </li></ul>
  17. 17. Printing the Output of a Pipeline <ul><li>A pipe can be used to connect the output of a utility as an input to the print utility. </li></ul><ul><li>The “col –bx” and the “colcrt” utilities are used to remove control characters that are of value to the terminal. </li></ul>
  18. 18. Printing Multiple Copies <ul><li>Any of the following commands can be used to print multiple copies of a file: </li></ul><ul><ul><ul><li>lp –n (number of copies to be printed in numeric value) file name. </li></ul></ul></ul><ul><ul><ul><li>lpr -# (number of copies to be printed in numeric value) file name. </li></ul></ul></ul>
  19. 19. Adding a Title Line to the Banner Page <ul><li>A banner page, also called the burst page, contains information about the printer and the user issuing the print request. </li></ul><ul><li>The “lp –t‘numbers file’ file name” or the “lpr –Pprinter –J’numbers file’ file name” command can be used to add a title and print the file. </li></ul>
  20. 20. Adding a Title Line to the Banner Page <ul><li>The “lp –dprinter –ttitle filename” or the “lpr –Pprinter –J’title’ filename” are the two formats of the print commands. </li></ul>
  21. 21. Checking the Status of Print Jobs <ul><li>All print requests are administered by a spooler. </li></ul><ul><li>A spooler is a program that receives print requests from multiple users and sends jobs one at a time to the printer. </li></ul><ul><li>The spooler makes it possible for the system to process simultaneous print job requests for several users. </li></ul><ul><li>The “lpstat” or the “lpq –Pprinter username” command can be use to examine the queue. </li></ul>
  22. 22. Canceling a Print Request <ul><li>The “cancel” or the “lprm” command can be used to remove jobs from the queue. </li></ul><ul><li>On a Linux system, all printing jobs owned by the user are removed from the queue. </li></ul><ul><li>On a UNIX system, the “–u” option is used to indicate jobs owned by the user. </li></ul>
  23. 23. Archiving Files <ul><li>Archiving files on floppy disks. </li></ul><ul><li>Creating archives with tar. </li></ul>
  24. 24. Archiving Files on Floppy Disks <ul><li>Copying a file to and from a floppy: </li></ul><ul><ul><li>Mtools is a set of programs that facilitate the copying of files to a floppy drive without going through the process of mounting the drive. </li></ul></ul><ul><ul><li>The “mcopy” command is used to copy a file to and from a floppy. </li></ul></ul><ul><ul><li>The command requires two arguments the file name from the current directory, and a:, which is an agreed name for the floppy. </li></ul></ul>
  25. 25. Archiving Files on Floppy Disks <ul><li>Copying a file to and from a floppy (continued): </li></ul><ul><ul><li>Multiple files can be copied by using the * sign in place of a particular filename. </li></ul></ul><ul><ul><li>Attributes such as permissions are not included in the copy. </li></ul></ul><ul><ul><li>When a file is copied from a floppy, the permissions for the newly copied file may not match its original permissions. </li></ul></ul><ul><ul><li>When the mcopy command creates a new file on the system, the default permissions for the new file are applied. </li></ul></ul>
  26. 26. Archiving Files on Floppy Disks <ul><li>Removing files and directories from a floppy: </li></ul><ul><ul><li>The “mdel” command is used to delete files. </li></ul></ul><ul><ul><li>The mdel command requires an argument, the name of the file(s) to be deleted. </li></ul></ul><ul><ul><li>The “mdeltree” command is used to delete directories. </li></ul></ul><ul><ul><li>This command requires one argument, the name of the directory to be deleted. </li></ul></ul>
  27. 27. Archiving Files on Floppy Disks <ul><li>Formatting a floppy disk: </li></ul><ul><ul><li>The “mformat” command is used to format a floppy. </li></ul></ul><ul><ul><li>The floppy is formatted in the DOS format. </li></ul></ul>
  28. 28. Creating Archives with tar <ul><li>The “tar” (tape archiving) utility is used extensively for making archive files on most systems. </li></ul><ul><li>The utility can be used to create a single file, called archive, which contains the files in a directory tree and all information about each file. </li></ul>
  29. 29. Creating Archives with tar <ul><li>The command used to create a tar archive is “tar –cvf filename.tar”. </li></ul><ul><li>The command instructs tar to create an archive in verbose mode and use a file to hold the archive. </li></ul><ul><li>The dot (.) is the source directory, from which all files are archived. </li></ul><ul><li>The “tar –tf filename” can be used to list the contents of the tar archive. </li></ul>
  30. 30. Creating Archives with tar <ul><li>Extracting files from an archive: </li></ul><ul><ul><li>The extension “.tar” is called a “tarball”. </li></ul></ul><ul><ul><li>A tarball can be moved, mailed, or placed on portable media. </li></ul></ul><ul><ul><li>The “tar –xvf filename.tar” is used to extract the directory tree from the archive. </li></ul></ul><ul><ul><li>The command provides instructions to extract the structure from the archive in verbose mode, from a file. </li></ul></ul>
  31. 31. Summary <ul><li>The split utility is used to break the contents of a long file into a series of small files. </li></ul><ul><li>The lp and the lpr utilities manage files directed to the printer. </li></ul><ul><li>The find utility searches through a directory tree for files based on specific criteria, and then takes action on each identified file. </li></ul>
  32. 32. Summary <ul><li>The mtools utility facilitates the copying of files to and from a floppy drive using a DOS-formatted floppy. </li></ul><ul><li>The tar utility is used to make an archive of a directory tree or a file. </li></ul><ul><li>The archive can be stored on permanent media, sent to a remote machine, or just used to move a structure from one location in a system to another. </li></ul>
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.