How do I sudo without having to enter my password?


I enter my first sudo command. I enter my password. For a while, I wont have to enter my password for subsequent sudo commands.

Now the question. I am someone who opens a lot of terminals. It would be very convenient if I don't have to enter passwords when I use sudo in the terminals I open after my first sudo, for the short time when I wont have to enter password for sudo in the terminal from which I have used sudo for the first time. (Sorry for the long sentence!)

Is it possible? If now why? If yes, how?

Answers 1

Sure it is. Run sudo visudo and add this line to your sudoers file:

Defaults !tty_tickets

As explained in man sudo:

tty_tickets If set, users must authenticate on a per-tty basis. With this flag enabled, sudo will use a separate record in the time stamp file for each tty. If disabled, a single record is used for all login sessions. This flag is on by default.

By setting tty_tickets...

0 0

This one is as much for you as it is for me. Every time I install a new system, I forget how to set the /etc/sudoers file so that I can execute certain applications as root using sudo without having to enter my password. This is very useful for scripts, or for harmless commands that you need te execute a lot – like vpnc – but still require root permissions.

Start by opening the editor of the sudoers-file:

$> sudo visudo

This will open the file in vim, which you might not be familiar with. No problem, just type i which puts it in insert-mode and it’ll work as any other editor.

Append a line in the following format at the end:

username ALL=NOPASSWD:command1, command2, ...

For example, mine:

david ALL=NOPASSWD:/usr/sbin/vpnc, /usr/sbin/vpnc-disconnect

As you can see, you need to use the full path for every binary. If you don’t know them by heart, find out using the whereis command:

$> whereis -b vpnc vpnc: /usr/sbin/vpnc...
0 0

If you use Ubuntu Linux it is quite likely that at some point or another you may have been frustrated at its asking for your password when trying to perform an administrative tasks, such as installing programs or changing system settings. Ubuntu uses the sudo tool to manage administrative rights rather than letting users easily log in as the root user. This is actually a good security measure. However, if you need to perform administrative tasks frequently it can get rather annoying. Here’s how you can set Ubuntu to not prompt for your password when using sudo.

Note: this is something that is not recommended if you are using your computer in a public place or at your work, as this will compromise the security of your data. You’re better off setting this at your home desktop where you are likely to trust more people.

Launch a terminal window and enter the following command:

# sudo visudo

Visudo is a tool used to edit the configuration file of sudo . The...

0 0

To answer my own question and maybe to raise some attention of others who might have better ideas, here is what I've come up with.

I created a script in my target host's home directory containing this:

#!/bin/sh if [ -t 0 ] ; then # interactive if [ -r $0.fifo ] ; then rm $0.fifo ; fi mkfifo -m 600 $0.fifo stty -echo echo -n "Password for upcoming winscp session: " read p stty echo echo echo -n "Waiting for connection..." echo $p > $0.fifo echo echo "Connected!" rm $0.fifo elif [ -r $0.fifo ] ; then # non interactive - fifo exists cat $0.fifo rm $0.fifo fi

In my winscp settings for the host I have now this configured as shell:


Before I invoke the winscp session I log in to the target host starting "mypass", which will then ask me for the password and put it into a fifo. As soon as the fifo was read, I get the message "Connected" and the fifo gets...

0 0

There's a few ways to do this. Here's two (pick the method you like):

Method 1: Using "askpass".

With this you always do sudo -A command. The -A argument tells sudo to execute a command that echos the password to stdout. That command is something you write. For this explaination let's call the command pw and stick it /usr/local/bin. So it's full pathname would be /usr/local/bin/pw.

sudo -A can get the pathname to pw a number of ways.

1. From the sudoers file.

Use visudo to add the following line to the sudoers file:

Defaults:ALL askpass=/usr/local/bin/pw

2. Using the SUDO_ASKPASS environment variable.

export SUDO_ASKPASS=/usr/local/bin/pw

This might work too (assuming SUDO_ASKPASS has been previously exported):

SUDO_ASKPASS=/usr/local/bin/pw sudo -A command


Method 2: Have sudo read the password from stdin

echo -n password | sudo -S...

0 0
*i dont know how this will affect a folder in place, i always make a new folder for this process*
i only know how to make it so all ftp users can access each other subdirectory, but this may work by just having "ftpadmin" in a ftp group.(note: i use this method to share a folder across 4 users on a desktop)

1. Change the umask in /etc/profile so that new files created by users will have write access granted to the group that owns the file:

sudo nano /etc/profile

change the last line so it looks like this:

umask 002

2. Make a new group "ftp" and include any usernames you want (try just adding ftpadmin) to be able to share the files in your shared directory in that group.

System->Administration->Users and Groups->[Manage Groups]->[Add group]

