-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
3,059 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
查询大于1G大小的文件 | ||
1 | ||
find / -type f -size +1G | ||
查询home目录大小 | ||
0 | ||
du -sh /home |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
查看网络连接 | ||
查看本地监听端口,服务,对应pid,程序名 | ||
1 | ||
netstat -tnlp | ||
谁连我 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
命令格式如下: | ||
cmd fhq 防火墙 | ||
cmd net 网络 | ||
cmd tmux tmux | ||
cmd file 文件目录 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#!/bin/bash | ||
|
||
# 检查命令是否存在并打印软件包管理器名称 | ||
check_command() { | ||
if command -v $1 &> /dev/null; then | ||
echo "$2 is available" | ||
exit 0 | ||
fi | ||
} | ||
|
||
# Check for common package managers | ||
check_command apt "APT (Debian, Ubuntu)" | ||
check_command apt-get "APT (Debian, Ubuntu)" | ||
check_command yum "YUM (CentOS, RHEL)" | ||
check_command dnf "DNF (Fedora, RHEL 8+)" | ||
check_command rpm "RPM (CentOS, RHEL, Fedora, SUSE)" | ||
check_command pacman "Pacman (Arch Linux)" | ||
check_command zypper "Zypper (openSUSE, SLES)" | ||
check_command eopkg "EOPKG (Solus)" | ||
check_command snap "Snap (Cross-distribution)" | ||
check_command flatpak "Flatpak (Cross-distribution)" | ||
check_command opkg "OPKG (OpenWrt, embedded systems)" | ||
check_command pkg "PKG (FreeBSD)" | ||
check_command apk "APK (Alpine Linux)" | ||
check_command xbps-install "XBPS (Void Linux)" | ||
check_command swupd "swupd (Clear Linux)" | ||
check_command pkgutil "pkgutil (Solaris, Illumos)" | ||
check_command pkg_add "pkg_add (OpenBSD)" | ||
check_command yast "YaST (SUSE Linux Enterprise)" | ||
check_command equo "Equo (Sabayon Linux)" | ||
check_command emerge "Portage (Gentoo)" | ||
check_command nix-env "Nix (NixOS)" | ||
check_command guix "Guix (GuixSD)" | ||
check_command ups "UPS (Unified Package System, Oracle Solaris)" | ||
|
||
# 如果没有找到公共包管理器 | ||
echo "No common package manager found" | ||
exit 1 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#include <iostream> | ||
#include <string> | ||
|
||
std::string replaceBracketedContent(const std::string& input) { | ||
std::string output = input; | ||
size_t startPos = 0; | ||
while ((startPos = output.find('[', startPos))!= std::string::npos) { | ||
size_t endPos = output.find(']', startPos); | ||
if (endPos == std::string::npos) { | ||
break; | ||
} | ||
std::string key = output.substr(startPos + 1, endPos - startPos - 1); | ||
std::cout << "请输入 " << key << ": "; | ||
std::string value; | ||
std::cin >> value; | ||
output.replace(startPos, endPos - startPos + 1, value); | ||
startPos = endPos + value.size(); | ||
} | ||
return output; | ||
} | ||
|
||
int main() { | ||
std::string input = "firewall-cmd --permanent --add-rich-rule=\"rule family=\"ipv4\" source address=\"[ip]\" port port=\"[port]\" protocol=\"tcp\" accept\""; | ||
std::string output = replaceBracketedContent(input); | ||
std::cout << output << std::endl; | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
#include <iostream> | ||
#include <fstream> | ||
#include <string> | ||
#include <list> | ||
#include <windows.h> | ||
|
||
// 定义一个结构体来存储每行的信息 | ||
struct CommandInfo { | ||
std::string description; | ||
int flag; | ||
std::string command; | ||
}; | ||
|
||
void displayCommandWithNewlines(const std::string& command) { | ||
for (size_t i = 0; i < command.size() - 1; ++i) { | ||
if (command[i] == '\\' && command[i + 1] == 'r') { | ||
std::cout << std::endl; | ||
++i; // 跳过第二个 '\r' | ||
} else { | ||
std::cout << command[i]; | ||
} | ||
} | ||
std::cout << command.back() << std::endl; // 输出最后一个字符 | ||
} | ||
|
||
int main(int argc, char *argv[]) { | ||
if (argc == 1) { | ||
std::ifstream file("readme.txt"); // Windows 上更常用 ".txt" 扩展名 | ||
if (file.is_open()) { | ||
std::string line; | ||
while (std::getline(file, line)) { | ||
std::cout << line << std::endl; | ||
} | ||
file.close(); | ||
} else { | ||
std::cerr << "无法打开文件 readme.txt" << std::endl; | ||
return 1; | ||
} | ||
return 0; | ||
} | ||
|
||
char buff[MAX_PATH]; | ||
std::string argName = argv[1]; | ||
std::string output = std::string(getenv("USERPROFILE")) + "\\cmd\\" + argName; | ||
std::list<CommandInfo> commandList; | ||
std::ifstream file(output); // 替换为实际的文件名 | ||
|
||
if (!file.is_open()) { | ||
std::cerr << "无法打开文件" << std::endl; | ||
return 1; | ||
} | ||
|
||
std::string line; | ||
int lineCount = 1; | ||
CommandInfo info; | ||
int sequenceNumber = 1; // 序列号 | ||
|
||
while (std::getline(file, line)) { | ||
switch (lineCount) { | ||
case 1: | ||
info.description = line; | ||
break; | ||
case 2: | ||
info.flag = std::stoi(line); // 将字符串转换为整数 | ||
break; | ||
case 3: | ||
info.command = line; | ||
commandList.push_back(info); | ||
std::cout << sequenceNumber << ". " << info.description << std::endl; | ||
sequenceNumber++; | ||
lineCount = 0; | ||
break; | ||
} | ||
lineCount++; | ||
} | ||
|
||
file.close(); | ||
|
||
int choice; | ||
std::cout << "请输入要执行的序列号: "; | ||
std::cin >> choice; | ||
|
||
auto it = commandList.begin(); | ||
std::advance(it, choice - 1); // 将迭代器移动到用户选择的位置 | ||
|
||
if (choice == 0 && it != commandList.end()) { | ||
displayCommandWithNewlines(it->command); | ||
} else if (it != commandList.end()) { | ||
if (it->flag == 1) { | ||
std::system(it->command.c_str()); // 在 Windows 下执行命令 | ||
} else { | ||
std::cout << it->command << std::endl; // 在屏幕上显示命令 | ||
} | ||
} else { | ||
std::cout << "无效的序列号" << std::endl; | ||
} | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
let g:netrw_dirhistmax =10 | ||
let g:netrw_dirhistcnt =2 | ||
let g:netrw_dirhist_2='/root/.vim' | ||
let g:netrw_dirhist_1='/etc/NetworkManager/system-connections' |
Oops, something went wrong.