链接命令:ln

ln -s [原文件] [目标文件]
命令英文原意:link
功能描述:生成链接文件
选项:-s 创建软链接,也叫符号链接

  硬链接特征:

  1.拥有相同的i节点和存储block块,可以看做是同一个文件

  2.可通过i节点识别

  3.不能跨分区

  4.不能针对目录使用

[root@localhost ~]# ls
anaconda-ks.cfg binaries binaries.tar.gz initial-setup-ks.cfg test123
[root@localhost ~]# ln /root/anaconda-ks.cfg /tmp/ana.hard
[root@localhost ~]# ls -i /root/anaconda-ks.cfg /tmp/ana.hard --两个文件的i节点是相同的
25165890 /root/anaconda-ks.cfg 25165890 /tmp/ana.hard

  软链接特征:

  1.类似Windows快捷方式

  2.软链接拥有自己的i节点和block块,但是数据块儿中只保存原文件的文件名和i节点号,并没有实际的文件数据

  3.软链接的权限都为777,但是实际的权限需要看原文件的权限

  4.修改任意文件,另一个都改变

  5.删除原文件,软链接不能使用(原文件必须写绝对路径,否则原文件和目标文件必须在同一目录下)

[root@localhost ~]# ls
anaconda-ks.cfg binaries binaries.tar.gz initial-setup-ks.cfg test123 test3
[root@localhost ~]# ln -s /root/test3 /tmp/test3.soft
[root@localhost ~]# ln /root/test3 /tmp/test3.hard
[root@localhost ~]# ll -i
总用量 20172
25165890 -rw-------. 2 root root 2165 5月 13 16:15 anaconda-ks.cfg
17070804 drwxr-xr-x. 14 501 games 175 6月 17 2017 binaries
25288936 -rw-r--r--. 1 root root 20647102 6月 22 2017 binaries.tar.gz
25165908 -rw-r--r--. 1 root root 2213 5月 13 16:17 initial-setup-ks.cfg
8546987 drwxr-xr-x. 3 root root 19 6月 15 16:59 test123
25708548 -rw-r--r--. 2 root root 0 6月 16 11:15 test3
[root@localhost ~]# ll -i /tmp/
总用量 256
17070621 -rw-------. 1 root root 2165 6月 15 16:22 ana
17071146 -rw-------. 1 root root 2165 5月 13 16:15 anaconda-ks.cfg
25165890 -rw-------. 2 root root 2165 5月 13 16:15 ana.hard
25521547 drwxr-xr-x. 3 root root 19 6月 15 16:25 test1
8388685 drwxr-xr-x. 3 root root 19 6月 15 16:24 test3
25708548 -rw-r--r--. 2 root root 0 6月 16 11:15 test3.hard
17071129 lrwxrwxrwx. 1 root root 11 6月 16 11:16 test3.soft -> /root/test3
[root@localhost ~]# echo 111 >> /root/test3
[root@localhost ~]# cat /tmp/test3.soft
111
[root@localhost ~]# cat /tmp/test3.hard
111
[root@localhost ~]# echo 2222 >> /tmp/test3.soft
[root@localhost ~]# cat /tmp/test3.hard
111
2222
[root@localhost ~]# cat /root/test3
111
2222
[root@localhost ~]# echo 3333 >> /tmp/test3.hard
[root@localhost ~]# cat /root/test3
111
2222
3333
[root@localhost ~]# cat /tmp/test3.soft
111
2222
3333
[root@localhost ~]# rm -rf /root/test3
[root@localhost ~]# cat /tmp/test3.hard
111
2222
3333
[root@localhost ~]# cat /tmp/test3.soft
cat: /tmp/test3.soft: 没有那个文件或目录

  

