-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathadd_commands.py
More file actions
333 lines (326 loc) · 13.8 KB
/
Copy pathadd_commands.py
File metadata and controls
333 lines (326 loc) · 13.8 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
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
import json
import os
filepath = 'quickref/data/commands.json'
with open(filepath, 'r') as f:
data = json.load(f)
existing_names = {c['name'] for c in data}
new_commands = [
{
"name": "whoami",
"category": "Linux",
"subcategory": "User Management",
"description": "Print the effective user ID.",
"syntax": "whoami [OPTION]...",
"examples": [{"command": "whoami", "description": "Display the current logged in user name."}],
"related_commands": ["id", "users", "w"],
"keywords": ["user", "login", "identity"]
},
{
"name": "cd",
"category": "Linux",
"subcategory": "File Management",
"description": "Change the shell working directory.",
"syntax": "cd [DIRECTORY]",
"examples": [
{"command": "cd /var/log", "description": "Navigate to the /var/log directory."},
{"command": "cd ..", "description": "Navigate to the parent directory."},
{"command": "cd ~", "description": "Navigate to the home directory."}
],
"related_commands": ["pwd", "ls", "pushd"],
"keywords": ["directory", "navigate", "change"]
},
{
"name": "pwd",
"category": "Linux",
"subcategory": "File Management",
"description": "Print name of current/working directory.",
"syntax": "pwd [OPTION]...",
"examples": [{"command": "pwd", "description": "Show the current directory path."}],
"related_commands": ["cd", "ls"],
"keywords": ["directory", "path", "current"]
},
{
"name": "cp",
"category": "Linux",
"subcategory": "File Management",
"description": "Copy files and directories.",
"syntax": "cp [OPTION]... SOURCE DEST",
"examples": [
{"command": "cp file1.txt file2.txt", "description": "Copy file1.txt to file2.txt."},
{"command": "cp -r dir1/ dir2/", "description": "Copy a directory recursively."}
],
"related_commands": ["mv", "rsync", "scp"],
"keywords": ["copy", "duplicate", "backup"]
},
{
"name": "mv",
"category": "Linux",
"subcategory": "File Management",
"description": "Move or rename files or directories.",
"syntax": "mv [OPTION]... SOURCE DEST",
"examples": [
{"command": "mv old.txt new.txt", "description": "Rename old.txt to new.txt."},
{"command": "mv file.txt /tmp/", "description": "Move file.txt to the /tmp/ directory."}
],
"related_commands": ["cp", "rm"],
"keywords": ["move", "rename"]
},
{
"name": "rm",
"category": "Linux",
"subcategory": "File Management",
"description": "Remove files or directories.",
"syntax": "rm [OPTION]... FILE...",
"examples": [
{"command": "rm file.txt", "description": "Remove file.txt."},
{"command": "rm -rf old_dir/", "description": "Forcefully remove a directory and its contents (dangerous)."}
],
"related_commands": ["rmdir", "unlink"],
"keywords": ["remove", "delete", "erase"]
},
{
"name": "mkdir",
"category": "Linux",
"subcategory": "File Management",
"description": "Make directories.",
"syntax": "mkdir [OPTION]... DIRECTORY...",
"examples": [
{"command": "mkdir new_folder", "description": "Create a directory named new_folder."},
{"command": "mkdir -p a/b/c", "description": "Create a directory tree, making parent directories as needed."}
],
"related_commands": ["rmdir", "touch"],
"keywords": ["make", "directory", "folder", "create"]
},
{
"name": "rmdir",
"category": "Linux",
"subcategory": "File Management",
"description": "Remove empty directories.",
"syntax": "rmdir [OPTION]... DIRECTORY...",
"examples": [{"command": "rmdir empty_folder", "description": "Remove the directory empty_folder if it contains no files."}],
"related_commands": ["rm", "mkdir"],
"keywords": ["remove", "delete", "directory", "empty"]
},
{
"name": "touch",
"category": "Linux",
"subcategory": "File Management",
"description": "Change file timestamps or create empty files.",
"syntax": "touch [OPTION]... FILE...",
"examples": [{"command": "touch new_file.txt", "description": "Create an empty file or update the access time if it exists."}],
"related_commands": ["echo", "cat"],
"keywords": ["create", "file", "timestamp", "empty"]
},
{
"name": "chgrp",
"category": "Linux",
"subcategory": "Permissions",
"description": "Change group ownership.",
"syntax": "chgrp [OPTION]... GROUP FILE...",
"examples": [{"command": "chgrp developers file.txt", "description": "Change the group ownership of file.txt to 'developers'."}],
"related_commands": ["chown", "chmod"],
"keywords": ["group", "ownership", "permissions"]
},
{
"name": "cat",
"category": "Linux",
"subcategory": "File Management",
"description": "Concatenate files and print on the standard output.",
"syntax": "cat [OPTION]... [FILE]...",
"examples": [
{"command": "cat file.txt", "description": "Display the contents of file.txt."},
{"command": "cat file1.txt file2.txt > combined.txt", "description": "Concatenate file1 and file2 into combined.txt."}
],
"related_commands": ["less", "more", "head", "tail"],
"keywords": ["read", "display", "concatenate", "view"]
},
{
"name": "init",
"category": "Linux",
"subcategory": "System",
"description": "System and service manager (typically symlinked to systemd or similar).",
"syntax": "init [0123456Ss]",
"examples": [
{"command": "init 0", "description": "Halt/Shutdown the system."},
{"command": "init 6", "description": "Reboot the system."}
],
"related_commands": ["systemctl", "shutdown", "reboot", "telinit"],
"keywords": ["runlevel", "boot", "shutdown", "reboot"]
},
{
"name": "kill",
"category": "Linux",
"subcategory": "Processes",
"description": "Send a signal to a process (usually to terminate it).",
"syntax": "kill [OPTIONS] PID...",
"examples": [
{"command": "kill 1234", "description": "Send SIGTERM (15) to process 1234 to ask it to terminate cleanly."},
{"command": "kill -9 1234", "description": "Send SIGKILL (9) to force kill process 1234."}
],
"related_commands": ["killall", "pkill", "ps", "top"],
"keywords": ["terminate", "process", "signal", "stop"]
},
{
"name": "zdiff",
"category": "Linux",
"subcategory": "File Management",
"description": "Compare compressed files.",
"syntax": "zdiff [OPTIONS] FILE1 [FILE2]",
"examples": [{"command": "zdiff file1.gz file2.gz", "description": "Show the differences between two gzipped files."}],
"related_commands": ["diff", "zcmp", "zcat"],
"keywords": ["compare", "diff", "compressed", "gzip"]
},
{
"name": "echo",
"category": "Linux",
"subcategory": "Text Processing",
"description": "Display a line of text.",
"syntax": "echo [SHORT-OPTION]... [STRING]...",
"examples": [
{"command": "echo \"Hello World\"", "description": "Print Hello World to the terminal."},
{"command": "echo $PATH", "description": "Print the value of the PATH environment variable."}
],
"related_commands": ["printf", "cat"],
"keywords": ["print", "display", "variable", "text"]
},
{
"name": "clear",
"category": "Linux",
"subcategory": "Terminal",
"description": "Clear the terminal screen.",
"syntax": "clear [OPTIONS]",
"examples": [{"command": "clear", "description": "Clear the screen."}],
"related_commands": ["reset", "tput"],
"keywords": ["clean", "screen", "wipe", "terminal"]
},
{
"name": "history",
"category": "Linux",
"subcategory": "Terminal",
"description": "Display or manipulate the history list.",
"syntax": "history [OPTIONS]",
"examples": [
{"command": "history", "description": "Show the command history."},
{"command": "history -c", "description": "Clear the command history."}
],
"related_commands": ["!", "fc"],
"keywords": ["commands", "past", "history"]
},
{
"name": "man",
"category": "Linux",
"subcategory": "System",
"description": "An interface to the system reference manuals.",
"syntax": "man [OPTIONS] COMMAND",
"examples": [{"command": "man ls", "description": "Open the manual page for the ls command."}],
"related_commands": ["info", "help", "whatis", "apropos"],
"keywords": ["manual", "help", "documentation", "reference"]
},
{
"name": "tar",
"category": "Linux",
"subcategory": "File Management",
"description": "An archiving utility.",
"syntax": "tar [OPTION...] [FILE]...",
"examples": [
{"command": "tar -czvf archive.tar.gz folder/", "description": "Create a gzipped tar archive from a folder."},
{"command": "tar -xzvf archive.tar.gz", "description": "Extract a gzipped tar archive."}
],
"related_commands": ["gzip", "zip", "unzip"],
"keywords": ["archive", "compress", "extract", "zip"]
},
{
"name": "useradd",
"category": "Linux",
"subcategory": "User Management",
"description": "Create a new user or update default new user information.",
"syntax": "useradd [OPTIONS] LOGIN",
"examples": [{"command": "useradd -m -s /bin/bash john", "description": "Create user 'john' with a home directory and bash shell."}],
"related_commands": ["adduser", "usermod", "userdel", "passwd"],
"keywords": ["create user", "new user", "account"]
},
{
"name": "adduser",
"category": "Linux",
"subcategory": "User Management",
"description": "Add a user to the system (friendlier frontend to useradd on Debian/Ubuntu).",
"syntax": "adduser [OPTIONS] USER",
"examples": [{"command": "adduser john", "description": "Interactively create user 'john', setting up home dir and password."}],
"related_commands": ["useradd", "addgroup", "passwd"],
"keywords": ["create user", "new user", "account", "interactive"]
},
{
"name": "groupadd",
"category": "Linux",
"subcategory": "User Management",
"description": "Create a new group.",
"syntax": "groupadd [OPTIONS] GROUP",
"examples": [{"command": "groupadd developers", "description": "Create a new group called 'developers'."}],
"related_commands": ["addgroup", "groupmod", "groupdel"],
"keywords": ["create group", "new group"]
},
{
"name": "addgroup",
"category": "Linux",
"subcategory": "User Management",
"description": "Add a group to the system (friendlier frontend to groupadd).",
"syntax": "addgroup [OPTIONS] GROUP",
"examples": [{"command": "addgroup developers", "description": "Create a new group called 'developers'."}],
"related_commands": ["groupadd", "adduser"],
"keywords": ["create group", "new group", "interactive"]
},
{
"name": "wget",
"category": "Networking",
"subcategory": "Download",
"description": "The non-interactive network downloader.",
"syntax": "wget [OPTION]... [URL]...",
"examples": [
{"command": "wget https://example.com/file.zip", "description": "Download a file."},
{"command": "wget -c https://example.com/file.zip", "description": "Resume an interrupted download."}
],
"related_commands": ["curl", "scp", "rsync"],
"keywords": ["download", "fetch", "network", "http", "ftp"]
},
{
"name": "hostname",
"category": "Linux",
"subcategory": "System",
"description": "Show or set the system's host name.",
"syntax": "hostname [NAME]",
"examples": [
{"command": "hostname", "description": "Display the current hostname."},
{"command": "hostname new-server-name", "description": "Temporarily set the hostname to new-server-name."}
],
"related_commands": ["hostnamectl", "uname"],
"keywords": ["name", "server name", "computer name", "network"]
},
{
"name": "usermod",
"category": "Linux",
"subcategory": "User Management",
"description": "Modify a user account.",
"syntax": "usermod [OPTIONS] LOGIN",
"examples": [{"command": "usermod -aG sudo john", "description": "Add user 'john' to the 'sudo' group without removing them from other groups."}],
"related_commands": ["useradd", "userdel", "passwd"],
"keywords": ["modify user", "change user", "groups", "account"]
},
{
"name": "userdel",
"category": "Linux",
"subcategory": "User Management",
"description": "Delete a user account and related files.",
"syntax": "userdel [OPTIONS] LOGIN",
"examples": [{"command": "userdel -r john", "description": "Delete user 'john' and their home directory."}],
"related_commands": ["useradd", "usermod"],
"keywords": ["delete user", "remove user", "account"]
}
]
added = 0
for cmd in new_commands:
if cmd['name'] not in existing_names:
data.append(cmd)
added += 1
with open(filepath, 'w') as f:
json.dump(data, f, indent=2)
print(f"Added {added} commands. Total commands is now {len(data)}.")