Files & Filesystems / Perform Basic File Management
Subtitles of the Movie
Exam objective 1.103.3 has a weight of 3. Candidates should be able to use basic Linux line commands to manage files and directories. You should be able to copy, move, and remove files and directories. This includes copying multiple files and directories recursively, and removing files and directories recursively. You need to be able to specify file and directory names, using wild cards and using the Find command to locate and act on files based on name, type, size, or time. The most basic file management command is LS, which is short of short for List. By default, it lists all the files and directories in the current directory, except the hidden files. Hidden files are the ones that have a period as their first character. The A option, for All, includes the hidden files. Here you can see the two hidden names that are always present, and it also shows a hidden file that I created earlier. The L option lists the file and directory names in their long form, which includes permission information. If you name a directory, it simply lists its contents unless you use the D Option to tell it to list directory names, not contents. And you can combine the options on the command line. The Touch command can be used to update the access and modification dates of a file. If the named file does not exist, it creates an empty file. You can see that it did. The CP command copies files. You just name the from file and the to file and it makes an exact duplicate. You can see here that it did. If you name an existing directory as the destination, the file is copied into it with the same name it started with. This copied the test file into the VAR directory, and you can see that it did. MV is the Move command. It works like the copy command, except the original source file is deleted. It's mostly used to rename files and directories, as in this case. You can also delete files. RM is short for Remove. Be careful how you use the Remove command; it is final. You can create directories with mkdir, which is short for Make Directory. You can see the new directory here, and you can get rid of an empty directory with the rmdir, which is short for Remove Directory. The time will come when you need to find something, and you can find things with the Whereis command. This example shows you the location of the program named LS, and the location of its MAN page. If the source code for it had also been installed, it would have shown that, too. The Find command can be used to report the location of all the files matching specific criteria. The first argument here always specifies where the Find command is to start its search. In this example, the search starts with the root directory and searches all subdirectories. Then comes the specification of what you're looking for. In this example it's an exact match on the name CAT. The Find command has lots of options. You can search by date, type, size, file ownership, and a number of other things. There. It finally found all CATs. This example searches from the root directory for a depth of no more than four directories for everything that has a name starting with M and ending with N, and it must be a directory. Notice that the name with wild cards is in quotes. That's a safety measure to keep the shell from expanding the name before it gets to the Find command. This command looks in the directory tree of the Temp directory for files named Fred and executes the Remove command on each one of them. The pair of empty braces represent the name of the file found and the command must be followed by a backslash and semicolon, so it will work inside the shell correctly. Here are some file exercises. Look up the MAN page for LS and try some of the options. It has lots of them, and you'll be using this command often, so you need to be familiar with what it will do. In particular, try the upper case F option, which tags directory names with a slash. The Copy command can be used in a number of ways. Experiment with the R option, which is recursive. It copies entire directory structures, and what happens when you name two files followed by the name of a directory? Use mkdir to create a directory and Touch to create a file inside it, then try to use rmdir to erase the directory. Why won't that work? Try using RM with the R Option, the recursive option, on the directory name. Now what happened? Use the Find command to remove all the files in the Temp directory that are more than one week old. Also, when a program crashes, it dumps a large file named CORE. Are there any of those on your system? Locate the manual page and the executable code for the Find command.
Tutorial Information
| Course: | Linux Professional Institute: Level 2 |
| Author: | Arthur Griffith |
| SKU: | 33894 |
| ISBN: | 1-934743-79-8 |
| Release Date: | 2008-07-21 |
| Duration: | 7.5 hrs / 113 lessons |
| Captions: | Available on CD and Online University |
| Compatibility: |
Vista/XP/2000, OS X, Linux QuickTime 7, Flash 8 |
VTC Sign up & Benefits
- Unlimited Access
- 98,729 Video Tutorials (23,265 free)
- Video Available as Flash or QuickTime
- Over 1026 Courses
- $30 for One Month Access
- Multi-User Discounts Available
United States 