Linux Stall
  • Home
  • Android
  • How to
  • Perl
  • Tips
  • Tutorials
No Result
View All Result
Linux Stall
No Result
View All Result
Home FAQ

How to run sudo command without password on Linux?

Ayush Goyal by Ayush Goyal
June 21, 2015
in FAQ, Tips
45 0
0
How to run sudo command without password on Linux?
15
SHARES
753
VIEWS
Share on FacebookShare on Twitter

There comes a time when you want to execute a command with root privileges but you don’t want to enter root password again and again. May be you want to allow a user to be able to execute one particular command but can’t share root password or some command needs to be executed on boot but requires root..sounds familiar? Keep reading.

The kind of approach we will be using is very often frowned upon. Mainly because it beats the purpose of sudo i.e. allowing only privileged users to execute certain commands. It is also looked upon as security breach, but you are fine if you know what you are doing.

You can run sudo command without password on linux by modifying /etc/sudoers file which maintains – which user can execute what. Before editing this file, lets take a backup – just in case – it gets messed up.

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

/etc/sudoers file can be edited in any editor of your choice but it is highly recommended to use visudo command. If there is a syntax error in sudoers file then you will be locked out of shell and we don’t want that. While visudo command checks for correct syntax and restricts user from saving a corrupt sudoers file. Enter following command to edit sudoers file:

 sudo visudo

For example, if we want user “ayush” to be able to execute, say, “visudo” without asking for password then we will have to append following line in sudoers file in the end.

 ayush ALL = NOPASSWD: /usr/sbin/visudo 

This needs to be added at the very last of sudoers file because if there are matching entries then last line will override all previous occurrences.

This is how my sudoers looks after editing:

sudoers_sudo

Now, user “ayush” won’t be prompted to enter password while executing “sudo visudo”.

You can replace your own username and command(s) you want to execute without entering root password:

 [username] ALL = NOPASSWD: [command] 

This can be extended for multiple commands by comma separating them.

Tags: sudoTips
Previous Post

How to make password visible in linux terminal

Next Post

Protect Your SSH From Bruteforce With Fail2Ban

Ayush Goyal

Ayush Goyal

Yet another geek!

Related Posts

conceptual image, methaphor of busy and fast business, man with airplane desk
Tips

Drastically Speed up your Linux System with Preload

July 23, 2020
Professional Developer programmer working a software website design and coding technology, writing codes and database in company office, Global cyber connection technology.
Tips

Writing A Basic Expect Script For Automating Tasks

July 12, 2020
The three-dimensional network topology infographics with ip addresses 3d illustration
Tips

Useful Remote IPMI Commands For Managing Servers

July 11, 2020
How to add taskbar in Ubuntu 14.04?
FAQ

How to add taskbar in Ubuntu 14.04?

July 6, 2014
Add auto-complete to “yum”
Tips

Add auto-complete to “yum”

August 18, 2013
Learn Linux Online
FAQ

Top 10 places to learn Linux online

December 31, 2012
Next Post
Fail2Ban

Protect Your SSH From Bruteforce With Fail2Ban

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

  • Terms and Conditions
  • Contact Us
  • About Us

© 2012 - 2020 Linux Stall - A place for all your Linux needs.

No Result
View All Result
  • Home
  • Android
  • How to
  • Perl
  • Tips
  • Tutorials

© 2012 - 2020 Linux Stall - A place for all your Linux needs.

Welcome Back!

Login to your account below

Forgotten Password?

Create New Account!

Fill the forms bellow to register

All fields are required. Log In

Retrieve your password

Please enter your username or email address to reset your password.

Log In