Powered By

Powered by Blogger

Tampilkan postingan dengan label sudo. Tampilkan semua postingan
Tampilkan postingan dengan label sudo. Tampilkan semua postingan

Senin, 19 April 2010

How To Change The SUDO Password Time-out In Ubuntu [Quick Tip]

The first time you run a command with "sudo" in Ubuntu, you are asked for a password but after running one more command with "sudo" (after a short while), you are not prompted for a password again. That's because "sudo" has a default password time-out (I'm not sure how long it takes to expire though).

Here is a quick tip to set the exact time-out for "sudo" password remembering in Ubuntu. Open a terminal and type:

sudo visudo

Then scroll to the line that says:
Defaults env_reset

and edit it so that it looks like this:
Defaults env_reset , timestamp_timeout=X

Where X is the number of minutes after which the password should expire, so set it to whatever you want. If you set it to 0, the password will always be required.

Once you're done editing the file, press Ctrl + X, type "y" (yes), press ENTER and that's it.


[thanks to ubucentrum for the tip!]

Selasa, 09 Maret 2010

How To Autocomplete Commands Preceded By 'sudo' [Quick Ubuntu Tip]

When writing a command in the terminal, you can autocomplete it by pressing the TAB key. Example: type "nau" in the terminal and press TAB -> "nautilus" should show up (if you have Nautilus installed, obviously).

However, the autocomplete doesn't work in Ubuntu if you are trying to run a command with "sudo". For example, typing "sudo nau" and then pressing the TAB key will not autocomplete the command to "sudo nautilus".


Here is how to get autocomplete to work in the Terminal while using "sudo". Simply open the ".bashrc" hidden file from your home folder. If you use GNOME, paste this in a terminal to open it:

sudo gedit ~/.bashrc

Then paste this at the bottom of the file:
if [ "$PS1" ]; then
complete -cf sudo
fi

Then type this in a terminal to reload:
bash


Now try the example in the beginning of the file "sudo nau" and press TAB. It should now work.