In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article introduces the relevant knowledge of "how Linux/Ubuntu sudo can log in without entering a password". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
Open the Internet client, Synaptic, these related to the system have to enter the password, for most of us, using Linux is nothing more than a desktop application, there is no need to do something like the server for security.
Solution 1:
Enter safe mode at startup, when you are logged in with root, execute:
Chmod 740 / etc/sudoers
Then open the / etc/sudoers file and put the last line:
% admin ALL= (ALL)
Change to
% admin ALL= (ALL) NOPASSWD: NOPASSWD: ALL
Save exit.
Execute:
Chmod 0440 / etc/sudoers
Reboot your ubuntu.OK!
Solution 2:
By default, Ubuntu cannot log in directly with the root account, and root permissions must be obtained through su or sudo from the first created user (the one created at installation). This command is often used to operate the system in Ubuntu, so it is necessary for newcomers to recognize this command. This may not be convenient, but it increases security and prevents users from damaging the system due to misoperation.
Sudo
Format: sudo [other commands]
Sudo means Super user do. Sudo only plays the role of calling the root user in this process, and its function disappears after this operation is completed. If you want to use the command that invokes the root permission operation, you must use sudo again. Some of the process the system will require the user to enter a password, this password is the installation of the system you enter your password, note: this password will not enter a password like a password in Windows to have a * number, the purpose is to make the password more secure, because do not know how many of your password, which undoubtedly increases the difficulty of the password decipher. :)
Example:
We need to use sudo to change the permissions of upload.tar.gz in the current directory. If you want to change permissions on another file in the current directory, eva.tar.gz, you will need to use sudo again.
Ownlinux@server:/var/www$ sudo chmod 777 upload.tar.gz
[sudo] password for ownlinux: (enter your password at this time)
Ownlinux@server:/var/www$ sudo chmod 777 eva.tar.gz
[sudo] password for ownlinux:
Add:
Usually we are not logged in as root, but when we need root permission to execute certain commands (command), we usually use "sudo command" to execute command. Because I use Ubuntu, I often use sudo, and when I use sudo, I have to enter a password, so I'm looking for a way for sudo not to enter a password. Google a while ago, it is easy to find a way, but not enough to understand it, today, a careful study of the / etc/sudoers this file, on how to achieve their own needs is very clear. It was said on the Internet that the information I saw was often not written clearly, so I sorted it out according to my own needs.
Suppose my user name is jay (belongs to the admin group), so that sudo does not have a password as follows.
Run the command: sudo visudo or sudo vi / etc/sudoers. If vi edits, remember to use "wq!" when saving. Force a save, otherwise you will be prompted to read-only what cannot be saved.
The file / etc/sudoers will be edited. By default we will see the phrase "% admin ALL= (ALL) ALL", which allows the admin group to execute all commands on all hosts, which of course requires passwd.
1. If you want all users in the admin group to sudo without a password, you can change this line to "% admin ALL= (ALL) NOPASSWD: NOPASSWD ALL".
two。 If you just want the jay user sudo not to need a password, you can add the line "jay ALL = NOPASSWD: ALL".
3. If you let the jay user sudo execute certain commands without a password, you can write "jay ALL = NOPASSWD: / usr/bin/abc.sh, / usr/sbin/adduser" like this
4. To learn more about other configurations, please run "man sudoers" to see the help documentation.
Note: one of my own configurations did not take effect. I looked for the reason for a while. Let's stop here.
I added the line "jay ALL = NOPASSWD: ALL"; however, jay still needs to enter a password when performing sudo. Why?
It turns out that my line before the "% admin ALL= (ALL) ALL" group policy, the later group configuration overrides the previous configuration, while jay belongs to the admin group, so a password is required.
At this point, you just need to comment out the% admin line with #. OK! Then it takes effect immediately, maybe the system will read / etc/sudoers when sudo is executed, so it will take effect immediately.
In addition, it comes with a / etc/sudoers configuration of a server in the company:
The code is as follows:
Defaults env_reset
Defaults syslog=auth
Defaults log_year,logfile=/var/log/sudo.log
User_Alias ABC = abc
Cmnd_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/ruby
ABC ALL= (ALL) NOPASSWD:DEFAULT
By modifying / etc/sudoers
Sudo vi / etc/sudoers
Put the last line in / etc/sudoers
% admin ALL= (ALL)
Change to
% admin ALL= (ALL) NOPASSWD: NOPASSWD: ALL
Then force to save wq on OK
The above is not accurate, we should pay attention to the following points.
The edit / etc/sudoers file uses "Super Terminal" instead of a normal terminal. "Super Terminal" starts adding by right-clicking the "Edit menu" command.
Use wq after editing! Instead of wq quitting
This is the end of the content of "how to log in without entering a password for Linux/Ubuntu sudo". Thank you for your reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.