玩转Redhat Linux 8.0系列 | 制作文件间的链接

素材来源:Redhat Linux 8.0培训教材《RH124》、《RH134》和《RH294》

玩了5-6年的Linux,现在再来温习一遍RHCE培训教材,按照指导完成实验并与大家分享。

附上汇总贴:玩转Redhat Linux 8.0系列 | 合集_热爱编程的通信人的博客-CSDN博客


1 使用ssh命令, 以student用户身份登录servera。系统已配置为使用SSH密钥来进行身份验证,因此不需要提供密码。

[student@workstation ~]$ ssh student@servera
student@servera's password: 
Activate the web console with: systemctl enable --now cockpit.socket

This system is not registered to Red Hat Insights. See https://cloud.redhat.com/
To register this system, run: insights-client --register

Last login: Fri May 19 09:49:02 2023 from 172.16.190.1
[student@servera ~]$ 

2 为现有文件
/home/student/files/source.file创建硬链接/home/student/backups/source.backup。

2.1 查看文件
/home/student/files/source.file的链接数。

[student@servera ~]$ ls -l files/source.file 
-rw-rw-r--. 1 student student 5 May 19 09:56 files/source.file
[student@servera ~]$ 

2.2 创建硬链接
/home/student/backups/source.backup。将它链接到文件/home/student/files/source.file。

[student@servera ~]$ ln /home/student/files/source.file /home/student/backups/source.backup
[student@servera ~]$ 

2.3 验证原始的
/home/student/files/source.file和新链接的文件/home/student/backups/source.backup的链接数。两个文件的链接数应该都是2。

[student@servera ~]$ ls -l /home/student/files/
total 4
-rw-rw-r--. 2 student student 5 May 19 09:56 source.file
[student@servera ~]$ ls -l /home/student/backups/
total 4
-rw-rw-r--. 2 student student 5 May 19 09:56 source.backup
[student@servera ~]$ 

3 创建指向servera上的/tmp目录的软链接/home/student/tempdir。

3.1 创建软链接/home/student/tempdir, 并将它链接到/tmp。

[student@servera ~]$ ln -s /tmp /home/student/tempdir
[student@servera ~]$ 

3.2 使用ls -l命令验证新创建的软链接。

[student@servera ~]$ ls -l /home/student/tempdir
total 0
lrwxrwxrwx. 1 student student 4 May 19 09:59 tmp -> /tmp
[student@servera ~]$ 

4 从servera退出。

[student@servera ~]$ exit
logout
Connection to servera closed.
[student@workstation ~]$ 

猜你喜欢

转载自blog.csdn.net/guolianggsta/article/details/130784311