-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdeb-clear.cpp
More file actions
61 lines (55 loc) · 1.91 KB
/
Copy pathdeb-clear.cpp
File metadata and controls
61 lines (55 loc) · 1.91 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
/*
* Deb-Clear - Debian系LINUX发行版磁盘清理工具。
* Copyright (C) 2026 ChysnTech
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <cstdlib>
const std::string VERSION = "1.1";
const std::string PROGRAM_NAME = "Deb Clear";
void showVersion(){
std::cout << PROGRAM_NAME << " version " << VERSION << "\n";
}
//Main 主程序
int main(){
char lang;
char clear;
std::cout << "Deb Clear 磁盘储存清理程序" << std::endl;
std::system("df -h /");
std::cout << "你想要清理根文件系统(/)吗? \n 这需要sudo或者root权限才可以执行 (y/n)" << std::endl;
std::cin >> clear;
if(clear == 'y' || clear == 'Y'){
std::cout << "开始清理\n" << std::endl;
std::cout << "清理apt无用包...";
std::system("sudo apt clean");
std::system("sudo apt autopurge -y");
std::system("sudo apt autoclean");
std::cout << "清理用户缓存...\n";
std::system("rm -r ~/.cache/*");
std::cout << "清理日志...\n";
std::system("sudo journalctl --vacuum-size=100M");
std::cout << "清理tmp...\n";
std::system("sudo rm -r /tmp/*");
std::cout << "[ OK ] 完成清理,请检查。\n";
}if(clear == 'N' || clear == 'n'){
std::cout << "退出" << std::endl;
std::system("exit");
}
return 0;
}