3. give all users in the group full access to the directory, and tell it make all files created within that directory to the group of the directory:

sudo chgrp ftp /home/ftp
sudo chmod 775...

0 0

One of the most noticeable features of ubuntu is the common use of sudo in order to perform ‘root’ level tasks. By default the ‘root’ user is disabled leaving sudo as the most used method of running administrator level commands and tasks.

A intial setup of sudo requires the user to type in the password everytime the command is used. Although the autorization is maintained for a few minutes after the password is first used it can become quite tedious to constantly be prompted for a password on commonly used commands.

I have set up my own ubuntu 9.10 Karmic Koala system to allow the aptitude command to be run without having to type my password. This lets me cron a very small script to keep my system up-to-date without being prompted for a password.

Here’s how I set it up:

$ sudo visudo

Below the line “%admin ALL=(ALL) ALL” insert the following:

USERNAME ALL=NOPASSWD: /usr/bin/aptitude

for example:

jason ALL=NOPASSWD:...

0 0

Websites tell me to use sudo when I have no password, usually tell me one of two things.

It is bad security Or use 'sudo visudo' and the %admin ALL=(ALL) NOPASSWD: ALL line

I would like to not have a password on anything despite the security risks.

Going with option 2, I'm trying to avoid getting prompted to enter a password at all on my account.

So the problem with option 2, is that sudo is still prompting for a password that does not exist. So I can not use sudo visudo in order to remove the need to enter a password for sudo, because it prompts for a password.

If after that warning you still want to do it, then go to and follow the directions to enable super user account. Be forewarned that this is extremely dangerous. It can lead to undesired results happening to your computer with the slightest mistake. It also opens your computer up to many vulnerabilities. Having to...

0 0
The Linux Mint moderation/admin team is happy to offer this introduction on user rights under Linux. The target audience is primarily beginners but an advanced section is available at the end and may attract more advanced users.

People may wonder why they have to type their password in order to be allowed to perform simple tasks like installing new software or applying updates. As we will see, this simple behavior is one of the most powerful safety features of Linux.

Part 1: the basics

Normal users versus root user

When you log in to your system, you are by default logged in as a normal user. With this account, users run with reduced permissions. They have access to their own files, but can't edit system files, or install new software. Said in a different way, normal users are not authorized to perform any system operations.

A second user is present on a Linux installation: the root user. This user is essentially equivalent to an administrator account on...

0 0

It comes a time when for some reason someone forgets the login password for their


computer, hence they become unable to access the computer. That is not the end, there is always something that can be done.

All you need is a working keyboard and familiarity with a few commands in fixing this problem and access to the computer as this cannot be fixed remotely. First, you will have to reboot your computer, hold shift until you are able to access a screen as shown below. This screen offers various troubleshooting options for your computer. It’s necessary to understand some of these functions to make use of them when necessary, with computers anything happens. Equipping oneself with basic tools is always good. Here you will be shown on how to unlock a forgotten sudo password on both dual booting and single booting computers. By dual booting, I mean recovering a sudo password on a computer running several Oss Ubuntu included. By single booting I mean, resetting a...

0 0

Whenever I execute a command with 'sudo' in Unix I always get a prompt for entering my password. How do I skip entering my password?

When you are writing a script and in that script would like to execute a command that requires elevated privilege, you'd have issues because you'd need to enter the password afterwords. Suppose the command you want to execute is:

sudo rm *
And your password is 'myPassWord' without quotes, then here's what you do:

echo myPassWord | sudo -S rm *
'-S' is the option provided by 'sudo' command that means it'll read the password from the standard input instead of the terminal device. That's why you can pipe your password via 'echo' and you'll be able to skip the password prompt this way.

Enjoy! Questions? Let me...

0 0

In this article, we’re going to discuss Sudo, one of the frequently used commands in Linux. Sudo command stands for “superuser do”, It requires users to authenticate their password several times and asks them for confirmation to execute the commands before checking the file.

Key Benefit of Using this Tip

To avoid the tiresome process of inserting a password every time when you are working in Linux, our simple guidance provides you a solution to bypass the process of entering the password every time. However, you will need to consider certain security issues and consequences for allowing Sudo command without a password.

Run Sudo Command without a Password

We need to take /etc/sudoers file backup by typing the following command –

$ sudo cp /etc/sudoers /root/sudoers.bak

Edit the /etc/sudoers file by typing the visudo command:

$ sudo visudo

The output should be like the below image:

Append/edit the line as follows in the /etc/sudoers...

0 0


I have tried the above in an Ubuntu OS. It does not work and even with many other variations made to the sudoers file, I am always asked for a password when I execute sudo command.

