sh OS X清理
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了sh OS X清理相关的知识,希望对你有一定的参考价值。
#!/bin/bash
# https://github.com/n8felton/DeployStudio/blob/master/DeployStudio%20Admin.app/Contents/Frameworks/DSCore.framework/Versions/A/Resources/Tools/osxcleanup.sh
# https://managingosx.wordpress.com/2009/01/23/image-cleanup-script/
# https://wikis.uit.tufts.edu/confluence/display/exchange2010/Remove+account+in+Single+User+mode
# Copy this script to /private/var/root/.profile
echo Check and mount disk
/sbin/fsck -fy
/sbin/mount -uw /
echo Remove volume info db
/bin/rm -fv /private/var/db/volinfo.database 2>&1
echo Remove system keychain. Regenerated with systemkeychain
/bin/rm -fv /Library/Keychains/System.keychain
echo Clean up global caches and temp data
/bin/rm -rfv /Library/Caches/*
/bin/rm -rfv /System/Library/Caches/*
/bin/rm -rfv /Users/Shared/*
/bin/rm -fv /private/etc/ssh_host*
echo Network interfaces
echo This is regenerated on reboot and can differ on different hardware
/bin/rm -fv /private/var/db/NetworkInterfaces.xml 2>&1
echo Kerberos cleanup
/bin/rm -fv /etc/krb5.keytab 2>&1
/bin/rm -rfv /var/db/krb5kdc 2>&1
/bin/rm -fv /var/db/dslocal/nodes/Default/config/KerberosKDC.plist 2>&1
echo Clean up other random files and directories
/bin/rm -rfv /Library/Preferences/* 2>&1
/bin/rm -fv /System/Library/Extensions.kextcache 2>&1
/bin/rm -fv /System/Library/Extensions.mkext 2>&1
/bin/rm -fv /private/var/db/BootCache.playlist 2>&1
/bin/rm -fv /var/db/dhcpclient/leases/* 2>&1
/bin/rm -fv /var/db/dyld/dyld* 2>&1
/bin/rm -fv /var/pcast/server/krb_cc 2>&1
/bin/rm -fv /var/vm/sleepimage 2>&1
echo Remove the local user
/bin/rm -r /Users/itsadmin
/bin/rm -fv /var/db/dslocal/nodes/Default/users/itsadmin.plist
echo Generate new system keychain
/usr/sbin/systemkeychain -k /Library/Keychains/System.keychain -C -f
echo Seal the system
/bin/rm -fv /var/db/.AppleSetupDone
echo Cleanup roots home dir
rm -rfv /private/var/root/Desktop/*
rm -rfv /private/var/root/Documents/*
rm -rfv /private/var/root/Downloads/*
rm -rfv /private/var/root/Library/Caches/*
rm -rfv /private/var/root/Library/Recent\ Servers/*
rm -rfv /private/var/root/Library/Logs/*
rm -rfv /private/var/root/Library/Keychains/*
rm -rfv /private/var/root/Library/Preferences/ByHost/*
rm -fv /private/var/root/Library/Preferences/com.apple.recentitems.plist
echo Remove this script
srm -fv /private/var/root/.profile
srm -fv /private/var/root/.sh_history
以上是关于sh OS X清理的主要内容,如果未能解决你的问题,请参考以下文章