RedHatLinux033 Experiment Part 3 file and directory operations estimated time: 1 hour 30 minutes objective: familiar with functions, syntax and some basic file and directory control operations. Exercise effective combination of these commands to complete the general user task test start point: Install the RedHatLinux executable system, there is a non-privileged user student, password: student First step: directory and file organization scenarios/scenarios in your ho
Red Hat Linux 033 lab section
Test 3
File and directory operations
Estimated time: 1 hour 30 minutes
Objective: To be familiar with functions, syntax, and some basic file and directory control operations.
Exercise effectively combining these commands to complete Common User Tasks
Start Point of the experiment: The Red Hat Linux runable system is installed, and a unprivileged user, student, password: student
Step 1: Directory and file organization
Scenario/plot
There are a series of files in your home directory. You have decided to sort them out. you plan to generate some new subdirectories, and copy and move these files to the appropriate directories according to your plan. In addition, these files are not all useful and some are to be deleted.
Task:
1. log on to tty1.
2. After you log on to the system, you will enter your home directory. You can use "Print working directory" to check this situation
$ Pwd
/Home/student
3. Use each of the following commands to check if you have any files in your home directory:
$ Ls
$ Ls-
$ Ls-al
Why does the first and second commands return different numbers of files?
What is the maximum file returned by the third command in your current home directory?
Is there a subdirectory in your home directory?
4. Now you use touch to create a file for subsequent steps. How does this extension work in the following command?
Will be discussed in subsequent chapters. Now, just enter the following line (use the characters including curly braces {} and underline between the set and the Set)
$ Touch {report, memo, graph }_{ sep, oct, nov, dec }_{ a, B, c} {1, 2, 3}
5. Run the ls command to check the result of the last command. You will find that it generated 108
New empty file (you do not need to count ). These files represent the data files that you will use in this step. If you do not see these files, ask the instructor for help. Without these files, the subsequent steps of the test will not work.
6. To organize your files, you must first create some new directories and use mkdir to directly
Create subdirectories:
$ Mkdir a_reports
$ Mkdir September October November December
Then use ls to check your work.
7. Use the following command to generate some additional subdirectories in your new directory.
$ Cd a_reports
To switch to the directory, follow these steps:
$ Mkdir 1 2 3
Use ls to check the three new subdirectories named 1, 2, and 3 under your subdirectory a_reports.
8. First, remove all reports with "B" from the home directory and group them by month. It is a good method to verify the complex wildcard mode to be used. This ensures that it operates on the correct file. If you want to use this wildcard mode, you can use a harmless command to replace your command.
$ Cd
$ Ls-l * dec? B?
You will see nine "December" and "B" files listed, and move one of them to the December directory:
$ Mv graph_dec_b1 December
Use the following statement to move the rest:
$ Mv * dec? B? December
List the contents of the December directory to verify whether the mobile operation is successful:
$ Ls-l December
Total 0
-Rw-r -- 1 student 0 Sep 18 17:45 graph_dec_b1
-Rw-r -- 1 student 0 Sep 18 17:45 graph_dec_b2
-Rw-r -- 1 student 0 Sep 18 17:45 graph_dec_b3
-Rw-r -- 1 student 0 Sep 18 17:45 memo_dec_b1
-Rw-r -- 1 student 0 Sep 18 17:45 memo_dec_b2
-Rw-r -- 1 student 0 Sep 18 17:45 memo_dec_b3
-Rw-r -- 1 student 0 Sep 18 17:45 report_dec_b1
-Rw-r -- 1 student 0 Sep 18 17:45 report_dec_b2
-Rw-r -- 1 student 0 Sep 18 17:45 report_dec_b3