|28-08-2009, 06:32 AM
Trả Lời: n/a
Tạo symbolic link và hard link trong Linux
1. Create a symbolic link in UNIX
A symbolic link is a pointer to another file or directory. It can be used just like the original file or directory. A symbolic link appears in a long listing (ls -l) with a reference to the original file/directory. A symbolic link, as opposed to a hard link, is required when linking from one filesystem to another and can be used within a filesystem as well.
To create a symbolic link, the syntax of the command is similar to a copy or move command: existing file first, destination file second. For example, to link the directory /export/space/common/archive to /archive for easy access, use:
ln -s /export/space/common/archive /archive
To link the runtime control script /etc/init.d/httpd to /etc/rc2.d/S77httpd, use:
ln -s ../init.d/httpd S77httpd
Thi du 1:
De tao symbolic lien ket tu thu muc /vz4/private/200 den /vz/private/200
ta danh lenh sau nhu sau:
Chung ta khong can phai tao thu muc ten la: 200 trong thu muc /vz/private
Xoa Symbolic link:
de xoa lien ket symbolic link tren ta chi can go lenh sau:
2.Create a hard link in UNIX
A hard link is a reference to a file or directory that appears just like a file or directory, not a link. Hard links only work within a filesystem. In other words, don’t use hard links between mounted filesystems. A hard link is only a reference to the original file, not a copy of the file. If the original file is deleted, the information will be lost.
To create a hard link of the file /export/home/fred/stuff to /var/tmp/thing, use:
ln /export/home/fred/stuff /var/tmp/thing
The syntax for creating a hard link of a directory is the same.
To create a hard link of /var/www/html to /var/www/webroot, use:
ln /var/www/html /var/www/webroot