龙空技术网

跟老韩学Ubuntu Server 2204-alias指令实例

韩公子的Linux大集市 91

前言:

今天小伙伴们对“ubuntu服务器命令”大约比较关切,各位老铁们都需要了解一些“ubuntu服务器命令”的相关内容。那么小编同时在网上收集了一些关于“ubuntu服务器命令””的相关资讯,希望看官们能喜欢,姐妹们一起来了解一下吧!

alias实例-hanyw

alias指令的基本格式如下。

alias 名称=值

此处的值需要使用双引号或者单引号包裹起来。

实例1 设置问候语

hanyw@web01:~$ alias nihao='echo "Hi,你好,今天的天气真不错"'hanyw@web01:~$ nihao Hi,你好,今天的天气真不错

实例2 执行某脚本

hanyw@web01:~$ cat >./sysInfo.sh<<hanyw> uptime> vmstat 1 10> hanywhanyw@web01:~$ chmod 700 ./sysInfo.shhanyw@web01:~$ ls -lhrt ./sysInfo.sh-rwx------ 1 hanyw hanyw 19 Jul  8 12:21 ./sysInfo.shhanyw@web01:~$ pwd/home/hanywhanyw@web01:~$ ll /home/hanyw/sysInfo.sh -rwx------ 1 hanyw hanyw 19 Jul  8 12:21 /home/hanyw/sysInfo.sh*hanyw@web01:~$  /home/hanyw/sysInfo.sh 12:22:52 up 7 min,  1 user,  load average: 0.10, 0.30, 0.18procs -----------memory---------- ---swap-- -----io---- -system-- ------cpu----- r  b   swpd   free   buff  cache   si   so    bi    bo   in   cs us sy id wa st 0  0      0 1222756  34064 421732    0    0   799   607  291  729  3  6 91  0  0 0  0      0 1222756  34064 421768    0    0     0     0   65  121  0  0 100  0  0 0  0      0 1222756  34064 421768    0    0     0     0   67  132  0  0 100  0  0 0  0      0 1222756  34064 421768    0    0     0     0   70  129  0  0 100  0  0 0  0      0 1222756  34064 421768    0    0     0     0   71  132  0  0 100  0  0 0  0      0 1222756  34064 421768    0    0     0     0   65  128  0  0 100  0  0 1  0      0 1222756  34072 421760    0    0     0    28   70  129  0  0 100  0  0 0  0      0 1222756  34072 421768    0    0     0     0   65  118  0  0 100  0  0 0  0      0 1222756  34072 421768    0    0     0     0   68  125  0  0 100  0  0 0  0      0 1222756  34072 421768    0    0     0     0   65  122  0  0 100  0  0hanyw@web01:~$ alias sysInfo="/home/hanyw/sysInfo.sh"hanyw@web01:~$ sysInfo  12:23:19 up 7 min,  1 user,  load average: 0.11, 0.28, 0.18procs -----------memory---------- ---swap-- -----io---- -system-- ------cpu----- r  b   swpd   free   buff  cache   si   so    bi    bo   in   cs us sy id wa st 0  0      0 1222756  34072 421768    0    0   749   569  277  692  3  6 92  0  0 0  0      0 1222756  34072 421768    0    0     0     0   77  135  0  0 100  0  0 0  0      0 1222756  34072 421768    0    0     0     0   70  130  0  0 100  0  0 0  0      0 1222756  34072 421768    0    0     0     0   70  133  0  0 100  0  0 0  0      0 1222756  34072 421768    0    0     0     0   72  132  0  0 100  0  0 0  0      0 1222756  34072 421768    0    0     0     0   67  125  0  0 100  0  0 1  0      0 1222756  34072 421768    0    0     0     0   71  135  0  0 100  0  0 0  0      0 1222756  34072 421768    0    0     0     0   66  115  0  0 100  0  0 0  0      0 1222756  34072 421768    0    0     0     0   62  118  0  0 100  0  0 0  0      0 1222756  34072 421768    0    0     0     0   67  126  0  0 100  0  0

标签: #ubuntu服务器命令