stty(set tty)命令用于显示和修改当前注册的终端的属性。

该命令是一个用来改变并打印终端行设置的常用命令。

stty -a #将所有选项设置的当前状态写到标准输出中

old_stty_settings=stty -g #保存当前设置

stty “$old_stty_settings” #恢复当前设置

stty -echo #禁止回显,当您在键盘上输入时,并不出现在屏幕上

stty echo #打开回显

stty raw #设置原始输入

stty -raw #关闭原始输入

stty igncr #开启忽略回车符

stty -igncr#关闭忽略回车符

stty iuclc #开启在命令行下,禁止输出大写的方法

stty -iuclc #恢复在命令行下,禁止输出大写的方法

stty olcuc #开启在命令行下禁止输出小写

stty -olcuc#恢复在命令行下禁止输出小写

stty size #打印出终端的行数和列数

stty -a #将所有选项设置的当前状态写到标准输出中

stty -a

输出

speed 38400 baud; rows 31; columns 60; line = 0;
intr = ^C; quit = ^\; erase = ^?; kill = ^U; eof = ^D;
eol = <undef>; eol2 = <undef>; swtch = <undef>; start = ^Q;
stop = ^S; susp = ^Z; rprnt = ^R; werase = ^W; lnext = ^V;
discard = ^O; min = 1; time = 0;
-parenb -parodd -cmspar cs8 -hupcl -cstopb cread -clocal
-crtscts
-ignbrk -brkint -ignpar -parmrk -inpck -istrip -inlcr -igncr
icrnl ixon -ixoff -iuclc -ixany -imaxbel iutf8
opost -olcuc -ocrnl onlcr -onocr -onlret -ofill -ofdel nl0
cr0 tab0 bs0 vt0 ff0
isig icanon iexten echo echoe echok -echonl -noflsh -xcase
-tostop -echoprt echoctl echoke -flusho -extproc

stty -echo #禁止回显,当您在键盘上输入时,并不出现在屏幕上

输入命令也不会显示在屏幕上

stty -echo

stty echo #打开回显 从键盘输入的命令会显示在屏幕上

stty echo

stty raw #设置原始输入

打开以后的效果就是排版上会有些不同

stty raw

例如在运行下面的命令 会这样 排版不清楚,这就是原始输入被打开了

stty -a
speed 38400 baud; rows 32; columns 122; line = 0;
intr = ^C; quit = ^\; erase = ^?; kill = ^U; eof = ^D; eol = <undef>; eol2 = <undef>; swtch = <undef>; start = ^Q;
stop = ^S; susp = ^Z; rprnt = ^R; werase = ^W; lnext = ^V; discard = ^O; min = 1; time = 0;
-parenb -parodd -cmspar cs8 -hupcl -cstopb cread -clocal -crtscts
-ignbrk -brkint -ignpar -parmrk -inpck -istrip -inlcr -igncr -icrnl -ixon -ixoff -iuclc -ixany -imaxbel -iutf8
-opost -olcuc -ocrnl onlcr -onocr -onlret -ofill -ofdel nl0 cr0 tab0 bs0 vt0 ff0
-isig -icanon iexten echo echoe echok -echonl -noflsh -xcase -tostop -echoprt echoctl echoke -flusho -extproc

stty -raw #关闭原始输入

stty -raw

在运行上面的命令

stty -a
speed 38400 baud; rows 31; columns 60; line = 0;
intr = ^C; quit = ^\; erase = ^?; kill = ^U; eof = ^D;
eol = <undef>; eol2 = <undef>; swtch = <undef>; start = ^Q;
stop = ^S; susp = ^Z; rprnt = ^R; werase = ^W; lnext = ^V;
discard = ^O; min = 1; time = 0;
-parenb -parodd -cmspar cs8 -hupcl -cstopb cread -clocal
-crtscts
-ignbrk brkint ignpar -parmrk -inpck istrip -inlcr -igncr
icrnl ixon -ixoff -iuclc -ixany -imaxbel -iutf8
opost -olcuc -ocrnl onlcr -onocr -onlret -ofill -ofdel nl0
cr0 tab0 bs0 vt0 ff0
isig icanon iexten echo echoe echok -echonl -noflsh -xcase
-tostop -echoprt echoctl echoke -flusho -extproc

输出会经过排版了

stty igncr #开启忽略回车符

stty igncr

要是在终端shell 输入这个命令 终端就不能就收回车了

那么怎么执行命令呢 这代码只能在 shell 脚本文件中运行吗

stty -igncr#关闭忽略回车符

stty -igncr

运行 忽略回车的命令后,不知道怎么运行下面的命令…

只能重启shell

stty iuclc #开启在命令行下,禁止输出大写的方法

stty iuclc

这样在shell 终端中就输入不了大写

stty -iuclc #恢复在命令行下,禁止输出大写的方法

stty -iuclc

执行后 就可在终端再次输入大写字母

stty olcuc #开启在命令行下禁止输出小写

stty olcuc

禁止小写 ,要在shell终端中运行这个代码,估计又要重启shell了…

这样的代码只能在shell脚本中用吧

stty -olcuc#恢复在命令行下禁止输出小写

stty -olcuc

stty size 打印出终端行列

stty size
31 60

下面是shell stty -echo 这个命令适合输入密码

