我目前正在设置一个相当复杂的 bash 配置,它将在多台机器上使用。我试图找出是否可以确定我是通过 SSH 登录还是在本地计算机上登录。例如,通过这种方式,我可以根据该事实设置一些别名。就像别名一样halt,restart因为停止远程服务器可能不是最好的做法。
到目前为止我所知道的是,环境变量SSH_CLIENT是在我通过 ssh 登录时设置的。不幸的是,当我使用sudo -s. 我也知道我可以向 sudo 传递一个参数,指示 sudo 将我所有的环境变量复制到新的 shell 环境中,但是如果我不想这样做,还有其他方法吗?
如果我想显示分配给 eth1 的 IP 地址,我该如何在 Bash 中执行此操作?
我想更改默认的 shell env
并chsh -s /bin/zsh以root用户身份运行,
但是出现了一条错误消息:chsh: PAM authentication failed。
我发现这个线程http://ubuntuforums.org/showthread.php?t=1702833
但答案并没有解决我的问题
任何帮助,将不胜感激
这是/etc/pam.d/chsh的内容
#
# The PAM configuration file for the Shadow `chsh' service
#
# This will not allow a user to change their shell unless
# their current one is listed in /etc/shells. This keeps
# accounts with special shells from changing them.
auth required pam_shells.so
# This allows root to change user shell without being
# prompted for a password
auth …Run Code Online (Sandbox Code Playgroud) 我是 Linux 新手,正在尝试由主机预先配置的 Ubuntu 10.04。
当我使用预先配置的帐户登录(SSH)时,shell 提示为:user@hostname:~$
向上箭头滚动最近的 shell 命令列表,制表符完成按预期工作。
但是,当我创建一个帐户并使用该帐户登录 (SSH) 时,shell 提示只是“$”,向上箭头仅打印一个控制字符 (^[[A)。
谁能告诉我如何设置我的提示、制表符完成和向上箭头行为?当我向上箭头时,我得到控制字符这一事实让我认为我的帐户(或会话)处于某种我不熟悉的模式。
我知道 bashrc 中存储了 tab-completion 代码,我可以取消注释,但这似乎没有任何影响,即使在注销并重新登录后也是如此。
当我使用新帐户通过 SSH 登录时,我是否处于某种奇怪的模式,或者是否只需要设置一些会话/帐户设置,并且如果我知道要查找的内容,就可以在 Internet 上的任何地方找到信息?
我必须从文件夹中删除 200 000 个文件(所有这些文件),而且我不想删除文件夹本身。
使用 rm,我收到“参数列表太长”错误。我试图用 xargs 做一些事情,但我不是一个 Shell Guy,所以它不起作用:
find -name * | xargs rm -f
Run Code Online (Sandbox Code Playgroud) 运行grpck检查组,我看到这些错误:
'twinky' is a member of the 'foo' group in /etc/group but not in /etc/gshadow
'dipsy' is a member of the 'foo' group in /etc/group but not in /etc/gshadow
'laalaa' is a member of the 'foo' group in /etc/group but not in /etc/gshadow
'po' is a member of the 'foo' group in /etc/group but not in /etc/gshadow
'noonoo' is a member of the 'foo' group in /etc/group but not in /etc/gshadow
'dipsy' is a member of the 'foo' …Run Code Online (Sandbox Code Playgroud) 我目前正在使用rsync一个脚本,该脚本将 PHP 应用程序从登台部署到生产服务器。方法如下:
rsync -rzai --progress --stats --ignore-times --checksum /tmp/app_export/ root@app.com:/var/www/html/app/
Run Code Online (Sandbox Code Playgroud)
这当前正在输出正在比较的每个文件的列表(项目中的每个文件),但我希望它只输出修改过的文件,所以我可以运行它并--dry-run选择检查每个部署是否只更新所需的文件。
注意:到目前为止我能做的最好的是grep fcst结果,但我正在寻找一个rsync选项,我确定它在那里,但我在手册页中找不到它。
提前致谢!
我在https://www.gnupg.org/documentation/manuals/gnupg/Unattended-GPG-key-generation.html#Unattended-GPG-key-generation方法中发现无需用户交互即可生成 gpg 密钥,但它没有似乎工作。
我的脚本是:
#!/usr/bin/env bash
rm -rf .gnupg
mkdir -m 0700 .gnupg
touch .gnupg/gpg.conf
chmod 600 .gnupg/gpg.conf
tail -n +4 /usr/share/gnupg2/gpg-conf.skel > .gnupg/gpg.conf
touch .gnupg/{pub,sec}ring.gpg
cat >.gnupg/foo <<EOF
%echo Generating a basic OpenPGP key
Key-Type: RSA
Key-Length: 2048
Subkey-Type: RSA
Subkey-Length: 2048
Name-Real: User 1
Name-Comment: User 1
Name-Email: user@1.com
Expire-Date: 0
Passphrase: kljfhslfjkhsaljkhsdflgjkhsd
%pubring foo.pub
%secring foo.sec
# Do a commit here, so that we can later print "done" :-)
%commit
%echo done
EOF
gpg2 --verbose …Run Code Online (Sandbox Code Playgroud) 我使用 samba4 域帐户登录我的笔记本电脑。我想尝试zsh一下,但由于我的用户不在,/etc/passwd我发现chsh找不到我的用户。谁能建议我如何改变我的login_shell?
我看不到我的任何东西ldap.conf,nssswitch.conf或任何/etc/pam.d,帮助...
看着域控制器,我想也许我可以使用 samba-tool,但我没有看到任何帮助指向正确方向的帮助......
我们有一组包含 lucene 索引的目录。每个索引都是不同文件类型的混合(按扩展名区分),例如:
0/index/_2z6.frq
0/index/_2z6.fnm
..
1/index/_1sq.frq
1/index/_1sq.fnm
..
Run Code Online (Sandbox Code Playgroud)
(大约有 10 个不同的扩展名)
我们想按文件扩展名获得总数,例如:
.frq 21234
.fnm 34757
..
Run Code Online (Sandbox Code Playgroud)
我尝试了 du/awk/xargs 的各种组合,但发现做到这一点很棘手。
shell ×10
linux ×5
bash ×2
ssh ×2
accounts ×1
deployment ×1
filesystems ×1
gpg ×1
ip ×1
ip-address ×1
networking ×1
remove ×1
rsync ×1
samba4 ×1
terminal ×1
ubuntu ×1