linux终端窗口_如何在Linux的终端窗口中使密码星号可见

linux终端窗口

linux终端窗口

00_lead_image_asterisks_for_password

When you run a command using sudo in Linux, the Terminal prompts you to type in your password with no visual feedback as you type. We’ll show a quick tweak that will show asterisks (*) when you type in your password in the Terminal.

在Linux中使用sudo运行命令时,终端会提示您键入密码,并且键入时不会产生视觉反馈。 我们将显示一个快速调整,当您在终端中输入密码时,该调整将显示星号(*)。

NOTE: When we say to type something in this article and there are quotes around the text, DO NOT type the quotes, unless we specify otherwise.

注意:当我们说要在本文中键入某些内容并且文本周围有引号时,请不要键入引号,除非我们另外指定。

We will open the “/etc/sudoers” file and change a setting to customize the length of the grace period. To begin, press Ctrl + Alt + T to open a Terminal window. Type the following command at the prompt and press Enter.

我们将打开“ / etc / sudoers”文件并更改设置以自定义宽限期的长度。 首先,请按Ctrl + Alt + T打开“终端”窗口。 在提示符下键入以下命令,然后按Enter。

sudo visudo

苏多维苏多

Type your password when prompted and press Enter. Notice that no asterisks are displayed when you enter your password.

出现提示时输入密码,然后按Enter。 请注意,输入密码时不会显示星号。

01_opening_visudo_file

A file opens directly in the Terminal window using the Nano text editor. Use the arrow keys on your keyboard to move the cursor to the end of the following line:

使用Nano文本编辑器直接在“终端”窗口中打开一个文件。 使用键盘上的箭头键将光标移至以下行的末尾:

Defaults         env_reset

默认值env_reset

IMPORTANT: Never edit the sudoers file with a normal text editor. Always use the visudo command as described here. If the sudoers file has improper syntax, you will be left with a system where it’s impossible to obtain elevated or root privileges. The visudo command opens a text editor like you would with normal text files, but the command also validates the syntax of the file upon saving it. This prevents configuration errors in the sudoers file from blocking sudo operations, which could be your only method of obtaining root privileges.

重要说明:切勿使用常规文本编辑器编辑sudoers文件。 始终按此处所述使用visudo命令。 如果sudoers文件的语法不正确,您将获得无法获得提升特权或root特权的系统。 visudo命令像打开普通文本文件一样打开文本编辑器,但是该命令还会在保存文件时验证文件的语法。 这样可以防止sudoers文件中的配置错误阻止sudo操作,这可能是获取root特权的唯一方法。

Traditionally, Linux uses vi as the default editor, but Ubuntu has chosen to use Nano. If you would rather use vi as the default text editor in Ubuntu, rather than Nano, see our article.

传统上,Linux使用vi作为默认编辑器,但是Ubuntu选择使用Nano。 如果您希望使用vi作为Ubuntu中的默认文本编辑器,而不是Nano,请参阅我们的文章

02_env_reset_line_original

Change the line by adding “,pwfeedback” to the end of the line.

通过在行末添加“,pwfeedback”来更改行。

Defaults                 env_reset,pwfeedback

默认值env_reset,pwfeedback

03_env_reset_line_revised

You can also press Enter after “env_reset” to make a new line and type the following on the new line:

您也可以在“ env_reset”之后按Enter换行,并在新行中键入以下内容:

Defaults                 pwfeedback

默认为pwfeedback

NOTE: The space between “Defaults” and “pwfeedback” should be a tab.

注意:“默认值”和“ pwfeedback”之间的空格应为制表符。

04_env_reset_line_revised_separate_line

Once you have made the change, press Ctrl + X and type a “y” in response to the question that displays at the bottom of the window to save your changes.

进行更改后,按Ctrl + X并键入“ y”,以回答显示在窗口底部的问题以保存更改。

05_saving_and_exiting

You will be asked for the File Name to Write at the bottom. Press Enter to accept the default.

在底部将要求您输入要写入的文件名。 按Enter接受默认值。

06_file_name_to_write

You are returned to the command prompt. To close the Terminal window, type “exit” at the prompt and press Enter. You can also click the X button in the upper-left corner of the window.

您将返回到命令提示符。 要关闭“终端”窗口,请在提示符下键入“ exit”,然后按Enter。 您也可以单击窗口左上角的X按钮。

07_closing_terminal

The next time you open a Terminal window and run a command using sudo, you will see asterisks when entering your password at the prompt.

下次打开“终端”窗口并使用sudo运行命令时,在提示符下输入密码时会看到星号。

08_asterisks_for_password

NOTE: You must close the Terminal window and open it for the change to take place.

注意:您必须关闭并打开终端窗口以进行更改。

翻译自: https://www.howtogeek.com/194010/how-to-make-password-asterisks-visible-in-the-terminal-window-in-linux/

linux终端窗口

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值