共26个,如下:
root
daemon
bin
sys
sync
games
man
lp
mail
news
uucp
proxy
www-data
backup
list
irc
gnats
nobody
_apt
systemd-timesync
systemd-network
systemd-resolve
messagebus
sshd
systemd-coredump
redis
Intel(R) Xeon(R) Platinum 8369HC CPU @ 3.30GHz
数据截止至2024-7-10 15:58
总空间: 41955831808 MB(39 GB)
可用空间: 9529876480MB(8 GB)
路径:/tmp/exec_随机的八位字符串/
我们的代码程序名:prog
#include <fstream>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
int main() {
std::ifstream passwdFile("/etc/passwd");
if (!passwdFile) {
std::cerr << "Error: Unable to open /etc/passwd\n";
return 1;
}
std::string line;
while (std::getline(passwdFile, line)) {
std::istringstream iss(line);
std::string username;
std::getline(iss, username, ':');
std::cout << username << std::endl;
}
passwdFile.close();
return 0;
}
#include <iostream>
#include <fstream>
#include <string>
int main() {
std::string line;
std::ifstream cpuinfo("/proc/cpuinfo");
if (cpuinfo.is_open()) {
while (getline(cpuinfo, line)) {
if (line.find("model name") != std::string::npos) {
std::size_t pos = line.find(":");
if (pos != std::string::npos) {
std::string model = line.substr(pos + 2);
std::cout << model << std::endl;
break;
}
}
}
cpuinfo.close();
} else {
std::cerr << "Unable to open /proc/cpuinfo" << std::endl;
}
return 0;
}
#include <iostream>
#include <sys/statvfs.h>
int main() {
struct statvfs buf;
if (statvfs("/", &buf) == 0) {
unsigned long long total_space = buf.f_frsize * buf.f_blocks;
unsigned long long free_space = buf.f_frsize * buf.f_bfree;
std::cout << "总空间: " <<total_space<<" MB("<< total_space / (1024 * 1024 * 1024) << " GB)" << std::endl;
std::cout << "可用空间: "<<free_space<<"MB(" << free_space / (1024 * 1024 * 1024) << " GB)" << std::endl;
} else {
std::cerr << "获取文件系统信息失败" << std::endl;
return 1;
}
return 0;
}
#include <iostream>
#include <unistd.h>
int main(int argc, char *argv[]) {
char buffer[FILENAME_MAX];
if (argc > 0) {
std::cout << argv[0] << std::endl;
} else {
std::cerr << "无法获取程序文件名" << std::endl;
return 1;
}
return 0;
}