很多人问怎么样让sudo记住密码
我找到以前一个提速脚本
看见可以通过修改/etc/sudoers
sudo vi /etc/sudoers
把/etc/sudoers里面最后一行
%admin ALL=(ALL)
改为
%admin ALL=(ALL) NOPASSWD: NOPASSWD: ALL
然后强制保存 wq 就OK
以后sudo不在需要密码
但是个人认为这样会存在风险
个人建议使用sudo su
ps:把这个提速脚本一起给出
#!/bin/sh
######################################################################################
# faster-dapper.sh - Tweak default settings to speed up Ubuntu 6.06 Dapper Drake #
# Usage: ./faster-dapper.sh as a user in the admin group with full sudo access #
# #
# Version 0.4 written July 8, 2006 by Jeff Schroeder (jeffschroed@gmail.com) #
# License: GNU GPL 2 ONLY. See http://www.fsf.org/licensing/licenses/info/GPLv2.html #
######################################################################################
INSTALLED_DRIVE='`fdisk -l | grep Linux | head -1 | cut -d' ' -f1 | cut -d'/' -f3 | sed 's/[1-9]//'`'
# Disable sudo asking for your password for the remainder of the script
sudo sed -ie '/^%admin/s/ALL$/NOPASSWD: ALL/' /etc/sudoers
# Are we running on Dapper?
if ( ! grep 'Ubuntu 6.06' /etc/issue >/dev/null 2>&1); then
echo 'This script is only intended for Ubuntu 6.06 Dapper Drake'
exit 1
fi
logger ' -===== Installation log started on $(date) for faster-dapper.sh =====- ' #Logs installation information to /var/log/messages
echo ' -===== Installation started on $(date) for faster-dapper.sh =====- '
# Update the system
#sudo apt-get update && sudo apt-get --yes upgrade
# Enable the Completely Fair Queuing Linux process scheduler to handle high CPU usage situations better
if (! grep 'elevator=cfq' /boot/grub/menu.lst > /dev/null 2>&1); then
logger ' Kernel process scheduler changed to CFQ'
sudo sed -ie '/# defoptions/s/splash/splash elevator=cfq/' /boot/grub/menu.lst
sudo update-grub
else
echo 'Kernel process scheduler is already CFQ'
fi
# Preload is an adaptive readahead daemon. Read /usr/share/doc/preload/proposal.txt.gz after installing preload for more info
if [ ! -f /etc/preload.conf ]; then
logger ' Installed preload'
sudo apt-get --yes install preload
else
echo 'reload already installed'
fi
# Enable prelink which causes big applications like firefox and OO.o to load faster
if (! grep '^PRELINKING=yes' /etc/default/prelink > /dev/null 2>&1); then
logger ' Installed prelink'
sudo apt-get --yes install prelink && sudo sed -ie 's/unknown/yes/' /etc/default/prelink
# Uncomment this if you don't keep your computer on all night and want to have prelink run on newly installed software
# NOTE: This makes apt-get upgrade or apt-get dist-upgrade take a loooooong time.
#echo 'DPkg:ost-Invoke {'echo Running prelink, please wait...;/etc/cron.daily/prelink';}' >> /etc/apt/apt.conf
echo -n 'Running prelink for the first time so this might take awhile...'
sudo /etc/cron.daily/prelink && echo 'done'
else
echo 'relinking already enabled'
fi
# Disable ipv6 to improve network responsiveness and speed dhcp lease negotiation at boot time
if [ -d /etc/modprobe.d ]; then
if ( ! grep 'net-pf-10 off' /etc/modprobe.d/aliases > /dev/null 2>&1 ); then
logger ' Disabled ipv6'
sudo -u root echo 'alias net-pf-10 off' >> /etc/modprobe.d/aliases
fi
if ( ! grep 'ipv6 off' /etc/modprobe.d/aliases > /dev/null 2>&1 ); then
logger ' Disabled ipv6 alias'
sudo -u root echo 'alias ipv6 off' >> /etc/modprobe.d/aliases
fi
fi
# Speed up gnome a bit
logger ' Improved gnome speed'
gconftool-2 --set --type boolean /desktop/gnome/interface/enable_animations false
gconftool-2 --set --type boolean /apps/panel/global/enable_animations false
gconftool-2 --set --type string /apps/nautilus/preferences/preview_sound never
#gconftool-2 --set --type string /apps/nautilus/preferences/show_p_w_picpath_thumbnails never
#gconftool-2 --set --type string /apps/nautilus/preferences/show_icon_text never
# Performance tweak to speed up your hard drive
#logger ' Enabled IDE hard disk tweaks'
#sudo /sbin/hdparm -u1 -m16 -c1 -A1 -a64 -d1 -K1 $INSTALLED_DRIVE > /dev/null
# Performance tweak to speed up ext3 partitions with lots of files
#for volume in $(mount 2> /dev/null| grep ext3 | awk '{print $1}'); do
# logger ' Enabled dir_index ext3 option for $volume'
# sudo tune2fs -O dir_index '$volume'
#done
# Enable dash as /bin/sh to run shell scripts instead of bloated bash
# See
#if ( ! dpkg -l dash >/dev/null 2>&1 ); then
# sudo apt-get install dash && sudo update-alternatives --install /bin/sh sh /bin/dash 1
#else
# sudo update-alternatives --install /bin/sh sh /bin/dash 1
#fi
# Disable unnecessary services.
# Remove any of these if you use them: hplip: hp printers, bluez-utils: bluetooth, pppd-dns: dialup users.
for service in hplip ppp festival bluez-utils mdadm apmd brltty lvm evms pppd-dns waitnfs.sh; do
logger ' Disabled service $service'
sudo /etc/init.d/$service stop
sudo update-rc.d -f $service remove
done
# Disable more unnecessary services if the computer is not a laptop
# Comment out this section if you are using a laptop
for service in laptop-mode pcmcia pcmciautils; do
logger ' Disabled service $service'
sudo /etc/init.d/$service remove
sudo update-rc.d -f $service remove
done
# Re-enable password prompts for users in the admin group running sudo
#sudo sed -ie '/NOPASSWD/s/NOPASSWD: //' /etc/sudoers
logger ' -===== Installation log finished on $(date) for faster-dapper.sh =====- '
echo ' -===== Installation finished on $(date) for faster-dapper.sh =====- '
echo ' '
echo 'Your installation of Ubuntu 6.06 Dapper Drake should run faster now...'
echo 'lease reboot your computer for some changes to take affect.'
联系客服