所以我不小心输入了: sudo chmod a-wrx /etc
由于 etc 包含sudeors.d
许多其他重要内容,我无法登录/退出或执行任何管理任务。
我加载了 GRUB 并从那里获取 root 权限,我做了:
chmod a+wrx /etc
并最终登录到机器,但现在已经乱套了(无法正常关机、外观已改变,...等等)。
如何恢复安装时附带的 etc (或任何文件系统) 的默认权限 (无需重新安装系统)?
答案1
我在评论中发布的链接中有一个命令可以创建具有权限的文件。我在我的机器上执行了它并得到了这个。
- 首先这样做:https://askubuntu.com/a/309031/15811
- 然后将这些命令添加到脚本中(复制/粘贴;命名它
restoreetc.sh
、使其可执行(chmod 775 restoreetc.sh
)并执行它(gksudo restoreetc.sh
):
chmod a+x /etc/grub.d/20_linux_xen
chmod a+x /etc/grub.d/41_custom
chmod a+x /etc/grub.d/20_memtest86+
chmod a+x /etc/grub.d/00_header
chmod a+x /etc/grub.d/30_uefi-firmware
chmod a+x /etc/grub.d/10_linux
chmod a+x /etc/grub.d/40_custom
chmod a+x /etc/grub.d/05_debian_theme
chmod a+x /etc/grub.d/30_os-prober
chmod a+x /etc/gtk-3.0/settings.ini
chmod a+x /etc/brltty/latex-access.ctb
chmod a+x /etc/security/namespace.init
chmod a+x /etc/dhcp/dhclient-exit-hooks.d/zzz_avahi-autoipd
chmod a+x /etc/dhcp/dhclient-enter-hooks.d/avahi-autoipd
chmod a+x /etc/dhcp/dhclient-enter-hooks.d/samba
chmod a+x /etc/resolvconf/update-libc.d/avahi-daemon
chmod a+x /etc/resolvconf/update.d/libc
chmod a+x /etc/resolvconf/update.d/dnscache
chmod a+x /etc/mysql/debian-start
chmod a+x /etc/X11/xinit/xserverrc
chmod a+x /etc/X11/Xreset
chmod a+x /etc/X11/Xsession
chmod a+x /etc/dkms/template-dkms-mkdeb/debian/prerm
chmod a+x /etc/dkms/template-dkms-mkdeb/debian/postinst
chmod a+x /etc/dkms/template-dkms-mkdeb/debian/rules
chmod a+x /etc/wpa_supplicant/ifupdown.sh
chmod a+x /etc/wpa_supplicant/functions.sh
chmod a+x /etc/wpa_supplicant/action_wpa.sh
chmod a+x /etc/acpi/thinkpad-radiosw.sh
chmod a+x /etc/acpi/powerbtn.sh
chmod a+x /etc/acpi/fglrx-powermode.sh
chmod a+x /etc/acpi/asus-keyboard-backlight.sh
chmod a+x /etc/acpi/asus-wireless.sh
chmod a+x /etc/acpi/tosh-wireless.sh
chmod a+x /etc/acpi/ibm-wireless.sh
chmod a+x /etc/acpi/undock.sh
chmod a+x /etc/network/if-post-down.d/wireless-tools
chmod a+x /etc/network/if-pre-up.d/wireless-tools
chmod a+x /etc/network/if-pre-up.d/ethtool
chmod a+x /etc/network/if-up.d/avahi-autoipd
chmod a+x /etc/network/if-up.d/upstart
chmod a+x /etc/network/if-up.d/avahi-daemon
chmod a+x /etc/network/if-up.d/ethtool
chmod a+x /etc/network/if-up.d/000resolvconf
chmod a+x /etc/network/if-up.d/ntpdate
chmod a+x /etc/network/if-down.d/resolvconf
chmod a+x /etc/network/if-down.d/avahi-autoipd
chmod a+x /etc/network/if-down.d/upstart
chmod a+x /etc/smartd_warning.sh
chmod a+x /etc/init.d/sudo
chmod a+x /etc/init.d/dbus
chmod a+x /etc/init.d/brltty
chmod a+x /etc/init.d/cpufreqd
chmod a+x /etc/init.d/rcS
chmod a+x /etc/init.d/umountroot
chmod a+x /etc/init.d/saned
chmod a+x /etc/init.d/console-setup
chmod a+x /etc/init.d/unattended-upgrades
chmod a+x /etc/init.d/resolvconf
chmod a+x /etc/init.d/mysql
chmod a+x /etc/init.d/vboxautostart-service
chmod a+x /etc/init.d/single
chmod a+x /etc/init.d/loadcpufreq
chmod a+x /etc/init.d/rsync
chmod a+x /etc/init.d/apport
chmod a+x /etc/init.d/udev
chmod a+x /etc/init.d/urandom
chmod a+x /etc/init.d/dns-clean
chmod a+x /etc/init.d/bluetooth
chmod a+x /etc/init.d/vboxweb-service
chmod a+x /etc/init.d/killprocs
chmod a+x /etc/init.d/apparmor
chmod a+x /etc/init.d/lightdm
chmod a+x /etc/init.d/cups
chmod a+x /etc/init.d/rc
chmod a+x /etc/init.d/kmod
chmod a+x /etc/init.d/grub-common
chmod a+x /etc/init.d/vboxdrv
chmod a+x /etc/init.d/atieventsd
chmod a+x /etc/init.d/umountnfs.sh
chmod a+x /etc/init.d/rc.local
chmod a+x /etc/init.d/rsyslog
chmod a+x /etc/init.d/smartmontools
chmod a+x /etc/init.d/avahi-daemon
chmod a+x /etc/init.d/networking
chmod a+x /etc/init.d/bootchart
chmod a+x /etc/init.d/pulseaudio
chmod a+x /etc/init.d/pppd-dns
chmod a+x /etc/init.d/procps
chmod a+x /etc/init.d/tlp
chmod a+x /etc/init.d/halt
chmod a+x /etc/init.d/speech-dispatcher
chmod a+x /etc/init.d/anacron
chmod a+x /etc/init.d/umountfs
chmod a+x /etc/init.d/cpufrequtils
chmod a+x /etc/init.d/sendsigs
chmod a+x /etc/init.d/reboot
chmod a+x /etc/init.d/ondemand
chmod a+x /etc/init.d/x11-common
chmod a+x /etc/init.d/vboxballoonctrl-service
chmod a+x /etc/init.d/acpid
chmod a+x /etc/init.d/irqbalance
chmod a+x /etc/init.d/cups-browsed
chmod a+x /etc/init.d/kerneloops
chmod a+x /etc/pm/sleep.d/10_grub-common
chmod a+x /etc/pm/sleep.d/10_unattended-upgrades-hibernate
chmod a+x /etc/pm/sleep.d/novatel_3g_suspend
chmod a+x /etc/ppp/ipv6-down
chmod a+x /etc/ppp/ip-up.d/0dns-up
chmod a+x /etc/ppp/ip-up.d/0000usepeerdns
chmod a+x /etc/ppp/ip-up.d/000resolvconf
chmod a+x /etc/ppp/ip-down.d/0000usepeerdns
chmod a+x /etc/ppp/ip-down.d/0dns-down
chmod a+x /etc/ppp/ip-down.d/000resolvconf
chmod a+x /etc/ppp/ip-down
chmod a+x /etc/ppp/pppoe_on_boot
chmod a+x /etc/ppp/ipv6-up
chmod a+x /etc/ppp/ip-up
chmod a+x /etc/rmt
chmod a+x /etc/rc.local
chmod a+x /etc/cron.daily/0anacron
chmod a+x /etc/cron.daily/man-db
chmod a+x /etc/cron.daily/upstart
chmod a+x /etc/cron.daily/apport
chmod a+x /etc/cron.daily/update-notifier-common
chmod a+x /etc/cron.daily/cracklib-runtime
chmod a+x /etc/cron.daily/passwd
chmod a+x /etc/cron.daily/mlocate
chmod a+x /etc/cron.daily/bsdmainutils
chmod a+x /etc/cron.daily/popularity-contest
chmod a+x /etc/cron.daily/dpkg
chmod a+x /etc/cron.daily/apt
chmod a+x /etc/cron.daily/logrotate
chmod a+x /etc/smartmontools/run.d/10mail
chmod a+x /etc/smartmontools/run.d/10powersave-notify
chmod a+x /etc/NetworkManager/dispatcher.d/99tlp-rdw-nm
chmod a+x /etc/NetworkManager/dispatcher.d/01ifupdown
chmod a+x /etc/apm/event.d/20hdparm
chmod a+x /etc/apm/event.d/anacron
chmod a+x /etc/apm/scripts.d/alsa
chmod a+x /etc/update-motd.d/91-release-upgrade
chmod a+x /etc/update-motd.d/98-fsck-at-reboot
chmod a+x /etc/update-motd.d/10-help-text
chmod a+x /etc/update-motd.d/98-reboot-required
chmod a+x /etc/update-motd.d/00-header
chmod a+x /etc/update-motd.d/90-updates-available
chmod a+x /etc/cron.weekly/0anacron
chmod a+x /etc/cron.weekly/man-db
chmod a+x /etc/cron.weekly/fstrim
chmod a+x /etc/cron.weekly/update-notifier-common
chmod a+x /etc/cron.weekly/apt-xapian-index
chmod a+x /etc/avahi/avahi-autoipd.action
chmod a+x /etc/cron.monthly/0anacron
chmod a+x /etc/kernel/postinst.d/zz-update-grub
chmod a+x /etc/kernel/postinst.d/dkms
chmod a+x /etc/kernel/postinst.d/pm-utils
chmod a+x /etc/kernel/postinst.d/apt-auto-removal
chmod a+x /etc/kernel/postinst.d/initramfs-tools
chmod a+x /etc/kernel/header_postinst.d/dkms
chmod a+x /etc/kernel/postrm.d/zz-update-grub
chmod a+x /etc/kernel/postrm.d/initramfs-tools
chmod a+x /etc/kernel/prerm.d/dkms
chmod a+x /etc/pcmcia/comedi
chmod a+x /etc/ca-certificates/update.d/jks-keystore
答案2
为了运行 ssh,你还需要执行
chmod 400 /etc/ssh/ssh*key
和
service ssh restart