Linux常用命令——链接命令的更多相关文章

  1. ## 本篇文章对linux常用的一些命令做一下总结,如有需要补充以及不懂得地方,请在下方留言 适合于linux初学者,以及对命令掌握不牢的用来备忘

    本篇文章对linux常用的一些命令做一下总结,如有需要补充以及不懂得地方,请在下方留言 适合于linux初学者,以及对命令掌握不牢的用来备忘一,磁盘管理1.显示当前目录位置 pwd2.切换目录 cd ...

  2. Linux 常用的压缩命令有 gzip 和 zip

    Linux 常用的压缩命令有 gzip 和 zip,两种压缩包的结尾不同:zip 压缩的后文件是 *.zip ,而 gzip 压缩后的文件 *.gz 相应的解压缩命令则是 gunzip 和 unzip ...

  3. Linux学习笔记(三)Linux常用命令:链接命令和文件查找命令

    一.链接命令 ln -s [原文件] [目标文件] (link) -s意为创建软连接 硬链接和软连接 硬链接的特点: (1)拥有相同的 i 结点和block块,可以看作是同一个文件 (2)可以通过 i ...

  4. linux上ln链接命令详细说明

    ln是linux中又一个非常重要命令,它的功能是为某一个文件在另外一个位置建立一个同不的链接,这个命令最常用的参数是-s,具体用法是:ln –s 源文件 目标文件. 当我们需要在不同的目录,用到相同的 ...

  5. Linux下ln链接命令详解

    ln是linux中又一个非常重要命令,它的功能是为某一个文件在另外一个位置建立一个不同的链接,这个命令最常用的参数是-s,具体用法是:ln –s 源文件 目标文件. 当我们需要在不同的目录,用到相同的 ...

  6. linux常用60条命令 转

    Linux必学的60个命令   Linux提供了大量的命令,利用它可以有效地完成大量的工作,如磁盘操作.文件存取.目录操作.进程管理.文件权限设定等.所以,在Linux系统上工作离不开使用系统提供的命 ...

  7. 入门学习Linux常用必会命令实例详解

    Linux提供了大量的命令,利用它可以有效地完成大量的工作,如磁盘操作.文件存取.目录操作.进程管理.文件权限设定等.所以,在Linux系统上工作离不开使用系统提供的命令.要想真正理解Linux系统, ...

  8. linux中的链接命令

    ln 解释 命令名称:ln 命令英文原意:link 命令所在路径:/bin/ln 执行权限:所有用户 功能描述:生成链接文件 语法 ln -s [源文件] [目标文件] -s 创建软链接 示例 # 创 ...

  9. LINUX常用配置及命令

    一.   Fedora系统配置 1.      [设置网卡IP] 步骤如下: 1)     用root用户登陆,打开/etc/sysconfig/network-scripts/ifcfg-eth0文 ...

随机推荐

  1. field load respone data

    问题: AJAX 使用谷歌浏览器 POST 请求报如下错误 field load respone data 使用 火狐 浏览器就正常 调试1: 发现其实我请求的回调函数能打印出来数据,但是,在netw ...

  2. Android 4.4.2 动态加入JNI库方法记录 (一 JNI库层)

    欢迎转载,务必注明出处.http://blog.csdn.net/wang_shuai_ww/article/details/44456755 本篇是继<s5p4418 Android 4.4. ...

  3. 123 c#调用oracle存储过程返回数据集 --通过oracle存储过程返回数据集

    c#调用oracle存储过程返回数据集 2008-12-20 10:59:57|  分类: net|字号 订阅   CREATE OR REPLACE PACKAGE pkg_tableTypeIS  ...

  4. 【Silverlight】Bing Maps学习系列(四):使用图钉层(Pushpin layer)及地图图层(MapLayer)(转)

    [Silverlight]Bing Maps学习系列(四):使用图钉层(Pushpin layer)及地图图层(MapLayer) 如果我们需要在Bing Maps中加入一个小图钉标记,该如何实现了? ...

  5. 获取view宽高

    在oncreate()中利用view.getWidth()或是view.getHeiht()来获取view的宽和高,看似没有问题,其实他们去得值是0,并不是你想要的结果? 这是为什么呢? 在调用onc ...

  6. gitlab smtp设置

    QQ exmail gitlab_rails['smtp_enable'] = true gitlab_rails['smtp_address'] = "smtp.exmail.qq.com ...

  7. Linux 下編輯 PDF 檔的工具(PDF editor under Linux)(转载)

    转自:http://www.gtwang.org/2011/05/linux-pdf.html PDF 檔雖然是一個跨平台的檔案格式,但 Adobe 只有提供免費的 Adobe Reader,要看 P ...

  8. bzoj 1753: [Usaco2005 qua]Who's in the Middle【排序】

    --这可能是早年Pascal盛行的时候考排序的吧居然还是Glod-- #include<iostream> #include<cstdio> #include<algor ...

  9. 最近我总结的常用mate标签-常用mate标签

    昨天开始上班  ,今天晚上不是太忙 ,来写篇博客了 meta元素共有三个可选属性(http-equiv.name和scheme)和一个必选属性(content),content定义与 http-equ ...

  10. 生成自签名ca 证书 使nginx 支持https

    创建服务器私钥,命令会让你输入一个口令:$ openssl genrsa -des3 -out server.key 1024创建签名请求的证书(CSR):$ openssl req -new -ke ...