小编Chr*_*ski的帖子

使用绝对路径和相对路径时,符号链接未按预期更新

我正在尝试使用符号链接。我做了一些阅读,发现以下命令:

Creation -> ln -s {/path/to/file-name} {link-name}
Update -> ln -sfn {/path/to/file-name} {link-name}
Deletion -> rm {link-name}
Run Code Online (Sandbox Code Playgroud)

创建和删除工作正常。但是更新不起作用。执行此命令后,符号链接无效。

我在这里和那里都读过,无法更新/覆盖符号链接。所以网络上有矛盾的信息。谁是对的?如果可以更新/覆盖符号链接,我该如何实现?

更新

这是我的目录结构:

~/scripts/test/
~/scripts/test/remote_loc/
~/scripts/test/remote_loc/site1/
~/scripts/test/remote_loc/site1/stuff1.txt
~/scripts/test/remote_loc/site2/
~/scripts/test/remote_loc/site2/stuff2.txt
~/scripts/test/remote_loc/site2/
~/scripts/test/remote_loc/site3/stuff3.txt
Run Code Online (Sandbox Code Playgroud)

~/scripts/test/,当我执行:

ln -s /remote_loc/site1 test_link
Run Code Online (Sandbox Code Playgroud)

atest_link已创建,我可以创建,ls -l但它似乎已损坏(与我上面在问题中所说的相反)。

如何执行多目录级链接?

symbolic-link update

232
推荐指数
4
解决办法
33万
查看次数

查找 systemd 单元文件服务的位置

有许多不同的地方可以放置 systemd 单元文件。仅给定服务名称,是否有一种快速简便的方法可以询问 systemd 从何处读取服务声明?

systemd

110
推荐指数
2
解决办法
11万
查看次数

发送数据后如何自动关闭netcat连接?

我正在从脚本执行以下命令:

echo '{"hostUp": true}' | sudo /usr/local/bin/netcat localhost 8001

但是,netcat 客户端会无限期地保持打开状态。发送此数据后如何关闭连接?

linux command-line-interface netcat echo

39
推荐指数
2
解决办法
7万
查看次数

在单个规则中 iptables 多个源 IP

我想在 iptables(如果可能)中创建一个使用多个源 IP 地址的规则。这可能吗?

iptables

37
推荐指数
5
解决办法
12万
查看次数

如何从 rsync 输出已更改文件的列表?

我在 bash 脚本中使用 rsync 来保持几个服务器和 NAS 之间的文件同步。我遇到的一个问题是尝试生成在 rsync 期间已更改的文件列表。

这个想法是,当我运行 rsync 时,我可以将已更改的文件输出到文本文件中 - 更希望内存中有一个数组 - 然后在脚本存在之前,我可以对已更改的文件运行 chown 。

有没有人找到一种方法来执行这样的任务?

# specify the source directory
source_directory=/Users/jason/Desktop/source

# specify the destination directory
# DO NOT ADD THE SAME DIRECTORY NAME AS RSYNC WILL CREATE IT FOR YOU
destination_directory=/Users/jason/Desktop/destination

# run the rsync command
rsync -avz $source_directory $destination_directory

# grab the changed items and save to an array or temp file?

# loop through and chown each changed file
for changed_item …
Run Code Online (Sandbox Code Playgroud)

scripting bash rsync

33
推荐指数
3
解决办法
6万
查看次数

如何诊断 SSH 远程端口转发不起作用

使用该命令,ssh -v -R 2255:localhost:2255 root@example.com我试图找出为什么远程端口转发不起作用,直到我意识到GatewayPorts yes主机的 sshd_config 中不存在该命令。一旦我添加了它,它就成功了。

有什么办法可以诊断出这种情况吗?

SSH 甚至输出以下内容(没有 GatewayPorts yes):

debug1: Remote connections from LOCALHOST:2255 forwarded to local address localhost:2255
debug1: channel 0: new [client-session]
debug1: Requesting no-more-sessions@openssh.com
debug1: Entering interactive session.
debug1: pledge: network
debug1: client_input_global_request: rtype hostkeys-00@openssh.com want_reply 0
debug1: remote forward success for: listen 2255, connect localhost:2255
debug1: All remote forwarding requests processed
Run Code Online (Sandbox Code Playgroud)

networking ssh

7
推荐指数
2
解决办法
1万
查看次数

Apache 虚拟主机指向错误的文档根目录

我正在运行 Linux mint,并尝试使用 apache 设置虚拟主机。

我在 /etc/apache2/sites-available/ 中添加了以下文件(它是从该目录中的“默认”文件复制的)

<VirtualHost *:80>
        ServerAdmin webmaster@localhost
        ServerName testsite.dev
        DocumentRoot /home/chris/Projects/web/testsite

        <Directory /home/chris/Projects/web/testsite>
            Allow from all
            AllowOverride All
            Order allow,deny
        </Directory>

        ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
        <Directory "/usr/lib/cgi-bin">
            AllowOverride None
            Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
            Order allow,deny
            Allow from all
        </Directory>

        ErrorLog ${APACHE_LOG_DIR}/error.log

        # Possible values include: debug, info, notice, warn, error, crit,
        # alert, emerg.
        LogLevel warn

        CustomLog ${APACHE_LOG_DIR}/access.log combined

        Alias /doc/ "/usr/share/doc/"
        <Directory "/usr/share/doc/">
            Options Indexes MultiViews FollowSymLinks
            AllowOverride None
            Order deny,allow
            Deny from all
            Allow …
Run Code Online (Sandbox Code Playgroud)

virtualhost apache-2.2

5
推荐指数
1
解决办法
2万
查看次数

如何指定日志源自 systemd/journald 的fail2ban 过滤器/监狱?

我已经运行 nginx 并记录到 systemd/journald。

\n

如何指定来自 systemd 单元的日志源?

\n

man jail.conf我看到的后端列出为:

\n
       systemd\n              uses  systemd  python library to access the systemd journal.\n              Specifying logpath is not valid for this backend and instead\n              utilises  journalmatch from the jails associated filter con\xe2\x80\x90\n              fig.\n
Run Code Online (Sandbox Code Playgroud)\n

和:

\n
       journalmatch\n              specifies  the systemd journal match used to filter the journal entries. See journalctl(1) and systemd.journal-fields(7) for matches syntax and\n              more details on special journal fields. This option is only valid for the systemd …
Run Code Online (Sandbox Code Playgroud)

fail2ban systemd journald

5
推荐指数
0
解决办法
5124
查看次数