Книга: Fedora™ Unleashed, 2008 edition
Managing Files with the Shell
Managing Files with the Shell
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 recognize some of these commands (although their names differ from those you remember). Basic file management operations include paging (reading), moving, renaming, copying, searching, and deleting files and directories. These commands include the following:
? cat filename
— Outputs contents of filename to display
? less filename
— Allows scrolling while reading contents of filename
? mv file1 file2
— Renames file1
to file2
? mv file dir
— Moves file to specified directory
? cp file1 file2
— Copies file1
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:
$ rm abc*
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 11, "Automating Tasks."
NOTE
Learn more about using expressions by reading the ex
or grep
manual pages.
- Navigating Through the File System
- Managing Files with the Shell
- Working with Compressed Files
- Use Essential Commands from the /bin and /sbin Directories
- Use and Edit Files in the /etc Directory
- Protect the Contents of User Directories — /home
- Use the Contents of the /proc Directory to Interact with the Kernel
- Work with Shared Data in the /usr Directory
- Temporary File Storage in the /tmp Directory
- Access Variable Data Files in the /var Directory
- Use Essential Commands from the
- Access Variable Data Files in the
- Managing Passwords
- 14. Files and File I
- Thin Client Shell
- Managing encryption recovery policy
- Temporary File Storage in the
- Protect the Contents of User Directories —
- 4.4.4 The Dispatcher
- About the author
- Chapter 7. The state machine
- Appendix E. Other resources and links