软连接ln_软连接 没有l-程序员宅基地

技术标签: linux  

软连接ln

[root@even tmp]# ln --help
Usage: ln [OPTION]... [-T] TARGET LINK_NAME (1st form)
or: ln [OPTION]... TARGET (2nd form)
or: ln [OPTION]... TARGET... DIRECTORY (3rd form)
or: ln [OPTION]... -t DIRECTORY TARGET... (4th form)
In the 1st form, create a link to TARGET with the name LINK_NAME.
In the 2nd form, create a link to TARGET in the current directory.
In the 3rd and 4th forms, create links to each TARGET in DIRECTORY.
Create hard links by default, symbolic links with --symbolic.
When creating hard links, each TARGET must exist.

Mandatory arguments to long options are mandatory for short options too.
--backup[=CONTROL] make a backup of each existing destination file
-b like --backup but does not accept an argument
-d, -F, --directory allow the superuser to attempt to hard link
directories (note: will probably fail due to
system restrictions, even for the superuser)
-f, --force remove existing destination files
-n, --no-dereference treat destination that is a symlink to a
directory as if it were a normal file
-i, --interactive prompt whether to remove destinations
-s, --symbolic make symbolic links instead of hard links
-S, --suffix=SUFFIX override the usual backup suffix
-t, --target-directory=DIRECTORY specify the DIRECTORY in which to create
the links
-T, --no-target-directory treat LINK_NAME as a normal file
-v, --verbose print name of each file before linking
--help display this help and exit
--version output version information and exit

The backup suffix is~’, unless set with --suffix or SIMPLE_BACKUP_SUFFIX.The version control method may be selected via the --backup option or throughthe VERSION_CONTROL environment variable. Here are the values:`

none, off never make backups (even if --backup is given)
numbered, t make numbered backups
existing, nil numbered if numbered backups exist, simple otherwise
simple, never always make simple backups

Report bugs to <[email protected]>.

创建

ln -s [含有访问目标的文件或者目录] [自定义的软连接名称,可以是目录也可以是文件]

例子:/u01/testmount有脚本,有个程序需要访问这些脚本,但无法直接访问/u01/testmount

程序写死了只能访问/tmp目录,那么在/tmp下创建一个软连接,实际映射到/u01/testmount

[oracle@even testmount]$ pwd
/u01/testmount
[oracle@even testmount]$ ls -l
total 8
-rw-r--r-- 1 oracle oinstall 9 Jun 3 15:13 1.sh
-rw-r--r-- 1 oracle oinstall 6 Jun 3 15:13 2.sql
-rw-r--r-- 1 oracle oinstall 0 Jun 3 15:13 3.txt

[oracle@even testmount]$ **ln -s /u01/testmount /tmp/ln_access**
[oracle@even testmount]$ ll
total 8
-rw-r--r-- 1 oracle oinstall 9 Jun 3 15:13 1.sh
-rw-r--r-- 1 oracle oinstall 6 Jun 3 15:13 2.sql
-rw-r--r-- 1 oracle oinstall 0 Jun 3 15:13 3.txt
[oracle@even testmount]$ cd /tmp
[oracle@even tmp]$ ll
lrwxrwxrwx 1 oracle oinstall 14 Jun 3 16:16 ln_access -> /u01/testmount
[oracle@even tmp]$ cd ln_access
[oracle@even ln_access]$ ll
total 8
-rw-r--r-- 1 oracle oinstall 9 Jun 3 15:13 1.sh
-rw-r--r-- 1 oracle oinstall 6 Jun 3 15:13 2.sql
-rw-r--r-- 1 oracle oinstall 0 Jun 3 15:13 3.txt

压缩和解压

tar 打包默认不会备份目录下软连接指向的内容,需要加h参数,但要估算软连接指向的目录和文件的数据量。

定期对/tmp目录进行打包压缩然后清理

[root@even home]# tar -czvf tmp.tar.gz /tmp
tar: Removing leading `/’ from member names