#!/bin/sh
stty -echo
echo -n "Please Put in your password:"
read password
stty echo
echo -e "\nYour password is: $password"

Linux Ubuntu stty 使用的更多相关文章

  1. Linux command stty

    Linux command stty reference: https://blog.csdn.net/lqxandroid2012/article/details/78929506 [Purpose ...

  2. Arch Linux 安装博通 BCM4360 驱动(Arch Linux, Ubuntu, Debian, Fedora...)

    BCM4360 在2010年9月,博通完全开源的硬件驱动[1].该驱动程序 brcm80211已被列入到自2.6.37之后的内核中.随着2.6.39发布,这些驱动程序已被重新命名为 brcmsmac和 ...

  3. 在Linux(Ubuntu)下搭建ASP.NET Core环境并运行 继续跨平台

    最新教程:http://www.cnblogs.com/linezero/p/aspnetcoreubuntu.html 无需安装mono,在Linux(Ubuntu)下搭建ASP.NET Core环 ...

  4. Linux ubuntu 10.10安装OpenCv

    在windows系统下已经成功做出了一个打开摄像头并检测人脸的小程序了. 开始转战linux,因为最终目标是将程序移植到嵌入式开发板上面. 但是,问题接踵而至~ 首先linux上面要安装OpenCv, ...

  5. windows远程连接Linux(Ubuntu)的方法

    需要做的工作: 1.在Linux(Ubuntu)端安装.设置好SSH 2.下载putty,并通过putty的SSH连接登录Linux 一 .如何在Linux(Ubuntu)端安装.设置好SSH,获取I ...

  6. lampp 在linux ubuntu下自动开机启动

    lampp 在linux ubuntu下自动开机启动 lampp在linux下是不会自动启动的.需要手工处理.如下: 假如,你的lampp安装在 /opt/lampp 目录下,那么可以如下处理: 1. ...

  7. remote desktop connect btw Mac, Windows, Linux(Ubuntu) Mac,Windows,Linux之间的远程桌面连接

    目录 I. 预备 II. Mac连接Windows III. Windows连接Mac IV. Windows连接Ubuntu V. Mac连接Ubuntu VI. Ubuntu连接Mac VII, ...

  8. linux ubuntu系统下,adb不是内部命令 (如何才能让adb命令可以使用)

    linux ubuntu系统下,adb不是内部命令 原文地址 linux ubuntu系统下,adb不是内部命令 解决方法: 1.sudo gedit ~/.bashrc 2.将下面的两句加到上面打开 ...

  9. Linux(Ubuntu)下MySQL的安装与配置

    转自:http://www.2cto.com/database/201401/273423.html 在Linux下MySQL的安装,我一直觉得挺麻烦的,因为之前安装时就是由于复杂的配置导致有点晕.今 ...

随机推荐

  1. python中时间处理标准库DateTime加强版库:pendulum

    DateTime 的时区问题 Python的datetime可以处理2种类型的时间,分别为offset-naive和offset-aware.前者是指没有包含时区信息的时间,后者是指包含时区信息的时间 ...

  2. POJ1741——Tree(树的点分治)

    1 /* *********************************************** 2 Author :kuangbin 3 Created Time :2013-11-17 1 ...

  3. mysql5.7执行sql语句提示Expression #1 of ORDER BY clause is not in GROUP BY

    mysql 新版本出现group by 语句不兼容问题 [Err] 1055 - Expression #1 of ORDER BY clause is not in GROUP BY clause ...

  4. Centos8.X 搭建Grafana+Jmeter+Influxdb 性能实时监控平台

    前言 本篇文章引用了小菠萝测试笔记,大部分内容非原创,基于自身实操过程中,完善了部分. 本篇随笔是在Linux上搭建的,后面会补充在docker以及k8s上如何部署安装 工具介绍 工具 介绍 Jmet ...

  5. Shell系列(5)- 输出输入重定向及wc命令

    输出重定向: 在Linux当中,0代表输入:1代表正确输出:2代表错误输出 类型 符号 作用 正确输出重定向 命令 > 文件 以覆盖得方式,把命令得正确输出,输出到指定文件或设备当中 命令 &g ...

  6. NOI.AC#2007-light【根号分治】

    正题 题目链接:http://noi.ac/problem/2007 题目大意 \(n\)个格子排成一排,每个格子有一个\(0/1\)和一个颜色.开始每个格子都是\(0\),\(q\)次操作取反一个颜 ...

  7. 生动直观的Gif图告诉你如何安装Python安装第3方库,在线安装离线安装全都搞定

    前言 学Python的小伙伴都知道,Python学习过程中需要装不少的第3方的库,今天就和大家一起分享下第3方库的安装方法 在线安装(推荐安装式式) 点开Pycharm--file--Project- ...

  8. Unity 刚体问题 解决相互作用力

    在进行开发过程中,当两个都具有碰撞体和刚体的 游戏物体进行接触之后,或多或少都会出现相互作用力,对于体验有一定的影响. 需要在FixedUpdate(间隔固定的时间调用,不受游戏帧率的影响)  当中  ...

  9. HTML(思维导图)

  10. canvas 实现简单的画板功能添加手机端效果 1.01

    在上次的基础上,加了一些代码,手机端可操作 访问网址:https://chandler712.github.io/Item/ <!-- 简单版画板 --> <!DOCTYPE htm ...