Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I want to run a script without prompt for password.
I edited /etc/sudoers file and I wrote several lines behind last one. This is my file:
#
Defaults env_reset
# Host alias specification
# User alias specification
# Cmnd alias specification
# User privilege specification
root ALL=(ALL:ALL) ALL
# Members of the admin group may gain root privileges
%admin ALL=(ALL) ALL
# Allow members of group sudo to execute any command
%sudo ALL=(ALL:ALL) ALL
#includedir /etc/sudoers.d
jose ALL= NOPASSWD: /sbin/shutdown -h now
jose ALL= NOPASSWD: /sbin/shutdown -r now
jose ALL= NOPASSWD: /home/jose/sync.sh
I can shutdown and reboot without type password but when I try to run the last line, the script prompt for password.
The script code (that work fine with password) is:
What i did to solve a similar problem, was first making sure my user belongs to all the appropriate groups in /etc/group, putting the following in /etc/sudoers
Code:
Defaults:myuser !requiretty
Substitute your actual username for myuser
and running my script in an xterm with
Code:
xterm -e scriptname
Hope this points you in the right direction.
Also make sure that /home/jose/pc1 appears in /etc/fstab with the "user" flag set.
I guess the point is just that your script includes the sudo command to mount and unmount your remote drive.
I would try to add your samba drive in /etc/fstab with the option users so that non-root user can mount it, this might help.
good luck
p.s.: please, when posting code and/or terminal outputs use the [CODE] tags, it make the thread more readable..
Well, for me it's safe. I'm the only user on this system and login is protected anyway. If anyone could get into the system then they already have the password.
I admit it's not a good solution on a multi-user/networked system.
Well, for me it's safe. I'm the only user on this system and login is protected anyway. If anyone could get into the system then they already have the password.
I admit it's not a good solution on a multi-user/networked system.
just update /etc/sudoers in future, it's no more work at all.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.