[root@even home]# tar -tf tmp.tar.gz 发现安装包里没有软连接的内容
tmp/
tmp/hsperfdata_oracle/
tmp/hsperfdata_oracle/15778
tmp/hsperfdata_oracle/25244
tmp/hsperfdata_oracle/15849
tmp/hsperfdata_oracle/15713
tmp/.font-unix/
tmp/ln_access
tmp/.gdmDDWXH0
tmp/.X11-unix/
tmp/.X0-lock
tmp/gconfd-root/
tmp/gconfd-root/lock/
tmp/gconfd-root/lock/ior
tmp/.ICE-unix/
tmp/keyring-UyqNLP/
tmp/orbit-root/
tmp/orbit-root/bonobo-activation-register.lock
tmp/orbit-root/bonobo-activation-server-ior
tmp/keyring-UGeWOK/
tmp/ssh-yWwGqo3814/

打包时加上h参数解决软连接没有复制的情况,但如果软连接的目录是个海量目录就不建议了!!!

[root@even home]# tar -chzvf tmp.tar.gz /tmp

[root@even home]# tar -tf tmp.tar.gz
tmp/
tmp/hsperfdata_oracle/
tmp/hsperfdata_oracle/15778
tmp/hsperfdata_oracle/25244
tmp/hsperfdata_oracle/15849
tmp/hsperfdata_oracle/15713
tmp/.font-unix/
tmp/ln_access/
tmp/ln_access/2.sql
tmp/ln_access/1.sh
tmp/ln_access/3.txt
tmp/.gdmDDWXH0
tmp/.X11-unix/
tmp/.X0-lock
tmp/gconfd-root/
tmp/gconfd-root/lock/
tmp/gconfd-root/lock/ior
tmp/.ICE-unix/
tmp/keyring-UyqNLP/
tmp/orbit-root/
tmp/orbit-root/bonobo-activation-register.lock
tmp/orbit-root/bonobo-activation-server-ior
tmp/keyring-UGeWOK/
tmp/ssh-yWwGqo3814/

查找软连接

[root@even tmp]# ls -l|grep ^l
lrwxrwxrwx 1 oracle oinstall 14 Jun 3 16:16 ln_access -> /u01/testmount

[root@even /]# find /tmp -type l
/tmp/ln_access

删除软连接

进入查找到软连接的目录,利用rm -f当作文件删除即可

cd /tmp

rm -f ln_access

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/yipiaoyiyu/article/details/117528279

智能推荐

NYOJ 70-程序员宅基地

