• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Shell
2
3The shell provided by the OpenHarmony kernel supports basic debugging functions and provides commands related to the system, files, and network. It also supports commands customized based on service requirements.
4
5The shell function is used for debugging only. Currently, it does not support the functions such as tab completion and undo with a key.
6
7Some commands can be used only after the corresponding options are enabled by using **make menuconfig**.
8
9## Common Shell Commands
10
11### cat
12
13Displays the content of a text file. This command can be used only after **LOSCFG_FS_VFS** is enabled.
14
15#### Format
16
17cat [FILE]
18
19#### Parameters
20
21| Parameter| Description  | Value Range      |
22| ---- | ---------- | -------------- |
23| FILE | File path.| An existing file.|
24
25### cd
26
27Changes the current directory. This command can be used only after **LOSCFG_FS_VFS** is enabled.
28
29#### Format
30
31cd [path]
32
33#### Parameters
34
35| Parameter| Description  | Value Range      |
36| ---- | ---------- | -------------- |
37| path | File path.| Path of the new directory.|
38
39### cp
40
41Copies a file. This command can be used only after **LOSCFG_FS_VFS** is enabled.
42
43#### Format
44
45cp [SOURCEFILE] [DESTFILE]
46
47#### Parameters
48
49| Parameter      | Description      | Value Range                                 |
50| ---------- | -------------- | ----------------------------------------- |
51| SOURCEFILE | Path of the file to copy.  | Currently, only files are supported. Directories are not supported. The file cannot be empty.|
52| DESTFILE   | Path of the file created.| Directory and file names are supported. The directory must exist.         |
53
54### date
55
56Queries the system date and time.
57
58#### Format
59
60date
61
62#### Parameters
63
64None.
65
66### free
67
68Displays the memory usage of the system.
69
70#### Format
71
72free [ -k | -m ]
73
74#### Parameters
75
76| Parameter| Description         | Value Range|
77| ---- | ----------------- | -------- |
78| -k   | Display the memory usage in KiB.| N/A      |
79| -m   | Display the memory usage in MiB.| N/A      |
80
81### help
82
83Displays all commands in this operating system.
84
85#### Format
86
87help
88
89#### Parameters
90
91None.
92
93### ifconfig
94
95Displays the IP address, network mask, gateway, and MAC address of a network adapter. This command can be used only after **LWIP_SHELLCMD_ENABLE** is enabled.
96
97#### Format
98
99ifconfig
100
101#### Parameters
102
103None.
104
105### ls
106
107Displays the content of a directory. This command can be used only after **LOSCFG_FS_VFS** is enabled.
108
109#### Format
110
111ls  [DIRECTORY]
112
113#### Parameters
114
115| Parameter     | Description  | Value Range                                                    |
116| --------- | ---------- | ------------------------------------------------------------ |
117| DIRECTORY | Path of the directory.| If **DIRECTORY** is not specified, the content of the current directory is displayed.<br>If **DIRECTORY** is a valid directory, the content of the specified directory is displayed.<br>Currently, LiteOS-M does not support the root directory /.|
118
119### memusage
120
121Displays the memory waterline.
122
123#### Format
124
125memusage [-k/-m]
126
127#### Parameters
128
129| Parameter| Description         | Value Range|
130| ---- | ----------------- | -------- |
131| -k   | Display the memory usage in KiB.| N/A      |
132| -m   | Display the memory usage in MiB.| N/A      |
133
134### mkdir
135
136Creates a directory. This command can be used only after **LOSCFG_FS_VFS** is enabled.
137
138#### Format
139
140mkdir [DIRECTORY]
141
142#### Parameters
143
144| Parameter     | Description  | Value Range                             |
145| --------- | ---------- | ------------------------------------- |
146| DIRECTORY | Path of the directory.| The value of **DIRECTORY** can be an absolute path or a relative path.|
147
148### ping
149
150Checks whether the network is connected. This command can be used only after **LWIP_SHELLCMD_ENABLE** is enabled.
151
152#### Format
153
154ping [ip]
155
156#### Parameters
157
158| Parameter| Description                      | Value Range|
159| ---- | ------------------------------ | -------- |
160| ip   | IPv4 address of the network to test.| N/A      |
161
162### pwd
163
164Displays the current path. This command can be used only after **LOSCFG_FS_VFS** is enabled.
165
166#### Format
167
168pwd
169
170### rm
171
172Deletes a file or folder. This command can be used only after **LOSCFG_FS_VFS** is enabled.
173
174#### Format
175
176rm [FILE] or rm [-r/-R] [FILE]
177
178#### Parameters
179
180| Parameter | Description                       | Value Range                        |
181| ----- | ------------------------------- | -------------------------------- |
182| FILE  | File or folder name.| The value of **FILE** can be an absolute path or a relative path.|
183| -r/-R | If **FILE** is a folder, -r/-R needs to be set.   | N/A                              |
184
185### rmdir
186
187Deletes a folder. This command can be used only after **LOSCFG_FS_VFS** is enabled.
188
189#### Format
190
191rmdir [DIRECTORY]
192
193#### Parameters
194
195| Parameter     | Description  | Value Range                             |
196| --------- | ---------- | ------------------------------------- |
197| DIRECTORY | Path of the directory.| The value of **DIRECTORY** can be an absolute path or a relative path.|
198
199### task
200
201Displays the status of each task.
202
203#### Format
204
205task
206
207The displayed information includes the task No., priority, status, stack information, signal, event, CPU usage, and task name.
208
209### touch
210
211Creates a file. This command can be used only after **LOSCFG_FS_VFS** is enabled.
212
213#### Format
214
215touch [FILE]
216
217#### Parameters
218
219| Parameter| Description| Value Range                        |
220| ---- | -------- | -------------------------------- |
221| FILE | File name.| The value of **FILE** can be an absolute path or a relative path.|
222
223### stack
224
225Displays the stack information of a task. This command can be used only after **LOSCFG_DEBUG_TOOLS** is enabled. Enabling this function affects the performance.
226
227#### Format
228
229stack [ID]
230
231#### Parameters
232
233| Parameter| Description| Value Range                |
234| ---- | -------- | ------------------------ |
235| ID   | Task ID.| The task corresponding to the task ID must exist.|
236
237### hwi
238
239Queries the interrupt usage. This command can be used only after **LOSCFG_DEBUG_TOOLS** is enabled. Enabling this function affects the performance.
240
241#### Format
242
243hwi
244
245### st
246
247Queries scheduling information. This command can be used only afterf **LOSCFG_DEBUG_TOOLS** is enabled. Enabling this function affects the performance.
248
249#### Format
250
251st -s | st -e
252
253#### Parameters
254
255| Parameter| Description              | Value Range|
256| ---- | ---------------------- | -------- |
257| -s   | Start to record scheduling information.      | N/A      |
258| -e   | Stop recording and print scheduling information.| N/A      |
259