自制Linux终端锁屏工具
时间:2022-05-27 00:15:00|栏目:Linux|点击: 次
很多时候我们不能一直守护在自己的电脑旁边,而且有些文件并不想让别人知道。那么这时候来个锁屏,是再合适不过的了。今天分享一个自制的锁屏工具,如下。
准备
•操作系统 : 我这里是ElementaryOS虚拟机 + XShell 远程登录工具
•Shell语言 : 我使用的是默认的Bash Shell
•其他小工具 :
◦fortune:系统随机的从语库中选出一句英文成语。
◦cowsay : 在终端界面上显示出一个奶牛的语句框,配合管道连接上fortune,效果完美!
代码
#!/bin/bash
#scriptname:locktty
#writed by :Marksinoberg
#description : just for protecting our message when we leave away. And we can set the password every time.
reset;clear #清除屏幕
info="Please input the password you will use later!"
cowsay $info
read mypassword
echo "Screen will locked in 7 seconds!"
sleep 7
clear
#!/bin/bash
#scriptname:locktty
#writed by :javalee
#script start...
reset;clear #清除屏幕
info="Please input the password you will use later!"
cowsay $info
read mypassword
echo "Screen will locked in 7 seconds!"
sleep 7
clear
#加上这个倒记时的小东东,;)
trapper () { #建立个函数
trap ' ' 2 3 20 #忽略CTRL+C CTRL+ CTRL+Z信号
}
while : #进入死循环
do
trapper #调用函数
printf "nnnnnnnntttPlease enter unlock code:" | cowsay
stty -echo #屏蔽输入的字符
read input
case $input in
$mypassword)
printf "tt Hello $USER,Today is $(date +%T)n"
stty echo
break ;; #输入正确,挑出循环回到命令行
*)echo "Do not check my files,please! See as follows:"
sleep 3
clear
continue ;; #否则,继续循环
esac
done
您可能感兴趣的文章
- 06-17Linux进程信号的发送和保存方法
- 06-17Linux卸载自带jdk并安装新jdk版本的图文教程
- 06-17Linux系统中卸载与安装JDK的详细教程
- 06-17Linux系统配置NAT网络模式的详细步骤(附图文)
- 06-17Linux中的计划任务(crontab)使用方式
- 06-17Apache配置域名跳转的详细步骤
- 06-17Linux fsync系统调用方式
- 06-17Linux磁盘扩容lvm的使用详解
- 06-17Linux与Windows跨平台文件共享的实现方案
- 06-17Linux如何实现给/根目录扩容


阅读排行
推荐教程
- 05-27阿里云linux服务器安全设置(防火墙策略等)
- 05-27Linux命令学习总结之rmdir命令
- 10-12Linux系统 Centos7.4手动在线升级到Centos7.7
- 05-27SecureCRT中文显示乱码问题的解决方法
- 05-10Ubuntu系统安装ANSYS2021R1
- 06-12linux系统SSL证书部署https单/多站点
- 05-10ANSYS2021R1安装方法Linux centos Ubuntu系统
- 05-27apache密码生成工具htpasswd使用详解
- 11-07Clash Linux服务器安装详细教程
- 05-27Apache下开启SSI配置使html支持include包含的方法


