Mem:2.0G 428M 138M 145M 1.4G 1.1G
Swap:0B 0B 0B
懂得 bash shell 以及敕令的类型
bash shell 共有下面几类敕令:
- 别号,比如
ll
- 关键字,比如
if
- 函数 (用户自定义函数,比如
genpasswd
) - 内置敕令,比如
pwd
- 外部文件,比如
/bin/date
type 敕令 和 command 敕令 可以用来查看敕令类型:
date
和 free
都是外部敕令,而 file_repl
是 sudo -i /shared/takes/master.replication
的别号。你不克不及直接履行像 file_repl
如许的别号:
$ ssh user@remote file_repl
在 Unix 体系上无法直接经由过程 ssh 客户端履行 bash 别号
要解决这个问题可以用下面办法运行 ssh 敕令:
ssh
敕令选项:
-t
:强迫分派伪终端。可以用来在长途机械上履行随便率性的 基于屏幕的法度榜样,有时这异常有效。当应用-t
时你可能会收到一个类似 “bash: cannot set terminal process group (-1): Inappropriate ioctl for device. bash: no job control in this shell .” 的缺点。
bash shell 的选项:
-i
:运行交互 shell,如许 shell 才能运行 bash 别号。-c
:要履行的敕令取之于第一个非选项参数的敕令字符串。若在敕令字符串后面还有其他参数,这些参数会作为地位参数传递给敕令,参数大年夜$0
开端。
总之,要运行一个名叫 ll
的 bash 别号,可以运行下面敕令:
$ ssh -t vivek@server1.cyberciti.biz -ic 'll'
结不雅为:
Tue Dec 26 09:02:50 UTC 2017
Running bash aliases over ssh based session when using Unix or Linux ssh cli
下面是我的一个 shell 脚本的例子:
#!/bin/bash
I="tags.deleted.410"
O="/tmp/https.www.cyberciti.biz.410.url.conf"
box="vivek@server1.cyberciti.biz"
[!-f "$I" ] && { echo "$I file not found。"
推荐阅读
年前最后一场技巧盛宴 | 1月27日与京东、日记易技巧大年夜咖畅聊智能化运维成长趋势! 碰到过很多同业、客户问>>>详细阅读
本文标题:通过ssh会话执行bash别名
地址:http://www.17bianji.com/lsqh/40432.html
1/2 1