Which version of Ubuntu are you using? It flawlessly works from at least 7.04.

8.0x Server Version I will try your fix again on Friday. thanks

I overlooked the fact that it must be at the end of the file. In my version, the last line of code gives all users in the admin group root access but with a password required. If your line precedes this, then the effects are undone by the last line of code because my user login is also a member (unintentional) of admin.

Hi, i tried previous command and it works. I have Ubuntu Jaunty 9.04 alpha 6

hai its working fine in Kubuntu 8.04 sudo visudo jaleel ALL=NOPASSWD: ALL save and reboot thanks a lot

'ya dont need to reboot..


0 0

File sutest

#!/bin/bash echo "uid is ${UID}" echo "user is ${USER}" echo "username is ${USERNAME}"

run it: `./sutest' gives me

uid is 500 user is stephenp username is stephenp

but using sudo: sudo ./sutest gives

uid is 0 user is root username is stephenp

So you retain the original user name in $USERNAME when running as sudo. This leads to a solution similar to what others posted:

#!/bin/bash sudo -u ${USERNAME} normal_command_1 root_command_1 root_command_2 sudo -u ${USERNAME} normal_command_2 # etc.

Just sudo to invoke your script in the first place, it will prompt for the password once.

I originally wrote this answer on Linux, which does have some differences with OS X

OS X (I'm testing this on Mountain Lion 10.8.3) has an environment variable SUDO_USER when you're running sudo, which can be used in place of USERNAME above, or to be more cross-platform the script could check to see if SUDO_USER is set and use it if so, or use USERNAME if...

0 0

Vader, from your comment on your original question, you'd like to switch to an interactive shell running with super-user permissions, right?

Sudo has a specific argument to request a shell:

-s [command] The -s (shell) option runs the shell specified by the SHELL environment variable if it is set or the shell as specified in the password database. If a command is specified, it is passed to the shell for execution via the shell's -c option. If no command is specified, an interactive shell is executed.

This avoids the already mentioned security drawbacks, and allows to "go root" by using the following command:

sudo -s

IF I really have to run a root shell (in most cases I don't), then I find it very helpful to have the HOME environment variable of the shell set accordingly (to reflect running as "root"), this can be done using the "-H" flag. So the full command would be

sudo -s -H

You can find a lot more details in sudo's...

0 0

6.3.2. Setting Up Users And Passwords

Just before configuring the clock, the installer will allow you to set up the “root” account and/or an account for the first user. Other user accounts can be created after the installation has been completed. Set the Root Password

The root account is also called the super-user; it is a login that bypasses all security protection on your system. The root account should only be used to perform system administration, and only used for as short a time as possible.

Any password you create should contain at least 6 characters, and should contain both upper- and lower-case characters, as well as punctuation characters. Take extra care when setting your root password, since it is such a powerful account. Avoid dictionary words or use of any personal information which could be guessed.

If anyone ever tells you they need your root password, be extremely wary. You should normally never give your root password...

0 0

Set HISTIGNORE to "sudo -S"

$ export HISTIGNORE='*sudo -S*'

Then pass your password safely to sudo:

$ echo "your_password" | sudo -S -k

"HISTIGNORE" means to not save this command into the history. That is the history in memory or "~/.bash_history" file.

For example, the below will safely pipe your password to the sudo command, without retaining a history of your password.

“-S”, means to use stdin for the password,

“-k” means to ignore cached credentials to force sudo to always ask. This is for consistent behavior.

$ export HISTIGNORE='*sudo -S*' $ echo "" | sudo -S -k whoami $ echo "" | sudo -S -k cat /etc/shadow $ echo "" | sudo -S -k bash /tmp/

The downside to the above method is that if you want to see the commands you ran in the history later on they won't be there. Another method is to update the sudo authentication credential cache (default is enabled with 5 minutes timeout), then run the sudo separately. But the downside...

0 0

EDIT MAY 6,2016

I've written a script to update all settings for system connections in the /etc/Network-Manager/system-connections/ directory. The GUI that you use to edit individual connections, edits a particular file in that directory. The script updates all of the files - it just searches for those who don't have dns set with grep and sets it with awk.

Since accessing those files requires sudo access, run this script with sudo and then - restart network manager

#!/bin/bash # Author: Serg Kolo # Date: May 6, 2015 # Description: this script checks all settings for connections in # /etc/NetworkManager/system-connections/ , and if there's no custom # dns set , this script sets it; # NOTE: run sudo service network-manager restart after running this script set -x for file in /etc/NetworkManager/system-connections/* ; do grep 'dns=;' "$file" || ( awk '{print;if ($1=="[ipv4]"){getline; print "method=auto\ndns=208.67.220....
0 0
0 0