{"id":254126,"date":"2022-10-11T08:09:51","date_gmt":"2022-10-11T00:09:51","guid":{"rendered":"https:\/\/lrxjmw.cn\/?p=254126"},"modified":"2022-10-04T11:11:51","modified_gmt":"2022-10-04T03:11:51","slug":"ubuntu-system-cleaning-steps","status":"publish","type":"post","link":"https:\/\/lrxjmw.cn\/ubuntu-system-cleaning-steps.html","title":{"rendered":"Ubuntu\u7cfb\u7edf\u6e05\u7406\u6b65\u9aa4"},"content":{"rendered":"\n\n\n
\u5bfc\u8bfb<\/td>\n\u73b0\u5728\uff0c\u8bd5\u8bd5\u770b\u8fd9 4 \u4e2a\u7b80\u5355\u7684\u6b65\u9aa4\uff0c\u6765\u6e05\u7406\u4f60\u7684 Ubuntu \u7cfb\u7edf\u5427\u3002<\/strong><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n

\u8fd9\u4efd\u7cbe\u7b80\u6307\u5357\u5c06\u544a\u8bc9\u4f60\u5982\u4f55\u6e05\u7406 Ubuntu \u7cfb\u7edf\u4ee5\u53ca\u5982\u4f55\u91ca\u653e\u4e00\u4e9b\u78c1\u76d8\u7a7a\u95f4\u3002<\/p>\n

\u5982\u679c\u4f60\u7684 Ubuntu \u7cfb\u7edf\u5df2\u7ecf\u8fd0\u884c\u4e86\u81f3\u5c11\u4e00\u5e74\uff0c\u5c3d\u7ba1\u7cfb\u7edf\u662f\u6700\u65b0\u7684\uff0c\u4f60\u4ecd\u7136\u53ef\u80fd\u4f1a\u89c9\u5f97\u4f60\u7684 Ubuntu \u7cfb\u7edf\u8fd0\u884c\u7f13\u6162\u4e14\u6ede\u540e\u3002<\/p>\n

\u5728\u8fc7\u53bb\uff0c\u56e0\u4e3a\u4f60\u60f3\u8bd5\u9a8c\u67d0\u4e00\u5e94\u7528\u7a0b\u5e8f\uff0c\u6216\u662f\u5728\u770b\u5230\u4e86\u5b83\u7684\u597d\u8bc4\u63a8\u8350\u4e4b\u540e\uff0c\u800c\u5b89\u88c5\u4e86\u8bb8\u591a\u5e94\u7528\u7a0b\u5e8f\uff0c\u4f46\u4f60\u5e76\u6ca1\u6709\u5220\u9664\u5b83\u4eec\u3002\u4e0b\u9762\u8fd9\u4e9b\u65b9\u6cd5\u53ef\u4ee5\u5e2e\u52a9\u4f60\u627e\u51fa\u4e00\u4e9b\u53ef\u4ee5\u91ca\u653e\u7684\u9690\u85cf\u78c1\u76d8\u7a7a\u95f4\u3002<\/p>\n

\u6e05\u7406 Ubuntu \u7cfb\u7edf\u7684\u6b65\u9aa4<\/strong><\/div>\n
1\u3001\u6e05\u7406 Apt \u7f13\u5b58<\/strong><\/span><\/div>\n

Apt \u7f13\u5b58\u662f Ubuntu \u7cfb\u7edf\u4fdd\u5b58\u4f60\u4e0b\u8f7d\u8fc7\u7684\u6240\u6709\u6587\u4ef6\u7684\u5730\u65b9\uff0c\u4ee5\u4f9b\u4f60\u4e4b\u540e\u53ef\u4ee5\u67e5\u770b\u5b83\u3002\u5927\u591a\u6570\u7528\u6237\u4e0d\u4f1a\u53bb\u6e05\u7406 Apt \u7f13\u5b58\uff0c\u800c\u5b83\u5374\u53ef\u80fd\u4f1a\u5360\u7528\u6570\u767e\u5146\u5b57\u8282\u3002<\/p>\n

\u6253\u5f00\u7ec8\u7aef\uff0c\u5e76\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\uff0c\u53ef\u4ee5\u5f97\u5230\u4f60\u7684 Apt \u7f13\u5b58\u6709\u591a\u5c11\uff1a<\/p>\n

\r\ndu -sh \/var\/cache\/apt\/archives\r\n<\/pre>\n

\"\"
\n\u5982\u679c\u4f60\u7684 Ubuntu \u7cfb\u7edf\u5df2\u7ecf\u5b89\u88c5\u4e86\u5f88\u4e45\u7684\u8bdd\uff0c\u4f60\u5c06\u770b\u5230\u8fd9\u4e2a\u6570\u5b57\u975e\u5e38\u5927\u3002\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\u6765\u6e05\u7406 Apt \u7f13\u5b58\u3002<\/p>\n

\r\nsudo apt-get clean\r\n<\/pre>\n
2\u3001\u5220\u9664\u65e0\u7528\u7684\u5185\u6838<\/strong><\/span><\/div>\n

\u5982\u679c\u4f60\u5df2\u7ecf\u8fd0\u884c Ubuntu \u7cfb\u7edf\u8d85\u8fc7\u4e86\u4e00\u5e74\uff0c\u90a3\u4e48\u4f60\u5f88\u53ef\u80fd\u5b89\u88c5\u591a\u4e2a\u5185\u6838\u3002\u5982\u679c\u4f60\u7684\u786c\u4ef6\u662f\u6700\u65b0\u7684\uff0c\u5e76\u4e14\u4e0e Linux \u517c\u5bb9\u800c\u6ca1\u6709\u592a\u591a\u914d\u7f6e\uff0c\u4f60\u53ef\u4ee5\u5220\u9664\u65e7\u7684\u5185\u6838\uff0c\u4fdd\u7559\u6700\u65b0\u7684\u5185\u6838\u3002<\/p>\n

\u5728\u7ec8\u7aef\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\u6765\u5220\u9664\u65e7\u7684\u5185\u6838\uff1a<\/p>\n

\r\nsudo apt-get autoremove --purge\r\n<\/pre>\n

\"\"<\/p>\n

3\u3001\u5220\u9664\u65e7\u7684\u5e94\u7528\u7a0b\u5e8f\u548c\u8f6f\u4ef6\u5305<\/strong><\/span><\/div>\n

\u5982\u679c\u4f60\u662f\u4e00\u4e2a\u559c\u6b22\u5c1d\u8bd5 Linux \u5e94\u7528\u7a0b\u5e8f\u7684\u4eba\uff0c\u90a3\u4e48\u4f60\u7684\u7cfb\u7edf\u4e2d\u80af\u5b9a\u6709\u4e00\u4e9b\u4e0d\u518d\u9700\u8981\u7684\u6ca1\u7528\u7684\u5e94\u7528\u7a0b\u5e8f\u3002<\/p>\n

\u73b0\u5728\uff0c\u4f60\u53ef\u80fd\u5df2\u7ecf\u5fd8\u8bb0\u4e86\u4f60\u5b89\u88c5\u8fc7\u7684\u5e94\u7528\u7a0b\u5e8f\u540d\u79f0\u3002\u4e0d\u8fc7\u4f60\u53ef\u4ee5\u5728\u7ec8\u7aef\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\u6765\u67e5\u770b\u4f60\u6700\u8fd1\u5b89\u88c5\u7684\u5185\u5bb9\uff1a<\/p>\n

\u4f60\u4f1a\u5f97\u5230\u901a\u8fc7 \u200b\u200bapt\u200b\u200b \u547d\u4ee4\u5b89\u88c5\u7684\u5e94\u7528\u7a0b\u5e8f\u548c\u8f6f\u4ef6\u5305\u7684\u5217\u8868\uff1a<\/p>\n

\r\nhistory | grep \"apt-get install\"\r\n<\/pre>\n

\"\"<\/p>\n

\u4f60\u5c06\u5f97\u5230\u6700\u8fd1\u5b89\u88c5\u7684\u5e94\u7528\u7a0b\u5e8f\u5217\u8868\uff1a<\/p>\n

\r\ngrep \" install \" \/var\/log\/dpkg.log.1\r\nzgrep \" install \" \/var\/log\/dpkg.log.2.gz\r\n<\/pre>\n

\u4f60\u53ef\u4ee5\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\u6765\u5220\u9664\u5e94\u7528\u7a0b\u5e8f\u548c\u8f6f\u4ef6\u5305\uff1a<\/p>\n

\r\nsudo apt remove app1 package1\r\n<\/pre>\n
4\u3001\u4f7f\u7528\u7cfb\u7edf\u6e05\u7406\u5e94\u7528<\/strong><\/span><\/div>\n

\u6709\u5927\u91cf\u514d\u8d39\u548c\u539f\u751f\u7684\u7cfb\u7edf \u200b\u200b\u6e05\u7406\u5e94\u7528<\/a> \u53ef\u4ee5\u4f7f\u7528\u3002\u4f46\u662f\uff0c\u6211\u8ba4\u4e3a \u200b\u200bBleachBit<\/a>\u200b\u200b \u662f\u6e05\u7406\u7cfb\u7edf\u6700\u597d\u7684\u4e00\u4e2a\u5e94\u7528\uff0c\u56e0\u4e3a\u5b83\u7ecf\u4e45\u4e0d\u8870\u3002<\/p>\n

\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u5b89\u88c5 BleachBit \u6216\u901a\u8fc7\u5e94\u7528\u5546\u5e97\u5b89\u88c5\u3002<\/p>\n

\r\nsudo apt install bleachbit\r\n<\/pre>\n

\u5b89\u88c5\u540e\uff0c\u6253\u5f00 BleachBit\uff0c\u5e76\u8fd0\u884c\u626b\u63cf\u3002\u5b83\u4f1a\u5411\u4f60\u663e\u793a\u6d4f\u89c8\u5668\u5360\u7528\u7684\u6240\u6709\u7f13\u5b58\u6587\u4ef6\u3001\u4e34\u65f6\u6587\u4ef6\u3001\u5783\u573e\u7b49\uff0c\u4f60\u53ea\u9700\u5355\u51fb\u4e00\u4e2a\u6309\u94ae\u5373\u53ef\u6e05\u7406\u5b83\u3002<\/p>\n

\"\"<\/p>\n

\u9644\u9001\u6280\u5de7<\/strong><\/div>\n
\u6e05\u7406 Flatpak \u8f6f\u4ef6\u5305<\/strong><\/span><\/div>\n

Flatpak \u5e94\u7528\u7a0b\u5e8f\u548c\u8fd0\u884c\u65f6runtime\u4f1a\u5360\u7528\u5927\u91cf\u78c1\u76d8\u7a7a\u95f4\u3002\u56e0\u4e3a\u5728\u8bbe\u8ba1\u4e0a\uff0cFlatpak \u7684\u53ef\u6267\u884c\u6587\u4ef6\u7ed3\u5408\u4e86\u8fd0\u884c\u65f6\u3002\u5c3d\u7ba1\u8fd0\u884c\u65f6\u53ef\u4ee5\u5728\u76f8\u5173\u5e94\u7528\u7a0b\u5e8f\u4e4b\u95f4\u5171\u4eab\uff0c\u4f46\u8bb8\u591a\u672a\u4f7f\u7528\u7684\u5269\u4f59\u8fd0\u884c\u65f6\u53ef\u80fd\u4f1a\u5360\u7528\u4f60\u7684\u78c1\u76d8\u7a7a\u95f4\u3002<\/p>\n

\u5220\u9664\u4e00\u4e9b\u672a\u4f7f\u7528\u7684 Flatpak \u5305\u6700\u76f4\u63a5\u7684\u65b9\u6cd5\u662f\u4e0b\u9762\u7684\u547d\u4ee4\u3002\u5728\u7ec8\u7aef\u8fd0\u884c\u8fd9\u4e00\u547d\u4ee4\u3002<\/p>\n

\r\nflatpak uninstall --unused\r\n<\/pre>\n

\u53ef\u4ee5\u53c2\u8003 \u200b\u200b\u8fd9\u7bc7\u6587\u7ae0<\/a>\u200b\u200b \u4e86\u89e3\u6709\u5173 Flatpak \u5305\u7684\u66f4\u591a\u4fe1\u606f\u3002<\/p>\n

\u6e05\u7406\u672a\u4f7f\u7528\u7684 Snap \u9879\u76ee<\/strong><\/span><\/div>\n

\u5982\u679c\u4f60\u4f7f\u7528 Ubuntu \u7cfb\u7edf\uff0c\u90a3\u4e48\u4f60\u5f88\u6709\u53ef\u80fd\u4f7f\u7528\u7684\u662f Snap \u8f6f\u4ef6\u5305\u3002\u968f\u7740\u65f6\u95f4\u7684\u63a8\u79fb\uff0cSnap \u4f1a\u79ef\u7d2f\u4e0d\u76f8\u5173\u7684\u8fd0\u884c\u65f6\u548c\u6587\u4ef6\u3002\u4f60\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u811a\u672c\u6765\u6e05\u7406\u4e00\u4e9b\u6ca1\u7528\u7684 snap \u8fd0\u884c\u65f6\u3002<\/p>\n

\u5c06\u4e0b\u9762\u7684\u811a\u672c\u590d\u5236\u5230\u4e00\u4e2a\u65b0\u6587\u4ef6\u4e2d\uff0c\u5e76\u5c06\u5176\u547d\u540d\u4e3a \u200b\u200bclean_snap.sh\u200b\u200b\uff1a<\/p>\n

\u7136\u540e\u4f7f\u7528 \u200b\u200bchmod +x clean_snap.sh\u200b\u200b \u547d\u4ee4\u6765\u8d4b\u4e88\u5b83\u53ef\u6267\u884c\u6743\u9650\uff0c\u5e76\u901a\u8fc7 \u200b\u200b.\/clean_snap.sh\u200b\u200b \u8fd0\u884c<\/p>\n

\r\n#!\/bin\/bash  \r\n\r\n#Removes old revisions of snaps  \r\n\r\n#CLOSE ALL SNAPS BEFORE RUNNING THIS  \r\n\r\nset -eu  \r\n\r\nLANG=en_US.UTF-8 \r\n\r\nsnap list --all | awk '\/disabled\/{print $1, $3}' |\r\n\r\n      while read snapname revision; do\r\n\r\n          snap remove \"$snapname\" --revision=\"$revision\"\r\n\r\n      done\r\n<\/pre>\n

\u53ef\u4ee5\u53c2\u8003 \u200b\u200b\u8fd9\u7bc7\u6587\u7ae0<\/a>\u200b\u200b \u4e86\u89e3\u6709\u5173\u6e05\u7406 Snap \u5305\u7684\u66f4\u591a\u4fe1\u606f\u3002<\/p>\n

\u66f4\u591a\u6280\u5de7<\/strong><\/div>\n

\u4f60\u8fd8\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u6765\u624b\u52a8\u641c\u7d22\u5927\u6587\u4ef6\u3002<\/p>\n

\r\nfind \/home -type f -exec du -h {} + | sort -hr | head -20\r\n<\/pre>\n

\u4f8b\u5982\uff0c\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\uff0c\u4f60\u4f1a\u5f97\u5230\u6839\u76ee\u5f55 \u200b\u200b\/\u200b\u200b \u4e2d\u7684\u524d 20 \u4e2a\u5927\u6587\u4ef6\u3002\u73b0\u5728\u4f60\u53ef\u4ee5\u67e5\u770b\u5927\u6587\u4ef6\uff0c\u5e76\u4f7f\u7528\u6587\u4ef6\u7ba1\u7406\u5668\u624b\u52a8\u5220\u9664\u5b83\u4eec\u3002\u8bf7\u6ce8\u610f\u5220\u9664\u6587\u4ef6\u65f6\u8981\u975e\u5e38\u5c0f\u5fc3\u3002\u5c3d\u91cf\u4e0d\u8981\u6d89\u53ca \u200b\u200b\/home\u200b\u200b \u76ee\u5f55\u4ee5\u5916\u7684\u4efb\u4f55\u5185\u5bb9\u3002<\/p>\n

\"\"<\/p>\n

\u603b\u7ed3<\/strong><\/div>\n

\u8fd9\u6837\u5c31\u5b8c\u6210\u4e86\u3002\u5982\u679c\u4f60\u6309\u7167\u4e0a\u8ff0\u6b65\u9aa4\u64cd\u4f5c\uff0c\u4f60\u4e00\u5b9a\u80fd\u591f\u91ca\u653e Ubuntu \u7cfb\u7edf\u4e2d\u7684\u4e00\u4e9b\u7a7a\u95f4\uff0c\u73b0\u5728\u4f60\u7684\u7cfb\u7edf\u6709\u5269\u4f59\u7a7a\u95f4\u4e86\u3002\u4f60\u53ef\u4ee5\u6309\u7167\u8fd9\u4e9b\u63aa\u65bd\u6765\u6e05\u7406 Ubuntu \u7cfb\u7edf\u3002\u4e0d\u8981\u5fd8\u8bb0\u4f7f\u7528\u6700\u65b0\u7684\u8f6f\u4ef6\u5305\uff0c\u4f7f\u4f60\u7684\u7cfb\u7edf\u4fdd\u6301\u5230\u6700\u65b0\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"

\u8fd9\u4efd\u7cbe\u7b80\u6307\u5357\u5c06\u544a\u8bc9\u4f60\u5982\u4f55\u6e05\u7406 Ubuntu \u7cfb\u7edf\u4ee5\u53ca\u5982\u4f55\u91ca\u653e\u4e00\u4e9b\u78c1\u76d8\u7a7a\u95f4\u3002 \u5982\u679c\u4f60\u7684 Ubuntu \u7cfb\u7edf\u5df2\u7ecf\u8fd0 […]<\/p>\n","protected":false},"author":1329,"featured_media":254143,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[55],"tags":[],"class_list":["post-254126","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-thread"],"acf":[],"_links":{"self":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/254126","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/users\/1329"}],"replies":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/comments?post=254126"}],"version-history":[{"count":2,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/254126\/revisions"}],"predecessor-version":[{"id":254142,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/254126\/revisions\/254142"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media\/254143"}],"wp:attachment":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media?parent=254126"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/categories?post=254126"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/tags?post=254126"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}