Linux命令——mesg

参考:图解Linux命令之--mesg命令

Linux mesg命令

前言

在看一个脚本~/.profile 的时候发现了mesg命令以及一个奇怪用法

~/.profile 

# ~/.profile: executed by Bourne-compatible login shells.

if [ "$BASH" ]; then
  if [ -f ~/.bashrc ]; then
    . ~/.bashrc
  fi
fi

mesg n || true
View Code

meag命令

语法

mesg [ny]

功能

用来设置当前终端的写权限,即是否让其他用户向本终端发信息

参数

n 不允许其他用户将信息直接显示在你的屏幕上。

y 允许其他用户将信息直接显示在你的屏幕上。

演示

 1) 如果mesg n设置为n的话,用write,talk命令时,会显示write permission turned off提示

 2) 两个终端通过write命令发送讯息的过程

mesg n || true中 || true啥意思?

参考:What does the || true do in the mesg command do?

It forces the whole expression to exit with a success status: The operator "||" means the command to the right is only executed if the command beforehand exited with a "failure status" (exit code != 0). The "true" command does nothing but exit with exit code 0 which means "success".

简单翻一下

mesg n || true可以保证这句话退出状态是success。只有当||前面那句话执行失败,即mesg n 执行失败时,||后面才会执行。相当于||前面那句话退出码!0,现在变成0.

 

 

转载于:https://www.cnblogs.com/kelamoyujuzhen/p/9801285.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值