Linux/cmdtusudo does not need to enter the password. generally, we do not log on as the root user. However, when we execute some commands, we need to use the root permission. generally, we use sudocommand to execute commands. Because Ubuntu is used, sudo is often used ,... linux/Ubuntu sudo does not need to enter a password. generally, we do not log on as root, but we need to use the root permission when executing some commands, we usually use "sudo command" to execute command. Because Ubuntu is used, sudo is often used, and when sudo is used, a password is required, so I am looking for a method that does not enter a password for sudo. A few times ago, I Googled it and it was easy to find a method, but I didn't understand it enough. today, I carefully studied the/etc/sudoers file, we are very clear about how to implement our own needs. The information I see on the internet is often unclear, so I sorted it out according to my own needs. Assume that my username is jay (which belongs to the admin group) and sudo does not need a password as follows. Run the command: sudo cmddo or sudo vi/etc/sudoers. if vi is used for editing, remember to use "wq! "Force save. Otherwise, the system will prompt that read-only files cannot be saved. The/etc/sudoers file will be edited. By default, we will see a sentence "% admin ALL = (ALL) ALL", that is, allow the admin group to execute ALL commands on ALL hosts, of course passwd is required. 1. if you want to replace ALL users in the admin group with sudo without a password, you can change this line to "% admin ALL = (ALL) NOPASSWD: nopasswd all. 2. if you only want to make the jay user sudo not need a password, you can add a line like "jay ALL = NOPASSWD: ALL. 3. if you want jay sudo to execute several commands without a password, you can write "jay ALL = NOPASSWD:/usr/bin/abc. sh,/usr/sbin/adduser "4. for more configuration methods, run "man sudoers" to see the help documentation. Note: One of my own configurations does not take effect. I have to find the reason and write it here. I added a line like "jay ALL = NOPASSWD: ALL", but jay still needs to enter the password when executing sudo. why? Originally, before the "% admin ALL = (ALL) ALL" group policy, the group configuration that follows replaced the previous configuration, and jay belongs to the admin group, the password is required. In this case, you only need to comment out the % admin line. OK! Then it takes effect immediately. the system may read/etc/sudoers during sudo execution, so it takes effect immediately. In addition, a/etc/sudoers configuration for a company server is included: Defaults env_resetDefaults syslog = authDefaults log_year, logfile =/var/log/sudo. logUser_Alias ABC = abcCmnd_Alias DEFAULT =/bin/*,/sbin/ldconfig,/sbin/ifconfig,/usr/sbin/useradd,/usr/sbin/userdel,/bin/rpm, /usr/bin/yum,/sbin/service,/sbin/chkconfig, sudoedit/etc/rc. local, sudoedit/etc/hosts, sudoedit/etc/ld. so. conf,/bin/mount, sudoedit/etc/exports,/usr/bin/passwd [! -] *,! /Usr/bin/passwd root,/bin/su -[! -] *,! /Bin/su-root ,! /Bin/su root,/bin/bash,/usr/sbin/dmidecode,/usr/sbin/lsof,/usr/bin/du,/usr/bin/python, /usr/sbin/xm, sudoedit/etc/profile, sudoedit/etc/bashrc,/usr/bin/make, sudoedit/etc/security/limits. conf,/etc/init. d/*,/usr/bin/rubyABC ALL = (ALL) NOPASSWD: by modifying/etc/sudoers sudo vi/etc/sudoers, DEFAULT changes % admin ALL = (ALL) in the last line of/etc/sudoers to % admin ALL = (ALL) NOPASSWD: ALL and then force the wq to be saved. the above description is not accurate. pay attention to the following points. Edit the/etc/sudoers file and use the "superuser terminal" instead of the common terminal. Click "super user terminal" and right-click "Edit menu" to add it. Use wq after editing! Instead of exiting wq
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.