Managing files in your home directory involves using one or more easily remembered commands. If you have any familiarity with the now-ancient DOS, you will recognize some of these commands (although their names are different from those you remember). Basic file management operations include paging (reading), moving, renaming, copying, searching, and deleting files and directories. These commands include
• cat filename Outputs contents of filename to display
• less filename Allows scrolling while reading contents of filename
• mv filel file2 Renames filel to file2
• mv file dir Moves file to specified directory
• cp filel file2 Copies filel and creates file2
• rm file Deletes file
• rmdir dir Deletes directory (if empty)
• grep string file(s) Searches through files(s) and displays lines containing matching string
Note that each of these commands can be used with pattern-matching strings known as wildcards or expressions. For example, to delete all files in the current directory beginning with the letters abc, you can use an expression beginning with the first three letters of the desired filenames. An asterisk (*) is then appended to match all these files. Use a command line with the rm command like this:
Linux shells recognize many types of filenaming wildcards, but this is different from the capabilities of Linux commands supporting the use of more complex expressions. You learn more about using wildcards in Chapter 15.
Was this article helpful?