个人工具

“UbuntuHelp:RootSudoTimeout”的版本间的差异

来自Ubuntu中文

跳转至: 导航, 搜索
(创建新页面为 '{{From|https://help.ubuntu.com/community/RootSudoTimeout}} {{Languages|UbuntuHelp:RootSudoTimeout}} By default sudo remembers your password for 15 minutes. If you want to change...')
 
 
第5行: 第5行:
 
sudo visudo
 
sudo visudo
 
</nowiki></pre>
 
</nowiki></pre>
This opens the vi editor (by default) and points it to the sudoers file. You're now a super user editing one of the most important files on your system. No stress!
+
This opens an editor and points it to the sudoers file -- Ubuntu defaults to nano, other systems use Vi. You're now a super user editing one of the most important files on your system. No stress!
Vi instructions:
+
(Vi specific instructions noted with (vi!). Ignore these if you're using nano)
Vi is modeful editor and a bit klunky to use. Use the arrow keys to move to the end of the Defaults line. Then press they '''A''' (capital "a") key to move at the end of the current line and enter editing mode (append after the last character on the line).
+
* Use the arrow keys to move to the end of the Defaults line.  
In Ubuntu, visudo opens nano.
+
* (vi!) press the '''A''' (capital "a") key to move at the end of the current line and enter editing mode (append after the last character on the line).
Now type
+
* Now type
 
<pre><nowiki>
 
<pre><nowiki>
 
,timestamp_timeout=X
 
,timestamp_timeout=X
第15行: 第15行:
 
where X is the timeout expiration '''in minutes'''. If you specify 0 you will always be asked the password. If you specify a negative value, the timeout will never expire. E.g.
 
where X is the timeout expiration '''in minutes'''. If you specify 0 you will always be asked the password. If you specify a negative value, the timeout will never expire. E.g.
 
Defaults env_reset,timestamp_timeout=5
 
Defaults env_reset,timestamp_timeout=5
Then hit '''Escape''' to return to command mode. Now, if you're happy with your editing, type in ''':w''' <'''ENTER'''> to write the file and ''':q''' <'''ENTER'''> to exit vi. If you made a mistake, perhaps the easiest way is to redo from start, to exit without saving (hit '''Escape''' to enter the command mode) and then type ''':q!''' <'''ENTER'''>.
+
* (vi!) hit '''Escape''' to return to command mode. Now, if you're happy with your editing, type in ''':w''' <'''ENTER'''> to write the file and ''':q''' <'''ENTER'''> to exit vi. If you made a mistake, perhaps the easiest way is to redo from start, to exit without saving (hit '''Escape''' to enter the command mode) and then type ''':q!''' <'''ENTER'''>.
 +
* hit '''CTRL + X''', then '''Y''', then <'''ENTER'''> to save your file and exit nano.
 
You might want to read the sudoers and vi manual pages for additional information.
 
You might want to read the sudoers and vi manual pages for additional information.
 
<pre><nowiki>
 
<pre><nowiki>

2010年5月20日 (四) 00:06的最新版本

By default sudo remembers your password for 15 minutes. If you want to change that you can do so by

sudo visudo

This opens an editor and points it to the sudoers file -- Ubuntu defaults to nano, other systems use Vi. You're now a super user editing one of the most important files on your system. No stress! (Vi specific instructions noted with (vi!). Ignore these if you're using nano)

  • Use the arrow keys to move to the end of the Defaults line.
  • (vi!) press the A (capital "a") key to move at the end of the current line and enter editing mode (append after the last character on the line).
  • Now type
,timestamp_timeout=X

where X is the timeout expiration in minutes. If you specify 0 you will always be asked the password. If you specify a negative value, the timeout will never expire. E.g. Defaults env_reset,timestamp_timeout=5

  • (vi!) hit Escape to return to command mode. Now, if you're happy with your editing, type in :w <ENTER> to write the file and :q <ENTER> to exit vi. If you made a mistake, perhaps the easiest way is to redo from start, to exit without saving (hit Escape to enter the command mode) and then type :q! <ENTER>.
  • hit CTRL + X, then Y, then <ENTER> to save your file and exit nano.

You might want to read the sudoers and vi manual pages for additional information.

man sudoers
man vi