-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLinux CheatSheet.js
More file actions
187 lines (179 loc) · 8.47 KB
/
Linux CheatSheet.js
File metadata and controls
187 lines (179 loc) · 8.47 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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
let submenu = require("submenu");
let textbox = require("textbox");
function showCommands(category) {
let commands = {
"File Operations": [
"ls - List directory contents",
"cd - Change directory",
"pwd - Print working directory",
"cp - Copy files/directories",
"mv - Move/rename files/directories",
"rm - Remove files/directories",
"mkdir - Make directory",
"rmdir - Remove directory",
"touch - Create empty file/update timestamp",
"find - Search for files",
"tree - Display directory structure",
"ln - Create links between files",
"chmod - Change file permissions",
"chown - Change file owner and group",
"du - Estimate file space usage",
"file - Determine file type",
"dd - Convert and copy a file",
"rsync - Fast, versatile file copying tool"
],
"Text Processing": [
"cat - Concatenate and display file content",
"grep - Search text using patterns",
"sed - Stream editor for filtering/transforming text",
"awk - Pattern scanning and text processing",
"cut - Remove sections from lines of files",
"paste - Merge lines of files",
"sort - Sort lines of text",
"uniq - Report or omit repeated lines",
"wc - Print newline, word, and byte counts",
"tr - Translate or delete characters",
"diff - Compare files line by line",
"patch - Apply a diff file to an original",
"head - Output the first part of files",
"tail - Output the last part of files",
"less - View file content interactively",
"nano - Text editor",
"vim - Vi IMproved, a programmer's text editor",
"fold - Wrap each input line to fit in specified width"
],
"System Information": [
"uname - Print system information",
"top - Display system processes",
"htop - Interactive process viewer",
"ps - Report process status",
"pgrep - Look up processes based on name and other attributes",
"pkill - Signal processes based on name and other attributes",
"df - Report file system disk space usage",
"free - Display amount of free and used memory",
"whoami - Print effective user ID",
"id - Print real and effective user and group IDs",
"uptime - Show how long system has been running",
"lsblk - List block devices",
"lscpu - Display information about the CPU architecture",
"lsusb - List USB devices",
"lspci - List all PCI devices",
"dmesg - Print or control the kernel ring buffer",
"journalctl - Query the systemd journal",
"systemctl - Control the systemd system and service manager"
],
"Package Management": [
"apt-get - Package handling utility (Debian/Ubuntu)",
"apt - Package handling utility (Debian/Ubuntu)",
"dpkg - Package manager for Debian",
"yum - Package manager for RHEL/CentOS",
"dnf - Package manager for Fedora",
"rpm - RPM Package Manager",
"pacman - Package manager for Arch Linux",
"zypper - Package manager for openSUSE",
"snap - Universal Linux package manager",
"flatpak - Universal application distribution framework",
"pip - Package installer for Python",
"gem - Front-end to RubyGems, the Ruby package manager",
"npm - Package manager for JavaScript",
"cargo - Package manager for Rust",
"brew - Package manager for macOS (and Linux)"
],
"Network Operations": [
"ping - Send ICMP ECHO_REQUEST to network hosts",
"traceroute - Print the route packets trace to network host",
"netstat - Network statistics",
"ss - Another utility to investigate sockets",
"nmap - Network exploration tool and security scanner",
"curl - Transfer data from or to a server",
"wget - Non-interactive network downloader",
"ssh - OpenSSH SSH client (remote login program)",
"scp - Secure copy (remote file copy program)",
"rsync - A fast, versatile, remote (and local) file-copying tool",
"iptables - Administration tool for IPv4 packet filtering and NAT",
"ufw - Uncomplicated Firewall",
"dig - DNS lookup utility",
"host - DNS lookup utility",
"whois - Client for the whois directory service",
"ifconfig - Configure network interface",
"ip - Show / manipulate routing, network devices, interfaces and tunnels",
"nmcli - Command-line tool for controlling NetworkManager"
],
"Process Management": [
"ps - Report a snapshot of the current processes",
"top - Display Linux processes",
"htop - Interactive process viewer",
"kill - Send a signal to a process",
"killall - Kill processes by name",
"nice - Run a program with modified scheduling priority",
"renice - Alter priority of running processes",
"nohup - Run a command immune to hangups",
"screen - Screen manager with VT100/ANSI terminal emulation",
"tmux - Terminal multiplexer",
"bg - Send jobs to background",
"fg - Bring jobs to foreground",
"jobs - List active jobs",
"cron - Daemon to execute scheduled commands",
"at - Execute commands at a later time"
],
"User Management": [
"useradd - Create a new user or update default new user information",
"userdel - Delete a user account and related files",
"usermod - Modify a user account",
"groupadd - Create a new group",
"groupdel - Delete a group",
"groupmod - Modify a group definition",
"passwd - Change user password",
"chage - Change user password expiry information",
"su - Switch user",
"sudo - Execute a command as another user",
"w - Show who is logged on and what they are doing",
"last - Show listing of last logged in users",
"who - Show who is logged on",
"id - Print real and effective user and group IDs",
"groups - Print the groups a user is in"
]
};
submenu.setHeader(category + " Commands:");
for (let i = 0; i < commands[category].length; i++) {
submenu.addItem(commands[category][i], i);
}
let commandResult = submenu.show();
if (commandResult !== undefined) {
textbox.setConfig("end", "text");
textbox.clearText();
textbox.addText("Command Details:\n\n" + commands[category][commandResult] + "\n\nPress Back to return.");
textbox.show();
while (textbox.isOpen()) {
delay(100);
}
showCommands(category); // Return to command list after viewing details
}
}
function showCategories() {
submenu.addItem("File Operations", 0);
submenu.addItem("Text Processing", 1);
submenu.addItem("System Information", 2);
submenu.addItem("Package Management", 3);
submenu.addItem("Network Operations", 4);
submenu.addItem("Process Management", 5);
submenu.addItem("User Management", 6);
submenu.setHeader("Select a command category:");
let categoryResult = submenu.show();
if (categoryResult !== undefined) {
let categories = ["File Operations", "Text Processing", "System Information", "Package Management", "Network Operations", "Process Management", "User Management"];
showCommands(categories[categoryResult]);
showCategories(); // Return to category selection after viewing commands
}
}
function startCheatSheet() {
submenu.addItem("Ubuntu", 0);
submenu.addItem("Fedora", 1);
submenu.addItem("Arch Linux", 2);
submenu.setHeader("Select your Linux distribution:");
let distroResult = submenu.show();
if (distroResult !== undefined) {
showCategories();
}
}
startCheatSheet();