日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > linux >内容正文

linux

Linux终端怎么锁屏,自制Linux 终端 锁屏防窃助手

發布時間:2025/3/15 linux 24 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Linux终端怎么锁屏,自制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 "\n\n\n\n\n\n\n\n\t\t\tPlease enter unlock code:" | cowsay

stty -echo #屏蔽輸入的字符

read input

case $input in

$mypassword)

printf "\t\t 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

運行演示

程序運行開始:

mark@mark:~/temp/myscripts$ ./lockscreen.sh

______________________________________

/ Please input the password you \

\ will use later! /

--------------------------------------

\ ^__^

\ (oo)\_______

(__)\ )\/\

||----w |

|| ||

123

Screen will locked in 7 seconds!

由于靜態文本沒辦法顯示程序執行過程中的動態效果,所以直接看解鎖界面吧

當我們輸入不正確的密碼的時候,系統會提示輸入錯誤,以及一個幽默的“警告”

___________________________

/ \

\ Please enter unlock code: /

---------------------------

\ ^__^

\ (oo)\_______

(__)\ )\/\

||----w |

|| ||

Do not check my files,please! See as follows:

_________________________________________

/ Q: Why is it that the more accuracy you \

| demand from an interpolation |

| |

| function, the more expensive it becomes |

| to compute? A: That's the Law of Spline |

\ Demand. /

-----------------------------------------

\ ^__^

\ (oo)\_______

(__)\ )\/\

||----w |

|| ||

當我們密碼輸入正確的時候,如下:

___________________________

/ \

\ Please enter unlock code: /

---------------------------

\ ^__^

\ (oo)\_______

(__)\ )\/\

||----w |

|| ||

Hello mark,Today is 06:35:05

結語

代碼還是很簡單的,僅僅用到了shell腳本語法的幾個小命令。希望我這個腳本能拋磚引玉,打開你的思路,做出更好的鎖屏小腳本!

:-)

總結

以上是生活随笔為你收集整理的Linux终端怎么锁屏,自制Linux 终端 锁屏防窃助手的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。