Читать книгу Linux Bible - Christopher Negus - Страница 171
Exercises
ОглавлениеUse these exercises to test your knowledge of using the vi
(or vim)
text editor, commands for finding files (locate
and find
), and commands for searching files (grep
). These tasks assume that you are running a Fedora or Red Hat Enterprise Linux system (although some tasks work on other Linux systems as well). If you are stuck, solutions to the tasks are shown in Appendix B (although in Linux, there are often multiple ways to complete a task).
1 Copy the /etc/services file to the /tmp directory. Open the /tmp/services file in vim, and search for the term WorldWideWeb. Change that to read World Wide Web.
2 Find the following paragraph in your /tmp/services file (if it is not there, choose a different paragraph) and move it to the end of that file.# Note that it is presently the policy of IANA to assign a single well-known # port number for both TCP and UDP; hence, most entries here have two entries # even if the protocol doesn't support UDP operations. # Updated from RFC 1700, "Assigned Numbers" (October 1994). Not all ports # are included, only the more common ones.
3 Using ex mode, search for every occurrence of the term tcp (case-sensitive) in your /tmp/services file and change it to WHATEVER.
4 As a regular user, search the /etc directory for every file named passwd. Redirect error messages from your search to /dev/null.
5 Create a directory in your home directory called TEST. Create files in that directory named one, two, and three that have full read/write/execute permissions on for everyone (user, group, and other). Construct a find command to find those files and any other files that have write permission open to ″others″ from your home directory and below.
6 Find files under the /usr/share/doc directory that have not been modified in more than 300 days.
7 Create a /tmp/FILES directory. Find all files under the /usr/share directory that are more than 5MB and less than 10MB and copy them to the /tmp/FILES directory.
8 Find every file in the /tmp/FILES directory, and make a backup copy of each file in the same directory. Use each file's existing name, and just append .mybackup to create each backup file.
9 Install the kernel-doc package in Fedora or Red Hat Enterprise Linux. Using grep, search inside the files contained in the /usr/share/doc/kernel-doc* directory for the term e1000 (case-insensitive) and list the names of the files that contain that term.
10 Search for the e1000 term again in the same location, but this time list every line that contains the term and highlight the term in color.