文章浏览阅读59次。View Code 1 2 /* 3 思路: 4 比如:n=100,m=5 5 100是有20个5组成的 6 因此100减去一个5是95 ,减去两个是90 7 ...减去19个是0. 8 则是5 倍数的数有二十个(不是m的倍数的不能分解出m) 9 ,从这二十个10 数中各分解出一个5则有20个511 这二十个数变为12 20,19,18,...,1即 20的阶乘13 相当...

语音数字 v2.5_. 3t@u,。-程序员宅基地

文章浏览阅读4.7k次。为了快速输入身份证号码、电话号码、银行账号等数字时确保正确又不用检查, 输入数字时同时发声是很好的方法,所以我制作了这个”语音数字“脚本,非常好用。 注:本脚本需配合”0—9和点“的语音文件一起使用,可下载类似读数软件从中提取。;----------------------------; 语言数字 v2.0 By FeiYue;; 说明:将本脚本和语音文件放在同一目录编译即可;----------------------------#NoEnv#SingleInstance force_. 3t@u,。

进化算法(遗传算法、粒子群算法、差分算法)—— Rosenbrock函数优化_差分进化算法和粒子群-程序员宅基地

文章浏览阅读1.1k次。三种进化算法:遗传算法、粒子群算法、差分算法,以及它们再Rosenbrock函数优化问题中的应用。这是一篇学习笔记,可能有纰漏。_差分进化算法和粒子群

Sora普通人理解的原理——帧处理_sora每生成一帧需要消耗-程序员宅基地

文章浏览阅读817次,点赞21次,收藏9次。Sora普通人理解的原理——帧处理_sora每生成一帧需要消耗

如何训练专属的OCR文字识别模型_tesseract 中文训练模型-程序员宅基地

文章浏览阅读5.6k次。随着文档数字化的发展,光学字符识别 (OCR) 变得越来越流行,OCR 在处理基于图像的文档中发挥着至关重要的作用。基于电商APP移动端的业务场景,是否也能利用OCR来为用户提供更加便利的购物体验呢。_tesseract 中文训练模型

随便推点

jar包冲突问题_jar:file:/d:/program%20files/apache-maven-3.5.4/re-程序员宅基地

文章浏览阅读472次。slf4j的jar包冲突。SLF4J: Class path contains multiple SLF4J bindings.SLF4J: Found binding in [jar:file:/D:/apache-maven-3.5.3/repository/ch/qos/logback/logback-classic/1.1.11/logback-classic-1.1.11.jar!/..._jar:file:/d:/program%20files/apache-maven-3.5.4/repository/io/springfox/spri

Mybatis自动去重,以及id vs result_mybatis去重-程序员宅基地

文章浏览阅读3.6k次。今天大部分时间一直被一个问题困扰:当程序执行某Mapper.java的一个list函数,明明底层的SQL语句和ELK中的日志都显示返回了376条记录(如图1,图2),最后程序却只返回了209条。图1: 日志显示此list函数返回了376条记录图2: 日志有376条相关的ResultSet记录我一度以为这跟今天尝试使用的MyBatis分页插件PageHelper(使用了MySql的limit)有关,后面发现不是。即使不使用PageHelper,问题依旧。而且我发现一点:实际返回的209条记录里,似乎_mybatis去重

idea Translation IP 地址无法访问_翻译失败: 访问ip地址不在可访问ip列表-程序员宅基地

文章浏览阅读1.5k次。本人首先按照网上的方法申请了百度翻译 API,配置后出现IP无法访问,后选择以下方法解决。配置如图:参考:https://blog.csdn.net/ilyucs/article/details/106603368_翻译失败: 访问ip地址不在可访问ip列表

MySQL的安装和远程连接(Linux)_mysql 安装 远程-程序员宅基地

文章浏览阅读67次。MySQL安装sudo apt-get install mysql-server-5.6设置密码本地连接MySQL数据库root用户登录 :mysql -u root -p show databases;#显示数据库use mysql;#进入数据库show tables;#显示数据表远程连接数据库安装MySQL workbench连接数据库服务器,如果出现10061错误 cd /etc/mysql/ sudo vim my.cnf #打开MySQL配置文件将 _mysql 安装 远程

如何视觉隐藏网页内容,只让它们在屏幕阅读器中可用?_如何视觉隐藏网页内容,只让它们在屏幕阅读器中可用?-程序员宅基地

文章浏览阅读1.5k次。1.display:none;的缺陷 搜索引擎可能认为被隐藏的文字属于垃圾信息而被忽略 屏幕阅读器(是为视觉上有障碍的人设计的读取屏幕内容的程序)会忽略被隐藏的文字。 2. visibility: hidden ;的缺陷 这个大家应该比较熟悉就是隐藏的内容会占据他所应该占据物理空间 3.overflow:hidden;一个比较合理的方法 .texthidden { display:bl_如何视觉隐藏网页内容,只让它们在屏幕阅读器中可用?

Spring Cloud源码分析之Eureka篇第七章:续约_eureka续约源码分析-程序员宅基地

文章浏览阅读1.1k次,点赞2次,收藏3次。在文章《Spring Cloud源码分析之Eureka篇第四章:服务注册是如何发起的 》的分析中,我们知道了作为Eureka Client的应用启动时,在com.netflix.discovery.DiscoveryClient类的initScheduledTasks方法中,会做以下几件事:周期性更新服务列表;周期性服务续约;服务注册逻辑;本章学习的是周期性服务续约的相关代码,对应用如..._eureka续约源码分析

推荐文章

热门文章

相关标签