因此,在 Debian 上安装时,似乎遵循官方 MongoDB 安装说明 - 您正走向痛苦的世界。首先,它现在没有正确安装 - 我正在尝试删除所有已安装的 MongoDB 包,以便我可以从头开始。
令人沮丧的是,因为它没有安装干净(大概),它不会卸载。
最初,我使用此处的说明进行安装:http : //docs.mongodb.org/manual/tutorial/install-mongodb-on-debian/
目前,我已经设法删除了除了mongodb-org-server之外的每个包,只是不会去。
尝试删除会导致以下结果:
user@host:/$ sudo apt-get remove mongodb-org-server
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages will be REMOVED:
mongodb-org-server
0 upgraded, 0 newly installed, 1 to remove and 0 not upgraded.
1 not fully installed or removed.
After this operation, 23.9 MB disk space will be freed.
Do you want to continue [Y/n]? y
(Reading database …
Run Code Online (Sandbox Code Playgroud) 我正在sshd(8)
侦听domain
和https
端口上运行。(还有什么可以在这些端口上运行?:)
显然,真正的 DNS(当回退到 TCP 时)和 HTTPS 客户端可能会尝试连接到我的 SSH 服务器,监听这些端口。如何找出它从 DNS/TCP 和 HTTPS/TCP 客户端收到的连接尝试次数?例如,是否有一些模式可以让我搜索服务器的日志,以查找 DNS/TCP 客户端或与 SSH 服务器通信的 HTTPS/TCP 客户端所独有的模式?是否有一些网络工具可以轻松显示这一点?
我已经链接了 OpenBSD/etc/services
及sshd
更高版本,所以我显然对如何在 OpenBSD 上执行此操作感兴趣。但是,如果有一种跨平台的方式来执行此操作,并且不特定于任何单个操作系统,请包含它。
有一个脚本,我可以根据需要启动/停止各种服务。例如 Apache、BIND、MySQL、PostFix、Memcached、Tomcat 等等。
根据脚本等的状态选项,采取各种行动。
对于大多数情况,这很好用:(以 Apache 为例)
if service apache2 status >/dev/null; then
# ... do some action
fi
Run Code Online (Sandbox Code Playgroud)
对于其他人,必须使用其他技巧,例如mysqladmin ping
.
但是,我无法找到任何检查mongodb
.
service mongodb status
Run Code Online (Sandbox Code Playgroud)
它与 MySQL 和 yield具有相同的“疾病”,并且mongodb stop/waiting
即使服务未启动并运行,也评估为 true。
看过mongod
,mongostat
等等,但没有找到任何选项。
一种方法可能是使用ps
或更好地netstat
结合使用grep
或类似的方法,但想知道是否有更好(更原生/更有针对性)的方法来检查状态。也可以 grep for stop/waiting
,但不确定这有多可靠,并猜测它可能会在未来的升级中中断。
是否可以将通常分配给/home
(在 Debian 和 Ubuntu 等发行版中)的目录的功能(完全)赋予另一个目录?例如,如果您可以执行此操作并将其更改为,/xyz
那么所有新的人类拥有的用户目录都将安装在/xyz
(例如,Sally 的桌面路径将/xyz/Sally/Desktop
代替/home/Sally/Desktop
并且/home
不需要存在)。
I'm working on a portable program that saves paths and loads them. If it's used on a different computer with a home directory that isn't at /home
(and consequently there is no /home
, but rather another path with its functionality), then I'll want it to adjust the path to have the proper home directory location in it for the new computer …
在 Z shell 中使用https://unix.stackexchange.com/a/274499/5132的答案中的机制:
(
flock -x 200
echo "test";
) 200>mylockfile2
Run Code Online (Sandbox Code Playgroud)
回报
zsh: parse error near `200'
Run Code Online (Sandbox Code Playgroud)
在 bash 中它可以正常工作。这里可能有什么问题?
我有这个用于在 systemd 下运行服务的单元文件。
[Unit]
Description=Varnish HTTP accelerator log daemon
After=varnish.service
[Service]
User=root
Environment="LOG_FORMAT='\"%{X-Forwarded-For}i\" %u %t \"%r\" %s %b \"%{Referer}i\ %{User-agent}i\"'"
ExecStart=/usr/bin/varnishncsa -a -w /var/log/www/www.my_website_varnish.log -q "ReqHeader ~ '^Host: www.my_website.fr'" -F $LOG_FORMAT
ExecReload=/bin/kill -HUP $MAINPID
[Install]
WantedBy=multi-user.target
Run Code Online (Sandbox Code Playgroud)
如您所见,我在变量中定义日志格式并将其在命令行上传递给程序。这不起作用。
当我启动服务时,它被调用的实际命令行如下所示:
CGroup: /system.slice/varnishncsa.service
??60950 /usr/bin/varnishncsa -a -w /var/log/www/www.my_website_varnish.log -q ReqHeader ~ '^Host: www.my_website' -F "%{X-Forwarded-For}i" "root" /run "" /bin/sh ffd205c41b1e4c1088dac...
Run Code Online (Sandbox Code Playgroud)
正如你所看到的,systemd扩大%u
,%t
,%r
和其他人本身,他们通过在命令行上我的节目之前。这是错误的,而不是我们想要的。
对于它的价值,我正在按照https://wiki.deimos.fr/Nginx_%2B_Varnish_:_Cache_even_in_HTTPS_by_offloading_SSL 上的说明设置 Varnish。但是这个问题首先是让守护进程使用正确的命令行参数运行,而不是我的 Varnish 配置中的一个。
-F
顺便说一下,我正在尝试使用 更改日志格式,因为默认情况下,我的日志中将 127.0.0.1 作为访问者 IP 地址,这是 nginx 的 …
我有时会从curl 或本地文件系统中获取二进制文件。在大多数情况下,损坏的终端可以通过重置来修复。在其他情况下,特别是如果二进制文件很大,终端将卡住几分钟打印输出,如下所示:
又名
c1;2c1;2c1;2c1;2c1;2c1;2c1;2c1;2c1;2c1;2c1;2c1;2c1;2c1;2c1;2c1;2c1;2c1;2c1;2c1;
2c1;2c1;2c1;2c1;2c1;2c1;2c1;2c1;2c1;2c1;2c1;2c1;2c1;2c1;2c1;2c1;2c1;2c1;2c1;2c1;
2c1;2c1;2c1;2c1;2c1;2c1;2c1;2c1;2c1;2c1;2c1;2c1;2c1;2c1;2c1;2c1;2c1;2c1;2c1;2c1;
2c1;2c1;2c1;2c1;2c1;2c1;2c1;2c1;2c1;2c1;2c1;2c1;2c1;
Run Code Online (Sandbox Code Playgroud)
关于这个场景我有三个问题;
cat
在交互式会话中实际防范这种不良行为的情况?我最初的本能是将 cat 包装在一个函数中来检测这一点,但我很快意识到这是相当困难的,而且会有很多边缘情况。
function cat() {
# warn user if
# - argument 1 is a large executable
# - argument 1 to the previous command in the a pipe-chain looks like a large binary
# abort if
# - session is interactive and we are able to detect 2c1 garbage
}
Run Code Online (Sandbox Code Playgroud)
一个实用的解决方案可能是在查看“不安全”输入时始终使用 less (使用 LESSPIPE),但这个问题与寻呼机无关。我知道管子越来越少了。我每天都积极使用它们。也许 less+lesspipe是这个问题的解决方案,less 的作者在大约 20-30 …
每当我su
在我的 Debian 机器上以普通用户身份登录时尝试使用 su 到 root 时,它会默默地失败,将我转回原始用户和 shell。在搜索此问题时,我遇到了一些解决方案,该解决方案解释说,如果我尝试登录的用户在/etc/passwd
. root:x:0:0:root:/root:/bin/bash
.
我可以 su 到 root 的唯一方法是:
su -s /bin/sh
Run Code Online (Sandbox Code Playgroud)
因为它看起来像问题与bash
安装本身,我尝试重新安装bash
使用apt-get install --reinstall bash
,同时作为根用户登录,但错误依然存在。如何仅使用 bash 就可以登录到 root 用户su
?
我只是注意到,如果在输入 root 密码后按 Enter 和被转储回我的原始用户之间的时间跨度内,我尝试按ctrl+ c,su
工作并且我在 bash 中以 root 身份登录。
如果我root
使用 shell登录并/bin/bash
从那里运行,它会返回一个分段错误错误。
我试过跑步/bin/bash -x
。它似乎永远运行打印/opt/spark//bin:/opt/spark//bin:/opt/spark//bin
。当被迫用ctrl+停止时c,它bash
与root
用户一起运行,就好像什么都没发生一样。strace /bin/bash
似乎表明该命令试图/root/.bashrc
一遍又一遍地打开,直到出现段错误。
是否有仅对域名执行 DNS 查找的命令?比如
dns unix.stackexchange.com
which will return151.101.1.69
和gbnjk.com
will return error: domain not found
。
我想在我的终端中打开三个或更多终端选项卡。我想通过 shell 脚本或 shell 命令行以编程方式执行此操作,而不是通过终端仿真器的图形用户界面以交互方式执行此操作。
我该怎么做呢?