experimental 6:linux file systemLab Environment:
The Red Hat Enterprise Linux 6.0 operating system is installed and is a successful authentication system. There is another unprivileged user student, password student account exists.
Experimental Objectives:
Better understanding of Linux file system fundamentals, including creating and using links, locating files using the Locate and find commands, and archiving and compressing files.
Experimental background:
Every time you start, your system's primary hard drive starts to emit annoying noises.
You suspect that the hard drive may be sanitization, and that the data will be buried with them. Since you did not have a backup of the data before, you decided to manually back up several critical files. Suppose the/tmp directory is located on a different drive, so you decide to store the backup there temporarily.
Experimental Requirements:
1. Use ln to create a soft connection, a hard link, respectively
2. Use DH to view disk usage
3. Use tar, gzip, bzip2 to backup configuration files
The experiment is detailed:
1, use password student login as user student. If you are using a graphical environment, click [Application (Applications)]->[accessories (System Tools)]->[terminal (Terminal)] to open the terminal:
2. Use the CP command to copy the Usr/share/dict/word file to your home directory:
[Email protected] ~]$ cp/usr/share/dict/words.
Note: here '. ' Represents the current directory.
3. View/usr/share/dict/words Information:
[Email protected] ~]$ ls/usr/share/dict/words
-rw-r-r--1 root root 409305 Sep 21:08 linux.words
lrwxrwxrwx 1 root root one Sep 21:08 word, Linux.word
Here the file word is a symbolic link: the first character of the file mode is the ' l ' representing the symbolic link, and the file name includes the "--Linux.word" that shows the link target.
4. Create a symbolic link and a hard link in the home directory, pointing to the words file in your home directory:
[Email protected] ~]$ ln-s Word soft
[[Email protected] ~]$ ln word hard
5.
Test to see if the new connection correctly points to the data in the words.
We use the Head command to display the first 10 lines of the file:
[Email protected] ~]$ head hard soft
We can see that both outputs are the same, which means that our links are created correctly.
6. For a detailed view of two files, compare the differences between the two links:
[Email protected] ~]$ Ls-il hard Soft
84040-rw-r--r--2 Student student 4950996 14:43 hard
84021 lrwxrwxrwx 1 Student student 5, 15:18 soft, words
[Email protected] ~]$ stat hard Soft
File: ' Hard '
size:4950996
blocks:9712
IO block:4096 Regular file
device:fd01h/64769d inode:84040
Links:2
Access: (0644/-rw-r--r--) Uid: (500/student) Gid: (500/student)
Access:2011-08-22 15:22:48.000000000 +0800
Modify:2011-08-22 14:43:10.000000000 +0800
Change:2011-08-22 15:17:55.000000000 +0800
File: ' soft ', ' words '
Size:5
Blocks:2
IO block:4096 Symbolic Link
device:fd01h/64769d inode:84021
Links:1
Access: (0777/lrwxrwxrwx) Uid: (500/student) Gid: (500/student)
Access:2011-08-22 15:36:42.000000000 +0800
Modify:2011-08-22 15:18:35.000000000 +0800
Change:2011-08-22 15:18:35.000000000 +0800
7. Use the DF command to determine the total amount of free space on each file system:
[Email protected] ~]$ DH
[Email protected] ~]$ dh-h
[Email protected] ~]$ dh-h
Compare the differences in the output of those three.
8. Use the TAR command to package the contents of/etc and save in/tmp:
[email protected] ~]$ su
[Email protected] ~]$ tar-cvf/tmp/confbackup.tar/etc
9. View the properties of the compressed file, paying particular attention to the size of the TAR package:
[Email protected] ~]$ Ls-lh/tmp/confbackup.tar
10, use the gzip command to compress the archive file, note the size of this new file:
[Email protected] ~]$ cd/tmp
[Email protected] tmp]$ gzip-v Confbackup.tar
[Email protected] tmp]$ LS-LH confbackup.tar.gz
11, to the file decompression, with bzip2 re-compression, compare the size of the compressed file:
[Email protected] tmp]$ gunzip confbackup.tar.gz
[Email protected] tmp]$ bzip2-v Confbackup.tar
[Email protected] tmp]$ LS-LH confbackup.tar.bz2
12. Logout, clear.
SUM:
1. Theln command creates soft links (symbolic links) and hard links.
Ln-s Create a soft link, ln creates a hard link.
See below for details:
Linux/unix file system, there is so-called link, we can consider it as the alias of the file, and the link can be divided into two types: Hard link and soft link (symbolic link), the hard link means that a file can have multiple names, The soft-link approach is to produce a special file with the content of the file pointing to the location of another file. Hard links exist in the same file system, while soft links can span different file systems.
2,Head command , view the first 10 lines of the file.
3. A packed command, two compression commands .
Package: Tar
Compression: gzip and BZIP2
Compression ratio: TAR<GZIP<BZIP2.
See below for details:
[[email protected] ~]# TAR-CVF/TMP/ETC.TAR/ETC <== package only, do not compress!
[[email protected] ~]# tar-zcvf/tmp/etc.tar.gz/etc <== packaged, compressed with gzip
[[email protected] ~]# tar-jcvf/tmp/etc.tar.bz2/etc <== packaged, bzip2 compressed
# Note that the file name after parameter f is taken by yourself, and we are accustomed to using. Tar as a recognition.
# if the z parameter is added, the. tar.gz or. tgz represent the gzip compressed tar file ~
# If you add the J parameter, use. tar.bz2 as the file name.
# When the above instruction is executed, a warning message is displayed:
freecode:www.cnblogs.com/yym2013