提交 95ca5bab 编写于 作者: A Annie_wang

update docs

Signed-off-by: NAnnie_wang <annie.wangli@huawei.com>
上级 96b3b3e4
...@@ -3,216 +3,98 @@ ...@@ -3,216 +3,98 @@
## Basic Concepts ## Basic Concepts
In an OS that supports multiple tasks, modifying data in a memory area requires three steps: read data, modify data, and write data. However, data in a memory area may be simultaneously accessed by multiple tasks. If the data modification is interrupted by another task, the execution result of the operation is unpredictable. In an OS that supports multiple tasks, modifying data in memory involves three steps: read data, modify data, and write data. However, the data may be simultaneously accessed by multiple tasks. If the data modification is interrupted by another task, an unexpected result will be caused.
Although you can enable or disable interrupts to ensure that the multi-task execution results meet expectations, the system performance is affected. Although you can enable or disable interrupts to ensure expected results of multiple tasks, the system performance is affected.
The ARMv6 architecture has introduced the **LDREX** and **STREX** instructions to support more discreet non-blocking synchronization of the shared memory. The atomic operations implemented thereby can ensure that the "read-modify-write" operations on the same data will not be interrupted, that is, the operation atomicity is ensured. The ARMv6 architecture has introduced the **LDREX** and **STREX** instructions to support more discreet non-blocking synchronization of the shared memory. The atomic operations implemented thereby can ensure that the "read-modify-write" operations on the same data will not be interrupted, that is, the operation atomicity is ensured.
## Working Principles
The OpenHarmony system has encapsulated the **LDREX** and **STREX** in the ARMv6 architecture to provide a set of atomic operation APIs.
- LDREX Rx, \[Ry\]
Reads the value in the memory and marks the exclusive access to the memory segment.
- Reads the 4-byte memory data pointed by the register **Ry** and saves the data to the **Rx** register. ## Working Principles
- Adds an exclusive access flag to the memory area pointed by **Ry**.
- STREX Rf, Rx, \[Ry\]
Checks whether the memory has an exclusive access flag. If yes, the system updates the memory value and clears the flag. If no, the memory is not updated.
- If there is an exclusive access flag, the system: OpenHarmony has encapsulated the **LDREX** and **STREX** in the ARMv6 architecture to provide a set of atomic operation APIs.
- Updates the **Rx** register value to the memory pointed to by the **Ry** register.
- Sets the **Rf** register to **0**.
- If there is no exclusive access flag: - LDREX Rx, [Ry]
- The memory is not updated. Reads the value in the memory and marks the exclusive access to the memory segment.
- The system sets the **Rf** register to **1**. - Reads the 4-byte memory data pointed by the register **Ry** and saves the data to the **Rx** register.
- Adds an exclusive access flag to the memory area pointed by **Ry**.
- STREX Rf, Rx, [Ry]
Checks whether the memory has an exclusive access flag. If yes, the system updates the memory value and clears the flag. If no, the memory is not updated.
- If there is an exclusive access flag, the system:
- Updates the **Rx** register value to the memory pointed to by the **Ry** register.
- Sets the **Rf** register to **0**.
- If there is no exclusive access flag:
- The memory is not updated.
- The system sets the **Rf** register to **1**.
- Flag register - Flag register
- If the flag register is **0**, the system exits the loop and the atomic operation is complete. - If the flag register is **0**, the system exits the loop and the atomic operation is complete.
- If the flag register is **1**, the system continues the loop and performs the atomic operation again. - If the flag register is **1**, the system continues the loop and performs the atomic operation again.
## Development Guidelines ## Development Guidelines
### Available APIs ### Available APIs
The following table describes the APIs available for the OpenHarmony LiteOS-A kernel atomic operation module. For more details about the APIs, see the API reference. The following table describes the APIs available for the OpenHarmony LiteOS-A kernel atomic operation module.
**Table 1** Atomic operation APIs **Table 1** APIs for atomic operations
<a name="table29217519171"></a> | Category | API | Description |
<table><thead align="left"><tr id="row79375119172"><th class="cellrowborder" valign="top" width="21.21212121212121%" id="mcps1.2.4.1.1"><p id="p159375113174"><a name="p159375113174"></a><a name="p159375113174"></a>Function</p> | ------------ | ----------------------- | --------------------------- |
</th> | Read | LOS_AtomicRead | Reads 32-bit atomic data. |
<th class="cellrowborder" valign="top" width="33.39333933393339%" id="mcps1.2.4.1.2"><p id="p199385118173"><a name="p199385118173"></a><a name="p199385118173"></a>API</p> | Read | LOS_Atomic64Read | Reads 64-bit atomic data. |
</th> | Write | LOS_AtomicSet | Sets 32-bit atomic data. |
<th class="cellrowborder" valign="top" width="45.3945394539454%" id="mcps1.2.4.1.3"><p id="p18937511175"><a name="p18937511175"></a><a name="p18937511175"></a>Description</p> | Write | LOS_Atomic64Set | Sets 64-bit atomic data. |
</th> | Add | LOS_AtomicAdd | Adds 32-bit atomic data. |
</tr> | Add | LOS_Atomic64Add | Adds 64-bit atomic data. |
</thead> | Add | LOS_AtomicInc | Adds 1 to 32-bit atomic data. |
<tbody><tr id="row159315151712"><td class="cellrowborder" rowspan="2" valign="top" width="21.21212121212121%" headers="mcps1.2.4.1.1 "><p id="p593135115176"><a name="p593135115176"></a><a name="p593135115176"></a>Read</p> | Add | LOS_Atomic64Inc | Adds 1 to 64-bit atomic data. |
</td> | Add | LOS_AtomicIncRet | Adds 1 to 32-bit atomic data and returns the data. |
<td class="cellrowborder" valign="top" width="33.39333933393339%" headers="mcps1.2.4.1.2 "><p id="p1193651181714"><a name="p1193651181714"></a><a name="p1193651181714"></a>LOS_AtomicRead</p> | Add | LOS_Atomic64IncRet | Adds 1 to 64-bit atomic data and returns the data. |
</td> | Subtract | LOS_AtomicSub | Performs subtraction on 32-bit atomic data. |
<td class="cellrowborder" valign="top" width="45.3945394539454%" headers="mcps1.2.4.1.3 "><p id="p09316512178"><a name="p09316512178"></a><a name="p09316512178"></a>Reads 32-bit atomic data.</p> | Subtract | LOS_Atomic64Sub | Performs subtraction on 64-bit atomic data. |
</td> | Subtract | LOS_AtomicDec | Subtracts 1 from 32-bit atomic data. |
</tr> | Subtract | LOS_Atomic64Dec | Subtracts 1 from 64-bit atomic data. |
<tr id="row1493151161719"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p119395111718"><a name="p119395111718"></a><a name="p119395111718"></a>LOS_Atomic64Read</p> | Subtract | LOS_AtomicDecRet | Subtracts 1 from 32-bit atomic data and returns the result. |
</td> | Subtract | LOS_Atomic64DecRet | Subtracts 1 from 64-bit atomic data and returns the result. |
<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p49311514178"><a name="p49311514178"></a><a name="p49311514178"></a>Reads 64-bit atomic data.</p> | Swap | LOS_AtomicXchgByte | Swaps 8-bit memory data. |
</td> | Swap | LOS_AtomicXchg16bits | Swaps 16-bit memory data. |
</tr> | Swap | LOS_AtomicXchg32bits | Swaps 32-bit memory data. |
<tr id="row69365111712"><td class="cellrowborder" rowspan="2" valign="top" width="21.21212121212121%" headers="mcps1.2.4.1.1 "><p id="p199355111175"><a name="p199355111175"></a><a name="p199355111175"></a>Write</p> | Swap | LOS_AtomicXchg64bits | Swaps 64-bit memory data. |
</td> | Compare and swap| LOS_AtomicCmpXchgByte | Compares and swaps 8-bit memory data. |
<td class="cellrowborder" valign="top" width="33.39333933393339%" headers="mcps1.2.4.1.2 "><p id="p1693175191714"><a name="p1693175191714"></a><a name="p1693175191714"></a>LOS_AtomicSet</p> | Compare and swap| LOS_AtomicCmpXchg16bits | Compares and swaps 16-bit memory data.|
</td> | Compare and swap| LOS_AtomicCmpXchg32bits | Compares and swaps 32-bit memory data.|
<td class="cellrowborder" valign="top" width="45.3945394539454%" headers="mcps1.2.4.1.3 "><p id="p129320516173"><a name="p129320516173"></a><a name="p129320516173"></a>Sets 32-bit atomic data.</p> | Compare and swap| LOS_AtomicCmpXchg64bits | Compares and swaps 64-bit memory data.|
</td>
</tr>
<tr id="row1593651111718"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p7944510176"><a name="p7944510176"></a><a name="p7944510176"></a>LOS_Atomic64Set</p>
</td>
<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p294115191713"><a name="p294115191713"></a><a name="p294115191713"></a>Sets 64-bit atomic data.</p>
</td>
</tr>
<tr id="row149495114177"><td class="cellrowborder" rowspan="6" valign="top" width="21.21212121212121%" headers="mcps1.2.4.1.1 "><p id="p1394165151718"><a name="p1394165151718"></a><a name="p1394165151718"></a>Add</p>
</td>
<td class="cellrowborder" valign="top" width="33.39333933393339%" headers="mcps1.2.4.1.2 "><p id="p494115112179"><a name="p494115112179"></a><a name="p494115112179"></a>LOS_AtomicAdd</p>
</td>
<td class="cellrowborder" valign="top" width="45.3945394539454%" headers="mcps1.2.4.1.3 "><p id="p1694155120174"><a name="p1694155120174"></a><a name="p1694155120174"></a>Adds 32-bit atomic data.</p>
</td>
</tr>
<tr id="row394651101719"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p179435113171"><a name="p179435113171"></a><a name="p179435113171"></a>LOS_Atomic64Add</p>
</td>
<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p594851181718"><a name="p594851181718"></a><a name="p594851181718"></a>Adds 64-bit atomic data.</p>
</td>
</tr>
<tr id="row294185110171"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p1834102212615"><a name="p1834102212615"></a><a name="p1834102212615"></a>LOS_AtomicInc</p>
</td>
<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p129413519173"><a name="p129413519173"></a><a name="p129413519173"></a>Adds 1 to 32-bit atomic data.</p>
</td>
</tr>
<tr id="row1894175101713"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p1981302213264"><a name="p1981302213264"></a><a name="p1981302213264"></a>LOS_Atomic64Inc</p>
</td>
<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p167671640113316"><a name="p167671640113316"></a><a name="p167671640113316"></a>Adds 1 to 64-bit atomic data.</p>
</td>
</tr>
<tr id="row12946512178"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p1994051181716"><a name="p1994051181716"></a><a name="p1994051181716"></a>LOS_AtomicIncRet</p>
</td>
<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p59414511172"><a name="p59414511172"></a><a name="p59414511172"></a>Adds 1 to 32-bit atomic data and returns the data.</p>
</td>
</tr>
<tr id="row1994551101712"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p129414519173"><a name="p129414519173"></a><a name="p129414519173"></a>LOS_Atomic64IncRet</p>
</td>
<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p1194951111713"><a name="p1194951111713"></a><a name="p1194951111713"></a>Adds 1 to 64-bit atomic data and returns the data.</p>
</td>
</tr>
<tr id="row1794451121719"><td class="cellrowborder" rowspan="6" valign="top" width="21.21212121212121%" headers="mcps1.2.4.1.1 "><p id="p179412517173"><a name="p179412517173"></a><a name="p179412517173"></a>Subtract</p>
</td>
<td class="cellrowborder" valign="top" width="33.39333933393339%" headers="mcps1.2.4.1.2 "><p id="p89495115176"><a name="p89495115176"></a><a name="p89495115176"></a>LOS_AtomicSub</p>
</td>
<td class="cellrowborder" valign="top" width="45.3945394539454%" headers="mcps1.2.4.1.3 "><p id="p18220416345"><a name="p18220416345"></a><a name="p18220416345"></a>Performs subtraction on 32-bit atomic data.</p>
</td>
</tr>
<tr id="row139485131718"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p1894195116176"><a name="p1894195116176"></a><a name="p1894195116176"></a>LOS_Atomic64Sub</p>
</td>
<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p20822124173415"><a name="p20822124173415"></a><a name="p20822124173415"></a>Performs subtraction on 64-bit atomic data.</p>
</td>
</tr>
<tr id="row209505110175"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p7951051141713"><a name="p7951051141713"></a><a name="p7951051141713"></a>LOS_AtomicDec</p>
</td>
<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p382234117340"><a name="p382234117340"></a><a name="p382234117340"></a>Subtracts 1 from 32-bit atomic data.</p>
</td>
</tr>
<tr id="row995151171711"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p395151131715"><a name="p395151131715"></a><a name="p395151131715"></a>LOS_Atomic64Dec</p>
</td>
<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p1982244117340"><a name="p1982244117340"></a><a name="p1982244117340"></a>Subtracts 1 from 64-bit atomic data.</p>
</td>
</tr>
<tr id="row895155117179"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p395155151719"><a name="p395155151719"></a><a name="p395155151719"></a>LOS_AtomicDecRet</p>
</td>
<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p198222414349"><a name="p198222414349"></a><a name="p198222414349"></a>Subtracts 1 from 32-bit atomic data and returns the result.</p>
</td>
</tr>
<tr id="row59511518170"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p1495125119175"><a name="p1495125119175"></a><a name="p1495125119175"></a>LOS_Atomic64DecRet</p>
</td>
<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p198221841103419"><a name="p198221841103419"></a><a name="p198221841103419"></a>Subtracts 1 from 64-bit atomic data and returns the result.</p>
</td>
</tr>
<tr id="row159575131714"><td class="cellrowborder" rowspan="4" valign="top" width="21.21212121212121%" headers="mcps1.2.4.1.1 "><p id="p159585110177"><a name="p159585110177"></a><a name="p159585110177"></a>Swap</p>
</td>
<td class="cellrowborder" valign="top" width="33.39333933393339%" headers="mcps1.2.4.1.2 "><p id="p29515114174"><a name="p29515114174"></a><a name="p29515114174"></a>LOS_AtomicXchgByte</p>
</td>
<td class="cellrowborder" valign="top" width="45.3945394539454%" headers="mcps1.2.4.1.3 "><p id="p6956510177"><a name="p6956510177"></a><a name="p6956510177"></a>Swaps 8-bit memory data.</p>
</td>
</tr>
<tr id="row14951451111710"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p8952514173"><a name="p8952514173"></a><a name="p8952514173"></a>LOS_AtomicXchg16bits</p>
</td>
<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p12334173143919"><a name="p12334173143919"></a><a name="p12334173143919"></a>Swaps 16-bit memory data.</p>
</td>
</tr>
<tr id="row595251131716"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p1495145117171"><a name="p1495145117171"></a><a name="p1495145117171"></a>LOS_AtomicXchg32bits</p>
</td>
<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p9951513173"><a name="p9951513173"></a><a name="p9951513173"></a>Swaps 32-bit memory data.</p>
</td>
</tr>
<tr id="row195165131718"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p18951151141717"><a name="p18951151141717"></a><a name="p18951151141717"></a>LOS_AtomicXchg64bits</p>
</td>
<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p169685115172"><a name="p169685115172"></a><a name="p169685115172"></a>Swaps 64-bit memory data.</p>
</td>
</tr>
<tr id="row149616511175"><td class="cellrowborder" rowspan="4" valign="top" width="21.21212121212121%" headers="mcps1.2.4.1.1 "><p id="p49615120172"><a name="p49615120172"></a><a name="p49615120172"></a>Compare and swap</p>
</td>
<td class="cellrowborder" valign="top" width="33.39333933393339%" headers="mcps1.2.4.1.2 "><p id="p129605112171"><a name="p129605112171"></a><a name="p129605112171"></a>LOS_AtomicCmpXchgByte</p>
</td>
<td class="cellrowborder" valign="top" width="45.3945394539454%" headers="mcps1.2.4.1.3 "><p id="p6965510178"><a name="p6965510178"></a><a name="p6965510178"></a>Compares and swaps 8-bit memory data.</p>
</td>
</tr>
<tr id="row99605171713"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p109675131711"><a name="p109675131711"></a><a name="p109675131711"></a>LOS_AtomicCmpXchg16bits</p>
</td>
<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p17961951191719"><a name="p17961951191719"></a><a name="p17961951191719"></a>Compares and swaps 16-bit memory data.</p>
</td>
</tr>
<tr id="row169614513177"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p49645115172"><a name="p49645115172"></a><a name="p49645115172"></a>LOS_AtomicCmpXchg32bits</p>
</td>
<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p129611512175"><a name="p129611512175"></a><a name="p129611512175"></a>Compares and swaps 32-bit memory data.</p>
</td>
</tr>
<tr id="row696175110179"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p16961051161715"><a name="p16961051161715"></a><a name="p16961051161715"></a>LOS_AtomicCmpXchg64bits</p>
</td>
<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p1296205118179"><a name="p1296205118179"></a><a name="p1296205118179"></a>Compares and swaps 64-bit memory data.</p>
</td>
</tr>
</tbody>
</table>
### How to Develop ### How to Develop
When multiple tasks perform addition, subtraction, and swap operations on the same memory data, use atomic operations to ensure predictability of results. When multiple tasks perform addition, subtraction, and swap operations on the same memory data, use atomic operations to ensure predictability of results.
>![](../public_sys-resources/icon-note.gif) **NOTE**<br/> > **NOTE**<br>
>Atomic operation APIs support only integer data. > Atomic operation APIs support only integers.
### Development Example<a name="section8538651511"></a> ### Development Example
Example Description **Example Description**
Call the atomic operation APIs and observe the result. Call the atomic operation APIs and observe the result.
1. Create two tasks. 1. Create two tasks.
- Task 1: Call **LOS\_AtomicInc** to add the global variables 100 times. - Task 1: Call **LOS_AtomicInc** to add a global variable 100 times.
- Task 2: Call **LOS\_AtomicDec** to subtract the global variables 100 times. - Task 2: Call **LOS_AtomicDec** to subtract a global variable 100 times.
2. After the subtasks are complete, print the values of the global variables in the main task. 2. After the subtasks are complete, print the values of the global variable in the main task.
**Sample Code** **Sample Code**
The sample code is as follows: The sample code is as follows:
``` ```
#include "los_hwi.h" #include "los_hwi.h"
#include "los_atomic.h" #include "los_atomic.h"
...@@ -275,7 +157,7 @@ UINT32 Example_AtomicTaskEntry(VOID) ...@@ -275,7 +157,7 @@ UINT32 Example_AtomicTaskEntry(VOID)
**Verification** **Verification**
``` ```
g_sum = 0 g_sum = 0
``` ```
# Software Timer # Software Timer
## Basic Concepts<a name="section4118241563"></a> ## Basic Concepts
The software timer is a software-simulated timer based on system tick interrupts. When the preset tick counter value has elapsed, the user-defined callback will be invoked. The timing precision is related to the cycle of the system tick clock. Due to the limitation in hardware, the number of hardware timers cannot meet users' requirements. Therefore, the OpenHarmony LiteOS-A kernel provides the software timer function. The software timer allows more timing services to be created, increasing the number of timers. The software timer is a software-simulated timer based on system tick interrupts. When the preset tick counter value has elapsed, the user-defined callback will be invoked. The timing precision is related to the cycle of the system tick clock.
Due to the limitation in hardware, the number of hardware timers cannot meet users' requirements. The OpenHarmony LiteOS-A kernel provides the software timer function.
The software timer allows more timing services to be created, increasing the number of timers.
The software timer supports the following functions: The software timer supports the following functions:
- Disabling the software timer using a macro - Disabling the software timer using a macro
- Creating a software timer
- Starting a software timer
- Stopping a software timer
- Deleting a software timer
- Obtaining the number of remaining ticks of a software timer
## Working Principles<a name="section31079397569"></a> - Creating a software timer
The software timer is a system resource. When modules are initialized, a contiguous section of memory is allocated for software timers. The maximum number of timers supported by the system is configured by the **LOSCFG\_BASE\_CORE\_SWTMR\_LIMIT** macro in **los\_config.h**. Software timers use a queue and a task resource of the system. The software timers are triggered based on the First In First Out \(FIFO\) rule. For the timers set at the same time, the timer with a shorter value is always closer to the queue head than the timer with a longer value, and is preferentially triggered. The software timer counts time in ticks. When a software timer is created and started, the OpenHarmony system determines the timer expiry time based on the current system time \(in ticks\) and the timing interval set by the user, and adds the timer control structure to the global timing list. - Starting a software timer
- Stopping a software timer
- Deleting a software timer
- Obtaining the number of remaining ticks of a software timer
When a tick interrupt occurs, the tick interrupt handler scans the global timing list for expired timers. If such timers are found, the timers are recorded.
When the tick interrupt handling function is complete, the software timer task \(with the highest priority\) is woken up. In this task, the timeout callback function for the recorded timer is called. ## Working Principles
Timer States The software timer is a system resource. When modules are initialized, a contiguous section of memory is allocated for software timers. The maximum number of timers supported by the system is configured by the **LOSCFG_BASE_CORE_SWTMR_LIMIT** macro in **los_config.h**.
- OS\_SWTMR\_STATUS\_UNUSED Software timers use a queue and a task resource of the system. The software timers are triggered based on the First In First Out (FIFO) rule. For the timers set at the same time, the timer with a shorter value is always closer to the queue head than the timer with a longer value, and is preferentially triggered.
The timer is not in use. When the timer module is initialized, all timer resources in the system are set to this state. The software timer counts time in ticks. When a software timer is created and started, the OpenHarmony system determines the timer expiry time based on the current system time (in ticks) and the timing interval set by the user, and adds the timer control structure to the global timing list.
- OS\_SWTMR\_STATUS\_CREATED When a tick interrupt occurs, the tick interrupt handler scans the global timing list for expired timers. If such timers are found, the timers are recorded.
When the tick interrupt handler is complete, the software timer task (with the highest priority) will be woken up. In this task, the timeout callback for the recorded timer is called.
The timer is created but not started or the timer is stopped. When **LOS\_SwtmrCreate** is called for a timer that is not in use or **LOS\_SwtmrStop** is called for a newly started timer, the timer changes to this state. A software timer can be in any of the following states:
- OS\_SWTMR\_STATUS\_TICKING - OS_SWTMR_STATUS_UNUSED
The timer is not in use. When the timer module is initialized, all timer resources in the system are set to this state.
- OS_SWTMR_STATUS_CREATED
The timer is running \(counting\). When **LOS\_SwtmrStart** is called for a newly created timer, the timer enters this state. The timer is created but not started or the timer is stopped. When **LOS_SwtmrCreate** is called for a timer that is not in use or **LOS_SwtmrStop** is called for a newly started timer, the timer changes to this state.
- OS_SWTMR_STATUS_TICKING
Timer Modes The timer is running (counting). When **LOS_SwtmrStart** is called for a newly created timer, the timer enters this state.
The OpenHarmony provides three types of software timers: OpenHarmony provides three types of software timers:
- One-shot timer: Once started, the timer is automatically deleted after triggering only one timer event. - One-shot timer: Once started, the timer is automatically deleted after triggering only one timer event.
- Periodic timer: This type of timer periodically triggers timer events until it is manually stopped. - Periodic timer: This type of timer periodically triggers timer events until it is manually stopped.
- One-shot timer deleted by calling an API - One-shot timer deleted by calling an API
## Development Guidelines<a name="section18576131520577"></a>
## Development Guidelines
### Available APIs<a name="section3138019145719"></a>
The following table describes APIs available for the OpenHarmony LiteOS-A software timer module. For more details about the APIs, see the API reference. ### Available APIs
**Table 1** Software timer APIs The following table describes the APIs of the software timer module of the OpenHarmony LiteOS-A kernel.
<a name="table107038227425"></a> **Table 1** APIs for software timers
<table><thead align="left"><tr id="row2704122217420"><th class="cellrowborder" valign="top" width="20.6020602060206%" id="mcps1.2.4.1.1"><p id="p57041622144212"><a name="p57041622144212"></a><a name="p57041622144212"></a>Function</p>
</th> | Category | Description |
<th class="cellrowborder" valign="top" width="29.542954295429542%" id="mcps1.2.4.1.2"><p id="p19704142216424"><a name="p19704142216424"></a><a name="p19704142216424"></a>API</p> | ---------------------- | ------------------------------------------------------------ |
</th> | Creating or deleting a timer | **LOS_SwtmrCreate**: creates a software timer.<br>**LOS_SwtmrDelete**: deletes a software timer.|
<th class="cellrowborder" valign="top" width="49.85498549854985%" id="mcps1.2.4.1.3"><p id="p670412224217"><a name="p670412224217"></a><a name="p670412224217"></a>Description</p> | Starting or stopping a timer | **LOS_SwtmrStart**: starts a software timer.<br>**LOS_SwtmrStop**: stops a software timer.|
</th> | Obtaining remaining ticks of a software timer| **LOS_SwtmrTimeGet**: obtains the remaining ticks of a software timer. |
</tr>
</thead>
<tbody><tr id="row1470413222429"><td class="cellrowborder" rowspan="2" valign="top" width="20.6020602060206%" headers="mcps1.2.4.1.1 "><p id="p8284115918428"><a name="p8284115918428"></a><a name="p8284115918428"></a>Creating or deleting timers</p> ### How to Develop
</td>
<td class="cellrowborder" valign="top" width="29.542954295429542%" headers="mcps1.2.4.1.2 "><p id="p117045225428"><a name="p117045225428"></a><a name="p117045225428"></a>LOS_SwtmrCreate</p>
</td>
<td class="cellrowborder" valign="top" width="49.85498549854985%" headers="mcps1.2.4.1.3 "><p id="p170422234213"><a name="p170422234213"></a><a name="p170422234213"></a>Creates a software timer.</p>
</td>
</tr>
<tr id="row11704102217425"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p1970492213426"><a name="p1970492213426"></a><a name="p1970492213426"></a>LOS_SwtmrDelete</p>
</td>
<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p870442211421"><a name="p870442211421"></a><a name="p870442211421"></a>Deletes a software timer.</p>
</td>
</tr>
<tr id="row57041422184215"><td class="cellrowborder" rowspan="2" valign="top" width="20.6020602060206%" headers="mcps1.2.4.1.1 "><p id="p1476172124318"><a name="p1476172124318"></a><a name="p1476172124318"></a>Starting or stopping timers</p>
</td>
<td class="cellrowborder" valign="top" width="29.542954295429542%" headers="mcps1.2.4.1.2 "><p id="p167040225423"><a name="p167040225423"></a><a name="p167040225423"></a>LOS_SwtmrStart</p>
</td>
<td class="cellrowborder" valign="top" width="49.85498549854985%" headers="mcps1.2.4.1.3 "><p id="p1570412229421"><a name="p1570412229421"></a><a name="p1570412229421"></a>Starts a software timer.</p>
</td>
</tr>
<tr id="row15704172224219"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p1170422214216"><a name="p1170422214216"></a><a name="p1170422214216"></a>LOS_SwtmrStop</p>
</td>
<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p17705122211426"><a name="p17705122211426"></a><a name="p17705122211426"></a>Stops a software timer.</p>
</td>
</tr>
<tr id="row12705222154214"><td class="cellrowborder" valign="top" width="20.6020602060206%" headers="mcps1.2.4.1.1 "><p id="p0705622134214"><a name="p0705622134214"></a><a name="p0705622134214"></a>Obtaining remaining ticks of a software timer</p>
</td>
<td class="cellrowborder" valign="top" width="29.542954295429542%" headers="mcps1.2.4.1.2 "><p id="p177052220424"><a name="p177052220424"></a><a name="p177052220424"></a>LOS_SwtmrTimeGet</p>
</td>
<td class="cellrowborder" valign="top" width="49.85498549854985%" headers="mcps1.2.4.1.3 "><p id="p3705122264210"><a name="p3705122264210"></a><a name="p3705122264210"></a>Obtains the number of remaining ticks of a software timer.</p>
</td>
</tr>
</tbody>
</table>
### How to Develop<a name="section1344817403575"></a>
The typical development process of software timers is as follows: The typical development process of software timers is as follows:
1. Configure the software timer. 1. Configure the software timer.
- Check that **LOSCFG\_BASE\_CORE\_SWTMR** and **LOSCFG\_BASE\_IPC\_QUEUE** are enabled. - Check that **LOSCFG_BASE_CORE_SWTMR** and **LOSCFG_BASE_IPC_QUEUE** are enabled.
- Configure **LOSCFG\_BASE\_CORE\_SWTMR\_LIMIT** \(maximum number of software timers supported by the system\). - Configure **LOSCFG_BASE_CORE_SWTMR_LIMIT** (maximum number of software timers supported by the system).
- Configure **OS\_SWTMR\_HANDLE\_QUEUE\_SIZE** \(maximum length of the software timer queue\). - Configure **OS_SWTMR_HANDLE_QUEUE_SIZE** (maximum length of the software timer queue).
2. Call **LOS_SwtmrCreate** to create a software timer.
- Create a software timer with the specified timing duration, timeout handling function, and triggering mode.
- Return the function execution result (success or failure).
3. Call **LOS_SwtmrStart** to start the software timer.
2. Call **LOS\_SwtmrCreate** to create a software timer. 4. Call **LOS_SwtmrTimeGet** to obtain the remaining number of ticks of the software timer.
- Create a software timer with the specified timing duration, timeout handling function, and triggering mode.
- Return the function execution result \(success or failure\).
3. Call **LOS\_SwtmrStart** to start the software timer. 5. Call **LOS_SwtmrStop** to stop the software timer.
4. Call **LOS\_SwtmrTimeGet** to obtain the remaining number of ticks of the software timer.
5. Call **LOS\_SwtmrStop** to stop the software timer.
6. Call **LOS\_SwtmrDelete** to delete the software timer.
>![](../public_sys-resources/icon-note.gif) **NOTE:** 6. Call **LOS_SwtmrDelete** to delete the software timer.
>- Avoid too many operations in the callback function of the software timer. Do not use APIs or perform operations that may cause task suspension or blocking.
>- The software timers use a queue and a task resource of the system. The priority of the software timer tasks is set to **0** and cannot be changed.
>- The number of software timer resources that can be configured in the system is the total number of software timer resources available to the entire system, not the number of software timer resources available to users. For example, if the system software timer occupies one more resource, the number of software timer resources available to users decreases by one.
>- If a one-shot software timer is created, the system automatically deletes the timer and reclaims resources after the timer times out and the callback function is executed.
>- For a one-shot software timer that will not be automatically deleted after expiration, you need to call **LOS\_SwtmrDelete** to delete it and reclaim the timer resource to prevent resource leakage.
### Development Example<a name="section114416313585"></a> > **NOTE**<br>
>
> - Avoid too many operations in the callback of the software timer. Do not use APIs or perform operations that may cause task suspension or blocking.
>
> - The software timers use a queue and a task resource of the system. The priority of the software timer tasks is set to **0** and cannot be changed.
>
> - The number of software timer resources that can be configured in the system is the total number of software timer resources available to the entire system, not the number of software timer resources available to users. For example, if the system software timer occupies one more resource, the number of software timer resources available to users decreases by one.
>
> - If a one-shot software timer is created, the system automatically deletes the timer and reclaims resources after the timer times out and the callback is invoked.
>
> - For a one-shot software timer that will not be automatically deleted after expiration, you need to call **LOS_SwtmrDelete** to delete it and reclaim the timer resource to prevent resource leakage.
Prerequisites:
- In **los\_config.h**, **LOSCFG\_BASE\_CORE\_SWTMR** is enabled. ### Development Example
- The maximum number of software timers supported by the system \(**LOSCFG\_BASE\_CORE\_SWTMR\_LIMIT**\) is configured.
- The maximum length of the software timer queue \(**OS\_SWTMR\_HANDLE\_QUEUE\_SIZE**\) is configured. **Prerequisites**
- In **los_config.h**, **LOSCFG_BASE_CORE_SWTMR** is enabled.
- The maximum number of software timers supported by the system (**LOSCFG_BASE_CORE_SWTMR_LIMIT**) is configured.
- The maximum length of the software timer queue (**OS_SWTMR_HANDLE_QUEUE_SIZE**) is configured.
**Sample Code** **Sample Code**
...@@ -164,14 +150,14 @@ void Timer_example(void) ...@@ -164,14 +150,14 @@ void Timer_example(void)
UINT16 id2; // timer id UINT16 id2; // timer id
UINT32 uwTick; UINT32 uwTick;
/* Create a one-shot software timer, with the number of ticks set to 1000. When the number of ticks reaches 1000, callback function 1 is executed. */ /* Create a one-shot software timer, with the number of ticks set to 1000. Callback 1 will be invoked when the number of ticks reaches 1000. */
LOS_SwtmrCreate (1000, LOS_SWTMR_MODE_ONCE, Timer1_Callback, &id1, 1); LOS_SwtmrCreate (1000, LOS_SWTMR_MODE_ONCE, Timer1_Callback, &id1, 1);
/* Create a periodic software timer and execute callback function 2 every 100 ticks. */ /* Create a periodic software timer and invoke callback 2 every 100 ticks. */
LOS_SwtmrCreate(100, LOS_SWTMR_MODE_PERIOD, Timer2_Callback, &id2, 1); LOS_SwtmrCreate(100, LOS_SWTMR_MODE_PERIOD, Timer2_Callback, &id2, 1);
PRINTK("create Timer1 success\n"); PRINTK("create Timer1 success\n");
LOS_SwtmrStart (id1); // Start the one-shot software timer. LOS_SwtmrStart(id1); // Start the one-shot software timer.
dprintf("start Timer1 success\n"); dprintf("start Timer1 success\n");
LOS_TaskDelay(200); // Delay 200 ticks. LOS_TaskDelay(200); // Delay 200 ticks.
LOS_SwtmrTimeGet(id1, &uwTick); // Obtain the number of remaining ticks of the one-short software timer. LOS_SwtmrTimeGet(id1, &uwTick); // Obtain the number of remaining ticks of the one-short software timer.
...@@ -196,6 +182,7 @@ void Timer_example(void) ...@@ -196,6 +182,7 @@ void Timer_example(void)
**Output** **Output**
``` ```
create Timer1 success create Timer1 success
start Timer1 success start Timer1 success
...@@ -226,4 +213,3 @@ tick_last1=2101 ...@@ -226,4 +213,3 @@ tick_last1=2101
g_timercount2 =10 g_timercount2 =10
tick_last1=2201 tick_last1=2201
``` ```
...@@ -3,85 +3,64 @@ ...@@ -3,85 +3,64 @@
## Basic Concepts ## Basic Concepts
Time management provides all time-related services for applications based on the system clock. The system clock is generated by the interrupts triggered by the output pulse of a timer or counter. The system clock is generally defined as an integer or a long integer. The period of an output pulse is a "clock tick". The system clock is also called time scale or tick. The duration of a tick can be configured statically. People use second or millisecond as the time unit, while the operating system uses tick. When operations such as suspending a task or delaying a task are performed, the time management module converts time between ticks and seconds or milliseconds. Time management is performed based on the system clock. It provides time-related services for applications. The system clock is generated by the interrupts triggered by the output pulse of a timer or counter. The system clock is generally defined as an integer or a long integer. The period of an output pulse is a "clock tick".
The system clock is also called time scale or tick. The duration of a tick can be configured statically. People use second or millisecond as the time unit, while the operating system uses tick. When operations such as suspending a task or delaying a task are performed, the time management module converts time between ticks and seconds or milliseconds.
The mapping between ticks and seconds can be configured. The mapping between ticks and seconds can be configured.
- **Cycle** - Cycle
Cycle is the minimum time unit in the system. The cycle duration is determined by the system clock frequency, that is, the number of cycles per second.
- Tick
Cycle is the minimum time unit in the system. The cycle duration is determined by the system clock frequency, that is, the number of cycles per second. Tick is the basic time unit of the operating system and is determined by the number of ticks per second configured by the user.
The OpenHarmony time management module provides time conversion, statistics, and delay functions.
- **Tick**
Tick is the basic time unit of the operating system and is determined by the number of ticks per second configured by the user. ## Development Guidelines
Before you start, learn about the system time and the APIs for time management.
The OpenHarmony time management module provides time conversion, statistics, and delay functions to meet users' time requirements.
## Development Guidelines ### Available APIs
The time management module provides APIs to implement conversion between the system running time, ticks, and seconds/milliseconds. The following table describes APIs for OpenHarmony LiteOS-A time management. For more details about the APIs, see the API reference.
### Available APIs **Table 1** APIs for time management
| Category| API Description |
| -------- | ------------------------------------------------------------ |
| Time conversion| **LOS_MS2Tick**: converts milliseconds to ticks.<br>**LOS_Tick2MS**: converts ticks to milliseconds. |
| Time statistics| **LOS_TickCountGet**: obtains the number of current ticks.<br>**LOS_CyclePerTickGet**: obtains the number of cycles of each tick.|
The following table describes APIs available for the OpenHarmony LiteOS-A time management. For more details about the APIs, see the API reference.
**Table 1** APIs of the time management module
<a name="table1316220185211"></a>
<table><thead align="left"><tr id="row191622182021"><th class="cellrowborder" valign="top" width="33.33333333333333%" id="mcps1.2.4.1.1"><p id="p13162121815218"><a name="p13162121815218"></a><a name="p13162121815218"></a>Function</p>
</th>
<th class="cellrowborder" valign="top" width="33.33333333333333%" id="mcps1.2.4.1.2"><p id="p12162618623"><a name="p12162618623"></a><a name="p12162618623"></a>API</p>
</th>
<th class="cellrowborder" valign="top" width="33.33333333333333%" id="mcps1.2.4.1.3"><p id="p16162118427"><a name="p16162118427"></a><a name="p16162118427"></a>Description</p>
</th>
</tr>
</thead>
<tbody><tr id="row04981218910"><td class="cellrowborder" rowspan="2" valign="top" width="33.33333333333333%" headers="mcps1.2.4.1.1 "><p id="p6462616696"><a name="p6462616696"></a><a name="p6462616696"></a>Time conversion</p>
</td>
<td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.2.4.1.2 "><p id="p164931214913"><a name="p164931214913"></a><a name="p164931214913"></a>LOS_MS2Tick</p>
</td>
<td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.2.4.1.3 "><p id="p8504121996"><a name="p8504121996"></a><a name="p8504121996"></a>Converts milliseconds into ticks.</p>
</td>
</tr>
<tr id="row7162101814216"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p816311185217"><a name="p816311185217"></a><a name="p816311185217"></a>LOS_Tick2MS</p>
</td>
<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p161632181721"><a name="p161632181721"></a><a name="p161632181721"></a>Converts ticks into milliseconds.</p>
</td>
</tr>
<tr id="row1516317181227"><td class="cellrowborder" rowspan="2" valign="top" width="33.33333333333333%" headers="mcps1.2.4.1.1 "><p id="p1077619231696"><a name="p1077619231696"></a><a name="p1077619231696"></a>Time statistics</p>
</td>
<td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.2.4.1.2 "><p id="p181638181921"><a name="p181638181921"></a><a name="p181638181921"></a>LOS_TickCountGet</p>
</td>
<td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.2.4.1.3 "><p id="p615864811116"><a name="p615864811116"></a><a name="p615864811116"></a>Obtains the current number of ticks.</p>
</td>
</tr>
<tr id="row101631818620"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p71633181125"><a name="p71633181125"></a><a name="p71633181125"></a>LOS_CyclePerTickGet</p>
</td>
<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p151631718124"><a name="p151631718124"></a><a name="p151631718124"></a>Obtains the number of cycles per tick.</p>
</td>
</tr>
</tbody>
</table>
### How to Develop ### How to Develop
1. Call APIs to convert time. 1. Call APIs to convert time.
2. Call APIs to perform time statistics.
2. Call APIs to perform time statistics.
> **NOTE**
>
> - The system tick count can be obtained only after the system clock is enabled.
>
> - The time management module depends on **OS_SYS_CLOCK** and **LOSCFG_BASE_CORE_TICK_PER_SECOND** in **los_config.h**.
>
> - The number of system ticks is not counted when the interrupt feature is disabled. Therefore, the number of ticks cannot be used as the accurate time.
>![](public_sys-resources/icon-note.gif) **NOTE**<br/>
>- The system tick count can be obtained only after the system clock is enabled.
>- The time management module depends on **OS\_SYS\_CLOCK** and **LOSCFG\_BASE\_CORE\_TICK\_PER\_SECOND** in **los\_config.h**.
>- The number of system ticks is not counted when the interrupt feature is disabled. Therefore, the number of ticks cannot be used as the accurate time.
### Development Example ### Development Example
**Prerequisites**<br> **Prerequisites**
The following parameters are configured: The following parameters are configured:
- **LOSCFG\_BASE\_CORE\_TICK\_PER\_SECOND**: number of ticks per second in the system. The value range is (0, 1000]. - **LOSCFG_BASE_CORE_TICK_PER_SECOND**: number of ticks/second. The value range is (0, 1000).
- **OS\_SYS\_CLOCK**: system clock, in Hz.
- **OS_SYS_CLOCK**: system clock, in Hz.
**Sample Code** **Sample Code**
...@@ -92,15 +71,16 @@ VOID Example_TransformTime(VOID) ...@@ -92,15 +71,16 @@ VOID Example_TransformTime(VOID)
{ {
UINT32 uwMs; UINT32 uwMs;
UINT32 uwTick; UINT32 uwTick;
uwTick = LOS_MS2Tick(10000);// Convert 10000 ms into ticks. uwTick = LOS_MS2Tick(10000); // Convert 10000 ms to ticks.
PRINTK("uwTick = %d \n",uwTick); PRINTK("uwTick = %d \n",uwTick);
uwMs= LOS_Tick2MS(100); // Convert 100 ticks into ms. uwMs= LOS_Tick2MS(100); // Convert 100 ticks to ms.
PRINTK("uwMs = %d \n",uwMs); PRINTK("uwMs = %d \n",uwMs);
} }
``` ```
Time statistics and delay: Time statistics and delay:
``` ```
VOID Example_GetTime(VOID) VOID Example_GetTime(VOID)
{ {
...@@ -133,6 +113,7 @@ The result is as follows: ...@@ -133,6 +113,7 @@ The result is as follows:
Time conversion: Time conversion:
``` ```
uwTick = 10000 uwTick = 10000
uwMs = 100 uwMs = 100
...@@ -140,9 +121,9 @@ uwMs = 100 ...@@ -140,9 +121,9 @@ uwMs = 100
Time statistics and delay: Time statistics and delay:
``` ```
LOS_CyclePerTickGet = 49500 LOS_CyclePerTickGet = 49500
LOS_TickCountGet = 5042 LOS_TickCountGet = 347931
LOS_TickCountGet after delay = 5242 LOS_TickCountGet after delay = 348134
``` ```
...@@ -9,29 +9,25 @@ A mutex has three attributes: protocol attribute, priority upper limit attribute ...@@ -9,29 +9,25 @@ A mutex has three attributes: protocol attribute, priority upper limit attribute
- LOS_MUX_PRIO_NONE - LOS_MUX_PRIO_NONE
Do not inherit or protect the priority of the task requesting the mutex.
Do not inherit or protect the priority of the task requesting the mutex.
- LOS_MUX_PRIO_INHERIT - LOS_MUX_PRIO_INHERIT
Inherits the priority of the task that requests the mutex. This is the default protocol attribute. When the mutex protocol attribute is set to this value: If a task with a higher priority is blocked because the mutex is already held by a task, the priority of the task holding the mutex will be backed up to the priority bitmap of the task control block, and then set to be the same as that of the task of a higher priority. When the task holding the mutex releases the mutex, its task priority is restored to its original value.
Inherits the priority of the task that requests the mutex. This is the default protocol attribute. When the mutex protocol attribute is set to this value: If a task with a higher priority is blocked because the mutex is already held by a task, the priority of the task holding the mutex will be backed up to the priority bitmap of the task control block, and then set to be the same as that of the task of a higher priority. When the task holding the mutex releases the mutex, its task priority is restored to its original value.
- LOS_MUX_PRIO_PROTECT - LOS_MUX_PRIO_PROTECT
Protects the priority of the task that requests the mutex. When the mutex protocol attribute is set to this value: If the priority of the task that requests the mutex is lower than the upper limit of the mutex priority, the task priority will be backed up to the priority bitmap of the task control block, and then set to the upper limit value of the mutex priority. When the mutex is released, the task priority is restored to its original value. Protects the priority of the task that requests the mutex. When the mutex protocol attribute is set to this value: If the priority of the task that requests the mutex is lower than the upper limit of the mutex priority, the task priority will be backed up to the priority bitmap of the task control block, and then set to the upper limit value of the mutex priority. When the mutex is released, the task priority is restored to its original value.
The type attribute of a mutex specifies whether to check for deadlocks and whether to support recursive holding of the mutex. The type attribute can be any of the following: The type attribute of a mutex specifies whether to check for deadlocks and whether to support recursive holding of the mutex. The type attribute can be any of the following:
- LOS_MUX_NORMAL - LOS_MUX_NORMAL
Common mutex, which does not check for deadlocks. If a task repeatedly attempts to hold a mutex, the thread will be deadlocked. If the mutex type attribute is set to this value, a task cannot release a mutex held by another task or repeatedly release a mutex. Otherwise, unexpected results will be caused.
Common mutex, which does not check for deadlocks. If a task repeatedly attempts to hold a mutex, the thread will be deadlocked. If the mutex type attribute is set to this value, a task cannot release a mutex held by another task or repeatedly release a mutex. Otherwise, unexpected results will be caused.
- LOS_MUX_RECURSIVE - LOS_MUX_RECURSIVE
Recursive mutex, which is the default attribute. If the type attribute of a mutex is set to this value, a task can hold the mutex for multiple times. Another task can hold this mutex only when the number of lock holding times is the same as the number of lock release times. However, any attempt to hold a mutex held by another task or attempt to release a mutex that has been released will return an error code.
Recursive mutex, which is the default attribute. If the type attribute of a mutex is set to this value, a task can hold the mutex for multiple times. Another task can hold this mutex only when the number of lock holding times is the same as the number of lock release times. However, any attempt to hold a mutex held by another task or attempt to release a mutex that has been released will return an error code.
- LOS_MUX_ERRORCHECK - LOS_MUX_ERRORCHECK
...@@ -44,7 +40,7 @@ In a multi-task environment, multiple tasks may access the same shared resources ...@@ -44,7 +40,7 @@ In a multi-task environment, multiple tasks may access the same shared resources
When non-shared resources are accessed by a task, the mutex is locked. Other tasks will be blocked until the mutex is released by the task. The mutex allows only one task to access the shared resources at a time, ensuring integrity of operations on the shared resources. When non-shared resources are accessed by a task, the mutex is locked. Other tasks will be blocked until the mutex is released by the task. The mutex allows only one task to access the shared resources at a time, ensuring integrity of operations on the shared resources.
**Figure 1** Mutex working mechanism for the small system **Figure 1** Mutex working mechanism for the small system
![](figures/mutex-working-mechanism-for-small-systems.png "mutex-working-mechanism-for-small-systems") ![](figures/mutex-working-mechanism-for-small-systems.png "mutex-working-mechanism-for-small-systems")
......
# Futex # Futex
## Basic Concepts<a name="section643519912920"></a> ## Basic Concepts
Fast userspace mutex \(futex\) is a system call capability provided by the kernel. It is a basic component that combines with user-mode lock logic to form a user-mode lock. It is a lock working in both user mode and kernel mode, for example, userspace mutex, barrier and cond synchronization lock, and RW lock. The user-mode part implements lock logic, and the kernel-mode part schedules locks. Fast userspace mutex (futex) is a system call capability provided by the kernel. It is a basic component that combines with user-mode lock logic to form a user-mode lock. It is a lock working in both user mode and kernel mode, for example, userspace mutex, barrier and cond synchronization lock, and RW lock. The user-mode part implements lock logic, and the kernel-mode part schedules locks.
When a user-mode thread requests a lock, the lock status is first checked in user space. If no lock contention occurs, the user-mode thread acquires the lock directly. If lock contention occurs, the futex system call is invoked to request the kernel to suspend the thread and maintain the blocking queue. When a user-mode thread requests a lock, the lock status is first checked in user space. If no lock contention occurs, the user-mode thread acquires the lock directly. If lock contention occurs, the futex system call is invoked to request the kernel to suspend the thread and maintain the blocking queue.
When a user-mode thread releases a lock, the lock status is first checked in user space. If no other thread is blocked by the lock, the lock is directly released in user space. If there are threads blocked by the lock, the futex system call is invoked to request the kernel to wake up the threads in the blocking queue. When a user-mode thread releases a lock, the lock status is first checked in user space. If no other thread is blocked by the lock, the lock is directly released in user space. If there are threads blocked by the lock, the futex system call is invoked to request the kernel to wake up the threads in the blocking queue.
## Working Principles<a name="section16834132502910"></a>
## Working Principles
When thread scheduling is required to resolve lock contention or lock release in user space, the futex system call is invoked to pass the user-mode lock address to the kernel. The user-mode locks are distinguished by lock address in the futex of the kernel. The available virtual address space in user space is 1 GiB. To facilitate search and management of lock addresses, the kernel futex uses hash buckets to store the user-mode locks. When thread scheduling is required to resolve lock contention or lock release in user space, the futex system call is invoked to pass the user-mode lock address to the kernel. The user-mode locks are distinguished by lock address in the futex of the kernel. The available virtual address space in user space is 1 GiB. To facilitate search and management of lock addresses, the kernel futex uses hash buckets to store the user-mode locks.
There are 80 hash buckets. Buckets 0 to 63 are used to store private locks \(hashed based on virtual addresses\), and buckets 64 to 79 are used to store shared locks \(hashed based on physical addresses\). The private/shared attributes are determined by initialization of user-mode locks and the input parameters in the futex system call. There are 80 hash buckets used to store shared locks (hashed based on physical addresses). The private/shared attributes are determined by initialization of user-mode locks and the input parameters in the futex system call.
## Futex Design
**Figure 1** Futex design
**Figure 1** Futex design<a name="fig651353710598"></a>
![](figures/futex-design.jpg "futex-design") ![](figures/futex-design.jpg "futex-design")
As shown in the above figure, each futex hash bucket stores the futex nodes with the same hash value linked in a futex\_list. Each futex node corresponds to a suspended task. The key value of a node uniquely identifies a user-mode lock. The nodes with the same key value added to a queue\_list indicate a queue of tasks blocked by the same lock. As shown in the above figure, each futex hash bucket stores the futex nodes with the same hash value linked in a futex_list. Each futex node corresponds to a suspended task. The key value of a node uniquely identifies a user-mode lock. The nodes with the same key value added to a queue_list indicate a queue of tasks blocked by the same lock.
The following table describes the APIs available for the futex module. ## Available APIs
**Table 1** Futex module APIs APIs of the futex module
<a name="table1316220185211"></a> | Category | API | Description |
<table><thead align="left"><tr id="row191622182021"><th class="cellrowborder" valign="top" width="27.09270927092709%" id="mcps1.2.4.1.1"><p id="p13162121815218"><a name="p13162121815218"></a><a name="p13162121815218"></a>Function</p> | -------------- | -------------- | ------------------------------------- |
</th> | Putting a thread to wait | OsFutexWait | Inserts a node representing a blocked thread into the futex list.|
<th class="cellrowborder" valign="top" width="26.52265226522652%" id="mcps1.2.4.1.2"><p id="p12162618623"><a name="p12162618623"></a><a name="p12162618623"></a>API</p> | Waking up a thread| OsFutexWake | Wakes up a thread that is blocked by a specified lock. |
</th> | Modifying the lock address | OsFutexRequeue | Adjusts the position of a specified lock in the futex list. |
<th class="cellrowborder" valign="top" width="46.384638463846386%" id="mcps1.2.4.1.3"><p id="p16162118427"><a name="p16162118427"></a><a name="p16162118427"></a>Description</p>
</th>
</tr>
</thead>
<tbody><tr id="row04981218910"><td class="cellrowborder" valign="top" width="27.09270927092709%" headers="mcps1.2.4.1.1 "><p id="p6462616696"><a name="p6462616696"></a><a name="p6462616696"></a>Putting a thread to wait</p>
</td>
<td class="cellrowborder" valign="top" width="26.52265226522652%" headers="mcps1.2.4.1.2 "><p id="p164931214913"><a name="p164931214913"></a><a name="p164931214913"></a>OsFutexWait</p>
</td>
<td class="cellrowborder" valign="top" width="46.384638463846386%" headers="mcps1.2.4.1.3 "><p id="p8504121996"><a name="p8504121996"></a><a name="p8504121996"></a>Inserts a node representing a blocked thread into the futex list.</p>
</td>
</tr>
<tr id="row7162101814216"><td class="cellrowborder" valign="top" width="27.09270927092709%" headers="mcps1.2.4.1.1 "><p id="p37331032985"><a name="p37331032985"></a><a name="p37331032985"></a>Waking up a thread</p>
</td>
<td class="cellrowborder" valign="top" width="26.52265226522652%" headers="mcps1.2.4.1.2 "><p id="p816311185217"><a name="p816311185217"></a><a name="p816311185217"></a>OsFutexWake</p>
</td>
<td class="cellrowborder" valign="top" width="46.384638463846386%" headers="mcps1.2.4.1.3 "><p id="p161632181721"><a name="p161632181721"></a><a name="p161632181721"></a>Wakes up a thread that is blocked by a specified lock.</p>
</td>
</tr>
<tr id="row101631818620"><td class="cellrowborder" valign="top" width="27.09270927092709%" headers="mcps1.2.4.1.1 "><p id="p146111936887"><a name="p146111936887"></a><a name="p146111936887"></a>Modifying the lock address</p>
</td>
<td class="cellrowborder" valign="top" width="26.52265226522652%" headers="mcps1.2.4.1.2 "><p id="p71633181125"><a name="p71633181125"></a><a name="p71633181125"></a>OsFutexRequeue</p>
</td>
<td class="cellrowborder" valign="top" width="46.384638463846386%" headers="mcps1.2.4.1.3 "><p id="p151631718124"><a name="p151631718124"></a><a name="p151631718124"></a>Adjusts the position of a specified lock in the futex list.</p>
</td>
</tr>
</tbody>
</table>
>![](../public_sys-resources/icon-note.gif) **NOTE:**
>The futex system call and user-mode logic form a user-mode lock. Therefore, you are advised to use the locks via the user-mode POSIX APIs.
> **NOTE**<br>
> The futex system call and user-mode logic form a user-mode lock. Therefore, you are advised to use the locks via the user-mode POSIX APIs.
# Signal # Signal
## Basic Concepts<a name="section172788254307"></a> ## Basic Concepts
Signal is a common inter-process asynchronous communication mechanism. It uses software-simulated interrupt signals. When a process needs to communicate with another process, it sends a signal to the kernel. The kernel then transfers the signal to the destination process. The destination process does not need to wait for the signal. Signal is a common asynchronous communication mechanism between processes. It uses software-simulated interrupt signals. When a process needs to communicate with another process, it sends a signal to the kernel. The kernel transfers the signal to the target process. The target process does not need to wait for the signal.
## Working Principles<a name="section1249693812301"></a>
The following table describes the APIs available for signal operations. ## Working Principles
**Table 1** Signal operation process and APIs \(user-mode APIs\) The following table describes the APIs for signal operations.
<a name="table1316220185211"></a> **Table 1** Signal APIs (user-mode APIs)
<table><thead align="left"><tr id="row191622182021"><th class="cellrowborder" valign="top" width="27.09270927092709%" id="mcps1.2.4.1.1"><p id="p13162121815218"><a name="p13162121815218"></a><a name="p13162121815218"></a>Function</p>
</th>
<th class="cellrowborder" valign="top" width="26.49264926492649%" id="mcps1.2.4.1.2"><p id="p12162618623"><a name="p12162618623"></a><a name="p12162618623"></a>API</p>
</th>
<th class="cellrowborder" valign="top" width="46.41464146414641%" id="mcps1.2.4.1.3"><p id="p16162118427"><a name="p16162118427"></a><a name="p16162118427"></a>Description</p>
</th>
</tr>
</thead>
<tbody><tr id="row04981218910"><td class="cellrowborder" rowspan="2" valign="top" width="27.09270927092709%" headers="mcps1.2.4.1.1 "><p id="p6462616696"><a name="p6462616696"></a><a name="p6462616696"></a>Registering the signal callback</p>
</td>
<td class="cellrowborder" valign="top" width="26.49264926492649%" headers="mcps1.2.4.1.2 "><p id="p164931214913"><a name="p164931214913"></a><a name="p164931214913"></a>signal</p>
</td>
<td class="cellrowborder" valign="top" width="46.41464146414641%" headers="mcps1.2.4.1.3 "><p id="p8504121996"><a name="p8504121996"></a><a name="p8504121996"></a>Registers the main signal entry, and registers and unregisters the callback function of a signal.</p>
</td>
</tr>
<tr id="row5449183942119"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p5450153922110"><a name="p5450153922110"></a><a name="p5450153922110"></a>sigaction</p>
</td>
<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p1945083962113"><a name="p1945083962113"></a><a name="p1945083962113"></a>Same as <strong id="b1076755712371"><a name="b1076755712371"></a><a name="b1076755712371"></a>signal</strong>. This API is added with configuration options related to signal transmission. Currently, only some parameters in the <strong id="b18458105019218"><a name="b18458105019218"></a><a name="b18458105019218"></a>SIGINFO</strong> structure are supported.</p>
</td>
</tr>
<tr id="row7162101814216"><td class="cellrowborder" rowspan="5" valign="top" width="27.09270927092709%" headers="mcps1.2.4.1.1 "><p id="p37331032985"><a name="p37331032985"></a><a name="p37331032985"></a>Sending signals</p>
</td>
<td class="cellrowborder" valign="top" width="26.49264926492649%" headers="mcps1.2.4.1.2 "><p id="p816311185217"><a name="p816311185217"></a><a name="p816311185217"></a>kill</p>
</td>
<td class="cellrowborder" rowspan="5" align="left" valign="top" width="46.41464146414641%" headers="mcps1.2.4.1.3 "><p id="p161632181721"><a name="p161632181721"></a><a name="p161632181721"></a>Sends a signal to a process or sends messages to a thread in a process, and sets signal flags for threads in a process.</p>
</td>
</tr>
<tr id="row129182420243"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p149191745248"><a name="p149191745248"></a><a name="p149191745248"></a>pthread_kill</p>
</td>
</tr>
<tr id="row1026214719240"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p1226313762411"><a name="p1226313762411"></a><a name="p1226313762411"></a>raise</p>
</td>
</tr>
<tr id="row05632094242"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p45643914245"><a name="p45643914245"></a><a name="p45643914245"></a>alarm</p>
</td>
</tr>
<tr id="row3241512122417"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p324211202414"><a name="p324211202414"></a><a name="p324211202414"></a>abort</p>
</td>
</tr>
<tr id="row101631818620"><td class="cellrowborder" valign="top" width="27.09270927092709%" headers="mcps1.2.4.1.1 "><p id="p146111936887"><a name="p146111936887"></a><a name="p146111936887"></a>Triggering a callback</p>
</td>
<td class="cellrowborder" valign="top" width="26.49264926492649%" headers="mcps1.2.4.1.2 "><p id="p71633181125"><a name="p71633181125"></a><a name="p71633181125"></a>None</p>
</td>
<td class="cellrowborder" valign="top" width="46.41464146414641%" headers="mcps1.2.4.1.3 "><p id="p1126941694213"><a name="p1126941694213"></a><a name="p1126941694213"></a>Triggered by a system call or an interrupt. Before the switching between the kernel mode and user mode, the specified function in user mode is entered, and the corresponding callbacks are processed. After that, the original user-mode program continues to run.</p>
</td>
</tr>
</tbody>
</table>
>![](../public_sys-resources/icon-note.gif) **NOTE:** | Category | API | Description |
>The signal mechanism enables communication between user-mode programs. The user-mode POSIX APIs listed in the above table are recommended. | ---------------- | --------------------------------------------------- | ------------------------------------------------------------ |
>Register a callback function. | Registering/Unregistering a signal callback| signal | Registers the main signal entry, and registers or unregisters a callback for a signal. |
>``` | Registering a signal callback| sigaction | Same as **signal**. This API is added with configuration options related to signal transmission. Currently, only some parameters in the **SIGINFO** structure are supported.|
>void *signal(int sig, void (*func)(int))(int); | Sending a signal | kill<br>pthread_kill<br>raise<br>alarm<br>abort | Sends a signal to a process or sends a message to a thread in a process, and sets the signal flag for a thread in a process. |
>``` | Invoking a callback | NA | Called by a system call or an interrupt. Before the switching between the kernel mode and user mode, the callback in the specified function in user mode is processed. After that, the original user-mode program continues to run.|
>a. Signal 31 is used to register the handling entry of the process callback. Repeated registration is not allowed.
>b. Signals 0 to 30 are used to register and unregister callbacks.
>Register a callback.
>```
>int sigaction(int, const struct sigaction *__restrict, struct sigaction *__restrict);
>```
>You can obtain and modify the configuration of signal registration. Currently, only the **SIGINFO** options are supported. For details, see the description of the **sigtimedwait** API.
>Transmit a signal.
>a. Among the default signal-receiving behaviors, the process does not support **STOP**, **CONTINUE**, and **COREDUMP** defined in the POSIX standard.
>b. The **SIGSTOP**, **SIGKILL**, and **SIGCONT** signals cannot be shielded.
>c. If a process killed is not reclaimed by its parent process, the process becomes a zombie process.
>d. A process will not call back the signal received until the process is scheduled.
>e. When a process is killed, **SIGCHLD** is sent to its parent process. The signal sending action cannot be canceled.
>f. A process in the DELAY state cannot be woken up by a signal.
> **NOTE**<br>
> The signal mechanism enables communication between user-mode programs. The user-mode POSIX APIs listed in the above table are recommended.
>
> **Registering a Callback**
>
>
> ```
> void *signal(int sig, void (*func)(int))(int);
> ```
>
> - Signal 31 is used to register the handling entry of the process callback. Repeated registration is not allowed.
>
>
> - Signals 0 to 30 are used to register and unregister callbacks.
>
>
> **Registering a Callback**
>
>
> ```
> int sigaction(int, const struct sigaction ***restrict, struct sigaction ***restrict);
> ```
>
> You can obtain and modify the configuration of signal registration. Currently, only the **SIGINFO** options are supported. For details, see the description of the **sigtimedwait** API.
>
> **Sending a Signal**
>
> - Among the default signal-receiving behaviors, the process does not support **STOP**, **COTINUE**, and **COREDUMP** defined in POSIX.
>
>
> - The **SIGSTOP**, **SIGKILL**, and **SIGCONT** signals cannot be shielded.
>
>
> - If a process killed is not reclaimed by its parent process, the process becomes a zombie process.
>
>
> - A process will not call back the signal received until the process is scheduled.
>
>
> - When a process is killed, **SIGCHLD** is sent to its parent process. The signal sending action cannot be canceled.
>
>
> - A process in the DELAY state cannot be woken up by a signal.
# LiteIPC # LiteIPC
## Basic Concepts<a name="section1980994712918"></a> ## Basic Concepts
LiteIPC is a new inter-process communication \(IPC\) mechanism provided by the OpenHarmony LiteOS-A kernel. Different from the traditional System V IPC, LiteIPC is designed for Remote Procedure Call \(RPC\). In addition, it provides APIs for the upper layer through device files, not through traditional API functions.
LiteIPC has two important concepts: ServiceManager and Service. The entire system can have one ServiceManager and multiple Services. ServiceManager is responsible for registering and unregistering Services, and managing Service access permission \(only authorized tasks can send IPC messages to corresponding Services\).
## Working Principles<a name="section849811592918"></a>
ServiceManager registers the task that needs to receive IPC messages as a Service, and sets the access permission for the Service task \(specifies the tasks that can send IPC messages to the Service\). LiteIPC maintains an IPC message queue for each Service task in kernel mode. The message queue provides the upper-layer user-mode programs with the read operation \(receiving IPC messages\) and the write operations \(sending IPC messages\) through LiteIPC device files.
## Development Guidelines<a name="section17571315171017"></a>
### Available APIs<a name="section725022011103"></a>
**Table 1** LiteIPC module APIs \(for LiteOS-A internal use only\)
<a name="table1415203765610"></a>
<table><thead align="left"><tr id="row134151837125611"><th class="cellrowborder" valign="top" width="12.85128512851285%" id="mcps1.2.4.1.1"><p id="p16415637105612"><a name="p16415637105612"></a><a name="p16415637105612"></a>Function</p>
</th>
<th class="cellrowborder" valign="top" width="29.8029802980298%" id="mcps1.2.4.1.2"><p id="p11415163718562"><a name="p11415163718562"></a><a name="p11415163718562"></a>API</p>
</th>
<th class="cellrowborder" valign="top" width="57.34573457345735%" id="mcps1.2.4.1.3"><p id="p1641533755612"><a name="p1641533755612"></a><a name="p1641533755612"></a>Description</p>
</th>
</tr>
</thead>
<tbody><tr id="row0415737175610"><td class="cellrowborder" valign="top" width="12.85128512851285%" headers="mcps1.2.4.1.1 "><p id="p8866127195914"><a name="p8866127195914"></a><a name="p8866127195914"></a>Module initialization</p>
</td>
<td class="cellrowborder" valign="top" width="29.8029802980298%" headers="mcps1.2.4.1.2 "><p id="p58621910185914"><a name="p58621910185914"></a><a name="p58621910185914"></a>OsLiteIpcInit</p>
</td>
<td class="cellrowborder" valign="top" width="57.34573457345735%" headers="mcps1.2.4.1.3 "><p id="p48623102592"><a name="p48623102592"></a><a name="p48623102592"></a>Initializes the LiteIPC module.</p>
</td>
</tr>
<tr id="row1213865218584"><td class="cellrowborder" rowspan="3" valign="top" width="12.85128512851285%" headers="mcps1.2.4.1.1 "><p id="p1219312239566"><a name="p1219312239566"></a><a name="p1219312239566"></a>IPC message memory pool</p>
</td>
<td class="cellrowborder" valign="top" width="29.8029802980298%" headers="mcps1.2.4.1.2 "><p id="p20862510115911"><a name="p20862510115911"></a><a name="p20862510115911"></a>LiteIpcPoolInit</p>
</td>
<td class="cellrowborder" valign="top" width="57.34573457345735%" headers="mcps1.2.4.1.3 "><p id="p1886211011599"><a name="p1886211011599"></a><a name="p1886211011599"></a>Initializes the IPC message memory pool of processes.</p>
</td>
</tr>
<tr id="row3231257145813"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p3313428135414"><a name="p3313428135414"></a><a name="p3313428135414"></a>LiteIpcPoolReInit</p>
</td>
<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p586261085913"><a name="p586261085913"></a><a name="p586261085913"></a>Re-initializes the IPC message memory pool of processes.</p>
</td>
</tr>
<tr id="row73651459105815"><td class="cellrowborder" valign="top" headers="mcps1.2.4.1.1 "><p id="p464344145411"><a name="p464344145411"></a><a name="p464344145411"></a>LiteIpcPoolDelete</p>
</td>
<td class="cellrowborder" valign="top" headers="mcps1.2.4.1.2 "><p id="p555221518598"><a name="p555221518598"></a><a name="p555221518598"></a>Releases the IPC message memory pool of processes.</p>
</td>
</tr>
<tr id="row178321454145812"><td class="cellrowborder" valign="top" width="12.85128512851285%" headers="mcps1.2.4.1.1 "><p id="p19527545175517"><a name="p19527545175517"></a><a name="p19527545175517"></a>Service management</p>
</td>
<td class="cellrowborder" valign="top" width="29.8029802980298%" headers="mcps1.2.4.1.2 "><p id="p756845455415"><a name="p756845455415"></a><a name="p756845455415"></a>LiteIpcRemoveServiceHandle</p>
</td>
<td class="cellrowborder" valign="top" width="57.34573457345735%" headers="mcps1.2.4.1.3 "><p id="p1555261595915"><a name="p1555261595915"></a><a name="p1555261595915"></a>Deletes the specified Service.</p>
</td>
</tr>
</tbody>
</table>
>![](../public_sys-resources/icon-note.gif) **NOTE:**
>LiteIPC module APIs are used for LiteOS-A internal use only.
LiteIPC is a new inter-process communication (IPC) mechanism provided by the OpenHarmony LiteOS-A kernel. Different from the traditional System V IPC, LiteIPC is designed for Remote Procedure Call (RPC). In addition, it provides APIs for the upper layer through device files, not through traditional API functions.
LiteIPC has two important concepts: ServiceManager and Service. The entire system can have one ServiceManager and multiple Services.
ServiceManager provides the following functions:
- Registers and deregisters services.
- Manages the access permission of services. Only authorized tasks can send IPC messages to the service.
## Working Principles
ServiceManager registers the task that needs to receive IPC messages as a Service, and sets the access permission for the Service task (specifies the tasks that can send IPC messages to the Service).
LiteIPC maintains an IPC message queue for each Service task in kernel mode. The message queue provides the upper-layer user-mode programs with the read operation (receiving IPC messages) and the write operations (sending IPC messages) through LiteIPC device files.
## Development Guidelines
### Available APIs
**Table 1** APIs of the LiteIPC module (applicable to LiteOS-A only)
| Category | API Description |
| ------------- | ------------------------------------------------------------ |
| Module initialization | **OsLiteIpcInit**: initializes the LiteIPC module. |
| IPC message memory pool| - **LiteIpcPoolInit**: initializes the IPC message memory pool of a process.<br>- **LiteIpcPoolReInit**: reinitializes the IPC message memory pool of a process.<br>- **LiteIpcPoolDelete**: releases the IPC message memory pool of a process. |
| Service management | **LiteIpcRemoveServiceHandle**: deletes a service. |
> **NOTE**<br>
> The APIs of the LiteIPC module are dedicated for LiteOS-A internal use only.
# Dynamic Loading and Linking # Dynamic Loading and Linking
## Basic Concepts<a name="section208951139453"></a>
## Basic Concepts
The OpenHarmony dynamic loading and linking mechanism includes a kernel loader and a dynamic linker. The kernel loader loads application programs and the dynamic linker. The dynamic linker loads the shared library on which the application programs depend, and performs symbol relocation for the application programs and shared libraries. Compared with static linking, dynamic linking is a mechanism for delaying the linking of applications and dynamic libraries to run time. The OpenHarmony dynamic loading and linking mechanism includes a kernel loader and a dynamic linker. The kernel loader loads application programs and the dynamic linker. The dynamic linker loads the shared library on which the application programs depend, and performs symbol relocation for the application programs and shared libraries. Compared with static linking, dynamic linking is a mechanism for delaying the linking of applications and dynamic libraries to run time.
**Advantages of Dynamic Linking** **Advantages of Dynamic Linking**
1. Dynamic linking allows multiple applications to share code. The minimum loading unit is page. Dynamic linking saves disk and memory space than static linking. - Dynamic linking allows multiple applications to share code. The minimum loading unit is page. Dynamic linking saves disk and memory space than static linking.
2. When a shared library is upgraded, the new shared library overwrites the earlier version \(the APIs of the shared library are downward compatible\). You do not need to re-link the shared library.
3. The loading address can be randomized to prevent attacks and ensure security. - When a shared library is upgraded, the new shared library overwrites the earlier version (the APIs of the shared library are downward compatible). You do not need to re-link the shared library.
- The loading address can be randomized to prevent attacks and ensure security.
## Working Principles
## Working Principles<a name="section14140155320511"></a> **Figure 1** Dynamic loading process
**Figure 1** Dynamic loading process<a name="fig1797764116422"></a>
![](figures/dynamic-loading-process.png "dynamic-loading-process") ![](figures/dynamic-loading-process.png "dynamic-loading-process")
1. The kernel maps the **PT\_LOAD** section in the ELF file of the application to the process space. For files of the ET\_EXEC type, fixed address mapping is performed based on **p\_vaddr** in the **PT\_LOAD** section. For files of the ET\_DYN type \(position-independent executable programs, obtained through the compile option **-fPIE**\), the kernel selects the **base** address via **mmap** for mapping \(load\_addr = base + p\_vaddr\). 1. The kernel maps the **PT_LOAD** section in the ELF file of the application to the process space. For files of the ET_EXEC type, fixed address mapping is performed based on **p_vaddr** in the **PT_LOAD** section. For files of the ET_DYN type (position-independent executable programs, obtained through **-fPIE**), the kernel selects the **base** address via **mmap** for mapping (load_addr = base + p_vaddr).
2. If the application is statically linked \(static linking does not support the compile option **-fPIE**\), after the stack information is set, the system redirects to the address specified by **e\_entry** in the ELF file of the application and runs the application. If the program is dynamically linked, the application ELF file contains the **PT\_INTERP** section, which stores the dynamic linker path information \(ET\_DYN type\). The dynamic linker of musl is a part of the **libc-musl.so**. The entry of **libc-musl.so** is the entry of the dynamic linker. The kernel selects the **base** address for mapping via the **mmap** API, sets the stack information, redirects to the **base + e\_entry** \(entry of the dynamic linker\) address, and runs the dynamic linker.
3. The dynamic linker bootstraps and searches for all shared libraries on which the application depends, relocates the imported symbols, and finally redirects to the **e\_entry** \(or **base + e\_entry**\) of the application to run the application. 2. If the application is statically linked (static linking does not support **-fPIE**), after the stack information is set, the system redirects to the address specified by **e_entry** in the ELF file of the application and runs the application. If the program is dynamically linked, the application ELF file contains the **PT_INTERP** section, which stores the dynamic linker path information (ET_DYN type). The dynamic linker of musl is a part of the **libc-musl.so**. The entry of **libc-musl.so** is the entry of the dynamic linker. The kernel selects the **base** address for mapping via the **mmap** API, sets the stack information, redirects to the **base + e_entry** (entry of the dynamic linker) address, and runs the dynamic linker.
3. The dynamic linker bootstraps and searches for all shared libraries on which the application depends, relocates the imported symbols, and finally redirects to the **e_entry** (or **base + e_entry**) of the application to run the application.
**Figure 2** Program execution process
**Figure 2** Program execution process<a name="fig17879151310447"></a>
![](figures/program-execution-process.png "program-execution-process") ![](figures/program-execution-process.png "program-execution-process")
1. The loader and linker call **mmap** to map the **PT\_LOAD** section. 1. The loader and linker call **mmap** to map the **PT_LOAD** section.
2. The kernel calls **map\_pages** to search for and map the existing PageCache.
3. If there is no physical memory for mapping in the virtual memory region during program execution, the system triggers a page missing interrupt, which allows the ELF file to be read into the physical memory and adds the memory block to the pagecache. 2. The kernel calls **map_pages** to search for and map the existing PageCache.
4. Map the physical memory blocks of the file read to the virtual address region.
5. The program continues to run. 3. If there is no physical memory for mapping in the virtual memory region during program execution, the system triggers a page missing interrupt, which allows the ELF file to be read into the physical memory and adds the memory block to the pagecache.
## Development Guidelines<a name="section133501496612"></a> 4. Map the physical memory blocks of the file read to the virtual address region.
### Available APIs<a name="section874113201669"></a> 5. The program continues to run.
**Table 1** APIs of the kernel loader module
## Development Guidelines
<a name="table1415203765610"></a>
<table><thead align="left"><tr id="row134151837125611"><th class="cellrowborder" valign="top" width="12.85128512851285%" id="mcps1.2.4.1.1"><p id="p16415637105612"><a name="p16415637105612"></a><a name="p16415637105612"></a>Function</p>
</th> ### Available APIs
<th class="cellrowborder" valign="top" width="29.8029802980298%" id="mcps1.2.4.1.2"><p id="p11415163718562"><a name="p11415163718562"></a><a name="p11415163718562"></a>API</p>
</th> **Table 1** API of the kernel loader module
<th class="cellrowborder" valign="top" width="57.34573457345735%" id="mcps1.2.4.1.3"><p id="p1641533755612"><a name="p1641533755612"></a><a name="p1641533755612"></a>Description</p>
</th> | Category | API | Description |
</tr> | ---------- | ---------------- | -------------------------------- |
</thead> | Starting initialization| LOS_DoExecveFile | Executes the specified user program based on the input parameters.|
<tbody><tr id="row0415737175610"><td class="cellrowborder" valign="top" width="12.85128512851285%" headers="mcps1.2.4.1.1 "><p id="p8866127195914"><a name="p8866127195914"></a><a name="p8866127195914"></a>Module initialization</p>
</td>
<td class="cellrowborder" valign="top" width="29.8029802980298%" headers="mcps1.2.4.1.2 "><p id="p58621910185914"><a name="p58621910185914"></a><a name="p58621910185914"></a>LOS_DoExecveFile</p> ### How to Develop
</td>
<td class="cellrowborder" valign="top" width="57.34573457345735%" headers="mcps1.2.4.1.3 "><p id="p48623102592"><a name="p48623102592"></a><a name="p48623102592"></a>Executes the specified user program based on the input parameters.</p>
</td>
</tr>
</tbody>
</table>
### How to Develop<a name="section196712561563"></a>
The kernel cannot directly call the **LOS\_DoExecveFile** API to start a new process. This API is generally called through the **exec\(\)** API to create a new process using the system call mechanism.
The kernel cannot directly call the **LOS_DoExecveFile** API to start a new process. This API is generally called through the **exec()** API to create a new process using the system call mechanism.
# Virtual Dynamic Shared Object # Virtual Dynamic Shared Object
## Basic Concepts<a name="section174577181688"></a>
Different from a common dynamic shared library, which stores its .so files in the file system, the virtual dynamic shared object \(VDSO\) has its .so files stored in the system image. The kernel determines the .so files needed and provides them to the application program. That is why the VDSO is called a virtual dynamic shared library. ## Basic Concepts
The VDSO mechanism allows OpenHarmony user-mode programs to quickly obtain kernel-related data. It can accelerate certain system calls and implement quick read of non-sensitive data \(hardware and software configuration\). Different from a common dynamic shared library, which stores its .so files in the file system, the virtual dynamic shared object (VDSO) has its .so files stored in the system image. The kernel determines the .so files needed and provides them to the application program. That is why the VDSO is called a virtual dynamic shared library.
## Working Principles<a name="section546363114810"></a> The VDSO mechanism allows OpenHarmony user-mode programs to quickly obtain kernel-related data. It can accelerate certain system calls and implement quick read of non-sensitive data (hardware and software configuration).
The VDSO can be regarded as a section of memory \(read-only\) maintained by the kernel and mapped to the address space of the user-mode applications. By linking **vdso.so**, the applications can directly access this mapped memory instead of invoking system calls, accelerating application execution.
## Working Principles
The VDSO can be regarded as a section of memory (read-only) maintained by the kernel and mapped to the address space of the user-mode applications. By linking **vdso.so**, the applications can directly access this mapped memory instead of invoking system calls, accelerating application execution.
VDSO can be divided into: VDSO can be divided into:
- Data page: provides the kernel-time data mapped to the user process. - Data page: provides the kernel-time data mapped to the user process.
- Code page: provides the logic for shielding system calls. - Code page: provides the logic for shielding system calls.
**Figure 1** VDSO system design
**Figure 1** VDSO system design<a name="fig1986131094711"></a>
![](figures/vdso-system-design.jpg "vdso-system-design") ![](figures/vdso-system-design.jpg "vdso-system-design")
The VDSO mechanism involves the following steps: The VDSO mechanism involves the following steps:
...@@ -30,7 +33,7 @@ The VDSO mechanism involves the following steps: ...@@ -30,7 +33,7 @@ The VDSO mechanism involves the following steps:
5. Binds the VDSO symbols when the user program creates dynamic linking. 5. Binds the VDSO symbols when the user program creates dynamic linking.
6. The VDSO code page intercepts specific system calls \(for example, **clock\_gettime\(CLOCK\_REALTIME\_COARSE, &ts\)**\). 6. The VDSO code page intercepts specific system calls (for example, **clock_gettime(CLOCK_REALTIME_COARSE, &amp;ts)**).
7. The VDSO code page allows direct read of the mapped VDSO data page rather than invoking a system call. 7. The VDSO code page allows direct read of the mapped VDSO data page rather than invoking a system call.
...@@ -38,7 +41,10 @@ The VDSO mechanism involves the following steps: ...@@ -38,7 +41,10 @@ The VDSO mechanism involves the following steps:
9. Returns the data obtained from the VDSO data page to the user program. 9. Returns the data obtained from the VDSO data page to the user program.
>![](../public_sys-resources/icon-note.gif) **NOTE:** > **NOTE**<br>
>- The VDSO mechanism supports the **CLOCK\_REALTIME\_COARSE** and **CLOCK\_MONOTONIC\_COARSE** functions of the **clock\_gettime** API in the LibC library. For details about how to use the **clock\_gettime** API, see the POSIX standard. You can call **clock\_gettime\(CLOCK\_REALTIME\_COARSE, &ts\)** or **clock\_gettime\(CLOCK\_MONOTONIC\_COARSE, &ts\)** of the LibC library to use the VDSO. >
>- When VDSO is used, the time precision is the same as that of the tick interrupt of the system. The VDSO mechanism is applicable to the scenario where there is no demand for high time precision and **clock\_gettime** or **gettimeofday** is frequently triggered in a short period of time. The VDSO mechanism is not recommended for the system demanding high time precision. > - The VDSO mechanism supports the **CLOCK_REALTIME_COARSE** and **CLOCK_MONOTONIC_COARSE** functions of the **clock_gettime** API in the LibC library. For details about how to use the **clock_gettime** API, see the POSIX standard.
>
> - You can call **clock_gettime(CLOCK_REALTIME_COARSE, &amp;ts)** or **clock_gettime(CLOCK_MONOTONIC_COARSE, &amp;ts)** of the Libc library to use the VDSO.
>
> - When VDSO is used, the time precision is the same as that of the tick interrupt of the system. The VDSO mechanism is applicable to the scenario where there is no demand for high time precision and **clock_gettime** or **gettimeofday** is frequently triggered in a short period of time. The VDSO mechanism is not recommended for the system demanding high time precision.
# cpup # cpup
## Command Function<a name="section1842161614217"></a> ## Command Function
This command is used to query the CPU usage \(CPU percent\) of the system. This command is used to query the CPU percent (CPUP) of the system.
## Syntax<a name="section5629527427"></a>
cpup \[_mode_\] \[_taskID_\] ## Syntax
## Parameters<a name="section133651361023"></a> cpup [_mode_] [_taskID_]
**Table 1** Parameter description
<a name="table3774mcpsimp"></a> ## Parameters
<table><thead align="left"><tr id="row3780mcpsimp"><th class="cellrowborder" valign="top" width="16%" id="mcps1.2.4.1.1"><p id="p3782mcpsimp"><a name="p3782mcpsimp"></a><a name="p3782mcpsimp"></a>Parameter</p>
</th>
<th class="cellrowborder" valign="top" width="56.99999999999999%" id="mcps1.2.4.1.2"><p id="p3784mcpsimp"><a name="p3784mcpsimp"></a><a name="p3784mcpsimp"></a>Description</p>
</th>
<th class="cellrowborder" valign="top" width="27%" id="mcps1.2.4.1.3"><p id="p3786mcpsimp"><a name="p3786mcpsimp"></a><a name="p3786mcpsimp"></a>Value Range</p>
</th>
</tr>
</thead>
<tbody><tr id="row3787mcpsimp"><td class="cellrowborder" valign="top" width="16%" headers="mcps1.2.4.1.1 "><p id="p3789mcpsimp"><a name="p3789mcpsimp"></a><a name="p3789mcpsimp"></a>mode</p>
</td>
<td class="cellrowborder" valign="top" width="56.99999999999999%" headers="mcps1.2.4.1.2 "><a name="ul1530071303413"></a><a name="ul1530071303413"></a><ul id="ul1530071303413"><li>Displays the CPU usage of the system within the last 10 seconds by default.</li><li><strong id="b13709113084810"><a name="b13709113084810"></a><a name="b13709113084810"></a>0</strong>: displays the CPU usage within the last 10 seconds.</li><li><strong id="b10788133319480"><a name="b10788133319480"></a><a name="b10788133319480"></a>1</strong>: displays the CPU usage within the last 1 second.</li><li>Other value: displays the total CPU usage since the system is started.</li></ul>
</td>
<td class="cellrowborder" valign="top" width="27%" headers="mcps1.2.4.1.3 "><p id="p3794mcpsimp"><a name="p3794mcpsimp"></a><a name="p3794mcpsimp"></a>[0,0xFFFFFFFF]</p>
</td>
</tr>
<tr id="row3795mcpsimp"><td class="cellrowborder" valign="top" width="16%" headers="mcps1.2.4.1.1 "><p id="p3797mcpsimp"><a name="p3797mcpsimp"></a><a name="p3797mcpsimp"></a>taskID</p>
</td>
<td class="cellrowborder" valign="top" width="56.99999999999999%" headers="mcps1.2.4.1.2 "><p id="p3799mcpsimp"><a name="p3799mcpsimp"></a><a name="p3799mcpsimp"></a>Specifies the task ID.</p>
</td>
<td class="cellrowborder" valign="top" width="27%" headers="mcps1.2.4.1.3 "><p id="p3802mcpsimp"><a name="p3802mcpsimp"></a><a name="p3802mcpsimp"></a>[0,0xFFFFFFFF]</p>
</td>
</tr>
</tbody>
</table>
## Usage<a name="section156611948521"></a> **Table 1** Parameter description
- If no parameter is specified, the CPU usage of the system within the last 10 seconds is displayed. | Parameter| Description| Value Range|
- If only **mode** is specified, the CPU usage within the specified period is displayed. | -------- | -------- | -------- |
- If both **mode** and **taskID** are specified, the CPU usage of the specified task within the given period is displayed. | mode | Displays the CPUP of the system within the last 10 seconds by default.<br>- **0**: displays the CPUP within the last 10 seconds.<br>- **1**: displays the CPUP within the last 1 second.<br>- Other numbers: display the total CPUP since the system starts.| [0, 0xFFFFFFFF] |
| taskID | Specifies the task ID.| [0, 0xFFFFFFFF] |
## Example<a name="section68501605319"></a>
Run **cpup 1 5**. ## Usage Guidelines
## Output<a name="section19871522144219"></a> - If no parameter is specified, the CPU usage of the system within the last 10 seconds is displayed.
- If only **mode** is specified, the CPU usage within the specified period is displayed.
- If both **mode** and **taskID** are specified, the CPU usage of the specified task within the given period is displayed.
## Example
Run **cpup 1 5**.
## Output
CPU usage of task 5 in the last one second: CPU usage of task 5 in the last one second:
...@@ -58,4 +44,3 @@ OHOS # cpup 1 5pid 5 ...@@ -58,4 +44,3 @@ OHOS # cpup 1 5pid 5
CpuUsage in 1s: 0.0 CpuUsage in 1s: 0.0
``` ```
# date # date
## Command Function<a name="section56472016338"></a>
## Command Function
This command is used to query the system date and time. This command is used to query the system date and time.
## Syntax<a name="section16635112512316"></a>
## Syntax
- date
- date --help - date
- date +\[_Format_\]
- date -u - date --help
## Parameters<a name="section15896030039"></a> - date +[_Format_]
**Table 1** Parameter description - date -u
<a name="table3825mcpsimp"></a>
<table><thead align="left"><tr id="row3831mcpsimp"><th class="cellrowborder" valign="top" width="21%" id="mcps1.2.4.1.1"><p id="p3833mcpsimp"><a name="p3833mcpsimp"></a><a name="p3833mcpsimp"></a>Parameter</p> ## Parameters
</th>
<th class="cellrowborder" valign="top" width="50%" id="mcps1.2.4.1.2"><p id="p3835mcpsimp"><a name="p3835mcpsimp"></a><a name="p3835mcpsimp"></a>Description</p> **Table 1** Parameter description
</th>
<th class="cellrowborder" valign="top" width="28.999999999999996%" id="mcps1.2.4.1.3"><p id="p3837mcpsimp"><a name="p3837mcpsimp"></a><a name="p3837mcpsimp"></a>Value Range</p> | Parameter | Description | Value Range |
</th> | ------- | ------------------------------ | ---------------------- |
</tr> | --help | Displays help information. | N/A |
</thead> | +Format | Prints the date and time in the specified format.| Placeholders listed in **--help**|
<tbody><tr id="row14667120409"><td class="cellrowborder" valign="top" width="21%" headers="mcps1.2.4.1.1 "><p id="p5628123402"><a name="p5628123402"></a><a name="p5628123402"></a>--help</p> | -u | Displays UTC (not the current time zone). | N/A |
</td>
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.4.1.2 "><p id="p1162201234017"><a name="p1162201234017"></a><a name="p1162201234017"></a>Displays help information.</p>
</td> ## Usage Guidelines
<td class="cellrowborder" valign="top" width="28.999999999999996%" headers="mcps1.2.4.1.3 "><p id="p11621412194011"><a name="p11621412194011"></a><a name="p11621412194011"></a>N/A</p>
</td> - If no parameter is specified, the system date and time in UTC format are displayed by default.
</tr>
<tr id="row1566191264014"><td class="cellrowborder" valign="top" width="21%" headers="mcps1.2.4.1.1 "><p id="p186211254017"><a name="p186211254017"></a><a name="p186211254017"></a>+Format</p> - The **--help**, **+Format**, and **-u** parameters are mutually exclusive.
</td>
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.4.1.2 "><p id="p26216124407"><a name="p26216124407"></a><a name="p26216124407"></a>Prints the date and time in the specified <strong id="b115041849185916"><a name="b115041849185916"></a><a name="b115041849185916"></a>Format</strong>.</p> - Currently, this command cannot be used to set the time or date.
</td>
<td class="cellrowborder" valign="top" width="28.999999999999996%" headers="mcps1.2.4.1.3 "><p id="p46251220409"><a name="p46251220409"></a><a name="p46251220409"></a>Placeholders listed in <strong id="b36588246116"><a name="b36588246116"></a><a name="b36588246116"></a>--help</strong></p> ## Note
</td>
</tr> The shell does not support **date -u**. mksh supports it. To switch to mksh, run **cd bin** and **./mksh**.
<tr id="row1766111218401"><td class="cellrowborder" valign="top" width="21%" headers="mcps1.2.4.1.1 "><p id="p146291274011"><a name="p146291274011"></a><a name="p146291274011"></a>-u</p>
</td> ## Example
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.4.1.2 "><p id="p136291219403"><a name="p136291219403"></a><a name="p136291219403"></a>Displays UTC instead of the current time zone.</p>
</td> Run **date +%Y--%m--%d**.
<td class="cellrowborder" valign="top" width="28.999999999999996%" headers="mcps1.2.4.1.3 "><p id="p5628129407"><a name="p5628129407"></a><a name="p5628129407"></a>N/A</p>
</td>
</tr> ## Output
</tbody>
</table>
## Usage<a name="section116361036636"></a>
- If no parameter is specified, the system UTC date and time are displayed by default.
- The **--help**, **+Format**, and **-u** parameters are mutually exclusive.
- Currently, this command cannot be used to set the time or date.
## Example<a name="section021711411237"></a>
Run **date +%Y--%m--%d**.
## Output<a name="section17950184414312"></a>
System date in the specified format: System date in the specified format:
``` ```
OHOS:/$ date +%Y--%m--%d OHOS:/$ date +%Y--%m--%d
1970--01--01 1970--01--01
``` ```
# dmesg # dmesg
## Command Function<a name="section4643204919313"></a>
## Command Function
This command is used to display system boot and running information. This command is used to display system boot and running information.
## Syntax<a name="section6553153635"></a>
## Syntax
dmesg dmesg
dmesg \[_-c/-C/-D/-E/-L/-U_\] dmesg [_-c/-C/-D/-E/-L/-U_]
dmesg -s \[_size_\] dmesg -s [_size_]
dmesg -l \[_level_\] dmesg -l [_level_]
dmesg \> \[_fileA_\] dmesg &gt; [_fileA_]
## Parameters<a name="section208971157532"></a>
## Parameters
**Table 1** Parameter description
**Table 1** Parameter description
<a name="table3900mcpsimp"></a>
<table><thead align="left"><tr id="row3906mcpsimp"><th class="cellrowborder" valign="top" width="21%" id="mcps1.2.4.1.1"><p id="p3908mcpsimp"><a name="p3908mcpsimp"></a><a name="p3908mcpsimp"></a>Parameter</p> | Parameter | Description | Value Range |
</th> | --------------- | ---------------------------------------- | --------------- |
<th class="cellrowborder" valign="top" width="52%" id="mcps1.2.4.1.2"><p id="p3910mcpsimp"><a name="p3910mcpsimp"></a><a name="p3910mcpsimp"></a>Description</p> | -c | Prints content in the buffer and clears the buffer. | N/A |
</th> | -C | Clears the buffer. | N/A |
<th class="cellrowborder" valign="top" width="27%" id="mcps1.2.4.1.3"><p id="p3912mcpsimp"><a name="p3912mcpsimp"></a><a name="p3912mcpsimp"></a>Value Range</p> | -D/-E | Disables or enables printing to the console. | N/A |
</th> | -L/-U | Disables or enables printing via the serial port. | N/A |
</tr> | -s&nbsp;size | Sets the size of the buffer. size specifies the buffer size to set.| N/A |
</thead> | -l&nbsp;level | Sets the buffering level. | [0, 5] |
<tbody><tr id="row3913mcpsimp"><td class="cellrowborder" valign="top" width="21%" headers="mcps1.2.4.1.1 "><p id="p3915mcpsimp"><a name="p3915mcpsimp"></a><a name="p3915mcpsimp"></a>-c</p> | &gt;&nbsp;fileA | Writes the content in the buffer to a file. | N/A |
</td>
<td class="cellrowborder" valign="top" width="52%" headers="mcps1.2.4.1.2 "><p id="p3917mcpsimp"><a name="p3917mcpsimp"></a><a name="p3917mcpsimp"></a>Prints content in the buffer and clears the buffer.</p>
</td> ## Usage Guidelines
<td class="cellrowborder" valign="top" width="27%" headers="mcps1.2.4.1.3 "><p id="p3919mcpsimp"><a name="p3919mcpsimp"></a><a name="p3919mcpsimp"></a>N/A</p>
</td> - This command can be used only after **LOSCFG_SHELL_DMESG** is enabled. To enable **LOSCFG_SHELL_DMESG**, run the **make menuconfig** command in **kernel/liteos_a**. In the displayed dialog box, locate the **Debug** option and set **Enable Shell dmesg** to **Yes**.
</tr> Debug ---&gt; Enable a Debug Version ---&gt; Enable Shell ---&gt; Enable Shell dmesg
<tr id="row3920mcpsimp"><td class="cellrowborder" valign="top" width="21%" headers="mcps1.2.4.1.1 "><p id="p3922mcpsimp"><a name="p3922mcpsimp"></a><a name="p3922mcpsimp"></a>-C</p>
</td> - If no parameter is specified, all content in the buffer is printed.
<td class="cellrowborder" valign="top" width="52%" headers="mcps1.2.4.1.2 "><p id="p3924mcpsimp"><a name="p3924mcpsimp"></a><a name="p3924mcpsimp"></a>Clears the buffer.</p>
</td> - The parameters followed by hyphens (-) are mutually exclusive.
<td class="cellrowborder" valign="top" width="27%" headers="mcps1.2.4.1.3 "><p id="p3926mcpsimp"><a name="p3926mcpsimp"></a><a name="p3926mcpsimp"></a>N/A</p> 1. Before writing content to a file, ensure that the file system has been mounted.
</td> 2. Disabling the serial port printing will adversely affect shell. You are advised to set up a connection using Telnet before disabling the serial port.
</tr>
<tr id="row3927mcpsimp"><td class="cellrowborder" valign="top" width="21%" headers="mcps1.2.4.1.1 "><p id="p3929mcpsimp"><a name="p3929mcpsimp"></a><a name="p3929mcpsimp"></a>-D/-E</p>
</td> ## Example
<td class="cellrowborder" valign="top" width="52%" headers="mcps1.2.4.1.2 "><p id="p3931mcpsimp"><a name="p3931mcpsimp"></a><a name="p3931mcpsimp"></a>Disables or enables printing to the console.</p>
</td> Run **dmesg> dmesg.log**.
<td class="cellrowborder" valign="top" width="27%" headers="mcps1.2.4.1.3 "><p id="p3933mcpsimp"><a name="p3933mcpsimp"></a><a name="p3933mcpsimp"></a>N/A</p>
</td>
</tr> ## Output
<tr id="row3934mcpsimp"><td class="cellrowborder" valign="top" width="21%" headers="mcps1.2.4.1.1 "><p id="p3936mcpsimp"><a name="p3936mcpsimp"></a><a name="p3936mcpsimp"></a>-L/-U</p>
</td> Write the content in the buffer to the **dmesg.log** file.
<td class="cellrowborder" valign="top" width="52%" headers="mcps1.2.4.1.2 "><p id="p3938mcpsimp"><a name="p3938mcpsimp"></a><a name="p3938mcpsimp"></a>Disables or enables printing via the serial port.</p>
</td>
<td class="cellrowborder" valign="top" width="27%" headers="mcps1.2.4.1.3 "><p id="p3940mcpsimp"><a name="p3940mcpsimp"></a><a name="p3940mcpsimp"></a>N/A</p>
</td>
</tr>
<tr id="row3941mcpsimp"><td class="cellrowborder" valign="top" width="21%" headers="mcps1.2.4.1.1 "><p id="p3943mcpsimp"><a name="p3943mcpsimp"></a><a name="p3943mcpsimp"></a>-s size</p>
</td>
<td class="cellrowborder" valign="top" width="52%" headers="mcps1.2.4.1.2 "><p id="p3945mcpsimp"><a name="p3945mcpsimp"></a><a name="p3945mcpsimp"></a>Sets the size of the buffer.</p>
</td>
<td class="cellrowborder" valign="top" width="27%" headers="mcps1.2.4.1.3 "><p id="p3947mcpsimp"><a name="p3947mcpsimp"></a><a name="p3947mcpsimp"></a>N/A</p>
</td>
</tr>
<tr id="row3948mcpsimp"><td class="cellrowborder" valign="top" width="21%" headers="mcps1.2.4.1.1 "><p id="p3950mcpsimp"><a name="p3950mcpsimp"></a><a name="p3950mcpsimp"></a>-l level</p>
</td>
<td class="cellrowborder" valign="top" width="52%" headers="mcps1.2.4.1.2 "><p id="p3952mcpsimp"><a name="p3952mcpsimp"></a><a name="p3952mcpsimp"></a>Sets the buffering level.</p>
</td>
<td class="cellrowborder" valign="top" width="27%" headers="mcps1.2.4.1.3 "><p id="p3954mcpsimp"><a name="p3954mcpsimp"></a><a name="p3954mcpsimp"></a>0 - 5</p>
</td>
</tr>
<tr id="row3955mcpsimp"><td class="cellrowborder" valign="top" width="21%" headers="mcps1.2.4.1.1 "><p id="p3957mcpsimp"><a name="p3957mcpsimp"></a><a name="p3957mcpsimp"></a>&gt; fileA</p>
</td>
<td class="cellrowborder" valign="top" width="52%" headers="mcps1.2.4.1.2 "><p id="p717417317512"><a name="p717417317512"></a><a name="p717417317512"></a>Writes the content in the buffer to the specified file.</p>
</td>
<td class="cellrowborder" valign="top" width="27%" headers="mcps1.2.4.1.3 "><p id="p3961mcpsimp"><a name="p3961mcpsimp"></a><a name="p3961mcpsimp"></a>N/A</p>
</td>
</tr>
</tbody>
</table>
## Usage<a name="section213115219413"></a>
- This command depends on **LOSCFG\_SHELL\_DMESG**. Before using this command, select **Enable Shell dmesg** on **menuconfig**.
Debug ---\> Enable a Debug Version ---\> Enable Shell ---\> Enable Shell dmesg
- If no parameter is specified, all content in the buffer is printed.
- The parameters followed by hyphens \(-\) are mutually exclusive.
1. Before writing content to a file, ensure that the file system has been mounted.
2. Disabling the serial port printing will adversely affect shell. You are advised to set up a connection using Telnet before disabling the serial port.
## Example<a name="section13736564418"></a>
Run **dmesg\> dmesg.log**.
## Output<a name="section194005101413"></a>
Writing the content in the buffer to the **dmesg.log** file:
``` ```
OHOS # dmesg > dmesg.log OHOS # dmesg > dmesg.log
Dmesg write log to dmesg.log success Dmesg write log to dmesg.log success
``` ```
# exec # exec
## Command Function<a name="section4643204919313"></a> ## Command Function
This command is a built-in shell command used to execute user-mode programs. This command is a built-in shell command used to execute basic user-mode programs.
## Syntax<a name="section6553153635"></a>
exec <_executable-file_\> ## Syntax
## Parameters<a name="section208971157532"></a> exec &lt;*executable-file*&gt;
**Table 1** Parameter description
<a name="table3900mcpsimp"></a> ## Parameters
<table><thead align="left"><tr id="row3906mcpsimp"><th class="cellrowborder" valign="top" width="21%" id="mcps1.2.4.1.1"><p id="p3908mcpsimp"><a name="p3908mcpsimp"></a><a name="p3908mcpsimp"></a>Parameter</p>
</th>
<th class="cellrowborder" valign="top" width="52%" id="mcps1.2.4.1.2"><p id="p3910mcpsimp"><a name="p3910mcpsimp"></a><a name="p3910mcpsimp"></a>Description</p>
</th>
<th class="cellrowborder" valign="top" width="27%" id="mcps1.2.4.1.3"><p id="p3912mcpsimp"><a name="p3912mcpsimp"></a><a name="p3912mcpsimp"></a>Value Range</p>
</th>
</tr>
</thead>
<tbody><tr id="row3913mcpsimp"><td class="cellrowborder" valign="top" width="21%" headers="mcps1.2.4.1.1 "><p id="p3915mcpsimp"><a name="p3915mcpsimp"></a><a name="p3915mcpsimp"></a>executable-file</p>
</td>
<td class="cellrowborder" valign="top" width="52%" headers="mcps1.2.4.1.2 "><p id="p3917mcpsimp"><a name="p3917mcpsimp"></a><a name="p3917mcpsimp"></a>Indicates a valid executable file.</p>
</td>
<td class="cellrowborder" valign="top" width="27%" headers="mcps1.2.4.1.3 "><p id="p3919mcpsimp"><a name="p3919mcpsimp"></a><a name="p3919mcpsimp"></a>N/A</p>
</td>
</tr>
</tbody>
</table>
## Usage<a name="section213115219413"></a> **Table 1** Parameter description
| Parameter | Description |
| --------------- | ------------------ |
| executable-file | Specifies a valid executable file.|
## Usage Guidelines
Currently, this command supports only valid binary programs. The programs are successfully executed and then run in the background by default. However, the programs share the same device with the shell. As a result, the output of the programs and the shell may be interlaced. Currently, this command supports only valid binary programs. The programs are successfully executed and then run in the background by default. However, the programs share the same device with the shell. As a result, the output of the programs and the shell may be interlaced.
## Example<a name="section13736564418"></a>
Example: ## Example
Run **exec helloworld**. Run **exec helloworld**.
## Output
## Output<a name="section194005101413"></a>
``` ```
OHOS # exec helloworld OHOS # exec helloworld
OHOS # hello world! OHOS # hello world!
``` ```
>![](../public_sys-resources/icon-note.gif) **NOTE:** > **NOTE**<br>
>After the executable file is executed, the prompt **OHOS \#** is printed first. The shell **exec** command is executed in the background, causing the prompt to be printed in advance. > After the executable file is executed, the prompt **OHOS #** is printed first. The shell **exec** command is executed in the background, causing the prompt to be printed in advance.
# free # free
## Command Function<a name="section175151514841"></a>
## Command Function
This command is used to display the memory usage in the system. This command is used to display the memory usage in the system.
## Syntax<a name="section8488721749"></a>
## Syntax
free \[_-b | -k | -m | -g | -t_\]
free [_-b | -k | -m | -g | -t_]
## Parameters<a name="section27272181949"></a>
**Table 1** Parameter description ## Parameters
<a name="table110mcpsimp"></a> **Table 1** Parameter description
<table><thead align="left"><tr id="row116mcpsimp"><th class="cellrowborder" valign="top" width="21%" id="mcps1.2.4.1.1"><p id="p118mcpsimp"><a name="p118mcpsimp"></a><a name="p118mcpsimp"></a>Parameter</p>
</th> | Parameter| Description |
<th class="cellrowborder" valign="top" width="52%" id="mcps1.2.4.1.2"><p id="p120mcpsimp"><a name="p120mcpsimp"></a><a name="p120mcpsimp"></a>Description</p> | -------- | -------- |
</th> | No parameter| Displays the memory usage in bytes.|
<th class="cellrowborder" valign="top" width="27%" id="mcps1.2.4.1.3"><p id="p122mcpsimp"><a name="p122mcpsimp"></a><a name="p122mcpsimp"></a>Value Range</p> | --help/-h | Displays the parameters supported by the **free** command.|
</th> | -b | Displays the memory usage in bytes.|
</tr> | -k | Display the memory waterline in KiB.|
</thead> | -m | Display the memory waterline in MiB.|
<tbody><tr id="row1250317052114"><td class="cellrowborder" valign="top" width="21%" headers="mcps1.2.4.1.1 "><p id="p44861016218"><a name="p44861016218"></a><a name="p44861016218"></a>No parameter</p> | -g | Displays the memory usage in GiB.|
</td> | -t | Displays the memory usage in TiB.|
<td class="cellrowborder" valign="top" width="52%" headers="mcps1.2.4.1.2 "><p id="p64861302212"><a name="p64861302212"></a><a name="p64861302212"></a>Displays the memory usage in bytes.</p>
</td>
<td class="cellrowborder" valign="top" width="27%" headers="mcps1.2.4.1.3 "><p id="p1248619010215"><a name="p1248619010215"></a><a name="p1248619010215"></a>N/A</p> ## Usage Guidelines
</td>
</tr> None.
<tr id="row2503160182110"><td class="cellrowborder" valign="top" width="21%" headers="mcps1.2.4.1.1 "><p id="p1948618017215"><a name="p1948618017215"></a><a name="p1948618017215"></a>--help/-h</p>
</td>
<td class="cellrowborder" valign="top" width="52%" headers="mcps1.2.4.1.2 "><p id="p1648617012214"><a name="p1648617012214"></a><a name="p1648617012214"></a>Displays the parameters supported by the <strong id="b1247315411335"><a name="b1247315411335"></a><a name="b1247315411335"></a>free</strong> command.</p> ## Example
</td>
<td class="cellrowborder" valign="top" width="27%" headers="mcps1.2.4.1.3 "><p id="p11486205219"><a name="p11486205219"></a><a name="p11486205219"></a>N/A</p> Run **free**, **free -k**, and **free -m**, respectively.
</td>
</tr>
<tr id="row150318082111"><td class="cellrowborder" valign="top" width="21%" headers="mcps1.2.4.1.1 "><p id="p164861709216"><a name="p164861709216"></a><a name="p164861709216"></a>-b</p> ## Output
</td>
<td class="cellrowborder" valign="top" width="52%" headers="mcps1.2.4.1.2 "><p id="p54864013214"><a name="p54864013214"></a><a name="p54864013214"></a>Displays the memory usage in bytes.</p>
</td>
<td class="cellrowborder" valign="top" width="27%" headers="mcps1.2.4.1.3 "><p id="p124862014218"><a name="p124862014218"></a><a name="p124862014218"></a>N/A</p>
</td>
</tr>
<tr id="row750330162116"><td class="cellrowborder" valign="top" width="21%" headers="mcps1.2.4.1.1 "><p id="p1848615072110"><a name="p1848615072110"></a><a name="p1848615072110"></a>-k</p>
</td>
<td class="cellrowborder" valign="top" width="52%" headers="mcps1.2.4.1.2 "><p id="p1648670192120"><a name="p1648670192120"></a><a name="p1648670192120"></a>Displays the memory usage in KiB.</p>
</td>
<td class="cellrowborder" valign="top" width="27%" headers="mcps1.2.4.1.3 "><p id="p124861301216"><a name="p124861301216"></a><a name="p124861301216"></a>N/A</p>
</td>
</tr>
<tr id="row105021082114"><td class="cellrowborder" valign="top" width="21%" headers="mcps1.2.4.1.1 "><p id="p20486100122114"><a name="p20486100122114"></a><a name="p20486100122114"></a>-m</p>
</td>
<td class="cellrowborder" valign="top" width="52%" headers="mcps1.2.4.1.2 "><p id="p134869022114"><a name="p134869022114"></a><a name="p134869022114"></a>Displays the memory usage in MiB.</p>
</td>
<td class="cellrowborder" valign="top" width="27%" headers="mcps1.2.4.1.3 "><p id="p124868015219"><a name="p124868015219"></a><a name="p124868015219"></a>N/A</p>
</td>
</tr>
<tr id="row95021909216"><td class="cellrowborder" valign="top" width="21%" headers="mcps1.2.4.1.1 "><p id="p114861408218"><a name="p114861408218"></a><a name="p114861408218"></a>-g</p>
</td>
<td class="cellrowborder" valign="top" width="52%" headers="mcps1.2.4.1.2 "><p id="p348680122118"><a name="p348680122118"></a><a name="p348680122118"></a>Displays the memory usage in GiB.</p>
</td>
<td class="cellrowborder" valign="top" width="27%" headers="mcps1.2.4.1.3 "><p id="p64866011217"><a name="p64866011217"></a><a name="p64866011217"></a>N/A</p>
</td>
</tr>
<tr id="row125026092116"><td class="cellrowborder" valign="top" width="21%" headers="mcps1.2.4.1.1 "><p id="p19486101218"><a name="p19486101218"></a><a name="p19486101218"></a>-t</p>
</td>
<td class="cellrowborder" valign="top" width="52%" headers="mcps1.2.4.1.2 "><p id="p18486140132118"><a name="p18486140132118"></a><a name="p18486140132118"></a>Displays the memory usage in TiB.</p>
</td>
<td class="cellrowborder" valign="top" width="27%" headers="mcps1.2.4.1.3 "><p id="p048620142111"><a name="p048620142111"></a><a name="p048620142111"></a>N/A</p>
</td>
</tr>
</tbody>
</table>
## Usage<a name="section148661259410"></a>
None
## Example<a name="section68081530242"></a>
Run **free**, **free -k**, and **free -m**, respectively.
## Output<a name="section171235517543"></a>
``` ```
OHOS:/$ free OHOS:/$ free
...@@ -101,40 +57,13 @@ Mem: 2 2 0 0 0 ...@@ -101,40 +57,13 @@ Mem: 2 2 0 0 0
Swap: 0 0 0 Swap: 0 0 0
``` ```
**Table 2** Output **Table 2** Output description
<a name="table633mcpsimp"></a> | Parameter| Description|
<table><thead align="left"><tr id="row638mcpsimp"><th class="cellrowborder" valign="top" width="50%" id="mcps1.2.3.1.1"><p id="p640mcpsimp"><a name="p640mcpsimp"></a><a name="p640mcpsimp"></a>Parameter</p> | -------- | -------- |
</th> | total | Total size of the dynamic memory pool.|
<th class="cellrowborder" valign="top" width="50%" id="mcps1.2.3.1.2"><p id="p642mcpsimp"><a name="p642mcpsimp"></a><a name="p642mcpsimp"></a>Description</p> | used | Size of the used memory.|
</th> | free | Size of the unallocated memory.|
</tr> | shared | Size of the shared memory.|
</thead> | buffers | Size of the buffer.|
<tbody><tr id="row3746215112211"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p57373157224"><a name="p57373157224"></a><a name="p57373157224"></a>total</p>
</td>
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p1737315202218"><a name="p1737315202218"></a><a name="p1737315202218"></a>Total size of the dynamic memory pool</p>
</td>
</tr>
<tr id="row16746161582219"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p1173731512215"><a name="p1173731512215"></a><a name="p1173731512215"></a>used</p>
</td>
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p197376156222"><a name="p197376156222"></a><a name="p197376156222"></a>Size of the used memory</p>
</td>
</tr>
<tr id="row174661542216"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p8737141519228"><a name="p8737141519228"></a><a name="p8737141519228"></a>free</p>
</td>
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p97371915142218"><a name="p97371915142218"></a><a name="p97371915142218"></a>Size of the unallocated memory</p>
</td>
</tr>
<tr id="row1274520152227"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p1073821542210"><a name="p1073821542210"></a><a name="p1073821542210"></a>shared</p>
</td>
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p1773801514223"><a name="p1773801514223"></a><a name="p1773801514223"></a>Size of the shared memory</p>
</td>
</tr>
<tr id="row07452153229"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p773811512229"><a name="p773811512229"></a><a name="p773811512229"></a>buffers</p>
</td>
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p157381015192216"><a name="p157381015192216"></a><a name="p157381015192216"></a>Size of the buffer</p>
</td>
</tr>
</tbody>
</table>
# help # help
## Command Function<a name="section991211345413"></a>
## Command Function
This command is used to display all commands in the OS and some Toybox commands. This command is used to display all commands in the OS and some Toybox commands.
## Syntax<a name="section19103204016410"></a>
## Syntax
help help
## Parameters<a name="section1533416233432"></a>
None ## Parameters
None.
## Usage<a name="section4156445417"></a> ## Usage Guidelines
You can run **help** to display all commands in the current OS. You can run **help** to display all commands in the current OS.
## Example<a name="section12776124712417"></a>
Run **help**. ## Example
## Output<a name="section092662412544"></a> Run **help**.
## Output
All commands in the system: All commands in the system:
``` ```
After shell prompt "OHOS # ": After shell prompt "OHOS # ":
Use `<cmd> [args ...]` to run built-in shell commands listed above. Use `<cmd> [args ...]` to run built-in shell commands listed above.
Use `exec <cmd> [args ...]` or `./<cmd> [args ...]` to run external commands. Use `exec <cmd> [args ...]` or `./<cmd> [args ...]` to run external commands.
OHOS:/$ help OHOS:/$ help
*******************shell commands:************************* ***shell commands:*
arp cat cat_logmpp cd chgrp chmod arp cat cat_logmpp cd chgrp chmod
chown cp cpup date dhclient dmesg chown cp cpup date dhclient dmesg
dns format free help hi3881 hwi dns format free help hi3881 hwi
...@@ -44,11 +51,10 @@ watch writeproc ...@@ -44,11 +51,10 @@ watch writeproc
After shell prompt "OHOS # ": After shell prompt "OHOS # ":
Use `<cmd> [args ...]` to run built-in shell commands listed above. Use `<cmd> [args ...]` to run built-in shell commands listed above.
Use `exec <cmd> [args ...]` or `./<cmd> [args ...]` to run external commands. Use `exec <cmd> [args ...]` or `./<cmd> [args ...]` to run external commands.
*******************toybox commands:************************ ***toybox commands:
chgrp chmod chown cp date du free help ifconfig kill ls mkdir mount chgrp chmod chown cp date du free help ifconfig kill ls mkdir mount
mv ping ps reboot rm rmdir top touch umount uname mv ping ps reboot rm rmdir top touch umount uname
Use `toybox help [command]` to show usage information for a specific command. Use `toybox help [command]` to show usage information for a specific command.
Use `shell` to enter interactive legacy shell. Use `shell` to enter interactive legacy shell.
Use `alias` to display command aliases. Use `alias` to display command aliases.
``` ```
# hwi # hwi
## Command Function<a name="section445335110416"></a>
## Command Function
This command is used to query information about interrupts. This command is used to query information about interrupts.
## Syntax<a name="section1795712553416"></a>
hwi ## Syntax
## Parameters<a name="section92544592410"></a> hwi
None
## Usage<a name="section104151141252"></a>
- Run **hwi** to display the interrupt IDs, count of interrupts, and registered interrupt names of the system.
- If **LOSCFG\_CPUP\_INCLUDE\_IRQ** is enabled, the interrupt handling time \(ATime\), CPU usage, and type of each interrupt are also displayed.
## Example<a name="section11545171957"></a>
Run **hwi**.
## Output<a name="section075617368542"></a>
- Interrupt information \(**LOSCFG\_CPUP\_INCLUDE\_IRQ** disabled\):
```
OHOS # hwi
InterruptNo Count Name
0: 0:
1: 1025641:
2: 0:
29: 824049:
37: 0: rtc_alarm
38: 24: uart_pl011
48: 3: GPIO
59: 0:
62: 530: MMC_IRQ
63: 70: MMC_IRQ
64: 280: ETH
67: 58: tde
68: 0: JPGE_0
69: 0: IVE
70: 0: VGS
72: 0: VEDU_0
73: 0: nnie0
74: 0: nnie_gdc0
75: 0: VPSS
76: 0: VI_PROC0
77: 0: JPEGD_0
83: 49455: HIFB_SOFT_INT
87: 0: AIO interrupt
88: 0: VI_CAP0
89: 0: MIPI_RX
90: 49455: VO int
91: 49456: HIFB Int
96: 17601: MMC_IRQ
100: 0: SPI_HI35XX
101: 0: SPI_HI35XX
102: 0: SPI_HI35XX
```
- Interrupt information \(**LOSCFG\_CPUP\_INCLUDE\_IRQ** enabled\):
```
OHOS # hwi
InterruptNo Count ATime(us) CPUUSE CPUUSE10s CPUUSE1s Mode Name
0: 0 0 0.0 0.0 0.0 normal
1: 937031 0 0.1 0.1 0.1 normal
2: 0 0 0.0 0.0 0.0 normal
29: 726166 5 0.54 0.57 0.59 normal
37: 0 0 0.0 0.0 0.0 normal rtc_alarm
38: 17 5 0.0 0.0 0.0 normal uart_pl011
48: 3 4 0.0 0.0 0.0 normal GPIO
59: 0 0 0.0 0.0 0.0 normal
62: 531 1 0.0 0.0 0.0 normal MMC_IRQ
63: 69 1 0.0 0.0 0.0 normal MMC_IRQ
64: 292 2 0.0 0.0 0.0 normal ETH
67: 54 76 0.0 0.0 0.0 shared tde
68: 0 0 0.0 0.0 0.0 shared JPGE_0
69: 0 0 0.0 0.0 0.0 shared IVE
70: 0 0 0.0 0.0 0.0 shared VGS
72: 0 0 0.0 0.0 0.0 shared VEDU_0
73: 0 0 0.0 0.0 0.0 shared nnie0
74: 0 0 0.0 0.0 0.0 shared nnie_gdc0
75: 0 0 0.0 0.0 0.0 shared VPSS
76: 0 0 0.0 0.0 0.0 shared VI_PROC0
77: 0 0 0.0 0.0 0.0 shared JPEGD_0
83: 45529 8 0.5 0.5 0.5 shared HIFB_SOFT_INT
87: 0 0 0.0 0.0 0.0 shared AIO interrupt
88: 0 0 0.0 0.0 0.0 shared VI_CAP0
89: 0 0 0.0 0.0 0.0 shared MIPI_RX
90: 45534 11 0.6 0.7 0.7 shared VO int
91: 45533 2 0.1 0.1 0.1 shared HIFB Int
96: 17383 2 0.0 0.0 0.0 normal MMC_IRQ
100: 0 0 0.0 0.0 0.0 normal SPI_HI35XX
101: 0 0 0.0 0.0 0.0 normal SPI_HI35XX
102: 0 0 0.0 0.0 0.0 normal SPI_HI35XX
```
**Table 1** Output
<a name="table809mcpsimp"></a>
<table><thead align="left"><tr id="row814mcpsimp"><th class="cellrowborder" valign="top" width="50%" id="mcps1.2.3.1.1"><p id="p816mcpsimp"><a name="p816mcpsimp"></a><a name="p816mcpsimp"></a>Parameter</p>
</th>
<th class="cellrowborder" valign="top" width="50%" id="mcps1.2.3.1.2"><p id="p818mcpsimp"><a name="p818mcpsimp"></a><a name="p818mcpsimp"></a>Description</p>
</th>
</tr>
</thead>
<tbody><tr id="row20360171311398"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p172391401402"><a name="p172391401402"></a><a name="p172391401402"></a>InterruptNo</p>
</td>
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p42381940174013"><a name="p42381940174013"></a><a name="p42381940174013"></a>Interrupt ID</p>
</td>
</tr>
<tr id="row262535153913"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p1823824014402"><a name="p1823824014402"></a><a name="p1823824014402"></a>Count</p>
</td>
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p14237040144018"><a name="p14237040144018"></a><a name="p14237040144018"></a>Number of interrupts</p>
</td>
</tr>
<tr id="row9683953153916"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p6236124084018"><a name="p6236124084018"></a><a name="p6236124084018"></a>Name</p>
</td>
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p18235164014401"><a name="p18235164014401"></a><a name="p18235164014401"></a>Registered interrupt name</p>
</td>
</tr>
<tr id="row85721136402"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p1123434017409"><a name="p1123434017409"></a><a name="p1123434017409"></a>ATime</p>
</td>
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p2023424094014"><a name="p2023424094014"></a><a name="p2023424094014"></a>Interrupt handling time</p>
</td>
</tr>
<tr id="row19180126151415"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p6233040164020"><a name="p6233040164020"></a><a name="p6233040164020"></a>CPUUSE</p>
</td>
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p5232840104015"><a name="p5232840104015"></a><a name="p5232840104015"></a>CPU usage</p>
</td>
</tr>
<tr id="row511517331702"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p14231040164014"><a name="p14231040164014"></a><a name="p14231040164014"></a>CPUUSE10s</p>
</td>
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p1323011409405"><a name="p1323011409405"></a><a name="p1323011409405"></a>CPU usage within the last 10 seconds</p>
</td>
</tr>
<tr id="row1868124415413"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p9681144414114"><a name="p9681144414114"></a><a name="p9681144414114"></a>CPUUSE1s</p>
</td>
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p76814443417"><a name="p76814443417"></a><a name="p76814443417"></a>CPU usage within the last 1 second</p>
</td>
</tr>
<tr id="row7681164454112"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p1968124412411"><a name="p1968124412411"></a><a name="p1968124412411"></a>mode</p>
</td>
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p268134415419"><a name="p268134415419"></a><a name="p268134415419"></a>Interrupt type, which can be any of the following:</p>
<a name="ul682912412419"></a><a name="ul682912412419"></a><ul id="ul682912412419"><li><strong id="b35357873733839"><a name="b35357873733839"></a><a name="b35357873733839"></a>normal</strong>: non-shared interrupt.</li><li><strong id="b209107492433839"><a name="b209107492433839"></a><a name="b209107492433839"></a>shared</strong>: shared interrupt.</li></ul>
</td>
</tr>
</tbody>
</table>
## Parameters
None.
## Usage Guidelines
- Run **hwi** to display the interrupt IDs, count of interrupts, and registered interrupt names of the system.
- If **LOSCFG_CPUP_INCLUDE_IRQ** is enabled, the interrupt handling time (ATime), CPU usage, and type of each interrupt are also displayed.
## Example
Run **hwi**.
## Output
- Interrupt information (**LOSCFG_CPUP_INCLUDE_IRQ** disabled):
```
OHOS # hwi
InterruptNo Count Name
0: 0:
1: 1025641:
2: 0:
29: 824049:
37: 0: rtc_alarm
38: 24: uart_pl011
48: 3: GPIO
59: 0:
62: 530: MMC_IRQ
63: 70: MMC_IRQ
64: 280: ETH
67: 58: tde
68: 0: JPGE_0
69: 0: IVE
70: 0: VGS
72: 0: VEDU_0
73: 0: nnie0
74: 0: nnie_gdc0
75: 0: VPSS
76: 0: VI_PROC0
77: 0: JPEGD_0
83: 49455: HIFB_SOFT_INT
87: 0: AIO interrupt
88: 0: VI_CAP0
89: 0: MIPI_RX
90: 49455: VO int
91: 49456: HIFB Int
96: 17601: MMC_IRQ
100: 0: SPI_HI35XX
101: 0: SPI_HI35XX
102: 0: SPI_HI35XX
```
- Interrupt information (**LOSCFG_CPUP_INCLUDE_IRQ** enabled):
```
OHOS # hwi
InterruptNo Count ATime(us) CPUUSE CPUUSE10s CPUUSE1s Mode Name
0: 0 0 0.0 0.0 0.0 normal
1: 937031 0 0.1 0.1 0.1 normal
2: 0 0 0.0 0.0 0.0 normal
29: 726166 5 0.54 0.57 0.59 normal
37: 0 0 0.0 0.0 0.0 normal rtc_alarm
38: 17 5 0.0 0.0 0.0 normal uart_pl011
48: 3 4 0.0 0.0 0.0 normal GPIO
59: 0 0 0.0 0.0 0.0 normal
62: 531 1 0.0 0.0 0.0 normal MMC_IRQ
63: 69 1 0.0 0.0 0.0 normal MMC_IRQ
64: 292 2 0.0 0.0 0.0 normal ETH
67: 54 76 0.0 0.0 0.0 shared tde
68: 0 0 0.0 0.0 0.0 shared JPGE_0
69: 0 0 0.0 0.0 0.0 shared IVE
70: 0 0 0.0 0.0 0.0 shared VGS
72: 0 0 0.0 0.0 0.0 shared VEDU_0
73: 0 0 0.0 0.0 0.0 shared nnie0
74: 0 0 0.0 0.0 0.0 shared nnie_gdc0
75: 0 0 0.0 0.0 0.0 shared VPSS
76: 0 0 0.0 0.0 0.0 shared VI_PROC0
77: 0 0 0.0 0.0 0.0 shared JPEGD_0
83: 45529 8 0.5 0.5 0.5 shared HIFB_SOFT_INT
87: 0 0 0.0 0.0 0.0 shared AIO interrupt
88: 0 0 0.0 0.0 0.0 shared VI_CAP0
89: 0 0 0.0 0.0 0.0 shared MIPI_RX
90: 45534 11 0.6 0.7 0.7 shared VO int
91: 45533 2 0.1 0.1 0.1 shared HIFB Int
96: 17383 2 0.0 0.0 0.0 normal MMC_IRQ
100: 0 0 0.0 0.0 0.0 normal SPI_HI35XX
101: 0 0 0.0 0.0 0.0 normal SPI_HI35XX
102: 0 0 0.0 0.0 0.0 normal SPI_HI35XX
```
**Table 1** Output description
| Parameter| Description|
| -------- | -------- |
| InterruptNo | Interrupt number.|
| Count | Number of interrupts.|
| Name | Registered interrupt name.|
| ATime | Interrupt handling time.|
| CPUUSE | CPU usage.|
| CPUUSE10s | CPU usage in the last 10s.|
| CPUUSE1s | CPU usage in the last 1s.|
| mode | Interrupt type, which can be any of the following:<br>- **normal**: non-shared interrupt.<br>- **shared**: shared interrupt.|
# kill # kill
## Command Function<a name="section366714216619"></a>
## Command Function
This command is used to send a signal to a specified process.
This command is used to send a signal to a process to terminate the abnormal application.
## Syntax<a name="section8833164614615"></a>
kill \[-l \[_signo_\] | _-s signo_ | _-signo_\] _pid..._ ## Syntax
## Parameters<a name="section12809111019453"></a> kill [-l [_signo_] | _-s signo_ | _-signo_] *pid...*
**Table 1** Parameter description
## Parameters
<a name="table438mcpsimp"></a>
<table><thead align="left"><tr id="row444mcpsimp"><th class="cellrowborder" valign="top" width="21%" id="mcps1.2.4.1.1"><p id="p446mcpsimp"><a name="p446mcpsimp"></a><a name="p446mcpsimp"></a>Parameter</p> **Table 1** Parameter description
</th>
<th class="cellrowborder" valign="top" width="51.92%" id="mcps1.2.4.1.2"><p id="p448mcpsimp"><a name="p448mcpsimp"></a><a name="p448mcpsimp"></a>Description</p> | Parameter | Description | Value Range |
</th> | ------ | -------------------------- | ----------- |
<th class="cellrowborder" valign="top" width="27.08%" id="mcps1.2.4.1.3"><p id="p450mcpsimp"><a name="p450mcpsimp"></a><a name="p450mcpsimp"></a>Value Range</p> | --help | Displays the parameters supported by the **kill** command.| N/A |
</th> | -l | Lists the names and numbers of signals. | N/A |
</tr> | -s | Sends a signal. | N/A |
</thead> | signo | Specifies the signal number. | [1, 30] |
<tbody><tr id="row6412714183316"><td class="cellrowborder" valign="top" width="21%" headers="mcps1.2.4.1.1 "><p id="p940219144332"><a name="p940219144332"></a><a name="p940219144332"></a>--help</p> | pid | Specifies the process ID. | [1, MAX_INT] |
</td>
<td class="cellrowborder" valign="top" width="51.92%" headers="mcps1.2.4.1.2 "><p id="p3402191493310"><a name="p3402191493310"></a><a name="p3402191493310"></a>Displays the parameters supported by the <strong id="b277973411569"><a name="b277973411569"></a><a name="b277973411569"></a>kill</strong> command.</p> > **NOTICE**<br>
</td> > The value range of **signo** is [0, 64]. The recommended value range is [1, 30], and other values in the value range are reserved.
<td class="cellrowborder" valign="top" width="27.08%" headers="mcps1.2.4.1.3 "><p id="p4402161493316"><a name="p4402161493316"></a><a name="p4402161493316"></a>N/A</p>
</td>
</tr> ## Usage Guidelines
<tr id="row114122143330"><td class="cellrowborder" valign="top" width="21%" headers="mcps1.2.4.1.1 "><p id="p0402314103315"><a name="p0402314103315"></a><a name="p0402314103315"></a>-l</p>
</td> - The **signo** and **pid** parameters are mandatory.
<td class="cellrowborder" valign="top" width="51.92%" headers="mcps1.2.4.1.2 "><p id="p640281413313"><a name="p640281413313"></a><a name="p640281413313"></a>Lists the names and numbers of signals.</p>
</td> - The **pid** value range varies depending on the system configuration. For example, if the maximum **pid** value supported by the system is **256**, this value range is [1, 256].
<td class="cellrowborder" valign="top" width="27.08%" headers="mcps1.2.4.1.3 "><p id="p19402191416337"><a name="p19402191416337"></a><a name="p19402191416337"></a>N/A</p>
</td> ## Note
</tr>
<tr id="row12412131493314"><td class="cellrowborder" valign="top" width="21%" headers="mcps1.2.4.1.1 "><p id="p1240220141335"><a name="p1240220141335"></a><a name="p1240220141335"></a>-s</p> The **kill** command is not supported by the shell. mksh supports it. To switch to mksh, run **cd bin;** and **./mksh**.
</td>
<td class="cellrowborder" valign="top" width="51.92%" headers="mcps1.2.4.1.2 "><p id="p8402131411331"><a name="p8402131411331"></a><a name="p8402131411331"></a>Sends signals</p> ## Example
</td>
<td class="cellrowborder" valign="top" width="27.08%" headers="mcps1.2.4.1.3 "><p id="p140211415339"><a name="p140211415339"></a><a name="p140211415339"></a>N/A</p> - Query the process list before killing process 42.
</td>
</tr> ```
<tr id="row1441281443320"><td class="cellrowborder" valign="top" width="21%" headers="mcps1.2.4.1.1 "><p id="p14402171410332"><a name="p14402171410332"></a><a name="p14402171410332"></a>signo</p> OHOS:/$ ps
</td> allCpu(%): 4.67 sys, 195.33 idle
<td class="cellrowborder" valign="top" width="51.92%" headers="mcps1.2.4.1.2 "><p id="p114023144336"><a name="p114023144336"></a><a name="p114023144336"></a>Specifies the signal number.</p> PID PPID PGID UID Status VirtualMem ShareMem PhysicalMem CPUUSE10s PName
</td> 1 -1 1 0 Pending 0x33b000 0xbb000 0x4db02 0.0 init
<td class="cellrowborder" valign="top" width="27.08%" headers="mcps1.2.4.1.3 "><p id="p240212145333"><a name="p240212145333"></a><a name="p240212145333"></a>[1,30]</p> 2 -1 2 0 Pending 0xdabc08 0 0xdabc08 1.14 KProcess
</td> 3 1 3 7 Pending 0x72e000 0x1a3000 0x1d24c2 0.0 foundation
</tr> 4 1 4 8 Pending 0x362000 0xbb000 0x5c6ff 0.0 bundle_daemon
<tr id="row13411714143310"><td class="cellrowborder" valign="top" width="21%" headers="mcps1.2.4.1.1 "><p id="p5402131463314"><a name="p5402131463314"></a><a name="p5402131463314"></a>pid</p> 5 1 5 1 Pending 0xdfa000 0x2e7000 0x1484f0 0.0 appspawn
</td> 6 1 6 0 Pending 0x688000 0x137000 0x11bca0 0.0 media_server
<td class="cellrowborder" valign="top" width="51.92%" headers="mcps1.2.4.1.2 "><p id="p7402014113310"><a name="p7402014113310"></a><a name="p7402014113310"></a>Specifies the process ID.</p> 7 1 7 0 Pending 0x9d2000 0x103000 0xa1cdf 0.88 wms_server
</td> 8 1 8 2 Pending 0x1f5000 0x48000 0x47dc2 0.2 mksh
<td class="cellrowborder" valign="top" width="27.08%" headers="mcps1.2.4.1.3 "><p id="p24021514183317"><a name="p24021514183317"></a><a name="p24021514183317"></a>[1,MAX_INT]</p> 10 5 5 101 Pending 0x11ec000 0x2f9000 0x206047 0.93 com.example.launcher
</td> 12 1 12 0 Pending 0x4d4000 0x112000 0xe0882 0.0 deviceauth_service
</tr> 13 1 13 0 Pending 0x34f000 0xbd000 0x51799 0.0 sensor_service
</tbody> 14 1 14 2 Pending 0x34e000 0xb3000 0x52184 0.0 ai_server
</table> 15 1 15 0 Pending 0x61f000 0x13b000 0x168071 0.45 softbus_server
42 8 42 2 Pending 0x1c1000 0x3a000 0x1106a 0.9 test_demo
>![](../public_sys-resources/icon-notice.gif) **NOTICE:** 43 8 43 2 Running 0x1d7000 0x3a000 0x1e577 0.0 toybox
>The value range of **signo** is \[0, 64\]. The recommended value range is \[1, 30\], and other values in the value range are reserved. ```
## Usage<a name="section15935131220717"></a> - Send signal 9 (the default action of **SIGKILL** is to immediately terminate the process) to process 42 test_demo (a user-mode process). Then, check the current process list. The commands **kill -s 9 42** and **kill -9 42** have the same effect.
- The **signo** and **pid** parameters are mandatory. ```
- The **pid** value range varies depending on the system configuration. For example, if the maximum **pid** value supported by the system is **256**, this value range is \[1-256\]. OHOS:/$ kill -s 9 42
OHOS:/$
## Example<a name="section79281818476"></a> [1] + Killed ./nfs/test_demo
OHOS:/$ ps
- Query the process list before killing process 42. allCpu(%): 4.73 sys, 195.27 idle
PID PPID PGID UID Status VirtualMem ShareMem PhysicalMem CPUUSE10s PName
``` 1 -1 1 0 Pending 0x33b000 0xbb000 0x4e01c 0.0 init
OHOS:/$ ps 2 -1 2 0 Pending 0xda5fa4 0 0xda5fa4 1.14 KProcess
allCpu(%): 4.67 sys, 195.33 idle 3 1 3 7 Pending 0x72e000 0x1a3000 0x1d29dc 0.0 foundation
PID PPID PGID UID Status VirtualMem ShareMem PhysicalMem CPUUSE10s PName 4 1 4 8 Pending 0x362000 0xbb000 0x5cc19 0.0 bundle_daemon
1 -1 1 0 Pending 0x33b000 0xbb000 0x4db02 0.0 init 5 1 5 1 Pending 0xdfa000 0x2e7000 0x148a0a 0.0 appspawn
2 -1 2 0 Pending 0xdabc08 0 0xdabc08 1.14 KProcess 6 1 6 0 Pending 0x688000 0x137000 0x11c1ba 0.0 media_server
3 1 3 7 Pending 0x72e000 0x1a3000 0x1d24c2 0.0 foundation 7 1 7 0 Pending 0x9d2000 0x103000 0xa21f9 0.89 wms_server
4 1 4 8 Pending 0x362000 0xbb000 0x5c6ff 0.0 bundle_daemon 8 1 8 2 Pending 0x1f5000 0x48000 0x482dc 0.2 mksh
5 1 5 1 Pending 0xdfa000 0x2e7000 0x1484f0 0.0 appspawn 10 5 5 101 Pending 0x11ec000 0x2f9000 0x206561 0.93 com.example.launcher
6 1 6 0 Pending 0x688000 0x137000 0x11bca0 0.0 media_server 12 1 12 0 Pending 0x4d4000 0x112000 0xe0d9c 0.0 deviceauth_service
7 1 7 0 Pending 0x9d2000 0x103000 0xa1cdf 0.88 wms_server 13 1 13 0 Pending 0x34f000 0xbd000 0x51cb3 0.0 sensor_service
8 1 8 2 Pending 0x1f5000 0x48000 0x47dc2 0.2 mksh 14 1 14 2 Pending 0x34e000 0xb3000 0x5269e 0.0 ai_server
12 1 12 0 Pending 0x4d4000 0x112000 0xe0882 0.0 deviceauth_service 15 1 15 0 Pending 0x61f000 0x13b000 0x16858b 0.51 softbus_server
13 1 13 0 Pending 0x34f000 0xbd000 0x51799 0.0 sensor_service 45 8 45 2 Running 0x1d7000 0x3a000 0x1e9f5 0.0 toybox
14 1 14 2 Pending 0x34e000 0xb3000 0x52184 0.0 ai_server ```
15 1 15 0 Pending 0x61f000 0x13b000 0x168071 0.45 softbus_server
42 8 42 2 Pending 0x1c1000 0x3a000 0x1106a 0.9 test_demo - Run the **kill -100 31** command.
43 8 43 2 Running 0x1d7000 0x3a000 0x1e577 0.0 toybox
```
## Output
- Send signal 9 \(the default action of **SIGKILL** is to immediately terminate the process\) to process 42 test\_demo \(a user-mode process\). Then, check the current process list. The commands **kill -s 9 42** and **kill -9 42** have the same effect.
The command output is as follows:
```
OHOS:/$ kill -s 9 42 Example 1: The signal is successfully sent to process 42.
OHOS:/$
[1] + Killed ./nfs/test_demo
OHOS:/$ ps
allCpu(%): 4.73 sys, 195.27 idle
PID PPID PGID UID Status VirtualMem ShareMem PhysicalMem CPUUSE10s PName
1 -1 1 0 Pending 0x33b000 0xbb000 0x4e01c 0.0 init
2 -1 2 0 Pending 0xda5fa4 0 0xda5fa4 1.14 KProcess
3 1 3 7 Pending 0x72e000 0x1a3000 0x1d29dc 0.0 foundation
4 1 4 8 Pending 0x362000 0xbb000 0x5cc19 0.0 bundle_daemon
5 1 5 1 Pending 0xdfa000 0x2e7000 0x148a0a 0.0 appspawn
6 1 6 0 Pending 0x688000 0x137000 0x11c1ba 0.0 media_server
7 1 7 0 Pending 0x9d2000 0x103000 0xa21f9 0.89 wms_server
8 1 8 2 Pending 0x1f5000 0x48000 0x482dc 0.2 mksh
12 1 12 0 Pending 0x4d4000 0x112000 0xe0d9c 0.0 deviceauth_service
13 1 13 0 Pending 0x34f000 0xbd000 0x51cb3 0.0 sensor_service
14 1 14 2 Pending 0x34e000 0xb3000 0x5269e 0.0 ai_server
15 1 15 0 Pending 0x61f000 0x13b000 0x16858b 0.51 softbus_server
45 8 45 2 Running 0x1d7000 0x3a000 0x1e9f5 0.0 toybox
```
- Run the **kill -100 31** command.
## Output<a name="section12742311179"></a>
**Example 1**: The signal is successfully sent to process 42.
``` ```
OHOS:/$ kill -s 9 42 OHOS:/$ kill -s 9 42
...@@ -131,10 +107,10 @@ Process 42 is killed. ...@@ -131,10 +107,10 @@ Process 42 is killed.
**Example 2**: The signal fails to be sent to process 31. **Example 2**: The signal fails to be sent to process 31.
``` ```
OHOS:/$ kill -100 31 OHOS:/$ kill -100 31
kill: Unknown signal '(null)' kill: Unknown signal '(null)'
``` ```
**Unknown signal '\(null\)'** is displayed because the **signo** value **100** exceeds the value range \[0, 64\]. **Unknown signal '(null)'** is displayed because the **signo** value **100** exceeds the value range [0, 64].
# log # log
## Command Function<a name="section128219131856"></a>
## Command Function
This command is used to set and query log configuration. This command is used to set and query log configuration.
## Syntax<a name="section3894181710519"></a>
log level \[_levelNum_\] ## Syntax
log level [_levelNum_]
## Parameters<a name="section7693122310515"></a> ## Parameters
**Table 1** Parameter description **Table 1** Parameter description
<a name="table237mcpsimp"></a> | Parameter| Description| Value Range|
<table><thead align="left"><tr id="row243mcpsimp"><th class="cellrowborder" valign="top" width="21%" id="mcps1.2.4.1.1"><p id="p245mcpsimp"><a name="p245mcpsimp"></a><a name="p245mcpsimp"></a><strong id="b3369319192013"><a name="b3369319192013"></a><a name="b3369319192013"></a>Parameter</strong></p> | -------- | -------- | -------- |
</th> | levelNum | Specifies the level of logs to print.| [0, 5] |
<th class="cellrowborder" valign="top" width="52%" id="mcps1.2.4.1.2"><p id="p247mcpsimp"><a name="p247mcpsimp"></a><a name="p247mcpsimp"></a><strong id="b12646112413211"><a name="b12646112413211"></a><a name="b12646112413211"></a>Description</strong></p>
</th>
<th class="cellrowborder" valign="top" width="27%" id="mcps1.2.4.1.3"><p id="p249mcpsimp"><a name="p249mcpsimp"></a><a name="p249mcpsimp"></a><strong id="b13881153318285"><a name="b13881153318285"></a><a name="b13881153318285"></a>Value Range</strong></p>
</th>
</tr>
</thead>
<tbody><tr id="row250mcpsimp"><td class="cellrowborder" valign="top" width="21%" headers="mcps1.2.4.1.1 "><p id="p252mcpsimp"><a name="p252mcpsimp"></a><a name="p252mcpsimp"></a>levelNum</p>
</td>
<td class="cellrowborder" valign="top" width="52%" headers="mcps1.2.4.1.2 "><p id="p254mcpsimp"><a name="p254mcpsimp"></a><a name="p254mcpsimp"></a>Specifies the level of logs to print.</p>
</td>
<td class="cellrowborder" valign="top" width="27%" headers="mcps1.2.4.1.3 "><p id="p2270121719813"><a name="p2270121719813"></a><a name="p2270121719813"></a>[0,5]</p>
</td>
</tr>
</tbody>
</table>
## Usage<a name="section1982111281512"></a>
- This command depends on **LOSCFG\_SHELL\_LK**. Before using this command, select **Enable Shell lk** on **menuconfig**. ## Usage Guidelines
**Debug** ---\> **Enable a Debug Version** ---\> **Enable Shell** ---\> **Enable Shell lK** - This command can be used only after **LOSCFG_SHELL_LK** is enabled. Before using this command, set **Enable Shell lk** to **Yes** on **menuconfig**.
**Debug** ---&gt; **Enable a Debug Version** ---&gt; **Enable Shell** ---&gt; **Enable Shell lK**
- The **log level** command is used to set the log level, which can be any of the following: - The **log level** command sets the log level, which can be any of the following:
TRACE_EMG = 0,
TRACE\_EMG = 0, TRACE_COMMON = 1,
TRACE\_COMMON = 1, TRACE_ERROR = 2,
TRACE\_ERROR = 2, TRACE_WARN = 3,
TRACE\_WARN = 3, TRACE_INFO = 4,
TRACE\_INFO = 4, TRACE_DEBUG = 5
TRACE\_DEBUG = 5 If the log level specified is not within the value range, a message will be displayed.
If the log level specified is not within the value range, a message will be displayed. - If **[levelNum]** is not specified, this command displays the current log level and how to use it.
- If **\[levelNum\]** is not specified, this command queries the current log level. The usage method is also displayed. - If the log level is set to **4** or **5** in the source code of an OpenHarmony small system, a large number of logs will be printed.
- If the log level is set to **4** or **5** in the source code of the open-source small system, a large number of logs will be printed.
## Example<a name="section176301333259"></a>
Run **log level 3**. ## Example
## Output<a name="section14354765415"></a> Run **log level 3**.
## Output
The log print level is set to WARN.
Setting the log print level to WARN:
``` ```
OHOS # log level 3 OHOS # log level 3
Set current log level WARN Set current log level WARN
``` ```
# memcheck # memcheck
## Command Function<a name="section191633812516"></a>
## Command Function
This command is used to check whether the dynamically allocated memory block is complete and whether nodes in the memory pool are damaged due to out-of-bounds memory access. This command is used to check whether the dynamically allocated memory block is complete and whether nodes in the memory pool are damaged due to out-of-bounds memory access.
## Syntax<a name="section428816435510"></a>
## Syntax
memcheck memcheck
## Parameters<a name="section1939943304411"></a>
None ## Parameters
None.
## Usage Guidelines
## Usage<a name="section228914491951"></a> - If all nodes in the memory pool are complete, "system memcheck over, all passed!" is displayed.
- If all nodes in the memory pool are complete, "system memcheck over, all passed!" is displayed. - If a node in the memory pool is incomplete, information about the memory block of the corrupted node is displayed.
- If a node in the memory pool is incomplete, information about the memory block of the corrupted node is displayed.
## Example<a name="section17373205314515"></a>
Run **memcheck**. ## Example
## Output<a name="section13406205385413"></a> Run **memcheck**.
Example 1: All nodes in the memory pool are complete. Run **memcheck**, and memory overwriting occurs.
## Output
Example 1: No error is detected.
``` ```
OHOS # memcheck OHOS # memcheck
system memcheck over, all passed! system memcheck over, all passed!
``` ```
Example 2: Out-of-bounds memory access is detected. Example 2: Memory overwriting is detected.
``` ```
[L0S DLnkCheckMenl 349, memory check [L0S DLnkCheckMenl 349, memory check
...@@ -43,7 +52,7 @@ puмExcBuffAddr pc = 0x803ad7a4 ...@@ -43,7 +52,7 @@ puмExcBuffAddr pc = 0x803ad7a4
puwExcBuffAddr lr = 0x803ad7a4 puwExcBuffAddr lr = 0x803ad7a4
puwExcBuffAddr sp = 0х80cb7de0 puwExcBuffAddr sp = 0х80cb7de0
puwExcBuffAddr fp = 0x80cb7dec puwExcBuffAddr fp = 0x80cb7dec
*******backtrace begin******* ***backtrace begin***
traceback 0 -- lr = 0х8037cb84 traceback 0 -- lr = 0х8037cb84
traceback 0 -- fp = 0х80cb7e1c traceback 0 -- fp = 0х80cb7e1c
traceback 1 -- lr = 0х8037033c traceback 1 -- lr = 0х8037033c
...@@ -55,4 +64,3 @@ traceback 3 -- fp = 0х80cb7ea4 ...@@ -55,4 +64,3 @@ traceback 3 -- fp = 0х80cb7ea4
traceback 4 -- lr = 0x803ad9e8 traceback 4 -- lr = 0x803ad9e8
traceback 4 -- fp = 9x11111111 traceback 4 -- fp = 9x11111111
``` ```
# oom # oom
## Command Function<a name="section366714216619"></a>
## Command Function
This command is used to query and set the low memory threshold and the PageCache reclaim threshold. This command is used to query and set the low memory threshold and the PageCache reclaim threshold.
## Syntax<a name="section8833164614615"></a>
## Syntax
oom oom
oom -i \[_interval_\] oom -i [_interval_]
oom -m \[_mem byte_\] oom -m [_mem byte_]
oom -r \[_mem byte_\] oom -r [_mem byte_]
oom -h | --help oom -h | --help
## Parameters<a name="section12809111019453"></a>
## Parameters
**Table 1** Parameter description
**Table 1** Parameter description
<a name="table438mcpsimp"></a>
<table><thead align="left"><tr id="row444mcpsimp"><th class="cellrowborder" valign="top" width="21%" id="mcps1.2.4.1.1"><p id="p446mcpsimp"><a name="p446mcpsimp"></a><a name="p446mcpsimp"></a>Parameter</p> | Parameter | Description | Value Range |
</th> | ----------------------- | ------------------------------- | ------------------------------------------------------------ |
<th class="cellrowborder" valign="top" width="52%" id="mcps1.2.4.1.2"><p id="p448mcpsimp"><a name="p448mcpsimp"></a><a name="p448mcpsimp"></a>Description</p> | -i [interval] | Sets the interval (in ms) for checking the Out Of Memory (OOM) thread task.| [100, 10000] |
</th> | -m [mem byte] | Sets the low memory threshold (in MB). | 0 to 1<br>The value **0** means not to perform the low memory threshold check. |
<th class="cellrowborder" valign="top" width="27%" id="mcps1.2.4.1.3"><p id="p450mcpsimp"><a name="p450mcpsimp"></a><a name="p450mcpsimp"></a>Value Range</p> | -r [mem byte] | Sets the PageCache reclaim threshold. | Low memory threshold to the maximum available memory of the system<br>Generally, the size of a PageCache is 4 KB. Sometimes, it is 16 KB to 64 KB. |
</th> | -h \| --help | Displays help information. | N/A |
</tr>
</thead>
<tbody><tr id="row451mcpsimp"><td class="cellrowborder" valign="top" width="21%" headers="mcps1.2.4.1.1 "><p id="p5196112612119"><a name="p5196112612119"></a><a name="p5196112612119"></a>-i [interval]</p> ## Usage Guidelines
</td>
<td class="cellrowborder" valign="top" width="52%" headers="mcps1.2.4.1.2 "><p id="p1149945111817"><a name="p1149945111817"></a><a name="p1149945111817"></a>Sets the interval (in ms) for checking the Out Of Memory (OOM) thread task.</p> If no parameter is specified, this command displays the current OOM configuration.
</td>
<td class="cellrowborder" valign="top" width="27%" headers="mcps1.2.4.1.3 "><p id="p749810571812"><a name="p749810571812"></a><a name="p749810571812"></a>100 to 10000</p> > **NOTE**<br>
</td> > If the system memory is insufficient, the system displays a message indicating the insufficiency.
</tr>
<tr id="row18583553793"><td class="cellrowborder" valign="top" width="21%" headers="mcps1.2.4.1.1 "><p id="p95841853292"><a name="p95841853292"></a><a name="p95841853292"></a>-m [mem byte]</p>
</td> ## Example
<td class="cellrowborder" valign="top" width="52%" headers="mcps1.2.4.1.2 "><p id="p2058485315912"><a name="p2058485315912"></a><a name="p2058485315912"></a>Sets the low memory threshold (in MB).</p>
</td>
<td class="cellrowborder" valign="top" width="27%" headers="mcps1.2.4.1.3 "><p id="p1584105318917"><a name="p1584105318917"></a><a name="p1584105318917"></a>0 (disables the low memory check) to 1</p>
</td>
</tr>
<tr id="row17926124131218"><td class="cellrowborder" valign="top" width="21%" headers="mcps1.2.4.1.1 "><p id="p49266245128"><a name="p49266245128"></a><a name="p49266245128"></a>-r [mem byte]</p>
</td>
<td class="cellrowborder" valign="top" width="52%" headers="mcps1.2.4.1.2 "><p id="p159263241121"><a name="p159263241121"></a><a name="p159263241121"></a>Sets the PageCache reclaim threshold.</p>
</td>
<td class="cellrowborder" valign="top" width="27%" headers="mcps1.2.4.1.3 "><p id="p692642412121"><a name="p692642412121"></a><a name="p692642412121"></a>Ranging from the low memory threshold to the maximum available system memory</p>
</td>
</tr>
<tr id="row1176110379557"><td class="cellrowborder" valign="top" width="21%" headers="mcps1.2.4.1.1 "><p id="p4762113745519"><a name="p4762113745519"></a><a name="p4762113745519"></a>-h | --help</p>
</td>
<td class="cellrowborder" valign="top" width="52%" headers="mcps1.2.4.1.2 "><p id="p9762113775517"><a name="p9762113775517"></a><a name="p9762113775517"></a>Displays help information.</p>
</td>
<td class="cellrowborder" valign="top" width="27%" headers="mcps1.2.4.1.3 "><p id="p7762133765511"><a name="p7762133765511"></a><a name="p7762133765511"></a>N/A</p>
</td>
</tr>
</tbody>
</table>
## Usage<a name="section15935131220717"></a>
If no parameter is specified, this command displays the current OOM configuration.
>![](../public_sys-resources/icon-note.gif) **NOTE:**
>If the system memory is insufficient, the system displays a message indicating the insufficiency.
## Example<a name="section387104374416"></a>
Run the following commands: Run the following commands:
- oom - oom
- oom -i 100 - oom -i 100
## Output<a name="section12742311179"></a> ## Output
Example 1: The OOM configuration is displayed by default.
Example 1: displaying OOM configuration
``` ```
OHOS:/$ oom OHOS:/$ oom
...@@ -88,6 +62,7 @@ OHOS:/$ oom ...@@ -88,6 +62,7 @@ OHOS:/$ oom
Information displayed when the system memory is insufficient: Information displayed when the system memory is insufficient:
``` ```
T:20 Enter:IT MEM 00M 001 T:20 Enter:IT MEM 00M 001
[oom] OS is in low memory state [oom] OS is in low memory state
...@@ -124,7 +99,7 @@ R10 = 0xa0a0a0a ...@@ -124,7 +99,7 @@ R10 = 0xa0a0a0a
R11 = 0x20e20c8c R11 = 0x20e20c8c
R12 = 0х0 R12 = 0х0
CPSR = 0х80000010 CPSR = 0х80000010
*******backtrace beain******* ***backtrace beain***
traceback 0 -- lr = 0x9242e1c fp = 0х20e20cc4 lr in /usr/bin/testsuits apr 0x4be1c traceback 0 -- lr = 0x9242e1c fp = 0х20e20cc4 lr in /usr/bin/testsuits apr 0x4be1c
traceback 1 -- 1r = 0х92430cc fp = 0x20e20cdc lr in /usr/bin/testsuits app --> 0x4c0cc traceback 1 -- 1r = 0х92430cc fp = 0x20e20cdc lr in /usr/bin/testsuits app --> 0x4c0cc
traceback 2 -- 1r = 0x9396ab0 fp = 0x20e20cec lr in /usr/bin/testsuits app -> 0х19fab0 traceback 2 -- 1r = 0x9396ab0 fp = 0x20e20cec lr in /usr/bin/testsuits app -> 0х19fab0
...@@ -133,49 +108,23 @@ traceback 4 -- lr = 0x92427d4 fp = 0x20e20d44 lr in /usr/bin/testsuits app --> 0 ...@@ -133,49 +108,23 @@ traceback 4 -- lr = 0x92427d4 fp = 0x20e20d44 lr in /usr/bin/testsuits app --> 0
traceback 5 -- 1r = 0x20c4df50 fp = 0хb0b0b0b 1r in /1ib/libc.so - -> 0x62f50 traceback 5 -- 1r = 0x20c4df50 fp = 0хb0b0b0b 1r in /1ib/libc.so - -> 0x62f50
``` ```
Example 2: setting the OOM check interval to 100 ms
Example 2: The OOM check interval is set to 100 ms.
``` ```
OHOS:/$ oom -i 100 OHOS:/$ oom -i 100
[oom] set oom check interval (100)ms successful [oom] set oom check interval (100)ms successful
``` ```
**Table 2** Output
<a name="table487mcpsimp"></a>
<table><thead align="left"><tr id="row492mcpsimp"><th class="cellrowborder" valign="top" width="50%" id="mcps1.2.3.1.1"><p id="p494mcpsimp"><a name="p494mcpsimp"></a><a name="p494mcpsimp"></a>Output</p>
</th>
<th class="cellrowborder" valign="top" width="50%" id="mcps1.2.3.1.2"><p id="p496mcpsimp"><a name="p496mcpsimp"></a><a name="p496mcpsimp"></a>Description</p>
</th>
</tr>
</thead>
<tbody><tr id="row502mcpsimp"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p583513382179"><a name="p583513382179"></a><a name="p583513382179"></a>[oom] OS is in low memory state</p>
<p id="p636114453553"><a name="p636114453553"></a><a name="p636114453553"></a>total physical memory: 0x1bcf000(byte), used: 0x1b50000(byte), free: 0x7f000(byte), low memory threshold: 0x80000(byte)</p>
</td>
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p19833143819174"><a name="p19833143819174"></a><a name="p19833143819174"></a>The operating system has low memory.</p>
<p id="p83883291587"><a name="p83883291587"></a><a name="p83883291587"></a>The available physical memory in the operating system is <strong id="b15343050123397"><a name="b15343050123397"></a><a name="b15343050123397"></a>0x1bcf000</strong> bytes, <strong id="b18697901323397"><a name="b18697901323397"></a><a name="b18697901323397"></a>0x1b50000</strong> bytes have been used, and <strong id="b3252944373397"><a name="b3252944373397"></a><a name="b3252944373397"></a>0x7f000</strong> bytes are available. The current low memory threshold is <strong id="b13811086363397"><a name="b13811086363397"></a><a name="b13811086363397"></a>0x80000</strong> bytes.</p>
</td>
</tr>
<tr id="row1990234224612"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p3902144294612"><a name="p3902144294612"></a><a name="p3902144294612"></a>[oom] candidate victim process init pid: 1, actual phy mem byte: 82602</p>
</td>
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p13903144284610"><a name="p13903144284610"></a><a name="p13903144284610"></a>Memory usage of each process. The physical memory occupied by the <strong id="b143686319910"><a name="b143686319910"></a><a name="b143686319910"></a>init</strong> process is 82602 bytes.</p>
</td>
</tr>
<tr id="row520212272335"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p172038278339"><a name="p172038278339"></a><a name="p172038278339"></a>[oom] candidate victim process UserProcess12 pid: 12, actual phy mem byte: 25951558</p>
</td>
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p112034276331"><a name="p112034276331"></a><a name="p112034276331"></a>The actual memory used by the <strong id="b16405477923397"><a name="b16405477923397"></a><a name="b16405477923397"></a>UserProcess12</strong> process is <strong id="b10952024983397"><a name="b10952024983397"></a><a name="b10952024983397"></a>25951558</strong> bytes.</p>
</td>
</tr>
<tr id="row3273195033416"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p184989213512"><a name="p184989213512"></a><a name="p184989213512"></a>[oom] max phy mem used process UserProcess12 pid: 12, actual phy mem: 25951558</p>
</td>
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p112741750143417"><a name="p112741750143417"></a><a name="p112741750143417"></a>The process that uses the most memory currently is <strong id="b17770979863397"><a name="b17770979863397"></a><a name="b17770979863397"></a>UserProcess12</strong>.</p>
</td>
</tr>
<tr id="row16442089365"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p045148153618"><a name="p045148153618"></a><a name="p045148153618"></a>excFrom: User!</p>
</td>
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p6452818367"><a name="p6452818367"></a><a name="p6452818367"></a>The system memory is low, and the <strong id="b4088490143397"><a name="b4088490143397"></a><a name="b4088490143397"></a>UserProcess12</strong> process fails to apply for memory and exits.</p>
</td>
</tr>
</tbody>
</table>
**Table 2** Output description
| Parameter | Description |
| ------------------------------------------------------------ | ------------------------------------------------------------ |
| [oom] OS is in low memory state<br>total physical memory: 0x1bcf000(byte), used: 0x1b50000(byte), free: 0x7f000(byte), low memory threshold: 0x80000(byte) | The OS has low memory.<br>The total physical memory is **0x1bcf000** bytes, **0x1b50000** bytes are used, and **0x7f000** bytes are left.<br/>The current lower memory threshold is **0x80000** bytes. |
| [oom] candidate victim process init pid: 1, actual phy mem byte: 82602 | The memory occupied by the **init** process is 82602 bytes. |
| [oom] candidate victim process UserProcess12 pid: 12, actual phy mem byte: 25951558 | The memory used by the **UserProcess12** process is **25951558** bytes. |
| [oom] max phy mem used process UserProcess12 pid: 12, actual phy mem: 25951558 | The process that uses the most memory currently is **UserProcess12**. |
| excFrom: User! | The system memory is low, and the **UserProcess12** process fails to apply for memory and exits. |
# pmm # pmm
## Command Function<a name="section445335110416"></a>
## Command Function
This command is used to check the usage of the physical pages of the system memory and the page cache. This command is used to check the usage of the physical pages of the system memory and the page cache.
## Syntax<a name="section1795712553416"></a>
## Syntax
pmm pmm
## Parameters<a name="section92544592410"></a>
None ## Parameters
None.
## Usage Guidelines
This command is available only in the **Debug** version.
## Usage<a name="section104151141252"></a>
This command is available only in the **Debug** version. ## Example
## Example<a name="section11545171957"></a> Run **pmm**.
Run **pmm**.
## Output<a name="section075617368542"></a> ## Output
Usage of physical pages: Usage of physical pages:
...@@ -49,62 +55,17 @@ Vnode number = 67 ...@@ -49,62 +55,17 @@ Vnode number = 67
Vnode memory size = 10720(B) Vnode memory size = 10720(B)
``` ```
**Table 1** Output **Table 1** Output description
<a name="table5579102611579"></a> | Parameter| Description|
<table><thead align="left"><tr id="row12579162613572"><th class="cellrowborder" valign="top" width="50%" id="mcps1.2.3.1.1"><p id="p18579122619578"><a name="p18579122619578"></a><a name="p18579122619578"></a>Parameter</p> | -------- | -------- |
</th> | phys_seg | Address of the physical page control block.|
<th class="cellrowborder" valign="top" width="50%" id="mcps1.2.3.1.2"><p id="p11579182635718"><a name="p11579182635718"></a><a name="p11579182635718"></a>Description</p> | base | First physical page address, that is, start address of the physical page memory.|
</th> | size | Size of the physical page memory.|
</tr> | free_pages | Number of free physical pages.|
</thead> | active&nbsp;anon | Number of active anonymous pages in the page cache.|
<tbody><tr id="row1457942675720"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p2058042605713"><a name="p2058042605713"></a><a name="p2058042605713"></a>phys_seg</p> | inactive&nbsp;anon | Number of inactive anonymous pages in the page cache.|
</td> | active&nbsp;file | Number of active file pages in the page cache.|
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p1058062614579"><a name="p1058062614579"></a><a name="p1058062614579"></a>Address of the physical page control block</p> | inactive&nbsp;file | Number of inactive file pages in the page cache.|
</td> | pmm&nbsp;pages | **total** indicates the total number of physical pages. <br/>**used** indicates the number of used physical pages. <br/>**free** indicates the number of idle physical pages. |
</tr>
<tr id="row14580192616575"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p858062615712"><a name="p858062615712"></a><a name="p858062615712"></a>base</p>
</td>
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p1858082617577"><a name="p1858082617577"></a><a name="p1858082617577"></a>First physical page address, that is, start address of the physical page memory</p>
</td>
</tr>
<tr id="row17580826115719"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p5580226155713"><a name="p5580226155713"></a><a name="p5580226155713"></a>size</p>
</td>
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p85808262572"><a name="p85808262572"></a><a name="p85808262572"></a>Size of the physical page memory</p>
</td>
</tr>
<tr id="row161931831175912"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p201931631185913"><a name="p201931631185913"></a><a name="p201931631185913"></a>free_pages</p>
</td>
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p1919383125911"><a name="p1919383125911"></a><a name="p1919383125911"></a>Number of free physical pages</p>
</td>
</tr>
<tr id="row1397105119596"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p0397951175918"><a name="p0397951175918"></a><a name="p0397951175918"></a>active anon</p>
</td>
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p1139715117599"><a name="p1139715117599"></a><a name="p1139715117599"></a>Number of active anonymous pages in the page cache</p>
</td>
</tr>
<tr id="row16409173520010"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p941012351409"><a name="p941012351409"></a><a name="p941012351409"></a>inactive anon</p>
</td>
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p1341012355019"><a name="p1341012355019"></a><a name="p1341012355019"></a>Number of inactive anonymous pages in the page cache</p>
</td>
</tr>
<tr id="row467016386014"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p10670103818015"><a name="p10670103818015"></a><a name="p10670103818015"></a>active file</p>
</td>
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p1267012382019"><a name="p1267012382019"></a><a name="p1267012382019"></a>Number of active file pages in the page cache</p>
</td>
</tr>
<tr id="row18966641507"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p5966741706"><a name="p5966741706"></a><a name="p5966741706"></a>inactive file</p>
</td>
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p17966174115018"><a name="p17966174115018"></a><a name="p17966174115018"></a>Number of inactive file pages in the page cache</p>
</td>
</tr>
<tr id="row13183445101"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p318394514018"><a name="p318394514018"></a><a name="p318394514018"></a>pmm pages</p>
</td>
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p1616375952018"><a name="p1616375952018"></a><a name="p1616375952018"></a><strong id="b161631659162014"><a name="b161631659162014"></a><a name="b161631659162014"></a>total</strong>: total number of physical pages.</p>
<p id="p2029802122113"><a name="p2029802122113"></a><a name="p2029802122113"></a><strong id="b429822122113"><a name="b429822122113"></a><a name="b429822122113"></a>used</strong>: number of used physical pages.</p>
<p id="p1218312452014"><a name="p1218312452014"></a><a name="p1218312452014"></a><strong id="b132798755433826"><a name="b132798755433826"></a><a name="b132798755433826"></a>free</strong>: number of free physical pages.</p>
</td>
</tr>
</tbody>
</table>
# reboot # reboot
## Command Function<a name="section20643141481314"></a>
## Command Function
This command is used to restart a device. This command is used to restart a device.
## Syntax<a name="section1075441721316"></a>
## Syntax
reboot reboot
## Parameters<a name="section1472810220135"></a>
None ## Parameters
None.
## Usage Guidelines
## Usage<a name="section186772414131"></a> After the **reboot** command is executed, the device restarts immediately.
After the **reboot** command is executed, the device restarts immediately.
## Example<a name="section4764192791314"></a> ## Example
reboot reboot
## Output<a name="section5791253155517"></a>
None ## Output
None.
# reset # reset
## Command Function<a name="section366714216619"></a>
## Command Function
This command is used to restart a device. This command is used to restart a device.
## Syntax<a name="section8833164614615"></a>
## Syntax
reset reset
## Parameters<a name="section12809111019453"></a>
None ## Parameters
None.
## Usage Guidelines
## Usage<a name="section15935131220717"></a> After the **reset** command is executed, the device restarts immediately.
After the **reset** command is executed, the device restarts immediately.
## Example<a name="section79281818476"></a> ## Example
Run **reset**. Run **reset**.
## Output<a name="section12742311179"></a>
None ## Output
None.
# sem # sem
## Command Function<a name="section366714216619"></a>
## Command Function
This command is used to query information about kernel semaphores. This command is used to query information about kernel semaphores.
## Syntax<a name="section8833164614615"></a>
sem \[_ID__ / fulldata_\] ## Syntax
sem [_ID__ / fulldata_]
## Parameters
**Table 1** Parameter description
## Parameters<a name="section12809111019453"></a> | Parameter| Description| Value Range|
| -------- | -------- | -------- |
| ID | Specifies the semaphore ID.| [0, 1023] or [0x0, 0x3FF]|
| fulldata | Displays information about all semaphores in use. <br/>The displayed information includes **SemID**, **Count**, **Original Count**, **Creator TaskEntry**, and **Last Access Time**. | N/A |
**Table 1** Parameter description
<a name="table438mcpsimp"></a> ## Usage Guidelines
<table><thead align="left"><tr id="row444mcpsimp"><th class="cellrowborder" valign="top" width="21%" id="mcps1.2.4.1.1"><p id="p446mcpsimp"><a name="p446mcpsimp"></a><a name="p446mcpsimp"></a>Parameter</p>
</th>
<th class="cellrowborder" valign="top" width="52%" id="mcps1.2.4.1.2"><p id="p448mcpsimp"><a name="p448mcpsimp"></a><a name="p448mcpsimp"></a>Parameters</p>
</th>
<th class="cellrowborder" valign="top" width="27%" id="mcps1.2.4.1.3"><p id="p450mcpsimp"><a name="p450mcpsimp"></a><a name="p450mcpsimp"></a>Value Range</p>
</th>
</tr>
</thead>
<tbody><tr id="row451mcpsimp"><td class="cellrowborder" valign="top" width="21%" headers="mcps1.2.4.1.1 "><p id="p453mcpsimp"><a name="p453mcpsimp"></a><a name="p453mcpsimp"></a>ID</p>
</td>
<td class="cellrowborder" valign="top" width="52%" headers="mcps1.2.4.1.2 "><p id="p455mcpsimp"><a name="p455mcpsimp"></a><a name="p455mcpsimp"></a>Specifies the semaphore ID.</p>
</td>
<td class="cellrowborder" valign="top" width="27%" headers="mcps1.2.4.1.3 "><p id="p14422125918562"><a name="p14422125918562"></a><a name="p14422125918562"></a>[0, 1023] or [0x0, 0x3FF]</p>
</td>
</tr>
<tr id="row458mcpsimp"><td class="cellrowborder" valign="top" width="21%" headers="mcps1.2.4.1.1 "><p id="p460mcpsimp"><a name="p460mcpsimp"></a><a name="p460mcpsimp"></a>fulldata</p>
</td>
<td class="cellrowborder" valign="top" width="52%" headers="mcps1.2.4.1.2 "><p id="p462mcpsimp"><a name="p462mcpsimp"></a><a name="p462mcpsimp"></a>Queries information about all the semaphores in use. The information includes <strong id="b189454249533849"><a name="b189454249533849"></a><a name="b189454249533849"></a>SemID</strong>, <strong id="b162724654333849"><a name="b162724654333849"></a><a name="b162724654333849"></a>Count</strong>, <strong id="b111325307233849"><a name="b111325307233849"></a><a name="b111325307233849"></a>OriginalCount</strong>, <strong id="b182850346833849"><a name="b182850346833849"></a><a name="b182850346833849"></a>Creator(TaskEntry)</strong>, and <strong id="b213750533633849"><a name="b213750533633849"></a><a name="b213750533633849"></a>LastAccessTime</strong>.</p>
</td>
<td class="cellrowborder" valign="top" width="27%" headers="mcps1.2.4.1.3 "><p id="entry464mcpsimpp0"><a name="entry464mcpsimpp0"></a><a name="entry464mcpsimpp0"></a>N/A</p>
</td>
</tr>
</tbody>
</table>
## Usage<a name="section15935131220717"></a> - If no parameter is specified, this command displays the semaphore IDs and the number of times that each semaphore is used.
- If no parameter is specified, this command displays the semaphore IDs and the number of times that each semaphore is used. - If **ID** is specified, the use of the specified semaphore is displayed.
- If **ID** is specified, the use of the specified semaphore is displayed.
- The **fulldata** parameter depends on **LOSCFG\_DEBUG\_SEMAPHORE**. Before using this parameter, select **Enable Semaphore Debugging** on **menuconfig**.
Debug ---\> Enable a Debug Version ---\> Enable Debug LiteOS Kernel Resource ---\> Enable Semaphore Debugging - The **fulldata** parameter depends on **LOSCFG_DEBUG_SEMAPHORE**. Before using this parameter, set **Enable Semaphore Debugging** to **Yes** on **menuconfig**.
**Debug** ---&gt; **Enable a Debug Version** ---&gt; **Enable Debug LiteOS Kernel Resource** ---&gt; E**nable Semaphore Debugging**
## Example<a name="section79281818476"></a> ## Example
- Run **sem**. - Run **sem**.
- Configure **LOSCFG\_DEBUG\_SEMAPHORE** and run **sem fulldata**.
## Output<a name="section1975118519456"></a> - Configure **LOSCFG_DEBUG_SEMAPHORE** and run **sem fulldata**.
## Output
Example 1: brief semaphore information Example 1: brief semaphore information
...@@ -81,31 +67,17 @@ OHOS # sem ...@@ -81,31 +67,17 @@ OHOS # sem
0x00000006 0 0x00000006 0
``` ```
**Table 2** Output **Table 2** Output description
<a name="table487mcpsimp"></a> | Parameter| Description|
<table><thead align="left"><tr id="row492mcpsimp"><th class="cellrowborder" valign="top" width="50%" id="mcps1.2.3.1.1"><p id="p494mcpsimp"><a name="p494mcpsimp"></a><a name="p494mcpsimp"></a>Parameter</p> | -------- | -------- |
</th> | SemID | Semaphore ID.|
<th class="cellrowborder" valign="top" width="50%" id="mcps1.2.3.1.2"><p id="p496mcpsimp"><a name="p496mcpsimp"></a><a name="p496mcpsimp"></a>Description</p> | Count | Number of times that the semaphore is used.|
</th>
</tr> > **NOTE**<br>
</thead> > The **ID** value can be in decimal or hexadecimal format.
<tbody><tr id="row497mcpsimp"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p499mcpsimp"><a name="p499mcpsimp"></a><a name="p499mcpsimp"></a>SemID</p> >
</td> > When **ID** is a value within [0, 1023], semaphore information of the specified ID is displayed. If the specified semaphore is not used, a message is displayed to inform you of this case. For other values, a message is displayed indicating that the parameter is incorrect.
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p501mcpsimp"><a name="p501mcpsimp"></a><a name="p501mcpsimp"></a>Semaphore ID</p>
</td>
</tr>
<tr id="row502mcpsimp"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p504mcpsimp"><a name="p504mcpsimp"></a><a name="p504mcpsimp"></a>Count</p>
</td>
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p506mcpsimp"><a name="p506mcpsimp"></a><a name="p506mcpsimp"></a>Number of times that the semaphore is used</p>
</td>
</tr>
</tbody>
</table>
>![](../public_sys-resources/icon-note.gif) **NOTE**
>The **ID** value can be in decimal or hexadecimal format.
>When **ID** is a value within \[0, 1023\], semaphore information of the specified ID is displayed. If the specified semaphore is not used, a message is displayed to inform you of this case. For other values, a message is displayed indicating that the parameter is incorrect.
Example 2: detailed semaphore information Example 2: detailed semaphore information
...@@ -141,40 +113,12 @@ Used Semaphore List: ...@@ -141,40 +113,12 @@ Used Semaphore List:
0x38 0x1 0x1 0x404978fc 0x395 0x38 0x1 0x1 0x404978fc 0x395
``` ```
**Table 3** Output description **Table 3** Output description
<a name="table57783201041"></a>
<table><thead align="left"><tr id="row12778320943"><th class="cellrowborder" valign="top" width="50%" id="mcps1.2.3.1.1"><p id="p153641444643"><a name="p153641444643"></a><a name="p153641444643"></a>Parameter</p>
</th>
<th class="cellrowborder" valign="top" width="50%" id="mcps1.2.3.1.2"><p id="p236413447414"><a name="p236413447414"></a><a name="p236413447414"></a>Description</p>
</th>
</tr>
</thead>
<tbody><tr id="row14834640646"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p7829840647"><a name="p7829840647"></a><a name="p7829840647"></a>SemID</p>
</td>
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p118291440244"><a name="p118291440244"></a><a name="p118291440244"></a>Semaphore ID</p>
</td>
</tr>
<tr id="row78346401141"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p08292401349"><a name="p08292401349"></a><a name="p08292401349"></a>Count</p>
</td>
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p1829104012416"><a name="p1829104012416"></a><a name="p1829104012416"></a>Number of times that the semaphore is used</p>
</td>
</tr>
<tr id="row1883414404411"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p88291640847"><a name="p88291640847"></a><a name="p88291640847"></a>OriginalCount</p>
</td>
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p282916401148"><a name="p282916401148"></a><a name="p282916401148"></a>Original count of the semaphore</p>
</td>
</tr>
<tr id="row148347401646"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p1782914401646"><a name="p1782914401646"></a><a name="p1782914401646"></a>Creator</p>
</td>
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p168298407419"><a name="p168298407419"></a><a name="p168298407419"></a>Address of the entry function of the thread used to create the semaphore</p>
</td>
</tr>
<tr id="row783415401340"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p18829640549"><a name="p18829640549"></a><a name="p18829640549"></a>LastAccessTime</p>
</td>
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p198292406412"><a name="p198292406412"></a><a name="p198292406412"></a>Last time when the semaphore was accessed</p>
</td>
</tr>
</tbody>
</table>
| Parameter| Description|
| -------- | -------- |
| SemID | Semaphore ID.|
| Count | Number of times that the semaphore is used.|
| OriginalCount | Original count of the semaphore.|
| Creator | Address of the entry function of the thread used to create the semaphore.|
| LastAccessTime | Last time when the semaphore was accessed.|
# stack # stack
## Command Function<a name="section445335110416"></a> ## Command Function
This command is used to check the usage of each stack in the system. This command is used to check the usage of each stack in the system.
## Syntax<a name="section1795712553416"></a>
## Syntax
stack stack
## Parameters<a name="section92544592410"></a>
None ## Parameters
None.
## Usage Guidelines
None.
## Usage<a name="section104151141252"></a>
None ## Example
## Example<a name="section11545171957"></a> Run **stack**.
Run **stack**.
## Output<a name="section075617368542"></a> ## Output
System stack usage: System stack usage:
...@@ -35,40 +40,12 @@ OHOS # stack ...@@ -35,40 +40,12 @@ OHOS # stack
exc_stack 0 0x405c9000 0x1000 0x0 exc_stack 0 0x405c9000 0x1000 0x0
``` ```
**Table 1** Output **Table 1** Output description
<a name="table633mcpsimp"></a>
<table><thead align="left"><tr id="row638mcpsimp"><th class="cellrowborder" valign="top" width="50%" id="mcps1.2.3.1.1"><p id="p640mcpsimp"><a name="p640mcpsimp"></a><a name="p640mcpsimp"></a>Parameter</p>
</th>
<th class="cellrowborder" valign="top" width="50%" id="mcps1.2.3.1.2"><p id="p642mcpsimp"><a name="p642mcpsimp"></a><a name="p642mcpsimp"></a>Description</p>
</th>
</tr>
</thead>
<tbody><tr id="row643mcpsimp"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p645mcpsimp"><a name="p645mcpsimp"></a><a name="p645mcpsimp"></a>stack name</p>
</td>
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p647mcpsimp"><a name="p647mcpsimp"></a><a name="p647mcpsimp"></a>Name of the stack</p>
</td>
</tr>
<tr id="row648mcpsimp"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p650mcpsimp"><a name="p650mcpsimp"></a><a name="p650mcpsimp"></a>cpu id</p>
</td>
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p652mcpsimp"><a name="p652mcpsimp"></a><a name="p652mcpsimp"></a>CPU ID</p>
</td>
</tr>
<tr id="row653mcpsimp"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p655mcpsimp"><a name="p655mcpsimp"></a><a name="p655mcpsimp"></a>stack addr</p>
</td>
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p657mcpsimp"><a name="p657mcpsimp"></a><a name="p657mcpsimp"></a>Stack address</p>
</td>
</tr>
<tr id="row658mcpsimp"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p660mcpsimp"><a name="p660mcpsimp"></a><a name="p660mcpsimp"></a>total size</p>
</td>
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p662mcpsimp"><a name="p662mcpsimp"></a><a name="p662mcpsimp"></a>Total stack size</p>
</td>
</tr>
<tr id="row10101624938"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p610724734"><a name="p610724734"></a><a name="p610724734"></a>used size</p>
</td>
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p1510024539"><a name="p1510024539"></a><a name="p1510024539"></a>Size of the stack used</p>
</td>
</tr>
</tbody>
</table>
| Parameter| Description|
| -------- | -------- |
| stack&nbsp;name | Name of the stack.|
| cpu&nbsp;id | CPU number.|
| stack&nbsp;addr | Stack address.|
| total&nbsp;size | Total stack size.|
| used&nbsp;size | Size of the stack used.|
# su # su
## Command Function<a name="section297810431676"></a>
## Command Function
This command is used to switch the user account. This command is used to switch the user account.
## Syntax<a name="section157131147876"></a>
su \[_uid_\] \[_gid_\] ## Syntax
su [_uid_] [_gid_]
## Parameters
**Table 1** Parameter description
## Parameters<a name="section04145521671"></a> | Parameter| Description| Value Range|
| -------- | -------- | -------- |
| uid | Specifies the ID of the target user.| - Left blank<br>- [0, 60000] |
| gid | Specifies the ID of the target user group.| - Left blank<br>- [0, 60000] |
**Table 1** Parameter description
<a name="table1049mcpsimp"></a> ## Usage Guidelines
<table><thead align="left"><tr id="row1055mcpsimp"><th class="cellrowborder" valign="top" width="21%" id="mcps1.2.4.1.1"><p id="p1057mcpsimp"><a name="p1057mcpsimp"></a><a name="p1057mcpsimp"></a>Parameter</p>
</th>
<th class="cellrowborder" valign="top" width="51.93%" id="mcps1.2.4.1.2"><p id="p1059mcpsimp"><a name="p1059mcpsimp"></a><a name="p1059mcpsimp"></a>Description</p>
</th>
<th class="cellrowborder" valign="top" width="27.07%" id="mcps1.2.4.1.3"><p id="p1061mcpsimp"><a name="p1061mcpsimp"></a><a name="p1061mcpsimp"></a>Value Range</p>
</th>
</tr>
</thead>
<tbody><tr id="row1062mcpsimp"><td class="cellrowborder" valign="top" width="21%" headers="mcps1.2.4.1.1 "><p id="p1064mcpsimp"><a name="p1064mcpsimp"></a><a name="p1064mcpsimp"></a>uid</p>
</td>
<td class="cellrowborder" valign="top" width="51.93%" headers="mcps1.2.4.1.2 "><p id="p14138191243"><a name="p14138191243"></a><a name="p14138191243"></a>Specifies the ID of the target user.</p>
</td>
<td class="cellrowborder" valign="top" width="27.07%" headers="mcps1.2.4.1.3 "><a name="ul14151675449"></a><a name="ul14151675449"></a><ul id="ul14151675449"><li>Left blank</li><li>[0,60000]</li></ul>
</td>
</tr>
<tr id="row172161126124218"><td class="cellrowborder" valign="top" width="21%" headers="mcps1.2.4.1.1 "><p id="p12217026154215"><a name="p12217026154215"></a><a name="p12217026154215"></a>gid</p>
</td>
<td class="cellrowborder" valign="top" width="51.93%" headers="mcps1.2.4.1.2 "><p id="p48748461789"><a name="p48748461789"></a><a name="p48748461789"></a>Specifies the ID of the target user group.</p>
</td>
<td class="cellrowborder" valign="top" width="27.07%" headers="mcps1.2.4.1.3 "><a name="ul10433713134417"></a><a name="ul10433713134417"></a><ul id="ul10433713134417"><li>Left blank</li><li>[0,60000]</li></ul>
</td>
</tr>
</tbody>
</table>
## Usage<a name="section14615155610719"></a> - If no parameter is specified, the **su** command switches to user **root** by default. The **uid** and **gid** for user **root** are both **0**.
- If no parameter is specified, the **su** command switches to user **root** by default. The **uid** and **gid** for user **root** are both **0**. - If **uid** and **gid** are specified, this command allows commands to be executed as the user with the specified **uid** and **gid**.
- If **uid** and **gid** are specified, this command allows commands to be executed as the user with the specified **uid** and **gid**.
- If the input parameter is out of the range, an error message will be printed.
## Example<a name="section13338150985"></a> - If the input parameter is out of the range, an error message will be printed.
Run **su 1000 1000**.
## Output<a name="section125021924194613"></a> ## Example
Switching to the user with both **uid** and **gid** of **1000**: Run **su 1000 1000**.
## Output
The user with both **uid** and **gid** of **1000** is switched.
``` ```
OHOS # ls OHOS # ls
...@@ -63,4 +50,3 @@ Directory /data/system/param: ...@@ -63,4 +50,3 @@ Directory /data/system/param:
-rw-r--r-- O u:1000 g:1000 hello 2.txt -rw-r--r-- O u:1000 g:1000 hello 2.txt
-гw-r--r-- 0 u:0 g:0 hello_1.txt -гw-r--r-- 0 u:0 g:0 hello_1.txt
``` ```
# swtmr # swtmr
## Command Function<a name="section166171064814"></a> ## Command Function
This command is used to query information about system software timers. This command is used to query information about system software timers.
## Syntax<a name="section424011111682"></a>
swtmr \[_ID_\] ## Syntax
## Parameters<a name="section1268410459465"></a> swtmr [_ID_]
**Table 1** Parameter description
<a name="table517mcpsimp"></a> ## Parameters
<table><thead align="left"><tr id="row523mcpsimp"><th class="cellrowborder" valign="top" width="21%" id="mcps1.2.4.1.1"><p id="p525mcpsimp"><a name="p525mcpsimp"></a><a name="p525mcpsimp"></a>Parameter</p>
</th>
<th class="cellrowborder" valign="top" width="52%" id="mcps1.2.4.1.2"><p id="p527mcpsimp"><a name="p527mcpsimp"></a><a name="p527mcpsimp"></a>Description</p>
</th>
<th class="cellrowborder" valign="top" width="27%" id="mcps1.2.4.1.3"><p id="p529mcpsimp"><a name="p529mcpsimp"></a><a name="p529mcpsimp"></a>Value Range</p>
</th>
</tr>
</thead>
<tbody><tr id="row530mcpsimp"><td class="cellrowborder" valign="top" width="21%" headers="mcps1.2.4.1.1 "><p id="p532mcpsimp"><a name="p532mcpsimp"></a><a name="p532mcpsimp"></a>ID</p>
</td>
<td class="cellrowborder" valign="top" width="52%" headers="mcps1.2.4.1.2 "><p id="p534mcpsimp"><a name="p534mcpsimp"></a><a name="p534mcpsimp"></a>Specifies the ID of a software timer.</p>
</td>
<td class="cellrowborder" valign="top" width="27%" headers="mcps1.2.4.1.3 "><p id="p536mcpsimp"><a name="p536mcpsimp"></a><a name="p536mcpsimp"></a>[0,0xFFFFFFFF]</p>
</td>
</tr>
</tbody>
</table>
## Usage<a name="section169806213815"></a> **Table 1** Parameter description
- If no parameter is specified, information about all software timers is displayed. | Parameter| Description| Value Range|
- If the **ID** parameter is specified, information about the specified software timer is displayed. | -------- | -------- | -------- |
| ID | Specifies the ID of a software timer.| [0, 0xFFFFFFFF] |
## Example<a name="section16676026389"></a>
## Usage Guidelines
- If no parameter is specified, information about all software timers is displayed.
- If the **ID** parameter is specified, information about the specified software timer is displayed.
## Example
Run the following commands: Run the following commands:
- swtmr - swtmr
- swtmr 1
- swtmr 1
## Output<a name="section1541991614710"></a>
## Output
Example 1: information about all software timers Example 1: information about all software timers
...@@ -76,56 +68,19 @@ SwTmrID State Mode Interval Count Arg handlerAddr ...@@ -76,56 +68,19 @@ SwTmrID State Mode Interval Count Arg handlerAddr
0x00000001 Ticking Period 1000 841 0x00000000 0x4037fc04 0x00000001 Ticking Period 1000 841 0x00000000 0x4037fc04
``` ```
**Table 2** Output **Table 2** Output description
<a name="table551mcpsimp"></a> | Parameter| Description|
<table><thead align="left"><tr id="row556mcpsimp"><th class="cellrowborder" valign="top" width="50%" id="mcps1.2.3.1.1"><p id="p558mcpsimp"><a name="p558mcpsimp"></a><a name="p558mcpsimp"></a>Parameter</p> | -------- | -------- |
</th> | SwTmrID | ID of the software timer.|
<th class="cellrowborder" valign="top" width="50%" id="mcps1.2.3.1.2"><p id="p560mcpsimp"><a name="p560mcpsimp"></a><a name="p560mcpsimp"></a>Description</p> | State | Status of the software timer.<br>The status may be **UnUsed**, **Created**, or **Ticking**.|
</th> | Mode | Mode of the software timer.<br>The value can be **Once**, **Period**, or **NSD** (one-shot timer that will not be automatically deleted after the timer has expired).|
</tr> | Interval | Number of ticks for the software timer.|
</thead> | Count | Number of times that the software timer has been used.|
<tbody><tr id="row561mcpsimp"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p563mcpsimp"><a name="p563mcpsimp"></a><a name="p563mcpsimp"></a>SwTmrID</p> | Arg | Input parameter.|
</td> | handlerAddr | Address of the callback.|
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p565mcpsimp"><a name="p565mcpsimp"></a><a name="p565mcpsimp"></a>ID of the software timer</p>
</td> > **NOTE**<br>
</tr> > - The **ID** value can be in decimal or hexadecimal format.
<tr id="row566mcpsimp"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p568mcpsimp"><a name="p568mcpsimp"></a><a name="p568mcpsimp"></a>State</p> >
</td> > - If the **ID** value is within the range of [0, *Number of current software timers - 1*], the status of the specified software timer is returned. Otherwise, an error code is returned.
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p570mcpsimp"><a name="p570mcpsimp"></a><a name="p570mcpsimp"></a>Status of the software timer</p>
<p id="p88402543474"><a name="p88402543474"></a><a name="p88402543474"></a>The value can be <strong id="b164905263633836"><a name="b164905263633836"></a><a name="b164905263633836"></a>UnUsed</strong>, <strong id="b138979237833836"><a name="b138979237833836"></a><a name="b138979237833836"></a>Created</strong>, or <strong id="b3849463233836"><a name="b3849463233836"></a><a name="b3849463233836"></a>Ticking</strong>.</p>
</td>
</tr>
<tr id="row571mcpsimp"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p573mcpsimp"><a name="p573mcpsimp"></a><a name="p573mcpsimp"></a>Mode</p>
</td>
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p575mcpsimp"><a name="p575mcpsimp"></a><a name="p575mcpsimp"></a>Mode of the software timer</p>
<p id="p657320204499"><a name="p657320204499"></a><a name="p657320204499"></a>The value can be <strong id="b201632419733836"><a name="b201632419733836"></a><a name="b201632419733836"></a>Once</strong>, <strong id="b45281151733836"><a name="b45281151733836"></a><a name="b45281151733836"></a>Period</strong>, or <strong id="b73443815433836"><a name="b73443815433836"></a><a name="b73443815433836"></a>NSD</strong> (one-shot timer that will not be automatically deleted after the timer has expired).</p>
</td>
</tr>
<tr id="row576mcpsimp"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p578mcpsimp"><a name="p578mcpsimp"></a><a name="p578mcpsimp"></a>Interval</p>
</td>
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p580mcpsimp"><a name="p580mcpsimp"></a><a name="p580mcpsimp"></a>Number of ticks for the software timer</p>
</td>
</tr>
<tr id="row581mcpsimp"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p583mcpsimp"><a name="p583mcpsimp"></a><a name="p583mcpsimp"></a>Count</p>
</td>
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p585mcpsimp"><a name="p585mcpsimp"></a><a name="p585mcpsimp"></a>Number of times that the software timer has been used</p>
</td>
</tr>
<tr id="row586mcpsimp"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p588mcpsimp"><a name="p588mcpsimp"></a><a name="p588mcpsimp"></a>Arg</p>
</td>
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p590mcpsimp"><a name="p590mcpsimp"></a><a name="p590mcpsimp"></a>Input parameter</p>
</td>
</tr>
<tr id="row591mcpsimp"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p593mcpsimp"><a name="p593mcpsimp"></a><a name="p593mcpsimp"></a>handlerAddr</p>
</td>
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p595mcpsimp"><a name="p595mcpsimp"></a><a name="p595mcpsimp"></a>Address of the callback</p>
</td>
</tr>
</tbody>
</table>
>![](../public_sys-resources/icon-note.gif) **NOTE:**
>- The **ID** value can be in decimal or hexadecimal format.
>- If the **ID** value is within the range of \[0, _Number of current software timers - 1_\], the status of the specified software timer is returned. For other values, an error message is displayed.
# systeminfo # systeminfo
## Command Function<a name="section863016434820"></a>
## Command Function
This command is used to display the resource usage of the current operating system, including tasks, semaphores, mutexes, queues, and software timers. This command is used to display the resource usage of the current operating system, including tasks, semaphores, mutexes, queues, and software timers.
## Syntax<a name="section139791817795"></a>
## Syntax
systeminfo systeminfo
## Parameters<a name="section19472339164813"></a>
None ## Parameters
None.
## Usage<a name="section285522592"></a> ## Usage Guidelines
None None.
## Example<a name="section9471171015105"></a>
Run **systeminfo**. ## Example
## Output<a name="section1657011114915"></a> Run **systeminfo**.
## Output
Usage of system resources: Usage of system resources:
...@@ -34,60 +40,15 @@ OHOS:/$ systeminfo ...@@ -34,60 +40,15 @@ OHOS:/$ systeminfo
SwTmr 20 1024 YES SwTmr 20 1024 YES
``` ```
**Table 1** Output **Table 1** Output description
<a name="table633mcpsimp"></a> | Parameter | Description |
<table><thead align="left"><tr id="row638mcpsimp"><th class="cellrowborder" valign="top" width="50%" id="mcps1.2.3.1.1"><p id="p640mcpsimp"><a name="p640mcpsimp"></a><a name="p640mcpsimp"></a>Parameter</p> | ------- | -------------- |
</th> | Module | Module name. |
<th class="cellrowborder" valign="top" width="50%" id="mcps1.2.3.1.2"><p id="p642mcpsimp"><a name="p642mcpsimp"></a><a name="p642mcpsimp"></a>Description</p> | Used | Used resources. |
</th> | Total | Total resources. |
</tr> | Enabled | Whether the module is enabled.|
</thead> | Task | Task. |
<tbody><tr id="row643mcpsimp"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p645mcpsimp"><a name="p645mcpsimp"></a><a name="p645mcpsimp"></a>Module</p> | Sem | Semaphore. |
</td> | Queue | Using queues. |
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p647mcpsimp"><a name="p647mcpsimp"></a><a name="p647mcpsimp"></a>Module name</p> | SwTmr | Software timer. |
</td>
</tr>
<tr id="row648mcpsimp"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p650mcpsimp"><a name="p650mcpsimp"></a><a name="p650mcpsimp"></a>Used</p>
</td>
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p652mcpsimp"><a name="p652mcpsimp"></a><a name="p652mcpsimp"></a>Used resources</p>
</td>
</tr>
<tr id="row653mcpsimp"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p655mcpsimp"><a name="p655mcpsimp"></a><a name="p655mcpsimp"></a>Total</p>
</td>
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p657mcpsimp"><a name="p657mcpsimp"></a><a name="p657mcpsimp"></a>Total resources</p>
</td>
</tr>
<tr id="row658mcpsimp"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p660mcpsimp"><a name="p660mcpsimp"></a><a name="p660mcpsimp"></a>Enabled</p>
</td>
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p662mcpsimp"><a name="p662mcpsimp"></a><a name="p662mcpsimp"></a>Whether the module is enabled</p>
</td>
</tr>
<tr id="row10101624938"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p610724734"><a name="p610724734"></a><a name="p610724734"></a>Task</p>
</td>
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p1510024539"><a name="p1510024539"></a><a name="p1510024539"></a>Task</p>
</td>
</tr>
<tr id="row207288271839"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p572872713317"><a name="p572872713317"></a><a name="p572872713317"></a>Sem</p>
</td>
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p272852716315"><a name="p272852716315"></a><a name="p272852716315"></a>Semaphore</p>
</td>
</tr>
<tr id="row1774316321731"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p274343218317"><a name="p274343218317"></a><a name="p274343218317"></a>Mutex</p>
</td>
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p1974319321133"><a name="p1974319321133"></a><a name="p1974319321133"></a>Mutex</p>
</td>
</tr>
<tr id="row121618371536"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p0161183720314"><a name="p0161183720314"></a><a name="p0161183720314"></a>Queue</p>
</td>
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p09295155511"><a name="p09295155511"></a><a name="p09295155511"></a>Message queue</p>
</td>
</tr>
<tr id="row4935152211518"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p13935222154"><a name="p13935222154"></a><a name="p13935222154"></a>SwTmr</p>
</td>
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p0936182215515"><a name="p0936182215515"></a><a name="p0936182215515"></a>Software timer</p>
</td>
</tr>
</tbody>
</table>
# task # task
## Command Function<a name="section0533181714106"></a>
## Command Function
This command is used to query information about processes and threads. This command is used to query information about processes and threads.
## Syntax<a name="section1014412308101"></a>
## Syntax
task/task -a task/task -a
## Parameters<a name="section116057158506"></a>
## Parameters
**Table 1** Parameter description
**Table 1** Parameter description
<a name="table672mcpsimp"></a>
<table><thead align="left"><tr id="row678mcpsimp"><th class="cellrowborder" valign="top" width="21%" id="mcps1.2.4.1.1"><p id="p680mcpsimp"><a name="p680mcpsimp"></a><a name="p680mcpsimp"></a>Parameter</p> | Parameter| Description| Value Range|
</th> | -------- | -------- | -------- |
<th class="cellrowborder" valign="top" width="52%" id="mcps1.2.4.1.2"><p id="p682mcpsimp"><a name="p682mcpsimp"></a><a name="p682mcpsimp"></a>Description</p> | -a | Displays all information.| N/A |
</th>
<th class="cellrowborder" valign="top" width="27%" id="mcps1.2.4.1.3"><p id="p684mcpsimp"><a name="p684mcpsimp"></a><a name="p684mcpsimp"></a>Value Range</p>
</th> ## Usage Guidelines
</tr>
</thead>
<tbody><tr id="row685mcpsimp"><td class="cellrowborder" valign="top" width="21%" headers="mcps1.2.4.1.1 "><p id="p687mcpsimp"><a name="p687mcpsimp"></a><a name="p687mcpsimp"></a>-a</p>
</td>
<td class="cellrowborder" valign="top" width="52%" headers="mcps1.2.4.1.2 "><p id="p689mcpsimp"><a name="p689mcpsimp"></a><a name="p689mcpsimp"></a>Displays all information.</p>
</td>
<td class="cellrowborder" valign="top" width="27%" headers="mcps1.2.4.1.3 "><p id="p691mcpsimp"><a name="p691mcpsimp"></a><a name="p691mcpsimp"></a>N/A</p>
</td>
</tr>
</tbody>
</table>
## Usage<a name="section2053502951112"></a>
If no parameter is specified, partial task information is displayed by default. If no parameter is specified, partial task information is displayed by default.
## Example<a name="section12629113381116"></a>
Run **task**. ## Example
Run **task**.
## Output<a name="section19299103465015"></a>
Task information \(partial\): ## Output
Task information (partial):
``` ```
OHOS # task OHOS # task
...@@ -55,6 +46,7 @@ OHOS # task ...@@ -55,6 +46,7 @@ OHOS # task
6 1 6 0 Pending 0x688000 0x137000 0x11c518 0.0 media_server 6 1 6 0 Pending 0x688000 0x137000 0x11c518 0.0 media_server
7 1 7 0 Pending 0x9d2000 0x103000 0xa1ddf 0.89 wms_server 7 1 7 0 Pending 0x9d2000 0x103000 0xa1ddf 0.89 wms_server
8 1 1 1000 Running 0x2bf000 0x8f000 0x2a8c6 0.0 shell 8 1 1 1000 Running 0x2bf000 0x8f000 0x2a8c6 0.0 shell
9 5 5 101 Pending 0x11ea000 0x2f9000 0x20429d 0.97 com.example.launcher
11 1 11 0 Pending 0x4d4000 0x112000 0xe0ad7 0.0 deviceauth_service 11 1 11 0 Pending 0x4d4000 0x112000 0xe0ad7 0.0 deviceauth_service
12 1 12 0 Pending 0x34f000 0xbd000 0x519ee 0.0 sensor_service 12 1 12 0 Pending 0x34f000 0xbd000 0x519ee 0.0 sensor_service
13 1 13 2 Pending 0x34e000 0xb3000 0x523d9 0.0 ai_server 13 1 13 2 Pending 0x34e000 0xb3000 0x523d9 0.0 ai_server
...@@ -68,75 +60,19 @@ OHOS # task ...@@ -68,75 +60,19 @@ OHOS # task
7 2 0x3 -1 Pending 0x4e20 0xa5c 0.0 0 PlatformWorkerThread 7 2 0x3 -1 Pending 0x4e20 0xa5c 0.0 0 PlatformWorkerThread
``` ```
**Table 2** Output **Table 2** Output description
<a name="table809mcpsimp"></a> | Parameter| Description|
<table><thead align="left"><tr id="row814mcpsimp"><th class="cellrowborder" valign="top" width="50%" id="mcps1.2.3.1.1"><p id="p816mcpsimp"><a name="p816mcpsimp"></a><a name="p816mcpsimp"></a>Parameter</p> | -------- | -------- |
</th> | PID | Process ID.|
<th class="cellrowborder" valign="top" width="50%" id="mcps1.2.3.1.2"><p id="p818mcpsimp"><a name="p818mcpsimp"></a><a name="p818mcpsimp"></a>Description</p> | PPID | Parent process ID.|
</th> | PGID | Process group ID.|
</tr> | UID | User ID.|
</thead> | Status | Current task status.|
<tbody><tr id="row20360171311398"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p123611139397"><a name="p123611139397"></a><a name="p123611139397"></a>PID</p> | CPUUSE10s | CPU usage within last 10 seconds.|
</td> | PName | Name of the process.|
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p3361171333920"><a name="p3361171333920"></a><a name="p3361171333920"></a>Process ID</p> | TID | Task ID.|
</td> | StackSize | Size of the task stack.|
</tr> | WaterLine | Peak value of the stack used.|
<tr id="row262535153913"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p862625163918"><a name="p862625163918"></a><a name="p862625163918"></a>PPID</p> | MEMUSE | Memory usage.|
</td> | TaskName | Task name.|
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p1062611511398"><a name="p1062611511398"></a><a name="p1062611511398"></a>Parent process ID</p>
</td>
</tr>
<tr id="row9683953153916"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p76831753103915"><a name="p76831753103915"></a><a name="p76831753103915"></a>PGID</p>
</td>
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p2068355383916"><a name="p2068355383916"></a><a name="p2068355383916"></a>Process group ID</p>
</td>
</tr>
<tr id="row85721136402"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p8572151313402"><a name="p8572151313402"></a><a name="p8572151313402"></a>UID</p>
</td>
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p55721813164013"><a name="p55721813164013"></a><a name="p55721813164013"></a>User ID</p>
</td>
</tr>
<tr id="row19180126151415"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p836mcpsimp"><a name="p836mcpsimp"></a><a name="p836mcpsimp"></a>Status</p>
</td>
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p838mcpsimp"><a name="p838mcpsimp"></a><a name="p838mcpsimp"></a>Current task status</p>
</td>
</tr>
<tr id="row511517331702"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p2116833506"><a name="p2116833506"></a><a name="p2116833506"></a>CPUUSE10s</p>
</td>
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p2011611331604"><a name="p2011611331604"></a><a name="p2011611331604"></a>CPU usage within last 10 seconds</p>
</td>
</tr>
<tr id="row136191839311"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p66199397110"><a name="p66199397110"></a><a name="p66199397110"></a>PName</p>
</td>
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p11619153916110"><a name="p11619153916110"></a><a name="p11619153916110"></a>Process name</p>
</td>
</tr>
<tr id="row824mcpsimp"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p826mcpsimp"><a name="p826mcpsimp"></a><a name="p826mcpsimp"></a>TID</p>
</td>
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p828mcpsimp"><a name="p828mcpsimp"></a><a name="p828mcpsimp"></a>Task ID</p>
</td>
</tr>
<tr id="row839mcpsimp"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p841mcpsimp"><a name="p841mcpsimp"></a><a name="p841mcpsimp"></a>StackSize</p>
</td>
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p843mcpsimp"><a name="p843mcpsimp"></a><a name="p843mcpsimp"></a>Size of the task stack</p>
</td>
</tr>
<tr id="row844mcpsimp"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p846mcpsimp"><a name="p846mcpsimp"></a><a name="p846mcpsimp"></a>WaterLine</p>
</td>
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p848mcpsimp"><a name="p848mcpsimp"></a><a name="p848mcpsimp"></a>Peak value of the stack used</p>
</td>
</tr>
<tr id="row10188146131813"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p218912671818"><a name="p218912671818"></a><a name="p218912671818"></a>MEMUSE</p>
</td>
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p1518926151810"><a name="p1518926151810"></a><a name="p1518926151810"></a>Memory usage</p>
</td>
</tr>
<tr id="row45465584313"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p821mcpsimp"><a name="p821mcpsimp"></a><a name="p821mcpsimp"></a>TaskName</p>
</td>
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p823mcpsimp"><a name="p823mcpsimp"></a><a name="p823mcpsimp"></a>Task name</p>
</td>
</tr>
</tbody>
</table>
# top # top
## Command Function<a name="section20643141481314"></a>
## Command Function
This command is used to query process and thread information. This command is used to query process and thread information.
## Syntax<a name="section1075441721316"></a>
## Syntax
top \[_-a_\]
top [_-a_]
## Parameters<a name="section1472810220135"></a>
**Table 1** Parameter description ## Parameters
<a name="table966mcpsimp"></a> **Table 1** Parameter description
<table><thead align="left"><tr id="row973mcpsimp"><th class="cellrowborder" valign="top" width="19.801980198019802%" id="mcps1.2.5.1.1"><p id="p975mcpsimp"><a name="p975mcpsimp"></a><a name="p975mcpsimp"></a>Parameter</p>
</th> | Parameter | Description |
<th class="cellrowborder" valign="top" width="29.222922292229224%" id="mcps1.2.5.1.2"><p id="p977mcpsimp"><a name="p977mcpsimp"></a><a name="p977mcpsimp"></a>Description</p> | ------ | --------------------------- |
</th> | --help | Displays the parameters supported by the **top** command.|
<th class="cellrowborder" valign="top" width="22.26222622262226%" id="mcps1.2.5.1.3"><p id="p979mcpsimp"><a name="p979mcpsimp"></a><a name="p979mcpsimp"></a>Default Value</p> | -a | Displays detailed information. |
</th>
<th class="cellrowborder" valign="top" width="28.712871287128717%" id="mcps1.2.5.1.4"><p id="p981mcpsimp"><a name="p981mcpsimp"></a><a name="p981mcpsimp"></a>Value Range</p>
</th> ## Usage Guidelines
</tr>
</thead> If no parameter is specified, partial task information is displayed by default.
<tbody><tr id="row1643213388538"><td class="cellrowborder" valign="top" width="19.801980198019802%" headers="mcps1.2.5.1.1 "><p id="p11426113820531"><a name="p11426113820531"></a><a name="p11426113820531"></a>--help</p>
</td> ## Note
<td class="cellrowborder" valign="top" width="29.222922292229224%" headers="mcps1.2.5.1.2 "><p id="p942673885313"><a name="p942673885313"></a><a name="p942673885313"></a>Displays the parameters supported by the <strong id="b2435956125215"><a name="b2435956125215"></a><a name="b2435956125215"></a>top</strong> command.</p>
</td> Currently, the shell does not support this command. mksh supports it. To switch to mksh, run **cd bin** and **./mksh**.
<td class="cellrowborder" valign="top" width="22.26222622262226%" headers="mcps1.2.5.1.3 "><p id="p9426538195319"><a name="p9426538195319"></a><a name="p9426538195319"></a>N/A</p>
</td> ## Example
<td class="cellrowborder" valign="top" width="28.712871287128717%" headers="mcps1.2.5.1.4 ">&nbsp;&nbsp;</td>
</tr> Run **top**.
<tr id="row1943253865311"><td class="cellrowborder" valign="top" width="19.801980198019802%" headers="mcps1.2.5.1.1 "><p id="p1542613812537"><a name="p1542613812537"></a><a name="p1542613812537"></a>-a</p>
</td>
<td class="cellrowborder" valign="top" width="29.222922292229224%" headers="mcps1.2.5.1.2 "><p id="p1842663895320"><a name="p1842663895320"></a><a name="p1842663895320"></a>Displays detailed information.</p> ## Output
</td>
<td class="cellrowborder" valign="top" width="22.26222622262226%" headers="mcps1.2.5.1.3 "><p id="p13426123815313"><a name="p13426123815313"></a><a name="p13426123815313"></a>N/A</p>
</td>
<td class="cellrowborder" valign="top" width="28.712871287128717%" headers="mcps1.2.5.1.4 ">&nbsp;&nbsp;</td>
</tr>
</tbody>
</table>
## Usage<a name="section186772414131"></a>
If no parameter is specified, this command displays process and thread information of some tasks by default.
## Example<a name="section4764192791314"></a>
Run **top**.
## Output<a name="section5791253155517"></a>
Command output Command output
...@@ -97,75 +81,19 @@ OHOS:/$ top ...@@ -97,75 +81,19 @@ OHOS:/$ top
64 2 0x3 -1 Pending 0x4000 0x244 0.0 0 USB_NGIAN_BULK_TasK 64 2 0x3 -1 Pending 0x4000 0x244 0.0 0 USB_NGIAN_BULK_TasK
``` ```
**Table 2** Output description **Table 2** Output description
<a name="table1522165195511"></a> | Parameter | Description |
<table><thead align="left"><tr id="row1952285165514"><th class="cellrowborder" valign="top" width="50%" id="mcps1.2.3.1.1"><p id="p25224518556"><a name="p25224518556"></a><a name="p25224518556"></a>Parameter</p> | --------- | ----------------- |
</th> | PID | Process ID. |
<th class="cellrowborder" valign="top" width="50%" id="mcps1.2.3.1.2"><p id="p16522852554"><a name="p16522852554"></a><a name="p16522852554"></a>Description</p> | PPID | Parent process ID. |
</th> | PGID | Process group ID. |
</tr> | UID | User ID. |
</thead> | Status | Current task status. |
<tbody><tr id="row207354303550"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p107238309551"><a name="p107238309551"></a><a name="p107238309551"></a>PID</p> | CPUUSE10s | CPU usage within last 10 seconds.|
</td> | PName | Name of the process. |
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p372373015515"><a name="p372373015515"></a><a name="p372373015515"></a>Process ID</p> | TID | Task ID. |
</td> | StackSize | Size of the task stack. |
</tr> | WaterLine | Peak value of the stack used. |
<tr id="row1373513035514"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p972343012551"><a name="p972343012551"></a><a name="p972343012551"></a>PPID</p> | MEMUSE | Memory usage. |
</td> | TaskName | Task name. |
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p19723153055519"><a name="p19723153055519"></a><a name="p19723153055519"></a>Parent process ID</p>
</td>
</tr>
<tr id="row16735133035518"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p14723153065514"><a name="p14723153065514"></a><a name="p14723153065514"></a>PGID</p>
</td>
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p117231630165519"><a name="p117231630165519"></a><a name="p117231630165519"></a>Process group ID</p>
</td>
</tr>
<tr id="row157354306558"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p3723430195510"><a name="p3723430195510"></a><a name="p3723430195510"></a>UID</p>
</td>
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p1372373016559"><a name="p1372373016559"></a><a name="p1372373016559"></a>User ID</p>
</td>
</tr>
<tr id="row573515301555"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p1472318308552"><a name="p1472318308552"></a><a name="p1472318308552"></a>Status</p>
</td>
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p57231430165518"><a name="p57231430165518"></a><a name="p57231430165518"></a>Current task status</p>
</td>
</tr>
<tr id="row15735730135515"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p472363045510"><a name="p472363045510"></a><a name="p472363045510"></a>CPUUSE10s</p>
</td>
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p1172323019556"><a name="p1172323019556"></a><a name="p1172323019556"></a>CPU usage within last 10 seconds</p>
</td>
</tr>
<tr id="row16735163025519"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p10723183035516"><a name="p10723183035516"></a><a name="p10723183035516"></a>PName</p>
</td>
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p1472310309557"><a name="p1472310309557"></a><a name="p1472310309557"></a>Process name</p>
</td>
</tr>
<tr id="row973593017554"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p13724123075515"><a name="p13724123075515"></a><a name="p13724123075515"></a>TID</p>
</td>
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p12724630135510"><a name="p12724630135510"></a><a name="p12724630135510"></a>Task ID</p>
</td>
</tr>
<tr id="row157341730135512"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p87241930135520"><a name="p87241930135520"></a><a name="p87241930135520"></a>StackSize</p>
</td>
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p8724930135519"><a name="p8724930135519"></a><a name="p8724930135519"></a>Size of the task stack</p>
</td>
</tr>
<tr id="row187341330145517"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p1172483055520"><a name="p1172483055520"></a><a name="p1172483055520"></a>WaterLine</p>
</td>
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p10724103013559"><a name="p10724103013559"></a><a name="p10724103013559"></a>Peak value of the stack used</p>
</td>
</tr>
<tr id="row473473025513"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p87240306554"><a name="p87240306554"></a><a name="p87240306554"></a>MEMUSE</p>
</td>
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p10724123005519"><a name="p10724123005519"></a><a name="p10724123005519"></a>Memory usage</p>
</td>
</tr>
<tr id="row18734143035519"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p7724163011559"><a name="p7724163011559"></a><a name="p7724163011559"></a>TaskName</p>
</td>
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p872414301552"><a name="p872414301552"></a><a name="p872414301552"></a>Task name</p>
</td>
</tr>
</tbody>
</table>
# uname # uname
## Command Function<a name="section107697383115"></a>
## Command Function
This command is used to display the name, version creation time, system name, and version information of the current operating system. This command is used to display the name, version creation time, system name, and version information of the current operating system.
## Syntax<a name="section162824341116"></a>
## Syntax
uname \[_-a | -s | -r | -m | -n | -v | --help_\]
uname [_-a | -s | -r | -m | -n | -v | --help_]
**Table 1** Parameters
<a name="table909mcpsimp"></a> **Table 1** Parameter description
<table><thead align="left"><tr id="row914mcpsimp"><th class="cellrowborder" valign="top" width="33.989999999999995%" id="mcps1.2.3.1.1"><p id="p916mcpsimp"><a name="p916mcpsimp"></a><a name="p916mcpsimp"></a>Parameter</p>
</th> | Parameter | Description |
<th class="cellrowborder" valign="top" width="66.01%" id="mcps1.2.3.1.2"><p id="p918mcpsimp"><a name="p918mcpsimp"></a><a name="p918mcpsimp"></a>Parameters</p> | ------ | ----------------------- |
</th> | --help | Displays help information.|
</tr> | No parameter| Displays the operating system name by default. |
</thead> | -a | Displays all data. |
<tbody><tr id="row7659172561412"><td class="cellrowborder" valign="top" width="33.989999999999995%" headers="mcps1.2.3.1.1 "><p id="p9648112519147"><a name="p9648112519147"></a><a name="p9648112519147"></a>--help</p> | -s | Displays the operating system name. |
</td> | -r | Displays the kernel release version. |
<td class="cellrowborder" valign="top" width="66.01%" headers="mcps1.2.3.1.2 "><p id="p1664862551411"><a name="p1664862551411"></a><a name="p1664862551411"></a>Displays help information.</p> | -m | Displays the operating system architecture name. |
</td> | -n | Displays the network domain name of the host. |
</tr> | -v | Displays version information. |
<tr id="row365962510147"><td class="cellrowborder" valign="top" width="33.989999999999995%" headers="mcps1.2.3.1.1 "><p id="p26489259149"><a name="p26489259149"></a><a name="p26489259149"></a>No parameter</p>
</td>
<td class="cellrowborder" valign="top" width="66.01%" headers="mcps1.2.3.1.2 "><p id="p186484252141"><a name="p186484252141"></a><a name="p186484252141"></a>Displays the operating system name by default.</p> ## Usage Guidelines
</td>
</tr> - The **uname** command displays the name of the current operating system by default.
<tr id="row12659142511413"><td class="cellrowborder" valign="top" width="33.989999999999995%" headers="mcps1.2.3.1.1 "><p id="p156481253140"><a name="p156481253140"></a><a name="p156481253140"></a>-a</p>
</td> - Except **--help** and **-a**, other parameters can be used together. **uname -a** is equivalent to **uname -srmnv**.
<td class="cellrowborder" valign="top" width="66.01%" headers="mcps1.2.3.1.2 "><p id="p864872512145"><a name="p864872512145"></a><a name="p864872512145"></a>Displays all information.</p>
</td> ## Note
</tr>
<tr id="row365917254143"><td class="cellrowborder" valign="top" width="33.989999999999995%" headers="mcps1.2.3.1.1 "><p id="p136481625131417"><a name="p136481625131417"></a><a name="p136481625131417"></a>-s</p> The **-r**, **-m**, and **-n** parameters are not supported currently. mksh supports these parameters. To switch to mksh, run **cd bin** and **./mksh**.
</td>
<td class="cellrowborder" valign="top" width="66.01%" headers="mcps1.2.3.1.2 "><p id="p1064852514149"><a name="p1064852514149"></a><a name="p1064852514149"></a>Displays the operating system name.</p> ## Example
</td>
</tr>
<tr id="row196591425101413"><td class="cellrowborder" valign="top" width="33.989999999999995%" headers="mcps1.2.3.1.1 "><p id="p364814255144"><a name="p364814255144"></a><a name="p364814255144"></a>-r</p>
</td>
<td class="cellrowborder" valign="top" width="66.01%" headers="mcps1.2.3.1.2 "><p id="p1564872515145"><a name="p1564872515145"></a><a name="p1564872515145"></a>Displays the kernel release version.</p>
</td>
</tr>
<tr id="row10659202591419"><td class="cellrowborder" valign="top" width="33.989999999999995%" headers="mcps1.2.3.1.1 "><p id="p11648162520146"><a name="p11648162520146"></a><a name="p11648162520146"></a>-m</p>
</td>
<td class="cellrowborder" valign="top" width="66.01%" headers="mcps1.2.3.1.2 "><p id="p136489251143"><a name="p136489251143"></a><a name="p136489251143"></a>Displays the operating system architecture name.</p>
</td>
</tr>
<tr id="row126582025111417"><td class="cellrowborder" valign="top" width="33.989999999999995%" headers="mcps1.2.3.1.1 "><p id="p13648102551411"><a name="p13648102551411"></a><a name="p13648102551411"></a>-n</p>
</td>
<td class="cellrowborder" valign="top" width="66.01%" headers="mcps1.2.3.1.2 "><p id="p6648132512141"><a name="p6648132512141"></a><a name="p6648132512141"></a>Displays the network domain name of the host.</p>
</td>
</tr>
<tr id="row3658925151415"><td class="cellrowborder" valign="top" width="33.989999999999995%" headers="mcps1.2.3.1.1 "><p id="p9648152501414"><a name="p9648152501414"></a><a name="p9648152501414"></a>-v</p>
</td>
<td class="cellrowborder" valign="top" width="66.01%" headers="mcps1.2.3.1.2 "><p id="p46489250149"><a name="p46489250149"></a><a name="p46489250149"></a>Displays version information.</p>
</td>
</tr>
</tbody>
</table>
## Usage<a name="section2652124861114"></a>
- The **uname** command displays the name of the current operating system by default.
- Except **--help** and **-a**, other parameters can be used together. **uname -a** is equivalent to **uname -srmnv**.
## Example<a name="section0107995132"></a>
Run the following commands: Run the following commands:
- uname -a - uname -a
- uname -ms
- uname -ms
## Output<a name="section1215113245511"></a>
## Output
Example 1: all information of the operating system Example 1: all information of the operating system
``` ```
OHOS:/$ uname -a OHOS:/$ uname -a
LiteOS hisilicon 2.0.x.x Huawei LiteOS 2.0.x.x Oct 21 2021 17:39:32 Cortex-A7 LiteOS hisilicon 2.0.0.37 LiteOS 2.0.0.37 Oct 21 2021 17:39:32 Cortex-A7
OHOS:/$ OHOS:/$
``` ```
...@@ -89,4 +61,3 @@ OHOS:/$ uname -ms ...@@ -89,4 +61,3 @@ OHOS:/$ uname -ms
LiteOS Cortex-A7 LiteOS Cortex-A7
OHOS:/$ OHOS:/$
``` ```
# vmm # vmm
## Command Function<a name="section445335110416"></a>
## Command Function
This command is used to query the virtual memory used by a process. This command is used to query the virtual memory used by a process.
## Syntax<a name="section1795712553416"></a>
## Syntax
- vmm \[_-a / -h / --help_\]
- vmm \[_pid_\] - vmm [_-a / -h / --help_]
## Parameters<a name="section92544592410"></a> - vmm [_pid_]
**Table 1** Parameter description
## Parameters
<a name="table3900mcpsimp"></a>
<table><thead align="left"><tr id="row3906mcpsimp"><th class="cellrowborder" valign="top" width="21%" id="mcps1.2.4.1.1"><p id="p3908mcpsimp"><a name="p3908mcpsimp"></a><a name="p3908mcpsimp"></a>Parameter</p> **Table 1** Parameter description
</th>
<th class="cellrowborder" valign="top" width="52%" id="mcps1.2.4.1.2"><p id="p3910mcpsimp"><a name="p3910mcpsimp"></a><a name="p3910mcpsimp"></a>Description</p> | Parameter| Description| Value Range|
</th> | -------- | -------- | -------- |
<th class="cellrowborder" valign="top" width="27%" id="mcps1.2.4.1.3"><p id="p3912mcpsimp"><a name="p3912mcpsimp"></a><a name="p3912mcpsimp"></a>Value Range</p> | -a | Displays the virtual memory usage of all processes.| N/A |
</th> | -h&nbsp;\|&nbsp;--help | Displays help information.| N/A |
</tr> | pid | Specifies the ID of the process to query.| [0, 63] |
</thead>
<tbody><tr id="row3913mcpsimp"><td class="cellrowborder" valign="top" width="21%" headers="mcps1.2.4.1.1 "><p id="p17944444181717"><a name="p17944444181717"></a><a name="p17944444181717"></a>-a</p>
</td> ## Usage Guidelines
<td class="cellrowborder" valign="top" width="52%" headers="mcps1.2.4.1.2 "><p id="p209441344121716"><a name="p209441344121716"></a><a name="p209441344121716"></a>Displays the virtual memory usage of all processes.</p>
</td>
<td class="cellrowborder" valign="top" width="27%" headers="mcps1.2.4.1.3 "><p id="p3919mcpsimp"><a name="p3919mcpsimp"></a><a name="p3919mcpsimp"></a>N/A</p>
</td>
</tr>
<tr id="row3920mcpsimp"><td class="cellrowborder" valign="top" width="21%" headers="mcps1.2.4.1.1 "><p id="p1944124412171"><a name="p1944124412171"></a><a name="p1944124412171"></a>-h | --help</p>
</td>
<td class="cellrowborder" valign="top" width="52%" headers="mcps1.2.4.1.2 "><p id="p1494494441713"><a name="p1494494441713"></a><a name="p1494494441713"></a>Displays help information.</p>
</td>
<td class="cellrowborder" valign="top" width="27%" headers="mcps1.2.4.1.3 "><p id="p3926mcpsimp"><a name="p3926mcpsimp"></a><a name="p3926mcpsimp"></a>N/A</p>
</td>
</tr>
<tr id="row3934mcpsimp"><td class="cellrowborder" valign="top" width="21%" headers="mcps1.2.4.1.1 "><p id="p5945444181720"><a name="p5945444181720"></a><a name="p5945444181720"></a>pid</p>
</td>
<td class="cellrowborder" valign="top" width="52%" headers="mcps1.2.4.1.2 "><p id="p1594515442177"><a name="p1594515442177"></a><a name="p1594515442177"></a>Specifies the ID of the process to query.</p>
</td>
<td class="cellrowborder" valign="top" width="27%" headers="mcps1.2.4.1.3 "><p id="p3940mcpsimp"><a name="p3940mcpsimp"></a><a name="p3940mcpsimp"></a>[0,63]</p>
</td>
</tr>
</tbody>
</table>
## Usage<a name="section104151141252"></a>
By default, this command displays the virtual memory usage of all processes. By default, this command displays the virtual memory usage of all processes.
## Example<a name="section11545171957"></a>
Run **vmm 3**. ## Example
## Output<a name="section075617368542"></a> Run **vmm 3**.
## Output
Virtual memory usage of process 3: Virtual memory usage of process 3:
...@@ -82,92 +62,25 @@ OHOS # vmm 3 ...@@ -82,92 +62,25 @@ OHOS # vmm 3
0x408c3ce0 /lib/libc++.so 0x23cb0000 0x00001000 CH US RD WR 1 1 0x408c3ce0 /lib/libc++.so 0x23cb0000 0x00001000 CH US RD WR 1 1
``` ```
**Table 2** Basic process information **Table 2** Basic process information
<a name="table17136143042317"></a> | Parameter| Description|
<table><thead align="left"><tr id="row1113611307232"><th class="cellrowborder" valign="top" width="50%" id="mcps1.2.3.1.1"><p id="p17137173017232"><a name="p17137173017232"></a><a name="p17137173017232"></a>Parameter</p> | -------- | -------- |
</th> | PID | Process ID.|
<th class="cellrowborder" valign="top" width="50%" id="mcps1.2.3.1.2"><p id="p171371302230"><a name="p171371302230"></a><a name="p171371302230"></a>Description</p> | aspace | Address of the virtual memory control block.|
</th> | name | Process name.|
</tr> | base | Start address of the virtual memory.|
</thead> | size | Total Virtual Memory.|
<tbody><tr id="row11371230202317"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p0137630122313"><a name="p0137630122313"></a><a name="p0137630122313"></a>PID</p> | pages | Number of used physical pages.|
</td>
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p513793016233"><a name="p513793016233"></a><a name="p513793016233"></a>Process ID</p> **Table 3** Virtual memory interval information
</td>
</tr> | Parameter| Description|
<tr id="row61371630112315"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p18137133019236"><a name="p18137133019236"></a><a name="p18137133019236"></a>aspace</p> | -------- | -------- |
</td> | region | Address of the control block in the virtual memory region.|
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p9137130122311"><a name="p9137130122311"></a><a name="p9137130122311"></a>Address of the virtual memory control block</p> | name | Name of the virtual memory region.|
</td> | base | Start address of the virtual memory region.|
</tr> | size | Size of the virtual memory region.|
<tr id="row613793015232"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p12137230172311"><a name="p12137230172311"></a><a name="p12137230172311"></a>name</p> | mmu_flags | MMU mapping attribute of the virtual memory region.|
</td> | pages | Number of used physical pages, including that of the shared memory.|
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p19137193018235"><a name="p19137193018235"></a><a name="p19137193018235"></a>Process name</p> | pg/ref | Number of used physical pages.|
</td>
</tr>
<tr id="row1613763019237"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p1413723015233"><a name="p1413723015233"></a><a name="p1413723015233"></a>base</p>
</td>
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p1613783082319"><a name="p1613783082319"></a><a name="p1613783082319"></a>Start address of the virtual memory</p>
</td>
</tr>
<tr id="row141376308237"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p101371730162319"><a name="p101371730162319"></a><a name="p101371730162319"></a>size</p>
</td>
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p18137143092313"><a name="p18137143092313"></a><a name="p18137143092313"></a>Size of virtual memory</p>
</td>
</tr>
<tr id="row19137163072316"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p16137183013235"><a name="p16137183013235"></a><a name="p16137183013235"></a>pages</p>
</td>
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p5137130142314"><a name="p5137130142314"></a><a name="p5137130142314"></a>Number of used physical pages</p>
</td>
</tr>
</tbody>
</table>
**Table 3** Virtual memory region information
<a name="table1195314682418"></a>
<table><thead align="left"><tr id="row14953144632413"><th class="cellrowborder" valign="top" width="50%" id="mcps1.2.3.1.1"><p id="p1195314617242"><a name="p1195314617242"></a><a name="p1195314617242"></a>Parameter</p>
</th>
<th class="cellrowborder" valign="top" width="50%" id="mcps1.2.3.1.2"><p id="p13953174614243"><a name="p13953174614243"></a><a name="p13953174614243"></a>Description</p>
</th>
</tr>
</thead>
<tbody><tr id="row18953114610242"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p09531746132417"><a name="p09531746132417"></a><a name="p09531746132417"></a>region</p>
</td>
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p1795344642412"><a name="p1795344642412"></a><a name="p1795344642412"></a>Address of the control block in the virtual memory region</p>
</td>
</tr>
<tr id="row1795384682411"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p199531846112417"><a name="p199531846112417"></a><a name="p199531846112417"></a>name</p>
</td>
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p19539466245"><a name="p19539466245"></a><a name="p19539466245"></a>Name of the virtual memory region</p>
</td>
</tr>
<tr id="row99531446132410"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p139531946132417"><a name="p139531946132417"></a><a name="p139531946132417"></a>base</p>
</td>
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p139536468242"><a name="p139536468242"></a><a name="p139536468242"></a>Start address of the virtual memory region</p>
</td>
</tr>
<tr id="row79531046122418"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p11953546102418"><a name="p11953546102418"></a><a name="p11953546102418"></a>size</p>
</td>
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p89531246142419"><a name="p89531246142419"></a><a name="p89531246142419"></a>Size of the virtual memory region</p>
</td>
</tr>
<tr id="row1295315464240"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p7953154602419"><a name="p7953154602419"></a><a name="p7953154602419"></a>mmu_flags</p>
</td>
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p395464620242"><a name="p395464620242"></a><a name="p395464620242"></a>MMU mapping attribute of the virtual memory region</p>
</td>
</tr>
<tr id="row10954154692413"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p1195484642410"><a name="p1195484642410"></a><a name="p1195484642410"></a>pages</p>
</td>
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p29541546112416"><a name="p29541546112416"></a><a name="p29541546112416"></a>Number of used physical pages, including that of the shared memory</p>
</td>
</tr>
<tr id="row1395411463246"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p14954146152418"><a name="p14954146152418"></a><a name="p14954146152418"></a>pg/ref</p>
</td>
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p10954164642419"><a name="p10954164642419"></a><a name="p10954164642419"></a>Number of used physical pages</p>
</td>
</tr>
</tbody>
</table>
# watch # watch
## Command Function<a name="section20643141481314"></a>
## Command Function
This command is used to periodically run the specified command and display its execution result. This command is used to periodically run the specified command and display its execution result.
## Syntax<a name="section1075441721316"></a>
## Syntax
- watch
- watch \[_-c/-n/-t/--count/--interval/-no-title/--over_\] \[_command_\] - watch
## Parameters<a name="section1472810220135"></a> - watch [_-c/-n/-t/--count/--interval/-no-title/--over_] [_command_]
**Table 1** Parameter description
## Parameters
<a name="table966mcpsimp"></a>
<table><thead align="left"><tr id="row973mcpsimp"><th class="cellrowborder" valign="top" width="19.801980198019802%" id="mcps1.2.5.1.1"><p id="p975mcpsimp"><a name="p975mcpsimp"></a><a name="p975mcpsimp"></a>Parameter</p> **Table 1** Parameter description
</th>
<th class="cellrowborder" valign="top" width="29.222922292229224%" id="mcps1.2.5.1.2"><p id="p977mcpsimp"><a name="p977mcpsimp"></a><a name="p977mcpsimp"></a>Description</p> | Parameter| Description| Default Value| Value Range|
</th> | -------- | -------- | -------- | -------- |
<th class="cellrowborder" valign="top" width="22.26222622262226%" id="mcps1.2.5.1.3"><p id="p979mcpsimp"><a name="p979mcpsimp"></a><a name="p979mcpsimp"></a>Default Value</p> | -c&nbsp;/&nbsp;--count | Specifies the number of times that the specified command is executed.| 0xFFFFFF | (0, 0xFFFFFF]|
</th> | -n&nbsp;/&nbsp;--interval | Specifies the interval for running the command, in seconds.| 1s | (0, 0xFFFFFF]|
<th class="cellrowborder" valign="top" width="28.712871287128717%" id="mcps1.2.5.1.4"><p id="p981mcpsimp"><a name="p981mcpsimp"></a><a name="p981mcpsimp"></a>Value Range</p> | -t&nbsp;/&nbsp;-no-title | Disables time display on the top.| N/A | N/A |
</th> | command | Specifies the command to be monitored.| N/A | N/A |
</tr> | --over | Stops the current command monitoring.| N/A | N/A |
</thead>
<tbody><tr id="row982mcpsimp"><td class="cellrowborder" valign="top" width="19.801980198019802%" headers="mcps1.2.5.1.1 "><p id="p984mcpsimp"><a name="p984mcpsimp"></a><a name="p984mcpsimp"></a>-c / --count</p>
</td> ## Usage Guidelines
<td class="cellrowborder" valign="top" width="29.222922292229224%" headers="mcps1.2.5.1.2 "><p id="p986mcpsimp"><a name="p986mcpsimp"></a><a name="p986mcpsimp"></a>Specifies the number of times that the specified command is executed.</p>
</td> You can run the **watch --over** command to stop monitoring of the specified command.
<td class="cellrowborder" valign="top" width="22.26222622262226%" headers="mcps1.2.5.1.3 "><p id="p988mcpsimp"><a name="p988mcpsimp"></a><a name="p988mcpsimp"></a>0xFFFFFF</p>
</td>
<td class="cellrowborder" valign="top" width="28.712871287128717%" headers="mcps1.2.5.1.4 "><p id="p990mcpsimp"><a name="p990mcpsimp"></a><a name="p990mcpsimp"></a>(0, 0xFFFFFF]</p> ## Example
</td>
</tr> Run **watch -n 2 -c 6 task**.
<tr id="row991mcpsimp"><td class="cellrowborder" valign="top" width="19.801980198019802%" headers="mcps1.2.5.1.1 "><p id="p993mcpsimp"><a name="p993mcpsimp"></a><a name="p993mcpsimp"></a>-n / --interval</p>
</td>
<td class="cellrowborder" valign="top" width="29.222922292229224%" headers="mcps1.2.5.1.2 "><p id="p995mcpsimp"><a name="p995mcpsimp"></a><a name="p995mcpsimp"></a>Specifies the interval (in seconds) for periodically running the specified command.</p> ## Output
</td>
<td class="cellrowborder" valign="top" width="22.26222622262226%" headers="mcps1.2.5.1.3 "><p id="p997mcpsimp"><a name="p997mcpsimp"></a><a name="p997mcpsimp"></a>1s</p> Example: The **task** command is executed six times at an interval of 2 seconds.
</td>
<td class="cellrowborder" valign="top" width="28.712871287128717%" headers="mcps1.2.5.1.4 "><p id="p999mcpsimp"><a name="p999mcpsimp"></a><a name="p999mcpsimp"></a>(0, 0xFFFFFF]</p>
</td>
</tr>
<tr id="row1000mcpsimp"><td class="cellrowborder" valign="top" width="19.801980198019802%" headers="mcps1.2.5.1.1 "><p id="p1002mcpsimp"><a name="p1002mcpsimp"></a><a name="p1002mcpsimp"></a>-t / -no-title</p>
</td>
<td class="cellrowborder" valign="top" width="29.222922292229224%" headers="mcps1.2.5.1.2 "><p id="p1004mcpsimp"><a name="p1004mcpsimp"></a><a name="p1004mcpsimp"></a>Disables time display on the top.</p>
</td>
<td class="cellrowborder" valign="top" width="22.26222622262226%" headers="mcps1.2.5.1.3 "><p id="p1006mcpsimp"><a name="p1006mcpsimp"></a><a name="p1006mcpsimp"></a>N/A</p>
</td>
<td class="cellrowborder" valign="top" width="28.712871287128717%" headers="mcps1.2.5.1.4 "><p id="p1008mcpsimp"><a name="p1008mcpsimp"></a><a name="p1008mcpsimp"></a>N/A</p>
</td>
</tr>
<tr id="row1009mcpsimp"><td class="cellrowborder" valign="top" width="19.801980198019802%" headers="mcps1.2.5.1.1 "><p id="p1011mcpsimp"><a name="p1011mcpsimp"></a><a name="p1011mcpsimp"></a>command</p>
</td>
<td class="cellrowborder" valign="top" width="29.222922292229224%" headers="mcps1.2.5.1.2 "><p id="p1013mcpsimp"><a name="p1013mcpsimp"></a><a name="p1013mcpsimp"></a>Specifies the command to be monitored.</p>
</td>
<td class="cellrowborder" valign="top" width="22.26222622262226%" headers="mcps1.2.5.1.3 "><p id="p1015mcpsimp"><a name="p1015mcpsimp"></a><a name="p1015mcpsimp"></a>N/A</p>
</td>
<td class="cellrowborder" valign="top" width="28.712871287128717%" headers="mcps1.2.5.1.4 "><p id="p1017mcpsimp"><a name="p1017mcpsimp"></a><a name="p1017mcpsimp"></a>N/A</p>
</td>
</tr>
<tr id="row1018mcpsimp"><td class="cellrowborder" valign="top" width="19.801980198019802%" headers="mcps1.2.5.1.1 "><p id="p1020mcpsimp"><a name="p1020mcpsimp"></a><a name="p1020mcpsimp"></a>--over</p>
</td>
<td class="cellrowborder" valign="top" width="29.222922292229224%" headers="mcps1.2.5.1.2 "><p id="p1022mcpsimp"><a name="p1022mcpsimp"></a><a name="p1022mcpsimp"></a>Stops the current command monitoring.</p>
</td>
<td class="cellrowborder" valign="top" width="22.26222622262226%" headers="mcps1.2.5.1.3 "><p id="p1024mcpsimp"><a name="p1024mcpsimp"></a><a name="p1024mcpsimp"></a>N/A</p>
</td>
<td class="cellrowborder" valign="top" width="28.712871287128717%" headers="mcps1.2.5.1.4 "><p id="p1026mcpsimp"><a name="p1026mcpsimp"></a><a name="p1026mcpsimp"></a>N/A</p>
</td>
</tr>
</tbody>
</table>
## Usage<a name="section186772414131"></a>
You can run the **watch --over** command to stop monitoring of the specified command.
## Example<a name="section4764192791314"></a>
Run **watch -n 2 -c 6 task**.
## Output<a name="section5791253155517"></a>
Example: The **task** command is executed six times at an interval of 2 seconds.
``` ```
OHOS # watch -n 2 -c 6 task OHOS # watch -n 2 -c 6 task
...@@ -121,4 +77,3 @@ OHOS # ...@@ -121,4 +77,3 @@ OHOS #
17 2 0x3 0 Running 0x3000 0x73c 0.0 0 shellcmd_watch 17 2 0x3 0 Running 0x3000 0x73c 0.0 0 shellcmd_watch
18 2 0x3 -1 Pending 0x2710 0x3ac 0.0 0 GPIO_IRQ_TSK_0_4 18 2 0x3 -1 Pending 0x2710 0x3ac 0.0 0 GPIO_IRQ_TSK_0_4
``` ```
# cat # cat
## Command Function<a name="section16710153391315"></a>
## Command Function
This command is used to display the content of a text file. This command is used to display the content of a text file.
## Syntax<a name="section1699392313158"></a>
cat \[_pathname_\] ## Syntax
cat [_pathname_]
## Parameters<a name="section1677217374136"></a> ## Parameters
**Table 1** Parameter description **Table 1** Parameter description
<a name="table1049mcpsimp"></a> | Parameter| Description| Value Range|
<table><thead align="left"><tr id="row1055mcpsimp"><th class="cellrowborder" valign="top" width="21%" id="mcps1.2.4.1.1"><p id="p1057mcpsimp"><a name="p1057mcpsimp"></a><a name="p1057mcpsimp"></a><strong id="b2166111484619"><a name="b2166111484619"></a><a name="b2166111484619"></a>Parameter</strong></p> | -------- | -------- | -------- |
</th> | pathname | Specifies the file path. | An existing file |
<th class="cellrowborder" valign="top" width="52%" id="mcps1.2.4.1.2"><p id="p1059mcpsimp"><a name="p1059mcpsimp"></a><a name="p1059mcpsimp"></a><strong id="b17121718469"><a name="b17121718469"></a><a name="b17121718469"></a>Description</strong></p>
</th>
<th class="cellrowborder" valign="top" width="27%" id="mcps1.2.4.1.3"><p id="p1061mcpsimp"><a name="p1061mcpsimp"></a><a name="p1061mcpsimp"></a><strong id="b6990101716464"><a name="b6990101716464"></a><a name="b6990101716464"></a>Value Range</strong></p>
</th>
</tr>
</thead>
<tbody><tr id="row1062mcpsimp"><td class="cellrowborder" valign="top" width="21%" headers="mcps1.2.4.1.1 "><p id="p1064mcpsimp"><a name="p1064mcpsimp"></a><a name="p1064mcpsimp"></a>pathname</p>
</td>
<td class="cellrowborder" valign="top" width="52%" headers="mcps1.2.4.1.2 "><p id="p1066mcpsimp"><a name="p1066mcpsimp"></a><a name="p1066mcpsimp"></a>Specifies the file path.</p>
</td>
<td class="cellrowborder" valign="top" width="27%" headers="mcps1.2.4.1.3 "><p id="p1068mcpsimp"><a name="p1068mcpsimp"></a><a name="p1068mcpsimp"></a>An existing file</p>
</td>
</tr>
</tbody>
</table>
## Usage<a name="section186772414131"></a>
Run the **cat** \[_pathname_\] command to display the content of a text file. ## Usage Guidelines
## Example<a name="section12158131814561"></a> Run the **cat** [*pathname*] command to display the content of a text file.
Run **cat hello-harmony.txt**.
## Output<a name="section183926225561"></a> ## Example
Content of **hello-harmony.txt** Run **cat hello-openharmony.txt**.
## Output
Content of **hello-openharmony.txt**
``` ```
OHOS # cat hello-harmony.txt OHOS # cat hello-openharmony.txt
OHOS # Hello Harmony ;) OHOS # Hello openharmony ;)
``` ```
# cd # cd
## Command Function<a name="section11690184921316"></a> ## Command Function
This command is used to change the current working directory. This command is used to change the current working directory.
## Syntax<a name="section75695409569"></a>
cd \[_path_\] ## Syntax
## Parameters<a name="section71961353181311"></a> cd [_path_]
**Table 1** Parameter description
<a name="table1087mcpsimp"></a> ## Parameters
<table><thead align="left"><tr id="row1093mcpsimp"><th class="cellrowborder" valign="top" width="21%" id="mcps1.2.4.1.1"><p id="p1095mcpsimp"><a name="p1095mcpsimp"></a><a name="p1095mcpsimp"></a><strong id="b76096875111729"><a name="b76096875111729"></a><a name="b76096875111729"></a>Parameter</strong></p>
</th>
<th class="cellrowborder" valign="top" width="52%" id="mcps1.2.4.1.2"><p id="p1097mcpsimp"><a name="p1097mcpsimp"></a><a name="p1097mcpsimp"></a><strong id="b1343743615221"><a name="b1343743615221"></a><a name="b1343743615221"></a>Description</strong></p>
</th>
<th class="cellrowborder" valign="top" width="27%" id="mcps1.2.4.1.3"><p id="p1099mcpsimp"><a name="p1099mcpsimp"></a><a name="p1099mcpsimp"></a><strong id="b163024311311729"><a name="b163024311311729"></a><a name="b163024311311729"></a>Value Range</strong></p>
</th>
</tr>
</thead>
<tbody><tr id="row1100mcpsimp"><td class="cellrowborder" valign="top" width="21%" headers="mcps1.2.4.1.1 "><p id="p1102mcpsimp"><a name="p1102mcpsimp"></a><a name="p1102mcpsimp"></a>path</p>
</td>
<td class="cellrowborder" valign="top" width="52%" headers="mcps1.2.4.1.2 "><p id="p1104mcpsimp"><a name="p1104mcpsimp"></a><a name="p1104mcpsimp"></a>Specifies the target file path.</p>
</td>
<td class="cellrowborder" valign="top" width="27%" headers="mcps1.2.4.1.3 "><p id="p1106mcpsimp"><a name="p1106mcpsimp"></a><a name="p1106mcpsimp"></a>You must have the execution (search) permission for the specified directory.</p>
</td>
</tr>
</tbody>
</table>
## Usage<a name="section3629759111317"></a> **Table 1** Parameter description
- If **path** is not specified, this command switches to the root directory. | Parameter| Description| Value Range|
- If **path** is specified, this command switches to the specified directory. | -------- | -------- | -------- |
- The **path** value starting with a slash \(/\) represents the root directory. | path | Specifies the path of the new directory. | You must have the execution (search) permission on the specified directory.|
- The **path** value starting with a dot \(.\) represents the current directory.
- The **path** value starting with two dots \(..\) represents the parent directory.
- You can run **cd -** to alternate between two directories that are recently accessed.
## Example<a name="section211620301412"></a>
Run **cd ..**. ## Usage Guidelines
## Output<a name="section1968117214577"></a> - If **path** is not specified, this command switches to the root directory.
- If **path** is specified, this command switches to the specified directory.
- The **path** value starting with a slash (/) represents the root directory.
- The **path** value starting with a dot (.) represents the current directory.
- The **path** value starting with two dots (..) represents the parent directory.
- You can run **cd -** to alternate between two directories that are recently accessed.
## Example
Run **cd ..**.
## Output
Parent directory information: Parent directory information:
...@@ -55,4 +50,3 @@ OHOS:/$ ls ...@@ -55,4 +50,3 @@ OHOS:/$ ls
bin etc nfs sdcard system tmp vendor bin etc nfs sdcard system tmp vendor
dev lib proc storage test usr dev lib proc storage test usr
``` ```
# chgrp # chgrp
## Command Function<a name="section6103119161418"></a>
## Command Function
This command is used to change the file group. This command is used to change the file group.
## Syntax<a name="section186958132141"></a>
chgrp \[_group_\] \[_pathname_\] ## Syntax
chgrp [_group_] [_pathname_]
## Parameters
## Parameters<a name="section81796174141"></a> **Table 1** Parameter description
**Table 1** Parameter description | Parameter | Description | Value Range |
| -------- | ---------- | -------------- |
| group | Specifies the target file group.| [0, 0xFFFFFFFF] |
| pathname | Specifies the file path. | An existing file |
<a name="table1049mcpsimp"></a>
<table><thead align="left"><tr id="row1055mcpsimp"><th class="cellrowborder" valign="top" width="21%" id="mcps1.2.4.1.1"><p id="p1057mcpsimp"><a name="p1057mcpsimp"></a><a name="p1057mcpsimp"></a><strong id="b152503343511626"><a name="b152503343511626"></a><a name="b152503343511626"></a>Parameter</strong></p>
</th>
<th class="cellrowborder" valign="top" width="52%" id="mcps1.2.4.1.2"><p id="p1059mcpsimp"><a name="p1059mcpsimp"></a><a name="p1059mcpsimp"></a><strong id="b14728419275"><a name="b14728419275"></a><a name="b14728419275"></a>Description</strong></p>
</th>
<th class="cellrowborder" valign="top" width="27%" id="mcps1.2.4.1.3"><p id="p1061mcpsimp"><a name="p1061mcpsimp"></a><a name="p1061mcpsimp"></a><strong id="b71533702411626"><a name="b71533702411626"></a><a name="b71533702411626"></a>Value Range</strong></p>
</th>
</tr>
</thead>
<tbody><tr id="row1062mcpsimp"><td class="cellrowborder" valign="top" width="21%" headers="mcps1.2.4.1.1 "><p id="p1064mcpsimp"><a name="p1064mcpsimp"></a><a name="p1064mcpsimp"></a>group</p>
</td>
<td class="cellrowborder" valign="top" width="52%" headers="mcps1.2.4.1.2 "><p id="p1066mcpsimp"><a name="p1066mcpsimp"></a><a name="p1066mcpsimp"></a>Specifies the target file group.</p>
</td>
<td class="cellrowborder" valign="top" width="27%" headers="mcps1.2.4.1.3 "><p id="p1068mcpsimp"><a name="p1068mcpsimp"></a><a name="p1068mcpsimp"></a>[0, 0xFFFFFFFF]</p>
</td>
</tr>
<tr id="row172161126124218"><td class="cellrowborder" valign="top" width="21%" headers="mcps1.2.4.1.1 "><p id="p12217026154215"><a name="p12217026154215"></a><a name="p12217026154215"></a>pathname</p>
</td>
<td class="cellrowborder" valign="top" width="52%" headers="mcps1.2.4.1.2 "><p id="p4218826194210"><a name="p4218826194210"></a><a name="p4218826194210"></a>Specifies the file path.</p>
</td>
<td class="cellrowborder" valign="top" width="27%" headers="mcps1.2.4.1.3 "><p id="p182181026104214"><a name="p182181026104214"></a><a name="p182181026104214"></a>An existing file</p>
</td>
</tr>
</tbody>
</table>
## Usage<a name="section14330152417140"></a> ## Usage Guidelines
- Specify **group** to change the file group. - Specify **group** to change the file group.
- For the FAT file system, this command cannot be used to change user group IDs. - For the FAT file system, this command cannot be used to change user group IDs.
## Example<a name="section951823119149"></a> ## Note
Run **chgrp 100 testfile**. Currently, the shell does not support this command.
## Output<a name="section14271133125715"></a> ## Example
Changing the group ID of the **testfile** file in the **dev/** directory to **100** Run **chgrp 100 testfile**.
## Output
Change the group ID of the **testfile** file in the **dev/** directory to **100**.
``` ```
OHOS:/dev$ ll testfile OHOS:/dev$ ll testfile
...@@ -59,4 +47,3 @@ OHOS:/dev$ ll testfile ...@@ -59,4 +47,3 @@ OHOS:/dev$ ll testfile
-rw-r--r-- 0 0 100 0 1970-01-01 00:00 testfile -rw-r--r-- 0 0 100 0 1970-01-01 00:00 testfile
OHOS:/dev$ OHOS:/dev$
``` ```
# chmod # chmod
## Command Function<a name="section13992936121418"></a>
## Command Function
This command is used to change file operation permissions. This command is used to change file operation permissions.
## Syntax<a name="section63342439147"></a>
chmod \[_mode_\] \[_filename_\] ## Syntax
chmod [_mode_] [_filename_]
## Parameters
**Table 1** Parameter description
## Parameter Description<a name="section894414671411"></a> | Parameter | Description | Value Range |
| -------- | ------------------------------------------------------------ | -------------- |
| mode | Specifies the permissions for a file or directory. The value is an octal number, representing the permission of **User** (owner), **Group** (group), or **Others** (other groups).| [0, 777] |
| filename | Specifies the file path. | An existing file |
**Table 1** Parameters
<a name="table1049mcpsimp"></a> ## Usage Guidelines
<table><thead align="left"><tr id="row1055mcpsimp"><th class="cellrowborder" valign="top" width="21%" id="mcps1.2.4.1.1"><p id="p1057mcpsimp"><a name="p1057mcpsimp"></a><a name="p1057mcpsimp"></a>Parameter</p>
</th>
<th class="cellrowborder" valign="top" width="52%" id="mcps1.2.4.1.2"><p id="p1059mcpsimp"><a name="p1059mcpsimp"></a><a name="p1059mcpsimp"></a>Description</p>
</th>
<th class="cellrowborder" valign="top" width="27%" id="mcps1.2.4.1.3"><p id="p1061mcpsimp"><a name="p1061mcpsimp"></a><a name="p1061mcpsimp"></a>Value Range</p>
</th>
</tr>
</thead>
<tbody><tr id="row2981144101719"><td class="cellrowborder" valign="top" width="21%" headers="mcps1.2.4.1.1 "><p id="p20916441173"><a name="p20916441173"></a><a name="p20916441173"></a>mode</p>
</td>
<td class="cellrowborder" valign="top" width="52%" headers="mcps1.2.4.1.2 "><p id="p3911344161713"><a name="p3911344161713"></a><a name="p3911344161713"></a>Specifies the permissions for a file or directory. The value is an octal number, representing the permission of <strong id="b11602834153114"><a name="b11602834153114"></a><a name="b11602834153114"></a>User</strong> (owner), <strong id="b032113853120"><a name="b032113853120"></a><a name="b032113853120"></a>Group</strong> (group), or <strong id="b1980114418310"><a name="b1980114418310"></a><a name="b1980114418310"></a>Others</strong> (other groups).</p>
</td>
<td class="cellrowborder" valign="top" width="27%" headers="mcps1.2.4.1.3 "><p id="p1591744161719"><a name="p1591744161719"></a><a name="p1591744161719"></a>[0,777]</p>
</td>
</tr>
<tr id="row15985440173"><td class="cellrowborder" valign="top" width="21%" headers="mcps1.2.4.1.1 "><p id="p99124461717"><a name="p99124461717"></a><a name="p99124461717"></a>filename</p>
</td>
<td class="cellrowborder" valign="top" width="52%" headers="mcps1.2.4.1.2 "><p id="p149134481719"><a name="p149134481719"></a><a name="p149134481719"></a>Specifies the file name.</p>
</td>
<td class="cellrowborder" valign="top" width="27%" headers="mcps1.2.4.1.3 "><p id="p0911144181712"><a name="p0911144181712"></a><a name="p0911144181712"></a>An existing file</p>
</td>
</tr>
</tbody>
</table>
## Usage<a name="section182415221419"></a> - Specify **mode** to change file permissions.
- Specify **mode** to change file permissions. - For the files created on the FAT file system, the file permission attributes are the same as those of the mounted nodes. Currently, the node permissions include only user read and write. The **group** and **others** permissions do not take effect. In addition, only the user read and write permissions can be modified. The read and write permissions are **rw** and **ro** only. There is no such restriction for other file systems.
- For the files created on the FAT file system, the file permission attributes are the same as those of the mounted nodes. Currently, the node permissions include only user read and write. The **group** and **others** permissions do not take effect. In addition, only the user read and write permissions can be modified. The read and write permissions are **rw** and **ro** only. There is no such restriction for other file systems.
## Example<a name="section8518195718147"></a> ## Note
Change the permissions on the **hello-harmony.txt** file to **644** and **777**. Currently, the shell does not support this command.
## Output<a name="section127391818158"></a> ## Example
Modifying the permissions on the **hello-harmony.txt** file in the **/dev** directory: Change the permissions on the **hello-openharmony.txt** file to **644** and **777**.
## Output
Modify the permissions on the **hello-openharmony.txt** file in the **/dev** directory.
``` ```
OHOS:/dev$ chmod 644 hello-harmony.txt OHOS:/dev$ chmod 644 hello-openharmony.txt
OHOS:/dev$ ll hello-harmony.txt OHOS:/dev$ ll hello-openharmony.txt
-rw-r--r-- 0 0 0 0 1970-01-01 00:00 hello-harmony.txt -rw-r--r-- 0 0 0 0 1970-01-01 00:00 hello-openharmony.txt
OHOS:/dev$ chmod 777 hello-harmony.txt OHOS:/dev$ chmod 777 hello-openharmony.txt
OHOS:/dev$ ll hello-harmony.txt OHOS:/dev$ ll hello-openharmony.txt
-rwxrwxrwx 0 0 0 0 1970-01-01 00:00 hello-harmony.txt -rwxrwxrwx 0 0 0 0 1970-01-01 00:00 hello-openharmony.txt
``` ```
# chown # chown
## Command Function<a name="section247414691513"></a>
## Command Function
This command is used to change the owner of a file. This command is used to change the owner of a file.
## Syntax<a name="section14773151018159"></a>
## Syntax
chown \[_owner_\] \[_pathname_\]
chown [_owner_] [_pathname_]
## Parameters<a name="section598731391517"></a>
**Table 1** Parameter description ## Parameters
<a name="table1049mcpsimp"></a> **Table 1** Parameter description
<table><thead align="left"><tr id="row1055mcpsimp"><th class="cellrowborder" valign="top" width="21%" id="mcps1.2.4.1.1"><p id="p1057mcpsimp"><a name="p1057mcpsimp"></a><a name="p1057mcpsimp"></a><strong id="b130925344111510"><a name="b130925344111510"></a><a name="b130925344111510"></a>Parameter</strong></p>
</th> | Parameter | Description | Value Range |
<th class="cellrowborder" valign="top" width="52%" id="mcps1.2.4.1.2"><p id="p1059mcpsimp"><a name="p1059mcpsimp"></a><a name="p1059mcpsimp"></a><strong id="b1226032904716"><a name="b1226032904716"></a><a name="b1226032904716"></a>Description</strong></p> | -------- | ------------ | -------------- |
</th> | owner | Specifies the file owner. | [0, 0xFFFFFFFF] |
<th class="cellrowborder" valign="top" width="27%" id="mcps1.2.4.1.3"><p id="p1061mcpsimp"><a name="p1061mcpsimp"></a><a name="p1061mcpsimp"></a><strong id="b34190246311510"><a name="b34190246311510"></a><a name="b34190246311510"></a>Value Range</strong></p> | pathname | Specifies the file path. | An existing file |
</th>
</tr>
</thead> ## Usage Guidelines
<tbody><tr id="row1541931122113"><td class="cellrowborder" valign="top" width="21%" headers="mcps1.2.4.1.1 "><p id="p84121716217"><a name="p84121716217"></a><a name="p84121716217"></a>owner</p>
</td>
<td class="cellrowborder" valign="top" width="52%" headers="mcps1.2.4.1.2 "><p id="p14126172111"><a name="p14126172111"></a><a name="p14126172111"></a>Specifies the file owner.</p>
</td>
<td class="cellrowborder" valign="top" width="27%" headers="mcps1.2.4.1.3 "><p id="p24129113218"><a name="p24129113218"></a><a name="p24129113218"></a>[0,0xFFFFFFFF]</p>
</td>
</tr>
<tr id="row12419191192111"><td class="cellrowborder" valign="top" width="21%" headers="mcps1.2.4.1.1 "><p id="p141215115212"><a name="p141215115212"></a><a name="p141215115212"></a>pathname</p>
</td>
<td class="cellrowborder" valign="top" width="52%" headers="mcps1.2.4.1.2 "><p id="p7412315218"><a name="p7412315218"></a><a name="p7412315218"></a>Specifies the file path.</p>
</td>
<td class="cellrowborder" valign="top" width="27%" headers="mcps1.2.4.1.3 "><p id="p134126102118"><a name="p134126102118"></a><a name="p134126102118"></a>An existing file</p>
</td>
</tr>
</tbody>
</table>
## Usage<a name="section16524152071510"></a>
This command does not apply to the FAT file system. This command does not apply to the FAT file system.
## Example<a name="section17901152561510"></a> ## Note
Currently, the shell does not support this command.
Run **chown 100 testfile**. ## Example
## Output<a name="section15513163115816"></a> Run **chown 100 testfile**.
Changing the UID of the **testfile** file in **/dev** to **100**:
## Output
Change the UID of the **testfile** file in **/dev** to **100**.
``` ```
OHOS:/dev$ touch testfile OHOS:/dev$ touch testfile
...@@ -58,4 +46,3 @@ OHOS:/dev$ chown 100 testfile ...@@ -58,4 +46,3 @@ OHOS:/dev$ chown 100 testfile
OHOS:/dev$ ll testfile OHOS:/dev$ ll testfile
-rw-r--r-- 0 100 100 0 1970-01-01 00:00 testfile -rw-r--r-- 0 100 100 0 1970-01-01 00:00 testfile
``` ```
# cp # cp
## Command Function<a name="section6841203041513"></a>
## Command Function
This command is used to create a copy for a file. This command is used to create a copy for a file.
## Syntax<a name="section24286359150"></a>
## Syntax
cp \[_SOURCEFILE_\] \[_DESTFILE_\]
cp [_SOURCEFILE_] [_DESTFILE_]
## Parameters<a name="section558617385152"></a>
**Table 1** Parameter description ## Parameters
<a name="table1130mcpsimp"></a> **Table 1** Parameter description
<table><thead align="left"><tr id="row1136mcpsimp"><th class="cellrowborder" valign="top" width="21%" id="mcps1.2.4.1.1"><p id="p1138mcpsimp"><a name="p1138mcpsimp"></a><a name="p1138mcpsimp"></a><strong id="b203611832412"><a name="b203611832412"></a><a name="b203611832412"></a>Parameter</strong></p>
</th> | Parameter| Description| Value Range|
<th class="cellrowborder" valign="top" width="52%" id="mcps1.2.4.1.2"><p id="p1140mcpsimp"><a name="p1140mcpsimp"></a><a name="p1140mcpsimp"></a><strong id="b1170512342014"><a name="b1170512342014"></a><a name="b1170512342014"></a>Description</strong></p> | -------- | -------- | -------- |
</th> | --help | Displays help information.| N/A |
<th class="cellrowborder" valign="top" width="27%" id="mcps1.2.4.1.3"><p id="p1142mcpsimp"><a name="p1142mcpsimp"></a><a name="p1142mcpsimp"></a><strong id="b173835351418"><a name="b173835351418"></a><a name="b173835351418"></a>Value Range</strong></p> | SOURCEFILE | Specifies the file to copy.| This command does not support copy of a directory, but supports copy of multiple files at a time.|
</th> | DESTFILE | Specifies the file to create.| Both a directory and a file are supported.|
</tr>
</thead>
<tbody><tr id="row217620816236"><td class="cellrowborder" valign="top" width="21%" headers="mcps1.2.4.1.1 "><p id="p181687832310"><a name="p181687832310"></a><a name="p181687832310"></a>--help</p> ## Usage Guidelines
</td>
<td class="cellrowborder" valign="top" width="52%" headers="mcps1.2.4.1.2 "><p id="p181687882317"><a name="p181687882317"></a><a name="p181687882317"></a>Displays help information.</p> - The name of the source file cannot be the same as that of the destination file in the same path.
</td>
<td class="cellrowborder" valign="top" width="27%" headers="mcps1.2.4.1.3 "><p id="p18168118182312"><a name="p18168118182312"></a><a name="p18168118182312"></a>N/A</p> - **SOURCEFILE** must exist and cannot be a directory.
</td>
</tr> - The source file path supports asterisks (*) and question marks (?). The wildcard "\*" indicates any number of characters, and "?" indicates any single character. **DEST** does not support wildcard characters. If the specified **SOURCE** matches multiple files, **DEST** must be a directory.
<tr id="row1417648122313"><td class="cellrowborder" valign="top" width="21%" headers="mcps1.2.4.1.1 "><p id="p516816822316"><a name="p516816822316"></a><a name="p516816822316"></a>SOURCEFILE</p>
</td> - If **DEST** is a directory, this directory must exist. In this case, the destination file is named after the source file.
<td class="cellrowborder" valign="top" width="52%" headers="mcps1.2.4.1.2 "><p id="p81686862314"><a name="p81686862314"></a><a name="p81686862314"></a>Specifies the path of the source file.</p>
</td> - If the destination file path is a file, the directory for this file must exist. In this case, the file copy is renamed.
<td class="cellrowborder" valign="top" width="27%" headers="mcps1.2.4.1.3 "><p id="p1016811862312"><a name="p1016811862312"></a><a name="p1016811862312"></a>This command does not support copy of a directory, but supports copy of multiple files at a time.</p>
</td> - If the destination file does not exist, a new file is created. If the destination file already exists, the existing file is overwritten.
</tr>
<tr id="row191761384231"><td class="cellrowborder" valign="top" width="21%" headers="mcps1.2.4.1.1 "><p id="p13168880235"><a name="p13168880235"></a><a name="p13168880235"></a>DESTFILE</p> > **NOTICE**<br>
</td> > When important system resources are copied, unexpected results such as a system breakdown may occur. For example, when the **/dev/uartdev-1** file is copied, the system may stop responding.
<td class="cellrowborder" valign="top" width="52%" headers="mcps1.2.4.1.2 "><p id="p9168789231"><a name="p9168789231"></a><a name="p9168789231"></a>Specifies the destination file path.</p>
</td>
<td class="cellrowborder" valign="top" width="27%" headers="mcps1.2.4.1.3 "><p id="p316810810235"><a name="p316810810235"></a><a name="p316810810235"></a>Both a directory and a file are supported.</p> ## Example
</td>
</tr> Run **cp hello-OHOS.txt hello-openharmony.txt ./tmp/**.
</tbody>
</table>
## Output
## Usage<a name="section16128156162"></a>
Copy **hello-OHOS.txt** and **hello-openharmony.txt** to **/tmp/**.
- The name of the source file cannot be the same as that of the destination file in the same path.
- **SOURCEFILE** must exist and cannot be a directory.
- **SOURCEFILE** supports wildcard characters \* and ?. The asterisk \(\*\) indicates any number of characters, and the question mark \(?\) represents a single character. **DESTFILE** does not support wildcard characters. If **SOURCEFILE** specifies multiple files, **DESTFILE** must be a directory.
- If **DESTFILE** specifies a directory, this directory must exist. In this case, the destination file is named after the source file.
- If **DESTFILE** specifies a file, the directory for this file must exist. In this case, the file copy is renamed.
- If the destination file does not exist, a new file is created. If the destination file already exists, the existing file is overwritten.
>![](../public_sys-resources/icon-notice.gif) **NOTICE:**
>When important system resources are copied, unexpected results such as a system breakdown may occur. For example, when the **/dev/uartdev-1** file is copied, the system may stop responding.
## Example<a name="section19354171211618"></a>
Run **cp hello-OHOS.txt hello-harmony.txt ./tmp/**.
## Output<a name="section16754183195914"></a>
Copying **hello-OHOS.txt** and **hello-harmony.txt** to **/tmp/**:
``` ```
OHOS:/$ ls OHOS:/$ ls
bin hello-OHOS.txt proc system vendor bin hello-OHOS.txt proc system vendor
dev hello-harmony.txt sdcard userdata dev hello-openharmony.txt sdcard userdata
etc lib storage usr etc lib storage usr
OHOS:/$ mkdir tmp OHOS:/$ mkdir tmp
OHOS:/$ cp hello-OHOS.txt hello-harmony.txt tmp/ OHOS:/$ cp hello-OHOS.txt hello-openharmony.txt tmp/
OHOS:/$ ll tmp OHOS:/$ ll tmp
total 0 total 0
-rwxrwxrwx 1 0 0 0 1979-12-31 00:00 hello-OHOS.txt* -rwxrwxrwx 1 0 0 0 1979-12-31 00:00 hello-OHOS.txt*
-rwxrwxrwx 1 0 0 0 1979-12-31 00:00 hello-harmony.txt* -rwxrwxrwx 1 0 0 0 1979-12-31 00:00 hello-openharmony.txt*
``` ```
# du # du
## Command Function<a name="section201149459368"></a>
## Command Function
This command is used to query the disk space occupied by a file. This command is used to query the disk space occupied by a file.
## Syntax<a name="section579813484364"></a>
## Syntax
du \[_-kKmh_\] \[_file..._\]
du [_-kKmh_] [_file..._]
## Parameters<a name="section168065311366"></a>
**Table 1** Parameter description ## Parameters
<a name="table1845mcpsimp"></a> **Table 1** Parameter description
<table><thead align="left"><tr id="row1851mcpsimp"><th class="cellrowborder" valign="top" width="20.84%" id="mcps1.2.4.1.1"><p id="p1853mcpsimp"><a name="p1853mcpsimp"></a><a name="p1853mcpsimp"></a>Parameter</p>
</th> | Parameter | Description |
<th class="cellrowborder" valign="top" width="52.16%" id="mcps1.2.4.1.2"><p id="p1855mcpsimp"><a name="p1855mcpsimp"></a><a name="p1855mcpsimp"></a>Description</p> | ------ | ------------------------------------------------------------ |
</th> | --help | Displays the parameters supported by the **du** command. |
<th class="cellrowborder" valign="top" width="27%" id="mcps1.2.4.1.3"><p id="p1857mcpsimp"><a name="p1857mcpsimp"></a><a name="p1857mcpsimp"></a>Value Range</p> | -k | Displays the occupied blocks, each of which is 1024 bytes by default. |
</th> | -K | Displays the occupied blocks, each of which is 512 bytes (POSIX). |
</tr> | -m | Displays the disk space in MB. |
</thead> | -h | Displays the disk space in human-readable format K, M, and G, for example, **1K**, **243M**, or **2G**.|
<tbody><tr id="row10230133312716"><td class="cellrowborder" valign="top" width="20.84%" headers="mcps1.2.4.1.1 "><p id="p1921613332713"><a name="p1921613332713"></a><a name="p1921613332713"></a>--help</p> | file | Specifies the target file. |
</td>
<td class="cellrowborder" valign="top" width="52.16%" headers="mcps1.2.4.1.2 "><p id="p14216153332715"><a name="p14216153332715"></a><a name="p14216153332715"></a>Displays the parameters supported by the <strong id="b22402916307"><a name="b22402916307"></a><a name="b22402916307"></a>du</strong> command.</p>
</td> ## Usage Guidelines
<td class="cellrowborder" valign="top" width="27%" headers="mcps1.2.4.1.3 "><p id="p20216173362720"><a name="p20216173362720"></a><a name="p20216173362720"></a>N/A</p>
</td> - The **du** command is used to obtain the disk usage of a file rather than a directory.
</tr>
<tr id="row1223010339271"><td class="cellrowborder" valign="top" width="20.84%" headers="mcps1.2.4.1.1 "><p id="p112161733202717"><a name="p112161733202717"></a><a name="p112161733202717"></a>-k</p> - The value of **file** must be the file name. It cannot contain the directory where the file is located.
</td>
<td class="cellrowborder" valign="top" width="52.16%" headers="mcps1.2.4.1.2 "><p id="p142161833172710"><a name="p142161833172710"></a><a name="p142161833172710"></a>Displays the occupied blocks, each of which is 1024 bytes by default.</p> ## Note
</td>
<td class="cellrowborder" valign="top" width="27%" headers="mcps1.2.4.1.3 "><p id="p42161335276"><a name="p42161335276"></a><a name="p42161335276"></a>N/A</p> Currently, the shell does not support this command. mksh supports it. To switch to mksh, run **cd bin** and **./mksh**.
</td>
</tr> ## Example
<tr id="row4230933182718"><td class="cellrowborder" valign="top" width="20.84%" headers="mcps1.2.4.1.1 "><p id="p152161336278"><a name="p152161336278"></a><a name="p152161336278"></a>-K</p>
</td> Run **du -h testfile**.
<td class="cellrowborder" valign="top" width="52.16%" headers="mcps1.2.4.1.2 "><p id="p13216103319274"><a name="p13216103319274"></a><a name="p13216103319274"></a>Displays the occupied blocks, each of which is 512 bytes (POSIX).</p>
</td>
<td class="cellrowborder" valign="top" width="27%" headers="mcps1.2.4.1.3 "><p id="p192169337273"><a name="p192169337273"></a><a name="p192169337273"></a>N/A</p> ## Output
</td>
</tr> Disk space occupied by **testfile**.
<tr id="row1230103352716"><td class="cellrowborder" valign="top" width="20.84%" headers="mcps1.2.4.1.1 "><p id="p132161833192716"><a name="p132161833192716"></a><a name="p132161833192716"></a>-m</p>
</td>
<td class="cellrowborder" valign="top" width="52.16%" headers="mcps1.2.4.1.2 "><p id="p621673332720"><a name="p621673332720"></a><a name="p621673332720"></a>Displays the disk space in MB.</p>
</td>
<td class="cellrowborder" valign="top" width="27%" headers="mcps1.2.4.1.3 "><p id="p1321614336271"><a name="p1321614336271"></a><a name="p1321614336271"></a>N/A</p>
</td>
</tr>
<tr id="row10229133315272"><td class="cellrowborder" valign="top" width="20.84%" headers="mcps1.2.4.1.1 "><p id="p14216153313276"><a name="p14216153313276"></a><a name="p14216153313276"></a>-h</p>
</td>
<td class="cellrowborder" valign="top" width="52.16%" headers="mcps1.2.4.1.2 "><p id="p2216533192717"><a name="p2216533192717"></a><a name="p2216533192717"></a>Displays the disk space in human-readable format K, M, and G, for example, <strong id="b1315823125013"><a name="b1315823125013"></a><a name="b1315823125013"></a>1K</strong>, <strong id="b385962710225"><a name="b385962710225"></a><a name="b385962710225"></a>243M</strong>, or <strong id="b1114122962214"><a name="b1114122962214"></a><a name="b1114122962214"></a>2G</strong>.</p>
</td>
<td class="cellrowborder" valign="top" width="27%" headers="mcps1.2.4.1.3 "><p id="p162161333102720"><a name="p162161333102720"></a><a name="p162161333102720"></a>N/A</p>
</td>
</tr>
<tr id="row1322918333273"><td class="cellrowborder" valign="top" width="20.84%" headers="mcps1.2.4.1.1 "><p id="p182160331270"><a name="p182160331270"></a><a name="p182160331270"></a>file</p>
</td>
<td class="cellrowborder" valign="top" width="52.16%" headers="mcps1.2.4.1.2 "><p id="p19216103310272"><a name="p19216103310272"></a><a name="p19216103310272"></a>Specifies the target file.</p>
</td>
<td class="cellrowborder" valign="top" width="27%" headers="mcps1.2.4.1.3 "><p id="p182171332271"><a name="p182171332271"></a><a name="p182171332271"></a>N/A</p>
</td>
</tr>
</tbody>
</table>
## Usage<a name="section19190125723612"></a>
- The **du** command is used to obtain the disk usage of a file rather than a directory.
- The value of **file** must be the file name. It cannot contain the directory where the file is located.
## Example<a name="section10383416372"></a>
Run **du -h testfile**.
## Output<a name="section16633113552815"></a>
Command output
``` ```
OHOS:/$ du -h testfile OHOS:/$ du -h testfile
1.8K testfile 1.8K testfile
``` ```
# format # format
## Command Function<a name="section1922331919169"></a> ## Command Function
This command is used for disk formatting. This command is used for disk formatting.
## Syntax<a name="section249226169"></a>
## Syntax
format <_dev\_inodename_\> <_sectors_\> <_option_\> \[_label_\]
format &lt;*dev*inodename_&gt; &lt;*sectors*&gt; &lt;*option*&gt; [_label_]
## Parameters<a name="section985173416177"></a>
**Table 1** Parameter description ## Parameters
<a name="table1183mcpsimp"></a> **Table 1** Parameter description
<table><thead align="left"><tr id="row1188mcpsimp"><th class="cellrowborder" valign="top" width="34%" id="mcps1.2.3.1.1"><p id="p1190mcpsimp"><a name="p1190mcpsimp"></a><a name="p1190mcpsimp"></a><strong id="b101095916104"><a name="b101095916104"></a><a name="b101095916104"></a>Parameter</strong></p>
</th> | Parameter| Description|
<th class="cellrowborder" valign="top" width="66%" id="mcps1.2.3.1.2"><p id="p1192mcpsimp"><a name="p1192mcpsimp"></a><a name="p1192mcpsimp"></a><strong id="b14213111171020"><a name="b14213111171020"></a><a name="b14213111171020"></a>Description</strong></p> | -------- | -------- |
</th> | dev_inodename | Specifies the device name. |
</tr> | sectors | Specifies the size of the allocated memory unit or sector. <br/>The value must be **0** or a power of **2**.<br/>The value **0** means to leave this parameter blank. <br/>For FAT32, the maximum value is **128**. If the parameter is set to **0**, a proper cluster size is automatically selected. The available cluster size range varies depending on the partition size. If the cluster size is incorrectly specified, the formatting may fail. |
</thead> | option | Specifies the file system type. The options are as follows:<br>- **0x01**: FMT_FAT<br>- **0x02**: FMT_FAT32<br>- **0x07**: FMT_ANY<br>- **0x08**: FMT_ERASE (USB does not support this option.)<br>If an invalid value is specified, the system automatically selects the formatting mode. If the low-level formatting bit is **1** during the formatting of a USB flash drive, an error message is printed.|
<tbody><tr id="row1193mcpsimp"><td class="cellrowborder" valign="top" width="34%" headers="mcps1.2.3.1.1 "><p id="p1195mcpsimp"><a name="p1195mcpsimp"></a><a name="p1195mcpsimp"></a>dev_inodename</p> | label | Specifies the volume label name. This parameter is optional, and the value is a string. <br/>If **null** is specified for this parameter, the previously set volume label name is cleared. |
</td>
<td class="cellrowborder" valign="top" width="66%" headers="mcps1.2.3.1.2 "><p id="p1197mcpsimp"><a name="p1197mcpsimp"></a><a name="p1197mcpsimp"></a>Specifies the device name.</p>
</td> ## Usage Guidelines
</tr>
<tr id="row1203mcpsimp"><td class="cellrowborder" valign="top" width="34%" headers="mcps1.2.3.1.1 "><p id="p1205mcpsimp"><a name="p1205mcpsimp"></a><a name="p1205mcpsimp"></a>sectors</p> - The **format** command is used for disk formatting. You can find the device name in the **dev** directory. A storage card must be installed before the formatting.
</td>
<td class="cellrowborder" valign="top" width="66%" headers="mcps1.2.3.1.2 "><p id="p1207mcpsimp"><a name="p1207mcpsimp"></a><a name="p1207mcpsimp"></a>Specifies the size of the allocated memory unit or sector. The value <strong id="b1574273871018"><a name="b1574273871018"></a><a name="b1574273871018"></a>0</strong> indicates null. (The value must be <strong id="b16428721113"><a name="b16428721113"></a><a name="b16428721113"></a>0</strong> or a power of <strong id="b1053419931111"><a name="b1053419931111"></a><a name="b1053419931111"></a>2</strong>. For FAT32, the maximum value is <strong id="b51473841110"><a name="b51473841110"></a><a name="b51473841110"></a>128</strong>. If the parameter is set to <strong id="b99547931214"><a name="b99547931214"></a><a name="b99547931214"></a>0</strong>, a proper cluster size is automatically selected. The available cluster size range varies depending on the partition size. If the cluster size is incorrectly specified, the formatting may fail.)</p> - The **format** command can be used to format the USB flash drive, SD card, and MMC, but not the NAND flash or NOR flash.
</td>
</tr> - An invalid **sectors** value may cause exceptions.
<tr id="row1208mcpsimp"><td class="cellrowborder" valign="top" width="34%" headers="mcps1.2.3.1.1 "><p id="p1210mcpsimp"><a name="p1210mcpsimp"></a><a name="p1210mcpsimp"></a>option</p>
</td>
<td class="cellrowborder" valign="top" width="66%" headers="mcps1.2.3.1.2 "><div class="p" id="p1212mcpsimp"><a name="p1212mcpsimp"></a><a name="p1212mcpsimp"></a>Specifies the file system type. The options are as follows:<a name="ul10971366369"></a><a name="ul10971366369"></a><ul id="ul10971366369"><li><strong id="b169384514517"><a name="b169384514517"></a><a name="b169384514517"></a>0x01</strong>: FMT_FAT</li><li><strong id="b143061510125114"><a name="b143061510125114"></a><a name="b143061510125114"></a>0x02</strong>: FMT_FAT32</li><li><strong id="b3245614165116"><a name="b3245614165116"></a><a name="b3245614165116"></a>0x07</strong>: FMT_ANY</li><li><strong id="b018121813512"><a name="b018121813512"></a><a name="b018121813512"></a>0x08</strong>: FMT_ERASE (not supported by the USB flash drive)</li></ul> ## Example
</div>
<p id="p28366459374"><a name="p28366459374"></a><a name="p28366459374"></a>If an invalid value is specified, the system automatically selects the formatting mode. If the low-level formatting bit is <strong id="b4634562520"><a name="b4634562520"></a><a name="b4634562520"></a>1</strong> during the formatting of a USB flash drive, an error message is printed.</p> Run **format /dev/mmcblk0 128 2**.
</td>
</tr>
<tr id="row1213mcpsimp"><td class="cellrowborder" valign="top" width="34%" headers="mcps1.2.3.1.1 "><p id="p1215mcpsimp"><a name="p1215mcpsimp"></a><a name="p1215mcpsimp"></a>label</p> ## Output
</td>
<td class="cellrowborder" valign="top" width="66%" headers="mcps1.2.3.1.2 "><p id="p1217mcpsimp"><a name="p1217mcpsimp"></a><a name="p1217mcpsimp"></a>Specifies the volume label name. This parameter is optional, and the value is a string. If <strong id="b16648426102713"><a name="b16648426102713"></a><a name="b16648426102713"></a>null</strong> is specified for this parameter, the previously set volume label name is cleared.</p> Format an MMC.
</td>
</tr>
</tbody>
</table>
## Usage<a name="section1510162714162"></a>
- The **format** command is used for disk formatting. You can find the device name in the **dev** directory. A storage card must be installed before the formatting.
- The **format** command can be used to format the USB flash drive, SD card, and MMC, but not the NAND flash or NOR flash.
- An invalid **sectors** value may cause exceptions.
## Example<a name="section25691431161611"></a>
Run **format /dev/mmcblk0 128 2**.
## Output<a name="section17368112365920"></a>
Formatting an MMC:
``` ```
OHOS # format /dev/mmcblk1 128 2 OHOS # format /dev/mmcblk1 128 2
Format to FAT32, 128 sectors per cluster. Format to FAT32, 128 sectors per cluster.
format /dev/mmcblk1 Success format /dev/mmcblk1 Success
``` ```
# ls # ls
## Command Function<a name="section6538163771614"></a>
## Command Function
This command is used to display the content of a specified directory.
This command is used to display the content of a directory.
## Syntax<a name="section45881743111616"></a>
ls \[_-ACHLSZacdfhiklmnopqrstux1_\] \[_--color_\[_=auto_\]\] \[_directory..._\] ## Syntax
>![](../public_sys-resources/icon-note.gif) **NOTE:** ls [_-ACHLSZacdfhiklmnopqrstux1_] [_--color_[_=auto_]] [_directory..._]
>During the system boot process, **ls=toybox ls --color=auto**, **ll = ls -alF**, **la=ls -A**, and **l=ls -CF** commands have been enabled using **alias** so that the initial actions of these commands are the same as those on Linux. For details, see the output description. To view help information, run **toybox ls --help**.
> **NOTE**<br>
## Parameters<a name="section17528148171617"></a> > During the system boot process, **ls=toybox ls --color=auto**, **ll = ls -alF**, **la=ls -A**, and **l=ls -CF** commands have been enabled using **alias** so that the initial actions of these commands are the same as those on Linux. For details, see **Output**. To view help information, run **toybox ls --help**.
**Table 1** Command parameter description
## Parameters
<a name="table1244mcpsimp"></a>
<table><thead align="left"><tr id="row1250mcpsimp"><th class="cellrowborder" valign="top" width="21%" id="mcps1.2.4.1.1"><p id="p1252mcpsimp"><a name="p1252mcpsimp"></a><a name="p1252mcpsimp"></a><strong id="b85851402216"><a name="b85851402216"></a><a name="b85851402216"></a>Parameter</strong></p> **Table 1** Command parameter description
</th>
<th class="cellrowborder" valign="top" width="52%" id="mcps1.2.4.1.2"><p id="p1254mcpsimp"><a name="p1254mcpsimp"></a><a name="p1254mcpsimp"></a><strong id="b128175424215"><a name="b128175424215"></a><a name="b128175424215"></a>Description</strong></p> | Parameter | Description | Value Range |
</th> | ------ | ------------------------------------------------------------ | ----------------------------- |
<th class="cellrowborder" valign="top" width="27%" id="mcps1.2.4.1.3"><p id="p1256mcpsimp"><a name="p1256mcpsimp"></a><a name="p1256mcpsimp"></a><strong id="b184580431629"><a name="b184580431629"></a><a name="b184580431629"></a>Value Range</strong></p> | --help | Displays parameters supported by the **ls** command and their usage. | N/A |
</th> | -a | Displays all files, including hidden files. | N/A |
</tr> | -b | Escapes non-graphical characters. | N/A |
</thead> | -c | Uses **ctime** as the file timestamp. This parameter must be used together with **-l**. | N/A |
<tbody><tr id="row1165411114303"><td class="cellrowborder" valign="top" width="21%" headers="mcps1.2.4.1.1 "><p id="p16614161193017"><a name="p16614161193017"></a><a name="p16614161193017"></a>--help</p> | -d | Displays only the directory, rather than listing the content of the directory. | N/A |
</td> | -i | Displays the node ID of a file. | N/A |
<td class="cellrowborder" valign="top" width="52%" headers="mcps1.2.4.1.2 "><p id="p161410110302"><a name="p161410110302"></a><a name="p161410110302"></a>Displays parameters supported by the <strong id="b05047195230"><a name="b05047195230"></a><a name="b05047195230"></a>ls</strong> command and their usage.</p> | -p | Adds a slash (/) after the directory. | N/A |
</td> | -q | Displays non-printable characters, such as "?". | N/A |
<td class="cellrowborder" valign="top" width="27%" headers="mcps1.2.4.1.3 "><p id="p196141211193014"><a name="p196141211193014"></a><a name="p196141211193014"></a>N/A</p> | -s | Provides information about the memory occupied by the directory and its members, in 1024 bytes. | N/A |
</td> | -u | Uses the last access time of the file as the timestamp. This option is used together with **-l**. | N/A |
</tr> | -A | Lists all files except implied . and .. | N/A |
<tr id="row3653131173015"><td class="cellrowborder" valign="top" width="21%" headers="mcps1.2.4.1.1 "><p id="p76141511123013"><a name="p76141511123013"></a><a name="p76141511123013"></a>-a</p> | -H | Follows symbolic links listed in the command line. | N/A |
</td> | -L | Follows symbolic links. | N/A |
<td class="cellrowborder" valign="top" width="52%" headers="mcps1.2.4.1.2 "><p id="p861431163012"><a name="p861431163012"></a><a name="p861431163012"></a>Displays all files, including .hidden files.</p> | -Z | Displays security context. | N/A |
</td> | path | Specifies the path of the target directory.<br/>If **path** is left blank, the content of the current directory is displayed.<br>If **path** is an invalid directory, "ls&nbsp;error:&nbsp;No&nbsp;such&nbsp;directory." is displayed.<br><br>If **path** is a valid directory, the content of the specified directory is displayed. | Left blank<br>A valid directory|
<td class="cellrowborder" valign="top" width="27%" headers="mcps1.2.4.1.3 "><p id="p161421153016"><a name="p161421153016"></a><a name="p161421153016"></a>N/A</p>
</td> **Table 2** Output format parameters
</tr>
<tr id="row6653161163013"><td class="cellrowborder" valign="top" width="21%" headers="mcps1.2.4.1.1 "><p id="p10614131116307"><a name="p10614131116307"></a><a name="p10614131116307"></a>-b</p> | Parameter | Description |
</td> | ------- | --------------------------------------- |
<td class="cellrowborder" valign="top" width="52%" headers="mcps1.2.4.1.2 "><p id="p6614511113013"><a name="p6614511113013"></a><a name="p6614511113013"></a>Escapes non-graphical characters.</p> | -1 | Lists one file per line. |
</td> | -c | Lists entries by column. |
<td class="cellrowborder" valign="top" width="27%" headers="mcps1.2.4.1.3 "><p id="p16614161110307"><a name="p16614161110307"></a><a name="p16614161110307"></a>N/A</p> | -g | Like **-l**, but do not list the owner. |
</td> | -h | Displays the total size of files in the directory, in KiB.|
</tr> | -l | Displays detailed information about files in the directory. |
<tr id="row165311113302"><td class="cellrowborder" valign="top" width="21%" headers="mcps1.2.4.1.1 "><p id="p761517119300"><a name="p761517119300"></a><a name="p761517119300"></a>-c</p> | -m | Fills width with a list of entries separated by a comma. |
</td> | -n | Like **-l**, but lists numeric user and group IDs.|
<td class="cellrowborder" valign="top" width="52%" headers="mcps1.2.4.1.2 "><p id="p6615121114307"><a name="p6615121114307"></a><a name="p6615121114307"></a>Uses ctime as the file timestamp. This parameter must be used together with <strong id="b644143217354"><a name="b644143217354"></a><a name="b644143217354"></a>-l</strong>.</p> | -o | Like **-l**, but do not list group information. |
</td> | -x | Lists entries by line, instead of by column. |
<td class="cellrowborder" valign="top" width="27%" headers="mcps1.2.4.1.3 "><p id="p861561115308"><a name="p861561115308"></a><a name="p861561115308"></a>N/A</p> | -ll | Lists the file time attribute as ns. |
</td>
</tr> **Table 3** Parameters for sorting (by the initial letter by default)
<tr id="row19652131193018"><td class="cellrowborder" valign="top" width="21%" headers="mcps1.2.4.1.1 "><p id="p1861591117301"><a name="p1861591117301"></a><a name="p1861591117301"></a>-d</p>
</td> | Parameter| Description |
<td class="cellrowborder" valign="top" width="52%" headers="mcps1.2.4.1.2 "><p id="p126151511193010"><a name="p126151511193010"></a><a name="p126151511193010"></a>Displays only the directory, rather than listing the content of the directory.</p> | ---- | ------------------------------------------ |
</td> | -f | Do not sort. |
<td class="cellrowborder" valign="top" width="27%" headers="mcps1.2.4.1.3 "><p id="p061521133020"><a name="p061521133020"></a><a name="p061521133020"></a>N/A</p> | -r | Sorts in reverse order. |
</td> | -t | Sorts by time, newest first.|
</tr> | -S | Sorts by file size, largest first. |
<tr id="row265212115302"><td class="cellrowborder" valign="top" width="21%" headers="mcps1.2.4.1.1 "><p id="p12615151183012"><a name="p12615151183012"></a><a name="p12615151183012"></a>-i</p>
</td> **Table 4** Color printing
<td class="cellrowborder" valign="top" width="52%" headers="mcps1.2.4.1.2 "><p id="p11615511193012"><a name="p11615511193012"></a><a name="p11615511193012"></a>Displays the node ID of a file.</p>
</td> | Parameter| Default Configuration |
<td class="cellrowborder" valign="top" width="27%" headers="mcps1.2.4.1.3 "><p id="p1361591103015"><a name="p1361591103015"></a><a name="p1361591103015"></a>N/A</p> | ---- | ------------------------------------------ |
</td> | --color | device=yellow symlink=turquoise/red dir=blue socket=purple files: exe=green suid=red suidfile=redback stickydir=greenback=auto means detect if output is a tty. |
</tr>
<tr id="row66529118309"><td class="cellrowborder" valign="top" width="21%" headers="mcps1.2.4.1.1 "><p id="p9615211133012"><a name="p9615211133012"></a><a name="p9615211133012"></a>-p</p> ## Usage Guidelines
</td>
<td class="cellrowborder" valign="top" width="52%" headers="mcps1.2.4.1.2 "><p id="p3615131103017"><a name="p3615131103017"></a><a name="p3615131103017"></a>Adds a slash (/) after the directory.</p> The file node information of the FAT file system inherits from its parent node. The parent node ID is **0**. Therefore, if you run the **ls -i** command on the Hi3516D V300 development board, the file node IDs displayed are all **0**.
</td>
<td class="cellrowborder" valign="top" width="27%" headers="mcps1.2.4.1.3 "><p id="p1361551112302"><a name="p1361551112302"></a><a name="p1361551112302"></a>N/A</p>
</td> ## Note
</tr>
<tr id="row13651111183016"><td class="cellrowborder" valign="top" width="21%" headers="mcps1.2.4.1.1 "><p id="p186151811183010"><a name="p186151811183010"></a><a name="p186151811183010"></a>-q</p> The shell does not support **ls** parameters. mksh supports them. To switch to mksh, run **cd bin** and **./mksh**.
</td>
<td class="cellrowborder" valign="top" width="52%" headers="mcps1.2.4.1.2 "><p id="p19615511123011"><a name="p19615511123011"></a><a name="p19615511123011"></a>Displays non-printable characters, such as "?".</p> ## Example
</td>
<td class="cellrowborder" valign="top" width="27%" headers="mcps1.2.4.1.3 "><p id="p6615151111303"><a name="p6615151111303"></a><a name="p6615151111303"></a>N/A</p>
</td>
</tr>
<tr id="row26511711113018"><td class="cellrowborder" valign="top" width="21%" headers="mcps1.2.4.1.1 "><p id="p1861581111304"><a name="p1861581111304"></a><a name="p1861581111304"></a>-s</p>
</td>
<td class="cellrowborder" valign="top" width="52%" headers="mcps1.2.4.1.2 "><p id="p161511114303"><a name="p161511114303"></a><a name="p161511114303"></a>Provides information about the memory occupied by the directory and its members, in 1024 bytes.</p>
</td>
<td class="cellrowborder" valign="top" width="27%" headers="mcps1.2.4.1.3 "><p id="p1061514115307"><a name="p1061514115307"></a><a name="p1061514115307"></a>N/A</p>
</td>
</tr>
<tr id="row4650181183020"><td class="cellrowborder" valign="top" width="21%" headers="mcps1.2.4.1.1 "><p id="p8615101133017"><a name="p8615101133017"></a><a name="p8615101133017"></a>-u</p>
</td>
<td class="cellrowborder" valign="top" width="52%" headers="mcps1.2.4.1.2 "><p id="p761501113306"><a name="p761501113306"></a><a name="p761501113306"></a>Uses the last access time of the file as the timestamp. This option is used together with <strong id="b83441545164512"><a name="b83441545164512"></a><a name="b83441545164512"></a>-l</strong>.</p>
</td>
<td class="cellrowborder" valign="top" width="27%" headers="mcps1.2.4.1.3 "><p id="p86153111309"><a name="p86153111309"></a><a name="p86153111309"></a>N/A</p>
</td>
</tr>
<tr id="row1365021120308"><td class="cellrowborder" valign="top" width="21%" headers="mcps1.2.4.1.1 "><p id="p36151011193016"><a name="p36151011193016"></a><a name="p36151011193016"></a>-A</p>
</td>
<td class="cellrowborder" valign="top" width="52%" headers="mcps1.2.4.1.2 "><p id="p56151511183019"><a name="p56151511183019"></a><a name="p56151511183019"></a>Lists all files except implied . and ..</p>
</td>
<td class="cellrowborder" valign="top" width="27%" headers="mcps1.2.4.1.3 "><p id="p8615411193019"><a name="p8615411193019"></a><a name="p8615411193019"></a>N/A</p>
</td>
</tr>
<tr id="row13650151114302"><td class="cellrowborder" valign="top" width="21%" headers="mcps1.2.4.1.1 "><p id="p20615411183017"><a name="p20615411183017"></a><a name="p20615411183017"></a>-H</p>
</td>
<td class="cellrowborder" valign="top" width="52%" headers="mcps1.2.4.1.2 "><p id="p19615151118304"><a name="p19615151118304"></a><a name="p19615151118304"></a>Follows symbolic links listed in the command line.</p>
</td>
<td class="cellrowborder" valign="top" width="27%" headers="mcps1.2.4.1.3 "><p id="p10615161112307"><a name="p10615161112307"></a><a name="p10615161112307"></a>N/A</p>
</td>
</tr>
<tr id="row1865071119306"><td class="cellrowborder" valign="top" width="21%" headers="mcps1.2.4.1.1 "><p id="p206151911123017"><a name="p206151911123017"></a><a name="p206151911123017"></a>-L</p>
</td>
<td class="cellrowborder" valign="top" width="52%" headers="mcps1.2.4.1.2 "><p id="p5615911203017"><a name="p5615911203017"></a><a name="p5615911203017"></a>Follows symbolic links.</p>
</td>
<td class="cellrowborder" valign="top" width="27%" headers="mcps1.2.4.1.3 "><p id="p16615111111307"><a name="p16615111111307"></a><a name="p16615111111307"></a>N/A</p>
</td>
</tr>
<tr id="row16649411173019"><td class="cellrowborder" valign="top" width="21%" headers="mcps1.2.4.1.1 "><p id="p1861581116309"><a name="p1861581116309"></a><a name="p1861581116309"></a>-Z</p>
</td>
<td class="cellrowborder" valign="top" width="52%" headers="mcps1.2.4.1.2 "><p id="p7616151112301"><a name="p7616151112301"></a><a name="p7616151112301"></a>Displays security context.</p>
</td>
<td class="cellrowborder" valign="top" width="27%" headers="mcps1.2.4.1.3 "><p id="p12616411173010"><a name="p12616411173010"></a><a name="p12616411173010"></a>N/A</p>
</td>
</tr>
<tr id="row186497114307"><td class="cellrowborder" valign="top" width="21%" headers="mcps1.2.4.1.1 "><p id="p17616211113010"><a name="p17616211113010"></a><a name="p17616211113010"></a>path</p>
</td>
<td class="cellrowborder" valign="top" width="52%" headers="mcps1.2.4.1.2 "><p id="p1761611110307"><a name="p1761611110307"></a><a name="p1761611110307"></a>If <strong id="b115515262034"><a name="b115515262034"></a><a name="b115515262034"></a>path</strong> is left blank, the content of the current directory is displayed.</p>
<p id="p10616141117308"><a name="p10616141117308"></a><a name="p10616141117308"></a>If <strong id="b9593204114312"><a name="b9593204114312"></a><a name="b9593204114312"></a>path</strong> is an invalid file name, the following failure message is displayed:</p>
<p id="p1061631112303"><a name="p1061631112303"></a><a name="p1061631112303"></a><strong id="b19604131716416"><a name="b19604131716416"></a><a name="b19604131716416"></a>ls error: No such directory</strong></p>
<p id="p206161111143018"><a name="p206161111143018"></a><a name="p206161111143018"></a>If <strong id="b615314272412"><a name="b615314272412"></a><a name="b615314272412"></a>path</strong> is a valid directory, the content of that directory is displayed.</p>
</td>
<td class="cellrowborder" valign="top" width="27%" headers="mcps1.2.4.1.3 "><p id="p761617115309"><a name="p761617115309"></a><a name="p761617115309"></a>Left blank or a valid directory</p>
</td>
</tr>
</tbody>
</table>
**Table 2** Output parameters
<a name="table197022663018"></a>
<table><thead align="left"><tr id="row7970172614303"><th class="cellrowborder" valign="top" width="21%" id="mcps1.2.4.1.1"><p id="p8970122616304"><a name="p8970122616304"></a><a name="p8970122616304"></a>Parameter</p>
</th>
<th class="cellrowborder" valign="top" width="52%" id="mcps1.2.4.1.2"><p id="p197012633020"><a name="p197012633020"></a><a name="p197012633020"></a><strong id="b1961069541"><a name="b1961069541"></a><a name="b1961069541"></a>Description</strong></p>
</th>
<th class="cellrowborder" valign="top" width="27%" id="mcps1.2.4.1.3"><p id="p1397092603018"><a name="p1397092603018"></a><a name="p1397092603018"></a>Value Range</p>
</th>
</tr>
</thead>
<tbody><tr id="row106817566303"><td class="cellrowborder" valign="top" width="21%" headers="mcps1.2.4.1.1 "><p id="p365845683010"><a name="p365845683010"></a><a name="p365845683010"></a>-1</p>
</td>
<td class="cellrowborder" valign="top" width="52%" headers="mcps1.2.4.1.2 "><p id="p1865811565309"><a name="p1865811565309"></a><a name="p1865811565309"></a>Lists one file per line.</p>
</td>
<td class="cellrowborder" valign="top" width="27%" headers="mcps1.2.4.1.3 "><p id="p0658195616305"><a name="p0658195616305"></a><a name="p0658195616305"></a>N/A</p>
</td>
</tr>
<tr id="row15680155633011"><td class="cellrowborder" valign="top" width="21%" headers="mcps1.2.4.1.1 "><p id="p116585565301"><a name="p116585565301"></a><a name="p116585565301"></a>-c</p>
</td>
<td class="cellrowborder" valign="top" width="52%" headers="mcps1.2.4.1.2 "><p id="p1065865611302"><a name="p1065865611302"></a><a name="p1065865611302"></a>Lists entries by column.</p>
</td>
<td class="cellrowborder" valign="top" width="27%" headers="mcps1.2.4.1.3 "><p id="p06581456113013"><a name="p06581456113013"></a><a name="p06581456113013"></a>N/A</p>
</td>
</tr>
<tr id="row11680556173014"><td class="cellrowborder" valign="top" width="21%" headers="mcps1.2.4.1.1 "><p id="p86581756193012"><a name="p86581756193012"></a><a name="p86581756193012"></a>-g</p>
</td>
<td class="cellrowborder" valign="top" width="52%" headers="mcps1.2.4.1.2 "><p id="p20658356183018"><a name="p20658356183018"></a><a name="p20658356183018"></a>Like <strong id="b206161282355"><a name="b206161282355"></a><a name="b206161282355"></a>-l</strong>, but do not list owner.</p>
</td>
<td class="cellrowborder" valign="top" width="27%" headers="mcps1.2.4.1.3 "><p id="p7658165663019"><a name="p7658165663019"></a><a name="p7658165663019"></a>N/A</p>
</td>
</tr>
<tr id="row19680105614309"><td class="cellrowborder" valign="top" width="21%" headers="mcps1.2.4.1.1 "><p id="p17658185612306"><a name="p17658185612306"></a><a name="p17658185612306"></a>-h</p>
</td>
<td class="cellrowborder" valign="top" width="52%" headers="mcps1.2.4.1.2 "><p id="p16581756143014"><a name="p16581756143014"></a><a name="p16581756143014"></a>Displays the total size of files in the directory, in KiB.</p>
</td>
<td class="cellrowborder" valign="top" width="27%" headers="mcps1.2.4.1.3 "><p id="p1865814565305"><a name="p1865814565305"></a><a name="p1865814565305"></a>N/A</p>
</td>
</tr>
<tr id="row46801356143016"><td class="cellrowborder" valign="top" width="21%" headers="mcps1.2.4.1.1 "><p id="p11658056123016"><a name="p11658056123016"></a><a name="p11658056123016"></a>-l</p>
</td>
<td class="cellrowborder" valign="top" width="52%" headers="mcps1.2.4.1.2 "><p id="p1465875603018"><a name="p1465875603018"></a><a name="p1465875603018"></a>Displays detailed information about files in the directory.</p>
</td>
<td class="cellrowborder" valign="top" width="27%" headers="mcps1.2.4.1.3 "><p id="p10658105673015"><a name="p10658105673015"></a><a name="p10658105673015"></a>N/A</p>
</td>
</tr>
<tr id="row136791256203013"><td class="cellrowborder" valign="top" width="21%" headers="mcps1.2.4.1.1 "><p id="p10658125616303"><a name="p10658125616303"></a><a name="p10658125616303"></a>-m</p>
</td>
<td class="cellrowborder" valign="top" width="52%" headers="mcps1.2.4.1.2 "><p id="p15658115620304"><a name="p15658115620304"></a><a name="p15658115620304"></a>Fills width with a list of entries separated by a comma.</p>
</td>
<td class="cellrowborder" valign="top" width="27%" headers="mcps1.2.4.1.3 "><p id="p26584563301"><a name="p26584563301"></a><a name="p26584563301"></a>N/A</p>
</td>
</tr>
<tr id="row176791156163014"><td class="cellrowborder" valign="top" width="21%" headers="mcps1.2.4.1.1 "><p id="p265875611309"><a name="p265875611309"></a><a name="p265875611309"></a>-n</p>
</td>
<td class="cellrowborder" valign="top" width="52%" headers="mcps1.2.4.1.2 "><p id="p1465895663016"><a name="p1465895663016"></a><a name="p1465895663016"></a>Like <strong id="b88319189351"><a name="b88319189351"></a><a name="b88319189351"></a>-l</strong>, but lists numeric user and group IDs.</p>
</td>
<td class="cellrowborder" valign="top" width="27%" headers="mcps1.2.4.1.3 "><p id="p9658135613011"><a name="p9658135613011"></a><a name="p9658135613011"></a>N/A</p>
</td>
</tr>
<tr id="row10679185653015"><td class="cellrowborder" valign="top" width="21%" headers="mcps1.2.4.1.1 "><p id="p365815562303"><a name="p365815562303"></a><a name="p365815562303"></a>-o</p>
</td>
<td class="cellrowborder" valign="top" width="52%" headers="mcps1.2.4.1.2 "><p id="p12658956193017"><a name="p12658956193017"></a><a name="p12658956193017"></a>Like <strong id="b24118395354"><a name="b24118395354"></a><a name="b24118395354"></a>-l</strong>, but do not list group information.</p>
</td>
<td class="cellrowborder" valign="top" width="27%" headers="mcps1.2.4.1.3 "><p id="p8658155610309"><a name="p8658155610309"></a><a name="p8658155610309"></a>N/A</p>
</td>
</tr>
<tr id="row176791656123015"><td class="cellrowborder" valign="top" width="21%" headers="mcps1.2.4.1.1 "><p id="p1765865643019"><a name="p1765865643019"></a><a name="p1765865643019"></a>-x</p>
</td>
<td class="cellrowborder" valign="top" width="52%" headers="mcps1.2.4.1.2 "><p id="p13658456123014"><a name="p13658456123014"></a><a name="p13658456123014"></a>Lists entries by line, instead of by column.</p>
</td>
<td class="cellrowborder" valign="top" width="27%" headers="mcps1.2.4.1.3 "><p id="p196581256103015"><a name="p196581256103015"></a><a name="p196581256103015"></a>N/A</p>
</td>
</tr>
<tr id="row1467820567304"><td class="cellrowborder" valign="top" width="21%" headers="mcps1.2.4.1.1 "><p id="p06584565305"><a name="p06584565305"></a><a name="p06584565305"></a>-ll</p>
</td>
<td class="cellrowborder" valign="top" width="52%" headers="mcps1.2.4.1.2 "><p id="p365855610302"><a name="p365855610302"></a><a name="p365855610302"></a>Lists the file time attribute as ns.</p>
</td>
<td class="cellrowborder" valign="top" width="27%" headers="mcps1.2.4.1.3 "><p id="p365845653010"><a name="p365845653010"></a><a name="p365845653010"></a>N/A</p>
</td>
</tr>
<tr id="row176781456183019"><td class="cellrowborder" valign="top" width="21%" headers="mcps1.2.4.1.1 "><p id="p11659256133013"><a name="p11659256133013"></a><a name="p11659256133013"></a>--color</p>
</td>
<td class="cellrowborder" valign="top" width="52%" headers="mcps1.2.4.1.2 "><p id="p2659756123020"><a name="p2659756123020"></a><a name="p2659756123020"></a>Colorizes the output.</p>
</td>
<td class="cellrowborder" valign="top" width="27%" headers="mcps1.2.4.1.3 "><p id="p2659135633011"><a name="p2659135633011"></a><a name="p2659135633011"></a>Default value: device=yellow symlink=turquoise/red dir=blue socket=purple files: exe=green suid=red suidfile=redback stickydir=greenback=auto means detect if output is a tty.</p>
</td>
</tr>
</tbody>
</table>
**Table 3** Sorting parameters \(sorted by the initial letter by default\)
<a name="table164254153318"></a>
<table><thead align="left"><tr id="row2425191515317"><th class="cellrowborder" valign="top" width="21%" id="mcps1.2.4.1.1"><p id="p74259156313"><a name="p74259156313"></a><a name="p74259156313"></a>Parameter</p>
</th>
<th class="cellrowborder" valign="top" width="52%" id="mcps1.2.4.1.2"><p id="p542501512317"><a name="p542501512317"></a><a name="p542501512317"></a><strong id="b237939680"><a name="b237939680"></a><a name="b237939680"></a>Description</strong></p>
</th>
<th class="cellrowborder" valign="top" width="27%" id="mcps1.2.4.1.3"><p id="p1342513154318"><a name="p1342513154318"></a><a name="p1342513154318"></a>Value Range</p>
</th>
</tr>
</thead>
<tbody><tr id="row10358027153118"><td class="cellrowborder" valign="top" width="21%" headers="mcps1.2.4.1.1 "><p id="p83441727153114"><a name="p83441727153114"></a><a name="p83441727153114"></a>-f</p>
</td>
<td class="cellrowborder" valign="top" width="52%" headers="mcps1.2.4.1.2 "><p id="p18344132717315"><a name="p18344132717315"></a><a name="p18344132717315"></a>Do not sort.</p>
</td>
<td class="cellrowborder" valign="top" width="27%" headers="mcps1.2.4.1.3 "><p id="p1834402753112"><a name="p1834402753112"></a><a name="p1834402753112"></a>N/A</p>
</td>
</tr>
<tr id="row4357112714312"><td class="cellrowborder" valign="top" width="21%" headers="mcps1.2.4.1.1 "><p id="p6344162773117"><a name="p6344162773117"></a><a name="p6344162773117"></a>-r</p>
</td>
<td class="cellrowborder" valign="top" width="52%" headers="mcps1.2.4.1.2 "><p id="p11344102743115"><a name="p11344102743115"></a><a name="p11344102743115"></a>Reverse order while sorting.</p>
</td>
<td class="cellrowborder" valign="top" width="27%" headers="mcps1.2.4.1.3 "><p id="p2344142719315"><a name="p2344142719315"></a><a name="p2344142719315"></a>N/A</p>
</td>
</tr>
<tr id="row133571827153114"><td class="cellrowborder" valign="top" width="21%" headers="mcps1.2.4.1.1 "><p id="p2344152717318"><a name="p2344152717318"></a><a name="p2344152717318"></a>-t</p>
</td>
<td class="cellrowborder" valign="top" width="52%" headers="mcps1.2.4.1.2 "><p id="p10344727103114"><a name="p10344727103114"></a><a name="p10344727103114"></a>Sort by time, newest first.</p>
</td>
<td class="cellrowborder" valign="top" width="27%" headers="mcps1.2.4.1.3 "><p id="p73441927123116"><a name="p73441927123116"></a><a name="p73441927123116"></a>N/A</p>
</td>
</tr>
<tr id="row4357102773115"><td class="cellrowborder" valign="top" width="21%" headers="mcps1.2.4.1.1 "><p id="p83444274318"><a name="p83444274318"></a><a name="p83444274318"></a>-S</p>
</td>
<td class="cellrowborder" valign="top" width="52%" headers="mcps1.2.4.1.2 "><p id="p1134452715312"><a name="p1134452715312"></a><a name="p1134452715312"></a>Sort by file size, largest first.</p>
</td>
<td class="cellrowborder" valign="top" width="27%" headers="mcps1.2.4.1.3 "><p id="p1344122717310"><a name="p1344122717310"></a><a name="p1344122717310"></a>N/A</p>
</td>
</tr>
</tbody>
</table>
## Usage<a name="section041212533166"></a>
None
>![](../public_sys-resources/icon-notice.gif) **NOTICE:**
>The file node information of the FAT file system inherits from its parent node. The parent node ID is **0**. Therefore, if you run the **ls -i** command on the Hi3516D V300 development board, the file node IDs displayed are all **0**.
## Example<a name="section986105716167"></a>
Run the following commands: Run the following commands:
- ls - ls
- ll
## Output<a name="section2036124918592"></a> - ll
Example 1: **ls** command output
## Output
Example 1: **ls** command output
``` ```
OHOS:/$ ls OHOS:/$ ls
...@@ -292,7 +94,7 @@ bin etc nfs sdcard system usr ...@@ -292,7 +94,7 @@ bin etc nfs sdcard system usr
dev lib proc storage userdata vendor dev lib proc storage userdata vendor
``` ```
Example 2: **ll** command output Example 2: **ll** command output
``` ```
OHOS:/$ ll OHOS:/$ ll
...@@ -310,4 +112,3 @@ drwxrwxrwx 1 0 0 2048 2021-11-21 17:52 userdata/ ...@@ -310,4 +112,3 @@ drwxrwxrwx 1 0 0 2048 2021-11-21 17:52 userdata/
drwxrwxrwx 1 0 0 2048 2021-11-21 17:52 usr/ drwxrwxrwx 1 0 0 2048 2021-11-21 17:52 usr/
drwxrwxrwx 1 0 0 2048 2021-11-21 17:52 vendor/ drwxrwxrwx 1 0 0 2048 2021-11-21 17:52 vendor/
``` ```
# lsfd # lsfd
## Command Function<a name="section2053406181716"></a> ## Command Function
This command is used to display the file descriptors and names of the files that are open. This command is used to display the file descriptors and names of the files that are open.
## Syntax<a name="section523771017172"></a>
## Syntax
lsfd lsfd
## Usage<a name="section27241213201719"></a>
Run the **lsfd** command to display file descriptors and names of the opened files. ## Usage Guidelines
Run the **lsfd** command to display file descriptors and names of the opened files.
## Example<a name="section442617197173"></a> ## Example
Run **lsfd**. Run **lsfd**.
## Output<a name="section42491639151813"></a>
Example: **lsfd** command output ## Output
Example: **lsfd** command output
``` ```
OHOS # lsfd OHOS # lsfd
...@@ -57,4 +61,3 @@ OHOS # lsfd ...@@ -57,4 +61,3 @@ OHOS # lsfd
33 /dev/lite_ipc 33 /dev/lite_ipc
34 /dev/lite_ipc 34 /dev/lite_ipc
``` ```
# mkdir # mkdir
## Command Function<a name="section1083613274175"></a> ## Command Function
This command is used to create a directory. This command is used to create a directory.
## Syntax<a name="section820913118178"></a>
## Syntax
mkdir \[_-vp_\] \[_-m mode_\] \[_dirname..._\]
mkdir [_-vp_] [_-m mode_] [_dirname..._]
## Parameters<a name="section1256834121718"></a>
**Table 1** Parameter description ## Parameters
<a name="table1299mcpsimp"></a> **Table 1** Parameter description
<table><thead align="left"><tr id="row1305mcpsimp"><th class="cellrowborder" valign="top" width="21%" id="mcps1.2.4.1.1"><p id="p1307mcpsimp"><a name="p1307mcpsimp"></a><a name="p1307mcpsimp"></a><strong id="b209289681211447"><a name="b209289681211447"></a><a name="b209289681211447"></a>Parameter</strong></p>
</th> | Parameter | Description |
<th class="cellrowborder" valign="top" width="52%" id="mcps1.2.4.1.2"><p id="p1309mcpsimp"><a name="p1309mcpsimp"></a><a name="p1309mcpsimp"></a><strong id="b16886221330"><a name="b16886221330"></a><a name="b16886221330"></a>Description</strong></p> | --------- | ------------------------------ |
</th> | --help | Displays the parameters supported by the **mkdir** command. |
<th class="cellrowborder" valign="top" width="27%" id="mcps1.2.4.1.3"><p id="p1311mcpsimp"><a name="p1311mcpsimp"></a><a name="p1311mcpsimp"></a><strong id="b163527968011447"><a name="b163527968011447"></a><a name="b163527968011447"></a>Value Range</strong></p> | -m | Sets the permissions on the directory to create. |
</th> | -p | Creates parent and child directories recursively. |
</tr> | -v | Prints detailed information about the directory creation process.|
</thead> | directory | Specifies the directory to create. |
<tbody><tr id="row15431344183419"><td class="cellrowborder" valign="top" width="21%" headers="mcps1.2.4.1.1 "><p id="p85331144163414"><a name="p85331144163414"></a><a name="p85331144163414"></a>--help</p>
</td>
<td class="cellrowborder" valign="top" width="52%" headers="mcps1.2.4.1.2 "><p id="p2053354433413"><a name="p2053354433413"></a><a name="p2053354433413"></a>Displays the parameters supported by the <strong id="b1177313015559"><a name="b1177313015559"></a><a name="b1177313015559"></a>mkdir</strong> command.</p> ## Usage Guidelines
</td>
<td class="cellrowborder" valign="top" width="27%" headers="mcps1.2.4.1.3 "><p id="p16533144473411"><a name="p16533144473411"></a><a name="p16533144473411"></a>N/A</p> For the files created on the FAT file system, the file permission attributes are the same as those of the mounted nodes. Currently, the node permissions include only user read and write. The **group** and **others** permissions do not take effect.
</td>
</tr> In addition, only the user read and write permissions can be modified. The read and write permissions are **rw** and **ro** only. Therefore, when the **-m** option is specified in the **mkdir** command, only **777** and **555** permissions are available for the created directory, and the execute permission does not take effect.
<tr id="row9543644193413"><td class="cellrowborder" valign="top" width="21%" headers="mcps1.2.4.1.1 "><p id="p153374418344"><a name="p153374418344"></a><a name="p153374418344"></a>-m</p>
</td> ## Note
<td class="cellrowborder" valign="top" width="52%" headers="mcps1.2.4.1.2 "><p id="p9533114416343"><a name="p9533114416343"></a><a name="p9533114416343"></a>Sets the permissions on the directory to create.</p>
</td> Currently, the shell does not support this command. mksh supports it. To switch to mksh, run **cd bin** and **./mksh**.
<td class="cellrowborder" valign="top" width="27%" headers="mcps1.2.4.1.3 "><p id="p553334414343"><a name="p553334414343"></a><a name="p553334414343"></a>N/A</p>
</td> ## Example
</tr>
<tr id="row654224463420"><td class="cellrowborder" valign="top" width="21%" headers="mcps1.2.4.1.1 "><p id="p853334414347"><a name="p853334414347"></a><a name="p853334414347"></a>-p</p>
</td>
<td class="cellrowborder" valign="top" width="52%" headers="mcps1.2.4.1.2 "><p id="p3533184493418"><a name="p3533184493418"></a><a name="p3533184493418"></a>Creates parent and child directories recursively.</p>
</td>
<td class="cellrowborder" valign="top" width="27%" headers="mcps1.2.4.1.3 "><p id="p753313443344"><a name="p753313443344"></a><a name="p753313443344"></a>N/A</p>
</td>
</tr>
<tr id="row454234412343"><td class="cellrowborder" valign="top" width="21%" headers="mcps1.2.4.1.1 "><p id="p153315440349"><a name="p153315440349"></a><a name="p153315440349"></a>-v</p>
</td>
<td class="cellrowborder" valign="top" width="52%" headers="mcps1.2.4.1.2 "><p id="p453344420349"><a name="p453344420349"></a><a name="p453344420349"></a>Prints detailed information about the directory creation process.</p>
</td>
<td class="cellrowborder" valign="top" width="27%" headers="mcps1.2.4.1.3 "><p id="p553313444343"><a name="p553313444343"></a><a name="p553313444343"></a>N/A</p>
</td>
</tr>
<tr id="row17542644203418"><td class="cellrowborder" valign="top" width="21%" headers="mcps1.2.4.1.1 "><p id="p853394453413"><a name="p853394453413"></a><a name="p853394453413"></a>directory</p>
</td>
<td class="cellrowborder" valign="top" width="52%" headers="mcps1.2.4.1.2 "><p id="p653315443342"><a name="p653315443342"></a><a name="p653315443342"></a>Specifies the directory to create.</p>
</td>
<td class="cellrowborder" valign="top" width="27%" headers="mcps1.2.4.1.3 "><p id="p1553344410344"><a name="p1553344410344"></a><a name="p1553344410344"></a>N/A</p>
</td>
</tr>
</tbody>
</table>
## Usage<a name="section1294234115172"></a>
>![](../public_sys-resources/icon-notice.gif) **NOTICE:**
>For the files created on the FAT file system, the file permission attributes are the same as those of the mounted nodes. Currently, the node permissions include only user read and write. The **group** and **others** permissions do not take effect.
>In addition, only the user read and write permissions can be modified. The read and write permissions are **rw** and **ro** only. Therefore, when the **-m** option is specified in the **mkdir** command, only **777** and **555** permissions are available for the created directory, and the execute permission does not take effect.
## Example<a name="section1113345211713"></a>
Run the following commands: Run the following commands:
- mkdir testpath - mkdir testpath
- mkdir -m 777 testpath
- mkdir -pv testpath01/testpath02/testpath03 - mkdir -m 777 testpath
- mkdir -pv testpath01/testpath02/testpath03
## Output
Example 1: Create a directory named **testpath**.
## Output<a name="section10142201012"></a>
``` ```
OHOS:/tmp$ mkdir testpath OHOS:/tmp$ mkdir testpath
...@@ -83,7 +56,8 @@ total 2 ...@@ -83,7 +56,8 @@ total 2
drwxrwxrwx 1 0 0 2048 1979-12-31 00:00 testpath/ drwxrwxrwx 1 0 0 2048 1979-12-31 00:00 testpath/
``` ```
Example 2: creating a directory with specified permissions Example 2: Create a directory named **testpath** with specified permissions.
``` ```
OHOS:/tmp$ mkdir -m 777 testpath OHOS:/tmp$ mkdir -m 777 testpath
...@@ -92,7 +66,8 @@ total 2 ...@@ -92,7 +66,8 @@ total 2
drwxrwxrwx 1 0 0 2048 1979-12-31 00:00 testpath/ drwxrwxrwx 1 0 0 2048 1979-12-31 00:00 testpath/
``` ```
Example 3: creating directories recursively Example 3: Create directories recursively.
``` ```
OHOS:/tmp$ mkdir -pv testpath01/testpath02/testpath03 OHOS:/tmp$ mkdir -pv testpath01/testpath02/testpath03
...@@ -109,4 +84,3 @@ OHOS:/tmp$ ll testpath01/testpath02/ ...@@ -109,4 +84,3 @@ OHOS:/tmp$ ll testpath01/testpath02/
total 2 total 2
drwxrwxrwx 1 0 0 2048 1979-12-31 00:00 testpath03/ drwxrwxrwx 1 0 0 2048 1979-12-31 00:00 testpath03/
``` ```
# mount # mount
## Command Function<a name="section11631837182"></a> ## Command Function
This command is used to mount a device to a specified directory. This command is used to mount a device to a specified directory.
## Syntax<a name="section1697638111820"></a>
## Syntax
mount \[_-f_\] \[_-t TYPE_\] \[_-o OPTION,_\] \[\[_DEVICE_\] _DIR_\]
mount [_-f_] [_-t TYPE_] [_-o OPTION,_] [[_DEVICE_] _DIR_]
## Parameters<a name="section1650151221819"></a>
**Table 1** Parameter description ## Parameters
<a name="table1338mcpsimp"></a> **Table 1** Parameter description
<table><thead align="left"><tr id="row1344mcpsimp"><th class="cellrowborder" valign="top" width="21%" id="mcps1.2.4.1.1"><p id="p1346mcpsimp"><a name="p1346mcpsimp"></a><a name="p1346mcpsimp"></a><strong id="b84913249612"><a name="b84913249612"></a><a name="b84913249612"></a>Parameter</strong></p>
</th> | Parameter | Description | Value Range |
<th class="cellrowborder" valign="top" width="52%" id="mcps1.2.4.1.2"><p id="p1348mcpsimp"><a name="p1348mcpsimp"></a><a name="p1348mcpsimp"></a><strong id="b1136292612616"><a name="b1136292612616"></a><a name="b1136292612616"></a>Description</strong></p> | ------ | ----------------------------------------------------------- | ------------------------------------------------------------ |
</th> | --help | Displays the parameters supported by the **mount** command. | N/A |
<th class="cellrowborder" valign="top" width="27%" id="mcps1.2.4.1.3"><p id="p1350mcpsimp"><a name="p1350mcpsimp"></a><a name="p1350mcpsimp"></a><strong id="b4385271067"><a name="b4385271067"></a><a name="b4385271067"></a>Value Range</strong></p> | -f | Fakes mounting the file system (no mounting is actually performed). | N/A |
</th> | -t | Specifies the file system type. | vfat, yaffs, jffs, ramfs, nfs, procfs, romfs|
</tr> | -o | Specifies the mount options. | N/A |
</thead> | DEVICE | Specifies the device to mount (in the format of the device directory). | A device in the system |
<tbody><tr id="row081413014400"><td class="cellrowborder" valign="top" width="21%" headers="mcps1.2.4.1.1 "><p id="p080318303407"><a name="p080318303407"></a><a name="p080318303407"></a>--help</p> | DIR | Specifies the directory.<br>You must have the execution (search) permission on the specified directory.| N/A |
</td>
<td class="cellrowborder" valign="top" width="52%" headers="mcps1.2.4.1.2 "><p id="p8804113024018"><a name="p8804113024018"></a><a name="p8804113024018"></a>Displays the parameters supported by the <strong id="b07421044122514"><a name="b07421044122514"></a><a name="b07421044122514"></a>mount</strong> command.</p>
</td> ## Usage Guidelines
<td class="cellrowborder" valign="top" width="27%" headers="mcps1.2.4.1.3 "><p id="p280418307406"><a name="p280418307406"></a><a name="p280418307406"></a>N/A</p>
</td> By specifying the device to mount, directory, and file system format in the **mount** command, you can successfully mount the file system to the specified directory.
</tr>
<tr id="row1781443044019"><td class="cellrowborder" valign="top" width="21%" headers="mcps1.2.4.1.1 "><p id="p1580410305409"><a name="p1580410305409"></a><a name="p1580410305409"></a>-f</p> ## Note
</td>
<td class="cellrowborder" valign="top" width="52%" headers="mcps1.2.4.1.2 "><p id="p1980419305409"><a name="p1980419305409"></a><a name="p1980419305409"></a>Fakes mounting the file system (no mounting is actually performed).</p> Currently, the shell does not support this command. mksh supports it. To switch to mksh, run **cd bin** and **./mksh**.
</td>
<td class="cellrowborder" valign="top" width="27%" headers="mcps1.2.4.1.3 "><p id="p58041230114019"><a name="p58041230114019"></a><a name="p58041230114019"></a>N/A</p> ## Example
</td>
</tr> Run **mount -t nfs 192.168.1.3:/nfs nfs**.
<tr id="row1981411307404"><td class="cellrowborder" valign="top" width="21%" headers="mcps1.2.4.1.1 "><p id="p11804143024013"><a name="p11804143024013"></a><a name="p11804143024013"></a>-t</p>
</td>
<td class="cellrowborder" valign="top" width="52%" headers="mcps1.2.4.1.2 "><p id="p680443010409"><a name="p680443010409"></a><a name="p680443010409"></a>Specifies the file system type.</p> ## Output
</td>
<td class="cellrowborder" valign="top" width="27%" headers="mcps1.2.4.1.3 "><p id="p13804193034020"><a name="p13804193034020"></a><a name="p13804193034020"></a>vfat, yaffs, jffs, ramfs, nfs, procfs, romfs</p> Mount the **nfs** directory on the server with IP address of **192.168.1.3** to the newly created **/nfs** directory in the current system.
</td>
</tr>
<tr id="row20813330184020"><td class="cellrowborder" valign="top" width="21%" headers="mcps1.2.4.1.1 "><p id="p168041330194012"><a name="p168041330194012"></a><a name="p168041330194012"></a>-o</p>
</td>
<td class="cellrowborder" valign="top" width="52%" headers="mcps1.2.4.1.2 "><p id="p280473015402"><a name="p280473015402"></a><a name="p280473015402"></a>Specifies the mount options.</p>
</td>
<td class="cellrowborder" valign="top" width="27%" headers="mcps1.2.4.1.3 "><p id="p4804193020407"><a name="p4804193020407"></a><a name="p4804193020407"></a>N/A</p>
</td>
</tr>
<tr id="row0813730134015"><td class="cellrowborder" valign="top" width="21%" headers="mcps1.2.4.1.1 "><p id="p38041030124019"><a name="p38041030124019"></a><a name="p38041030124019"></a>DEVICE</p>
</td>
<td class="cellrowborder" valign="top" width="52%" headers="mcps1.2.4.1.2 "><p id="p28045303401"><a name="p28045303401"></a><a name="p28045303401"></a>Specifies the device to mount (in the format of the device directory).</p>
</td>
<td class="cellrowborder" valign="top" width="27%" headers="mcps1.2.4.1.3 "><p id="p8804113084010"><a name="p8804113084010"></a><a name="p8804113084010"></a>A device in the system</p>
</td>
</tr>
<tr id="row1381383044011"><td class="cellrowborder" valign="top" width="21%" headers="mcps1.2.4.1.1 "><p id="p7804133012406"><a name="p7804133012406"></a><a name="p7804133012406"></a>DIR</p>
</td>
<td class="cellrowborder" valign="top" width="52%" headers="mcps1.2.4.1.2 "><p id="p1380419308409"><a name="p1380419308409"></a><a name="p1380419308409"></a>Specifies the directory.</p>
<p id="p14804153014011"><a name="p14804153014011"></a><a name="p14804153014011"></a>You must have the execution (search) permission on the specified directory.</p>
</td>
<td class="cellrowborder" valign="top" width="27%" headers="mcps1.2.4.1.3 "><p id="p1780403094017"><a name="p1780403094017"></a><a name="p1780403094017"></a>N/A</p>
</td>
</tr>
</tbody>
</table>
## Usage<a name="section124541520171912"></a>
By specifying the device to mount, directory, and file system format in the **mount** command, you can successfully mount the file system to the specified directory.
## Example<a name="section7424625171917"></a>
Run **mount -t nfs 192.168.1.3:/nfs nfs**.
## Output<a name="section14757018116"></a>
Mounting the **nfs** directory on the server with IP address of **192.168.1.3** to the newly created **/nfs** directory in the current system
``` ```
OHOS:/$ mkdir nfs OHOS:/$ mkdir nfs
...@@ -90,4 +53,3 @@ OHOS:/$ ls nfs/ ...@@ -90,4 +53,3 @@ OHOS:/$ ls nfs/
OHOS_Image.bin hello rootfs_vfat.img OHOS_Image.bin hello rootfs_vfat.img
dev_tools mksh_rootfs_vfat.img test_demo dev_tools mksh_rootfs_vfat.img test_demo
``` ```
# mv # mv
## Command Function<a name="section201149459368"></a> ## Command Function
This command is used to move files. This command is used to move files.
## Syntax<a name="section579813484364"></a>
## Syntax
mv \[_-fivn_\] _SOURCE... DEST_
mv [_-fivn_] *SOURCE... DEST*
## Parameters<a name="section168065311366"></a>
**Table 1** Parameter description ## Parameters
<a name="table1845mcpsimp"></a> **Table 1** Parameter description
<table><thead align="left"><tr id="row1851mcpsimp"><th class="cellrowborder" valign="top" width="20.84%" id="mcps1.2.4.1.1"><p id="p1853mcpsimp"><a name="p1853mcpsimp"></a><a name="p1853mcpsimp"></a>Parameter</p>
</th> | Parameter | Description | Value Range |
<th class="cellrowborder" valign="top" width="52.16%" id="mcps1.2.4.1.2"><p id="p1855mcpsimp"><a name="p1855mcpsimp"></a><a name="p1855mcpsimp"></a>Description</p> | ------ | ------------------------------------------------------------ | ----------------------------------------------- |
</th> | -help | Displays help information. | N/A |
<th class="cellrowborder" valign="top" width="27%" id="mcps1.2.4.1.3"><p id="p1857mcpsimp"><a name="p1857mcpsimp"></a><a name="p1857mcpsimp"></a>Value Range</p> | -f | Forcibly overwrites the target file. | N/A |
</th> | -i | Provides information before moving a file that would overwrite an existing file or directory. Enter **y** to overwrite the file or directory, and enter **n** to cancel the operation.| N/A |
</tr> | -n | Do not overwrite any existing file or directory. | N/A |
</thead> | -v | This parameter does not take effect although it is supported by the latest Toybox code. | N/A |
<tbody><tr id="row20678165916440"><td class="cellrowborder" valign="top" width="20.84%" headers="mcps1.2.4.1.1 "><p id="p126571859174418"><a name="p126571859174418"></a><a name="p126571859174418"></a>-help</p> | SOURCE | Specifies the file to move. | This command cannot be used to move a directory. It can be used to move multiple files at a time.|
</td> | DEST | Specifies the destination file path. | Both a directory and a file are supported. |
<td class="cellrowborder" valign="top" width="52.16%" headers="mcps1.2.4.1.2 "><p id="p1165745918447"><a name="p1165745918447"></a><a name="p1165745918447"></a>Displays help information.</p>
</td>
<td class="cellrowborder" valign="top" width="27%" headers="mcps1.2.4.1.3 "><p id="p165725913441"><a name="p165725913441"></a><a name="p165725913441"></a>N/A</p> ## Usage Guidelines
</td>
</tr> - **SOURCEFILE** supports wildcard characters * and ?. The asterisk (*) indicates any number of characters, and the question mark (?) represents a single character. **DEST** does not support wildcard characters. If the specified **SOURCE** matches multiple files, **DEST** must be a directory.
<tr id="row12678159174418"><td class="cellrowborder" valign="top" width="20.84%" headers="mcps1.2.4.1.1 "><p id="p166571959164412"><a name="p166571959164412"></a><a name="p166571959164412"></a>-f</p>
</td> - If **DEST** is a directory, this directory must exist. In this case, the destination file is named after the source file.
<td class="cellrowborder" valign="top" width="52.16%" headers="mcps1.2.4.1.2 "><p id="p8657859134412"><a name="p8657859134412"></a><a name="p8657859134412"></a>Forcibly overwrites the target file.</p>
</td> - If **DEST** is a file, the directory for this file must exist.
<td class="cellrowborder" valign="top" width="27%" headers="mcps1.2.4.1.3 "><p id="p1965775904419"><a name="p1965775904419"></a><a name="p1965775904419"></a>N/A</p>
</td> - If the destination file already exists, it will be overwritten.
</tr>
<tr id="row126781259104418"><td class="cellrowborder" valign="top" width="20.84%" headers="mcps1.2.4.1.1 "><p id="p5657115954414"><a name="p5657115954414"></a><a name="p5657115954414"></a>-i</p> ## Note
</td>
<td class="cellrowborder" valign="top" width="52.16%" headers="mcps1.2.4.1.2 "><p id="p7657105917445"><a name="p7657105917445"></a><a name="p7657105917445"></a>Provides a prompt before moving a file that would overwrite an existing file. Enter <strong id="b886564463218"><a name="b886564463218"></a><a name="b886564463218"></a>y</strong> to overwrite the file or enter <strong id="b16826758113218"><a name="b16826758113218"></a><a name="b16826758113218"></a>n</strong> to cancel the operation.</p> Currently, the shell does not support this command. mksh supports it. To switch to mksh, run **cd bin** and **./mksh**.
</td>
<td class="cellrowborder" valign="top" width="27%" headers="mcps1.2.4.1.3 "><p id="p1165795924415"><a name="p1165795924415"></a><a name="p1165795924415"></a>N/A</p> ## Example
</td>
</tr>
<tr id="row186773599442"><td class="cellrowborder" valign="top" width="20.84%" headers="mcps1.2.4.1.1 "><p id="p86571059114410"><a name="p86571059114410"></a><a name="p86571059114410"></a>-n</p>
</td>
<td class="cellrowborder" valign="top" width="52.16%" headers="mcps1.2.4.1.2 "><p id="p36572059164415"><a name="p36572059164415"></a><a name="p36572059164415"></a>Do not overwrite any existing file or directory.</p>
</td>
<td class="cellrowborder" valign="top" width="27%" headers="mcps1.2.4.1.3 "><p id="p1965715944417"><a name="p1965715944417"></a><a name="p1965715944417"></a>N/A</p>
</td>
</tr>
<tr id="row66771159124413"><td class="cellrowborder" valign="top" width="20.84%" headers="mcps1.2.4.1.1 "><p id="p15657185964416"><a name="p15657185964416"></a><a name="p15657185964416"></a>-v</p>
</td>
<td class="cellrowborder" valign="top" width="52.16%" headers="mcps1.2.4.1.2 "><p id="p166571759124418"><a name="p166571759124418"></a><a name="p166571759124418"></a>This parameter does not take effect although it is supported by the latest Toybox code.</p>
</td>
<td class="cellrowborder" valign="top" width="27%" headers="mcps1.2.4.1.3 "><p id="p12657059184418"><a name="p12657059184418"></a><a name="p12657059184418"></a>N/A</p>
</td>
</tr>
<tr id="row11677145964419"><td class="cellrowborder" valign="top" width="20.84%" headers="mcps1.2.4.1.1 "><p id="p2657205924414"><a name="p2657205924414"></a><a name="p2657205924414"></a>SOURCE</p>
</td>
<td class="cellrowborder" valign="top" width="52.16%" headers="mcps1.2.4.1.2 "><p id="p3657205924416"><a name="p3657205924416"></a><a name="p3657205924416"></a>Specifies the path of the source file.</p>
</td>
<td class="cellrowborder" valign="top" width="27%" headers="mcps1.2.4.1.3 "><p id="p1365775904419"><a name="p1365775904419"></a><a name="p1365775904419"></a>This command cannot be used to move a directory. It can be used to move multiple files at a time.</p>
</td>
</tr>
<tr id="row1267615917447"><td class="cellrowborder" valign="top" width="20.84%" headers="mcps1.2.4.1.1 "><p id="p1658459144411"><a name="p1658459144411"></a><a name="p1658459144411"></a>DEST</p>
</td>
<td class="cellrowborder" valign="top" width="52.16%" headers="mcps1.2.4.1.2 "><p id="p265810599448"><a name="p265810599448"></a><a name="p265810599448"></a>Specifies the destination file path.</p>
</td>
<td class="cellrowborder" valign="top" width="27%" headers="mcps1.2.4.1.3 "><p id="p7658105914449"><a name="p7658105914449"></a><a name="p7658105914449"></a>Both a directory and a file are supported.</p>
</td>
</tr>
</tbody>
</table>
## Usage<a name="section19190125723612"></a>
- **SOURCE** supports wildcard characters \* and ?. The asterisk \(\*\) indicates any number of characters, and the question mark \(?\) represents a single character. **DEST** does not support wildcard characters. If the specified **SOURCE** matches multiple files, **DEST** must be a directory.
- If **DEST** is a directory, this directory must exist. In this case, the destination file is named after the source file.
- If **DEST** is a file, the directory for this file must exist.
- If the destination file already exists, it will be overwritten.
## Example<a name="section10383416372"></a>
Run the following commands: Run the following commands:
- mv -i test.txt testpath/ - mv -i test.txt testpath/
- mv test?.txt testpath/ \(Move **test3.txt**, **testA.txt**, and **test\_.txt**\)
## Output<a name="section131601649114511"></a> - mv test?.txt testpath/ (Move **test3.txt**, **testA.txt**, and **test_.txt**)
## Output
Example 1: Move a file.
Example 1: moving a file
``` ```
OHOS:/$ touch test.txt OHOS:/$ touch test.txt
...@@ -112,7 +74,8 @@ bin etc proc storage test.txt userdata vendor ...@@ -112,7 +74,8 @@ bin etc proc storage test.txt userdata vendor
dev lib sdcard system testpath usr dev lib sdcard system testpath usr
``` ```
Example 2: moving files using wildcards Example 2: Move files.
``` ```
OHOS:/$ ls OHOS:/$ ls
...@@ -125,4 +88,3 @@ dev lib sdcard system testpath usr ...@@ -125,4 +88,3 @@ dev lib sdcard system testpath usr
OHOS:/$ ls testpath/ OHOS:/$ ls testpath/
test.txt test3.txt testA.txt test_.txt test.txt test3.txt testA.txt test_.txt
``` ```
# partinfo # partinfo
## Command Function<a name="section1777503617199"></a> ## Command Function
This command is used to query information about the partitions of a hard disk or SD card identified by the system. This command is used to query information about the partitions of a hard disk or SD card identified by the system.
## Syntax<a name="section185501447132114"></a>
partinfo <_dev\_inodename_\> ## Syntax
## Parameters<a name="section1304151212252"></a> partinfo &lt;*dev*inodename_&gt;
**Table 1** Parameter description
<a name="table1390mcpsimp"></a> ## Parameters
<table><thead align="left"><tr id="row1396mcpsimp"><th class="cellrowborder" valign="top" width="22%" id="mcps1.2.4.1.1"><p id="p1398mcpsimp"><a name="p1398mcpsimp"></a><a name="p1398mcpsimp"></a><strong id="b130786349111516"><a name="b130786349111516"></a><a name="b130786349111516"></a>Parameter</strong></p>
</th>
<th class="cellrowborder" valign="top" width="51%" id="mcps1.2.4.1.2"><p id="p1400mcpsimp"><a name="p1400mcpsimp"></a><a name="p1400mcpsimp"></a><strong id="b1089142031013"><a name="b1089142031013"></a><a name="b1089142031013"></a>Description</strong></p>
</th>
<th class="cellrowborder" valign="top" width="27%" id="mcps1.2.4.1.3"><p id="p1402mcpsimp"><a name="p1402mcpsimp"></a><a name="p1402mcpsimp"></a><strong id="b17244395211516"><a name="b17244395211516"></a><a name="b17244395211516"></a>Value Range</strong></p>
</th>
</tr>
</thead>
<tbody><tr id="row1403mcpsimp"><td class="cellrowborder" valign="top" width="22%" headers="mcps1.2.4.1.1 "><p id="p1405mcpsimp"><a name="p1405mcpsimp"></a><a name="p1405mcpsimp"></a>dev_inodename</p>
</td>
<td class="cellrowborder" valign="top" width="51%" headers="mcps1.2.4.1.2 "><p id="p1407mcpsimp"><a name="p1407mcpsimp"></a><a name="p1407mcpsimp"></a>Specifies the name of the partition to be queried.</p>
</td>
<td class="cellrowborder" valign="top" width="27%" headers="mcps1.2.4.1.3 "><p id="p1409mcpsimp"><a name="p1409mcpsimp"></a><a name="p1409mcpsimp"></a>A valid partition name</p>
</td>
</tr>
</tbody>
</table>
## Usage<a name="section4566131982520"></a> **Table 1** Parameter description
None | Parameter| Description| Value Range|
| -------- | -------- | -------- |
| dev_inodename | Specifies the name of the partition to be queried.| A valid partition name|
## Example<a name="section4351134942514"></a>
Run **partinfo /dev/mmcblk0p0**. ## Usage Guidelines
## Output<a name="section66689331412"></a> None.
## Example
Run **partinfo /dev/mmcblk0p0**.
## Output
System partition information: System partition information:
``` ```
OHOS # partinfo /dev/mmcblk0p0 OHOS # partinfo /dev/mmcblk0p0
part info : part info :
...@@ -55,4 +46,3 @@ part filesystem : 00 ...@@ -55,4 +46,3 @@ part filesystem : 00
part sec start : 20480 part sec start : 20480
part sec count : 102400 part sec count : 102400
``` ```
# pwd # pwd
## Command Function<a name="section197737712267"></a> ## Command Function
This command is used to display the current path. This command is used to display the current path.
## Syntax<a name="section1544061016267"></a>
## Syntax
pwd pwd
## Parameters<a name="section599112120262"></a>
None ## Parameters
None.
## Usage Guidelines
## Usage<a name="section66901116152615"></a> The **pwd** command writes the full path (from the root directory) of the current directory to the standard output. The directories are separated by slashes (/). The directory following the first slash (/) indicates the root directory, and the last directory is the current directory.
The **pwd** command writes the full path \(from the root directory\) of the current directory to the standard output. The directories are separated by slashes \(/\). The directory following the first slash \(/\) indicates the root directory, and the last directory is the current directory.
## Example<a name="section7427181922612"></a> ## Example
Run **pwd**. Run **pwd**.
## Output<a name="section116313389418"></a>
## Output
Current path: Current path:
``` ```
OHOS:/sdcard/nfs$ pwd OHOS:/sdcard/nfs$ pwd
/sdcard/nfs /sdcard/nfs
``` ```
# rm # rm
## Command Function<a name="section181141523142613"></a> ## Command Function
This command is used to delete a file or folder. This command is used to delete a file or folder.
## Syntax<a name="section8800926132619"></a>
## Syntax
rm \[_-fv_\] _FILE or rm_ \[_-rv_\] \[_PATH_ | _filename_\]...
rm [_-fv_] *FILE or rm* [_-rv_] [_PATH_ | _filename_]...
## Parameters<a name="section15476229152617"></a>
**Table 1** Parameter description ## Parameters
<a name="table1507mcpsimp"></a> **Table 1** Parameter description
<table><thead align="left"><tr id="row1513mcpsimp"><th class="cellrowborder" valign="top" width="22.220000000000002%" id="mcps1.2.4.1.1"><p id="p1515mcpsimp"><a name="p1515mcpsimp"></a><a name="p1515mcpsimp"></a><strong id="b8231115224817"><a name="b8231115224817"></a><a name="b8231115224817"></a>Parameter</strong></p>
</th> | Parameter | Description |
<th class="cellrowborder" valign="top" width="51.519999999999996%" id="mcps1.2.4.1.2"><p id="p1517mcpsimp"><a name="p1517mcpsimp"></a><a name="p1517mcpsimp"></a><strong id="b1599275514488"><a name="b1599275514488"></a><a name="b1599275514488"></a>Description</strong></p> | ------------- | ------------------------------------------------ |
</th> | -r | Deletes empty or non-empty directories. |
<th class="cellrowborder" valign="top" width="26.26%" id="mcps1.2.4.1.3"><p id="p1519mcpsimp"><a name="p1519mcpsimp"></a><a name="p1519mcpsimp"></a><strong id="b186611453114810"><a name="b186611453114810"></a><a name="b186611453114810"></a>Value Range</strong></p> | -f | Deletes a file or directory forcibly without confirmation. No error will be reported when a file that does not exist is to be deleted.|
</th> | -v | Displays the deletion process. |
</tr> | PATH/filename | Specifies the name of the file or directory to delete. The value can be a path. |
</thead>
<tbody><tr id="row231513373307"><td class="cellrowborder" valign="top" width="22.220000000000002%" headers="mcps1.2.4.1.1 "><p id="p73091437173016"><a name="p73091437173016"></a><a name="p73091437173016"></a>-r</p>
</td> ## Usage Guidelines
<td class="cellrowborder" valign="top" width="51.519999999999996%" headers="mcps1.2.4.1.2 "><p id="p630917373307"><a name="p630917373307"></a><a name="p630917373307"></a>Deletes empty or non-empty directories.</p>
</td> - The **rm** command can be used to delete multiple files or folders at a time.
<td class="cellrowborder" valign="top" width="26.26%" headers="mcps1.2.4.1.3 "><p id="p1430943753016"><a name="p1430943753016"></a><a name="p1430943753016"></a>N/A</p>
</td> - You can run **rm -r** to delete a non-empty directory.
</tr>
<tr id="row1231583773013"><td class="cellrowborder" valign="top" width="22.220000000000002%" headers="mcps1.2.4.1.1 "><p id="p19309203763010"><a name="p19309203763010"></a><a name="p19309203763010"></a>-f</p> - If the **rm** command without **-f** is used to delete a file that does not exist, an error will be reported.
</td>
<td class="cellrowborder" valign="top" width="51.519999999999996%" headers="mcps1.2.4.1.2 "><p id="p53092373308"><a name="p53092373308"></a><a name="p53092373308"></a>Deletes a file or directory forcibly without confirmation. No error will be reported when a file that does not exist is to be deleted.</p> ## Note
</td>
<td class="cellrowborder" valign="top" width="26.26%" headers="mcps1.2.4.1.3 "><p id="p8309937153018"><a name="p8309937153018"></a><a name="p8309937153018"></a>N/A</p> The shell does not support **-v** or **-f**. mksh supports them. To switch to mksh, run **cd bin** and **./mksh**.
</td>
</tr> ## Example
<tr id="row331513719302"><td class="cellrowborder" valign="top" width="22.220000000000002%" headers="mcps1.2.4.1.1 "><p id="p5309103733013"><a name="p5309103733013"></a><a name="p5309103733013"></a>-v</p>
</td>
<td class="cellrowborder" valign="top" width="51.519999999999996%" headers="mcps1.2.4.1.2 "><p id="p1830913711300"><a name="p1830913711300"></a><a name="p1830913711300"></a>Displays the deletion process.</p>
</td>
<td class="cellrowborder" valign="top" width="26.26%" headers="mcps1.2.4.1.3 "><p id="p230933703015"><a name="p230933703015"></a><a name="p230933703015"></a>N/A</p>
</td>
</tr>
<tr id="row173147371301"><td class="cellrowborder" valign="top" width="22.220000000000002%" headers="mcps1.2.4.1.1 "><p id="p14309143753012"><a name="p14309143753012"></a><a name="p14309143753012"></a>PATH/filename</p>
</td>
<td class="cellrowborder" valign="top" width="51.519999999999996%" headers="mcps1.2.4.1.2 "><p id="p193091637183016"><a name="p193091637183016"></a><a name="p193091637183016"></a>Specifies the name of the file or directory to delete. The value can be a path.</p>
</td>
<td class="cellrowborder" valign="top" width="26.26%" headers="mcps1.2.4.1.3 "><p id="p10309173711309"><a name="p10309173711309"></a><a name="p10309173711309"></a>N/A</p>
</td>
</tr>
</tbody>
</table>
## Usage<a name="section10578163215262"></a>
- The **rm** command can be used to delete multiple files or folders at a time.
- You can run **rm -r** to delete a non-empty directory.
- If the **rm** command without **-f** is used to delete a file that does not exist, an error will be reported.
## Example<a name="section18548133511263"></a>
Run the following commands: Run the following commands:
- rm testfile - rm testfile
- rm -r testpath/
- rm -r testpath/
## Output<a name="section1565323814265"></a>
Example 1: deleting **testfile** ## Output
Example 1: Delete **testfile**.
``` ```
OHOS:/$ ls OHOS:/$ ls
...@@ -80,7 +59,8 @@ bin etc proc storage userdata vendor ...@@ -80,7 +59,8 @@ bin etc proc storage userdata vendor
dev lib sdcard system usr dev lib sdcard system usr
``` ```
Example 2: deleting **testpath**, a non-empty directory Example 2: Delete **testpath**, a non-empty directory.
``` ```
OHOS:/$ ls OHOS:/$ ls
...@@ -91,4 +71,3 @@ OHOS:/$ ls ...@@ -91,4 +71,3 @@ OHOS:/$ ls
bin etc proc storage userdata vendor bin etc proc storage userdata vendor
dev lib sdcard system usr dev lib sdcard system usr
``` ```
# rmdir # rmdir
## Command Function<a name="section1839611420266"></a> ## Command Function
This command is used to delete a directory. This command is used to delete a directory.
## Syntax<a name="section329574512266"></a>
## Syntax
rmdir \[_-p_\] \[_dirname..._\]
rmdir [_-p_] [_dirname..._]
## Parameters<a name="section15865747102620"></a>
**Table 1** Parameter description ## Parameters
<a name="table1557mcpsimp"></a> **Table 1** Parameter description
<table><thead align="left"><tr id="row1563mcpsimp"><th class="cellrowborder" valign="top" width="21%" id="mcps1.2.4.1.1"><p id="p1565mcpsimp"><a name="p1565mcpsimp"></a><a name="p1565mcpsimp"></a><strong id="b170710424141"><a name="b170710424141"></a><a name="b170710424141"></a>Parameter</strong></p>
</th> | Parameter| Description| Value Range|
<th class="cellrowborder" valign="top" width="52%" id="mcps1.2.4.1.2"><p id="p1567mcpsimp"><a name="p1567mcpsimp"></a><a name="p1567mcpsimp"></a><strong id="b10358846121415"><a name="b10358846121415"></a><a name="b10358846121415"></a>Description</strong></p> | -------- | -------- | -------- |
</th> | --help | Displays the parameters supported by the **rmdir** command.| N/A |
<th class="cellrowborder" valign="top" width="27%" id="mcps1.2.4.1.3"><p id="p1569mcpsimp"><a name="p1569mcpsimp"></a><a name="p1569mcpsimp"></a><strong id="b171032047111410"><a name="b171032047111410"></a><a name="b171032047111410"></a>Value Range</strong></p> | -p | Deletes a path.| N/A |
</th> | --ignore-fail-on-non-empty | Suppresses the error message when a non-empty directory is to be deleted.| N/A |
</tr> | dir | Specifies the name of the directory to delete. The directory must be empty. A path is supported.| N/A |
</thead>
<tbody><tr id="row17771161013316"><td class="cellrowborder" valign="top" width="21%" headers="mcps1.2.4.1.1 "><p id="p19752111019336"><a name="p19752111019336"></a><a name="p19752111019336"></a>--help</p>
</td> ## Usage Guidelines
<td class="cellrowborder" valign="top" width="52%" headers="mcps1.2.4.1.2 "><p id="p18752121015338"><a name="p18752121015338"></a><a name="p18752121015338"></a>Displays the parameters supported by the <strong id="b101038101521"><a name="b101038101521"></a><a name="b101038101521"></a>rmdir</strong> command.</p>
</td> - The **rmdir** command can only be used to delete directories.
<td class="cellrowborder" valign="top" width="27%" headers="mcps1.2.4.1.3 "><p id="p127521810103316"><a name="p127521810103316"></a><a name="p127521810103316"></a>N/A</p>
</td> - The **rmdir** command can delete only one directory at a time.
</tr>
<tr id="row977061043317"><td class="cellrowborder" valign="top" width="21%" headers="mcps1.2.4.1.1 "><p id="p67521810113316"><a name="p67521810113316"></a><a name="p67521810113316"></a>-p</p> - The **rmdir** command can delete only empty directories.
</td>
<td class="cellrowborder" valign="top" width="52%" headers="mcps1.2.4.1.2 "><p id="p1475271013319"><a name="p1475271013319"></a><a name="p1475271013319"></a>Deletes a path.</p>
</td> ## Example
<td class="cellrowborder" valign="top" width="27%" headers="mcps1.2.4.1.3 "><p id="p117525107338"><a name="p117525107338"></a><a name="p117525107338"></a>N/A</p>
</td> Run **rmdir dir**.
</tr>
<tr id="row2769810133315"><td class="cellrowborder" valign="top" width="21%" headers="mcps1.2.4.1.1 "><p id="p775211053314"><a name="p775211053314"></a><a name="p775211053314"></a>--ignore-fail-on-non-empty</p>
</td> ## Output
<td class="cellrowborder" valign="top" width="52%" headers="mcps1.2.4.1.2 "><p id="p77522010123314"><a name="p77522010123314"></a><a name="p77522010123314"></a>Suppresses the error message when a non-empty directory is to be deleted.</p>
</td> Delete the directory **dir**.
<td class="cellrowborder" valign="top" width="27%" headers="mcps1.2.4.1.3 "><p id="p1475281014339"><a name="p1475281014339"></a><a name="p1475281014339"></a>N/A</p>
</td>
</tr>
<tr id="row1776918105337"><td class="cellrowborder" valign="top" width="21%" headers="mcps1.2.4.1.1 "><p id="p5752141018337"><a name="p5752141018337"></a><a name="p5752141018337"></a>dir</p>
</td>
<td class="cellrowborder" valign="top" width="52%" headers="mcps1.2.4.1.2 "><p id="p3752161083313"><a name="p3752161083313"></a><a name="p3752161083313"></a>Specifies the name of the directory to delete. The directory must be empty. A path is supported.</p>
</td>
<td class="cellrowborder" valign="top" width="27%" headers="mcps1.2.4.1.3 "><p id="p57521210113313"><a name="p57521210113313"></a><a name="p57521210113313"></a>N/A</p>
</td>
</tr>
</tbody>
</table>
## Usage<a name="section107857508261"></a>
- The **rmdir** command can only be used to delete directories.
- The **rmdir** command can delete only one directory at a time.
- The **rmdir** command can delete only empty directories.
## Example<a name="section11196165315262"></a>
Run **rmdir dir**.
## Output<a name="section1073811415613"></a>
Deleting the directory **dir**:
``` ```
OHOS:/test$ mkdir dir OHOS:/test$ mkdir dir
...@@ -74,4 +49,3 @@ dir ...@@ -74,4 +49,3 @@ dir
OHOS:/test$ rmdir dir/ OHOS:/test$ rmdir dir/
OHOS:/test$ ls OHOS:/test$ ls
``` ```
# statfs # statfs
## Command Function<a name="section153921657152613"></a> ## Command Function
This command is used to print information about a file system, such as the type, total size, and available size. This command is used to print information about a file system, such as the type, total size, and available size.
## Syntax<a name="section135391102717"></a>
statfs \[_directory_\] ## Syntax
## Parameters<a name="section074312314279"></a> statfs [_directory_]
**Table 1** Parameter description
<a name="table1597mcpsimp"></a> ## Parameters
<table><thead align="left"><tr id="row1603mcpsimp"><th class="cellrowborder" valign="top" width="33.33333333333333%" id="mcps1.2.4.1.1"><p id="p1605mcpsimp"><a name="p1605mcpsimp"></a><a name="p1605mcpsimp"></a><strong id="b156942710240"><a name="b156942710240"></a><a name="b156942710240"></a>Parameter</strong></p>
</th>
<th class="cellrowborder" valign="top" width="33.33333333333333%" id="mcps1.2.4.1.2"><p id="p1607mcpsimp"><a name="p1607mcpsimp"></a><a name="p1607mcpsimp"></a><strong id="b1759110293240"><a name="b1759110293240"></a><a name="b1759110293240"></a>Description</strong></p>
</th>
<th class="cellrowborder" valign="top" width="33.33333333333333%" id="mcps1.2.4.1.3"><p id="p1609mcpsimp"><a name="p1609mcpsimp"></a><a name="p1609mcpsimp"></a><strong id="b10264183019242"><a name="b10264183019242"></a><a name="b10264183019242"></a>Value Range</strong></p>
</th>
</tr>
</thead>
<tbody><tr id="row1610mcpsimp"><td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.2.4.1.1 "><p id="p1612mcpsimp"><a name="p1612mcpsimp"></a><a name="p1612mcpsimp"></a>directory</p>
</td>
<td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.2.4.1.2 "><p id="p1615mcpsimp"><a name="p1615mcpsimp"></a><a name="p1615mcpsimp"></a>Specifies the file system directory.</p>
</td>
<td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.2.4.1.3 "><p id="p1617mcpsimp"><a name="p1617mcpsimp"></a><a name="p1617mcpsimp"></a>The file system must exist and support the <strong id="b1635148125717"><a name="b1635148125717"></a><a name="b1635148125717"></a>statfs</strong> command. The supported file systems include JFFS2, FAT, and NFS.</p>
</td>
</tr>
</tbody>
</table>
## Usage<a name="section133816772712"></a> **Table 1** Parameter description
| Parameter| Description| Value Range|
| -------- | -------- | -------- |
| directory | Specifies the file system directory.| The file system must exist and support the **statfs** command. The supported file systems include JFFS2, FAT, and NFS.|
## Usage Guidelines
The printed information varies depending on the file system. The printed information varies depending on the file system.
## Example<a name="section526149182717"></a>
## Example
The following uses the NFS as an example: The following uses the NFS as an example:
Run **statfs /nfs**. Run **statfs /nfs**.
**statfs** command output **statfs** command output
``` ```
OHOS # statfs ./nfs OHOS # statfs ./nfs
...@@ -57,4 +46,3 @@ statfs got: ...@@ -57,4 +46,3 @@ statfs got:
total size: 808742490112 Bytes total size: 808742490112 Bytes
free size: 255618461696 Bytes free size: 255618461696 Bytes
``` ```
# sync # sync
## Command Function<a name="section1285017122274"></a> ## Command Function
This command is used to synchronize cached data \(data in the file system\) to an SD card. This command is used to synchronize cached data (data in the file system) to an SD card.
## Syntax<a name="section4731516162712"></a>
## Syntax
sync sync
## Parameters<a name="section9352418122714"></a>
None ## Parameters
None.
## Usage Guidelines
- The **sync** command is used to refresh the cache. If no SD card is inserted, no operation will be performed.
## Usage<a name="section10725192142717"></a> - When an SD card is inserted, the cache information is synchronized to the SD card. If the synchronization is successful, no information is displayed.
- The **sync** command is used to refresh the cache. If no SD card is inserted, no operation will be performed.
- When an SD card is inserted, the cache information is synchronized to the SD card. If the synchronization is successful, no information is displayed.
## Example<a name="section414434814354"></a> ## Example
Run **sync**. Data will be synchronized to the SD card if an SD card is available, and no operation will be performed if no SD card is available. Run **sync**. Data will be synchronized to the SD card if an SD card is available, and no operation will be performed if no SD card is available.
## Output<a name="section19618121710317"></a>
None ## Output
None.
# touch # touch
## Command Function<a name="section17541924112716"></a> ## Command Function
- This command is used to create an empty file in a specified directory. - This command is used to create an empty file in a specified directory.
- If this command is executed to create an existing file, the execution will be successful but the timestamp will not be updated.
## Syntax<a name="section866182711274"></a> - If this command is executed to create an existing file, the execution will be successful but the timestamp will not be updated.
touch \[_filename_\]
## Parameters<a name="section268912296270"></a> ## Syntax
**Table 1** Parameter description touch [_filename_]
<a name="table1635mcpsimp"></a>
<table><thead align="left"><tr id="row1642mcpsimp"><th class="cellrowborder" valign="top" width="20.73%" id="mcps1.2.4.1.1"><p id="p1653mcpsimp"><a name="p1653mcpsimp"></a><a name="p1653mcpsimp"></a><strong id="b132581435193918"><a name="b132581435193918"></a><a name="b132581435193918"></a>Parameter</strong></p>
</th>
<th class="cellrowborder" valign="top" width="52.44%" id="mcps1.2.4.1.2"><p id="p1655mcpsimp"><a name="p1655mcpsimp"></a><a name="p1655mcpsimp"></a><strong id="b88661537163918"><a name="b88661537163918"></a><a name="b88661537163918"></a>Description</strong></p>
</th>
<th class="cellrowborder" valign="top" width="26.83%" id="mcps1.2.4.1.3"><p id="p1657mcpsimp"><a name="p1657mcpsimp"></a><a name="p1657mcpsimp"></a><strong id="b164851738193910"><a name="b164851738193910"></a><a name="b164851738193910"></a>Value Range</strong></p>
</th>
</tr>
</thead>
<tbody><tr id="row1323618419461"><td class="cellrowborder" valign="top" width="20.73%" headers="mcps1.2.4.1.1 "><p id="p1229443463"><a name="p1229443463"></a><a name="p1229443463"></a>--help</p>
</td>
<td class="cellrowborder" valign="top" width="52.44%" headers="mcps1.2.4.1.2 "><p id="p1122915417465"><a name="p1122915417465"></a><a name="p1122915417465"></a>Displays the parameters supported by the <strong id="b39321953125917"><a name="b39321953125917"></a><a name="b39321953125917"></a>touch</strong> command.</p>
</td>
<td class="cellrowborder" valign="top" width="26.83%" headers="mcps1.2.4.1.3 "><p id="p152291464613"><a name="p152291464613"></a><a name="p152291464613"></a>N/A</p>
</td>
</tr>
<tr id="row82356419461"><td class="cellrowborder" valign="top" width="20.73%" headers="mcps1.2.4.1.1 "><p id="p322913424613"><a name="p322913424613"></a><a name="p322913424613"></a>filename</p>
</td>
<td class="cellrowborder" valign="top" width="52.44%" headers="mcps1.2.4.1.2 "><p id="p162291494614"><a name="p162291494614"></a><a name="p162291494614"></a>Specifies the name of the file to create.</p>
</td>
<td class="cellrowborder" valign="top" width="26.83%" headers="mcps1.2.4.1.3 "><p id="p182291242462"><a name="p182291242462"></a><a name="p182291242462"></a>N/A</p>
</td>
</tr>
</tbody>
</table>
## Usage<a name="section412093332714"></a> ## Parameters
- The **touch** command creates an empty file that is readable and writeable. **Table 1** Parameter description
- You can use the **touch** command to create multiple files at a time.
>![](../public_sys-resources/icon-notice.gif) **NOTICE:** | Parameter | Description | Value Range|
>If you run the **touch** command to create a file in a directory storing important system resources, unexpected results such as a system breakdown may occur. For example, if you run the **touch uartdev-0** command in the **/dev** directory, the system may stop responding. | -------- | --------------------------- | -------- |
| --help | Displays the parameters supported by the **touch** command.| N/A |
| filename | Specifies the name of the file to create. | N/A |
## Example<a name="section414434814354"></a> ## Usage Guidelines
- The **touch** command creates an empty file that is readable and writeable.
- You can use the **touch** command to create multiple files at a time.
> **NOTICE**<br>
> If you run the **touch** command to create a file in a directory storing important system resources, unexpected results such as a system breakdown may occur. For example, if you run the **touch uartdev-0** command in the **/dev** directory, the system may stop responding.
## Note
The shell does not support **--help** or creation of multiple files at the same time. mksh supports it. To switch to mksh, run **cd bin** and **./mksh**.
## Example
Run the following commands: Run the following commands:
- touch file.c - touch file.c
- touch testfile1 testfile2 testfile3
## Output<a name="section1028419515711"></a> - touch testfile1 testfile2 testfile3
## Output
Example 1: Create a file named **file.c**.
Example 1: creating the **file.c** file
``` ```
OHOS:/tmp$ ls OHOS:/tmp$ ls
...@@ -70,7 +60,8 @@ total 0 ...@@ -70,7 +60,8 @@ total 0
-rwxrwxrwx 1 0 0 0 1979-12-31 00:00 file.c* -rwxrwxrwx 1 0 0 0 1979-12-31 00:00 file.c*
``` ```
Example 2: creating three files \(**testfile1**, **testfile2**, and **testfile3**\) Example 2: Create three files (**testfile1**, **testfile2**, and **testfile3**) at a time.
``` ```
*OHOS:/tmp$ *OHOS:/tmp$
...@@ -82,4 +73,3 @@ total 0 ...@@ -82,4 +73,3 @@ total 0
-rwxrwxrwx 1 0 0 0 1979-12-31 00:00 testfile3* -rwxrwxrwx 1 0 0 0 1979-12-31 00:00 testfile3*
OHOS:/tmp$ OHOS:/tmp$
``` ```
# umount # umount
## Command Function<a name="section365125133520"></a> ## Command Function
This command is used to unmount a specified file system. This command is used to unmount a file system.
## Syntax<a name="section9615254123512"></a>
## Syntax
umount \[_-a \[-t TYPE\]_\] \[_dir_\]
umount [_-a [-t TYPE]_] [_dir_]
## Parameters<a name="section63446577355"></a>
**Table 1** Parameter description ## Parameters
<a name="table1713mcpsimp"></a> **Table 1** Parameter description
<table><thead align="left"><tr id="row1719mcpsimp"><th class="cellrowborder" valign="top" width="21%" id="mcps1.2.4.1.1"><p id="p1721mcpsimp"><a name="p1721mcpsimp"></a><a name="p1721mcpsimp"></a><strong id="b18608121184416"><a name="b18608121184416"></a><a name="b18608121184416"></a>Parameter</strong></p>
</th> | Parameter | Description | Value Range |
<th class="cellrowborder" valign="top" width="52%" id="mcps1.2.4.1.2"><p id="p1723mcpsimp"><a name="p1723mcpsimp"></a><a name="p1723mcpsimp"></a><strong id="b123794114417"><a name="b123794114417"></a><a name="b123794114417"></a>Description</strong></p> | ------ | ------------------------------------------------------------ | -------------------------- |
</th> | --help | Displays the parameters supported by the **umount** command. | N/A |
<th class="cellrowborder" valign="top" width="27%" id="mcps1.2.4.1.3"><p id="p1725mcpsimp"><a name="p1725mcpsimp"></a><a name="p1725mcpsimp"></a><strong id="b8664446440"><a name="b8664446440"></a><a name="b8664446440"></a>Value Range</strong></p> | -a | Unmounts all file systems mounted. | N/A |
</th> | -t | Used together with the **-a** option to restrict the file systems specified by **-a**, allowing only the file system specified by **-t** to be unmounted.| N/A |
</tr> | dir | Specifies the directory from which the file system is to be unmounted. | Directory mounted with the file system|
</thead>
<tbody><tr id="row915417105016"><td class="cellrowborder" valign="top" width="21%" headers="mcps1.2.4.1.1 "><p id="p1299991675018"><a name="p1299991675018"></a><a name="p1299991675018"></a>--help</p>
</td> ## Usage Guidelines
<td class="cellrowborder" valign="top" width="52%" headers="mcps1.2.4.1.2 "><p id="p5999201625017"><a name="p5999201625017"></a><a name="p5999201625017"></a>Displays the parameters supported by the <strong id="b15196112818310"><a name="b15196112818310"></a><a name="b15196112818310"></a>umount</strong> command.</p>
</td> By specifying the **dir** parameter in the **unmount** command, you can unmount the specified file system.
<td class="cellrowborder" valign="top" width="27%" headers="mcps1.2.4.1.3 "><p id="p1899981685020"><a name="p1899981685020"></a><a name="p1899981685020"></a>N/A</p>
</td> ## Note
</tr>
<tr id="row17151317125011"><td class="cellrowborder" valign="top" width="21%" headers="mcps1.2.4.1.1 "><p id="p1399931616501"><a name="p1399931616501"></a><a name="p1399931616501"></a>-a</p> The shell does not support this command. mksh supports it. To switch to mksh, run **cd bin** and **./mksh**.
</td>
<td class="cellrowborder" valign="top" width="52%" headers="mcps1.2.4.1.2 "><p id="p159991716125019"><a name="p159991716125019"></a><a name="p159991716125019"></a>Unmounts all file systems mounted.</p> ## Example
</td>
<td class="cellrowborder" valign="top" width="27%" headers="mcps1.2.4.1.3 "><p id="p999918167508"><a name="p999918167508"></a><a name="p999918167508"></a>N/A</p>
</td>
</tr>
<tr id="row21414171504"><td class="cellrowborder" valign="top" width="21%" headers="mcps1.2.4.1.1 "><p id="p129997169509"><a name="p129997169509"></a><a name="p129997169509"></a>-t</p>
</td>
<td class="cellrowborder" valign="top" width="52%" headers="mcps1.2.4.1.2 "><p id="p49997167506"><a name="p49997167506"></a><a name="p49997167506"></a>Used together with the <strong id="b19922101571717"><a name="b19922101571717"></a><a name="b19922101571717"></a>-a</strong> option to restrict the file systems specified by <strong id="b1927154112172"><a name="b1927154112172"></a><a name="b1927154112172"></a>-a</strong>, allowing only the file system specified by <strong id="b99221198185"><a name="b99221198185"></a><a name="b99221198185"></a>-t</strong> to be unmounted.</p>
</td>
<td class="cellrowborder" valign="top" width="27%" headers="mcps1.2.4.1.3 "><p id="p0999171695016"><a name="p0999171695016"></a><a name="p0999171695016"></a>N/A</p>
</td>
</tr>
<tr id="row131441775015"><td class="cellrowborder" valign="top" width="21%" headers="mcps1.2.4.1.1 "><p id="p49990164502"><a name="p49990164502"></a><a name="p49990164502"></a>dir</p>
</td>
<td class="cellrowborder" valign="top" width="52%" headers="mcps1.2.4.1.2 "><p id="p129991162504"><a name="p129991162504"></a><a name="p129991162504"></a>Specifies the directory from which the file system is to be unmounted.</p>
</td>
<td class="cellrowborder" valign="top" width="27%" headers="mcps1.2.4.1.3 "><p id="p1499916164502"><a name="p1499916164502"></a><a name="p1499916164502"></a>Directory mounted with the file system</p>
</td>
</tr>
</tbody>
</table>
## Usage<a name="section92931509368"></a>
By specifying the **dir** parameter in the **unmount** command, you can unmount the specified file system from the directory.
## Example<a name="section144311323616"></a>
Run the following commands: Run the following commands:
- umount ./nfs - umount ./nfs
- umount -a -t nfs
- umount -a -t nfs
## Output<a name="section360525113611"></a>
**unmount** command output: ## Output
Example 1: Unmount the file system from **./nfs**.
Example 1: unmounting the file system from **./nfs**
``` ```
OHOS:/$ umount ./nfs/ OHOS:/$ umount ./nfs/
umount ok umount ok
``` ```
Example 2: unmounting all NFS directories Example 2: Unmount all NFS directories.
``` ```
OHOS:/$ umount -a -t nfs OHOS:/$ umount -a -t nfs
umount ok umount ok
``` ```
# writeproc # writeproc
## Command Function<a name="section366714216619"></a> ## Command Function
This command is used to write data to a specified proc file system. The proc file system supports the input of string parameters. Each file needs to implement its own method. This command is used to write data to the specified proc file system. The proc file system supports data of strings. The method for writing data needs to be implemented.
## Syntax<a name="section8833164614615"></a>
writeproc <_data_\> \>\> /proc/<_filename_\> ## Syntax
## Parameters<a name="section12809111019453"></a> writeproc &lt;*data*&gt; &gt;&gt; /proc/&lt;*filename*&gt;
**Table 1** Parameter description
<a name="table438mcpsimp"></a> ## Parameters
<table><thead align="left"><tr id="row444mcpsimp"><th class="cellrowborder" valign="top" width="21.000000000000004%" id="mcps1.2.4.1.1"><p id="p446mcpsimp"><a name="p446mcpsimp"></a><a name="p446mcpsimp"></a><strong id="b16354000851164"><a name="b16354000851164"></a><a name="b16354000851164"></a>Parameter</strong></p>
</th>
<th class="cellrowborder" valign="top" width="52.970000000000006%" id="mcps1.2.4.1.2"><p id="p448mcpsimp"><a name="p448mcpsimp"></a><a name="p448mcpsimp"></a><strong id="b2720614204911"><a name="b2720614204911"></a><a name="b2720614204911"></a>Description</strong></p>
</th>
<th class="cellrowborder" valign="top" width="26.030000000000005%" id="mcps1.2.4.1.3"><p id="p450mcpsimp"><a name="p450mcpsimp"></a><a name="p450mcpsimp"></a><strong id="b3067324051164"><a name="b3067324051164"></a><a name="b3067324051164"></a>Value Range</strong></p>
</th>
</tr>
</thead>
<tbody><tr id="row451mcpsimp"><td class="cellrowborder" valign="top" width="21.000000000000004%" headers="mcps1.2.4.1.1 "><p id="p2500105121818"><a name="p2500105121818"></a><a name="p2500105121818"></a>data</p>
</td>
<td class="cellrowborder" valign="top" width="52.970000000000006%" headers="mcps1.2.4.1.2 "><p id="p1149945111817"><a name="p1149945111817"></a><a name="p1149945111817"></a>Specifies the string to be entered, which ends with a space. If you need to enter a space, use <strong id="b11296145424918"><a name="b11296145424918"></a><a name="b11296145424918"></a>""</strong> to enclose the space.</p>
</td>
<td class="cellrowborder" valign="top" width="26.030000000000005%" headers="mcps1.2.4.1.3 "><p id="p749810571812"><a name="p749810571812"></a><a name="p749810571812"></a>N/A</p>
</td>
</tr>
<tr id="row155978258237"><td class="cellrowborder" valign="top" width="21.000000000000004%" headers="mcps1.2.4.1.1 "><p id="p195983258238"><a name="p195983258238"></a><a name="p195983258238"></a>filename</p>
</td>
<td class="cellrowborder" valign="top" width="52.970000000000006%" headers="mcps1.2.4.1.2 "><p id="p25985252238"><a name="p25985252238"></a><a name="p25985252238"></a>Specifies the proc file to which <strong id="b1319518261507"><a name="b1319518261507"></a><a name="b1319518261507"></a>data</strong> is to be passed.</p>
</td>
<td class="cellrowborder" valign="top" width="26.030000000000005%" headers="mcps1.2.4.1.3 "><p id="p10598425112312"><a name="p10598425112312"></a><a name="p10598425112312"></a>N/A</p>
</td>
</tr>
</tbody>
</table>
## Usage<a name="section15935131220717"></a> **Table 1** Parameter description
The proc file implements its own **write** command. Calling the **writeproc** command will pass the input parameters to the **write** command. | Parameter | Description |
| -------- | ---------------------------------------------------------- |
| data | Specifies the string to write, which ends with a space. If you need to write a space, use **""** to enclose the space. |
| filename | Specifies the proc file to which **data** is to write. |
>![](../public_sys-resources/icon-note.gif) **NOTE:**
>The procfs file system does not support multi-thread access.
## Example<a name="section79281818476"></a> ## Usage Guidelines
Run **writeproc test \>\> /proc/uptime**. The proc file system implements its own **write()** function. Calling the **writeproc** command will pass input parameters to the **write()** function.
## Output<a name="section12742311179"></a> > **NOTE**<br>
> The procfs file system does not support multi-thread access.
OHOS \# writeproc test \>\> /proc/uptime ## Note
\[INFO\]write buf is: test Currently, the shell does not support this command.
test \>\> /proc/uptime ## Example
>![](../public_sys-resources/icon-note.gif) **NOTE:** Run **writeproc test >> /proc/uptime**.
>The uptime proc file temporarily implements the **write** command. The **INFO** log is generated by the implemented **test** command.
## Output
```
OHOS \# writeproc test &gt;&gt; /proc/uptime
[INFO]write buf is: test
test &gt;&gt; /proc/uptime
```
> **NOTE**<br>
> The **uptime** proc file temporarily implements the **write()** function. The **INFO** log is generated by the **test()** function.
...@@ -3,24 +3,30 @@ ...@@ -3,24 +3,30 @@
## When to Use ## When to Use
When the system does not respond, you can use the magic key function to check whether the system is suspended by an interrupt lock (the magic key also does not respond) or view the system task running status. When the system does not respond, you can use the magic key to check whether the system is suspended by an interrupt lock or view the system task running status.
If interrupts are responded, you can use the magic key to check the task CPU usage (**cpup**) and find out the task with the highest CPU usage. Generally, the task with a higher priority preempts the CPU resources. If interrupts are responded, you can use the magic key to check the task CPU percent (CPUP) and locate the task with the highest CPUP. Generally, the task with a higher priority preempts the CPU resources.
## How to Use ## How to Configure
1. Configure the macro **LOSCFG_ENABLE_MAGICKEY**. The magic key depends on the macro **LOSCFG_ENABLE_MAGICKEY**.
The magic key depends on the **LOSCFG_ENABLE_MAGICKEY** macro. Before using the magic key, select **Enable MAGIC KEY** (**Debug** ---> **Enable MAGIC KEY**) on **menuconfig**. The magic key cannot be used if this option is disabled. To configure **LOSCFG_ENABLE_MAGICKEY**:
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** 1. Run the **make menuconfig** command in **kernel/liteos_a**.
> 2. Locate the **Debug** option and select **Enable MAGIC KEY**.
> On **menuconfig**, you can move the cursor to **LOSCFG_ENABLE_MAGICKEY** and enter a question mark (?) to view help Information.
This option is selected by default. If it is not selected, the magic key is invalid.
2. Press **Ctrl+R** to enable the magic key.
> **NOTE**<br>
> On **menuconfig**, you can move the cursor to **LOSCFG_ENABLE_MAGICKEY** and enter a question mark (?) to view help information.
## How to Use
1. Press **Ctrl+R** to enable the magic key.
When the UART or USB-to-virtual serial port is connected, press **Ctrl+R**. If "Magic key on" is displayed, the magic key is enabled. To disable it, press **Ctrl+R** again. If "Magic key off" is displayed, the magic key is disabled. When the UART or USB-to-virtual serial port is connected, press **Ctrl+R**. If "Magic key on" is displayed, the magic key is enabled. To disable it, press **Ctrl+R** again. If "Magic key off" is displayed, the magic key is disabled.
The functions of the magic key are as follows: The functions of the magic key are as follows:
...@@ -32,5 +38,5 @@ If interrupts are responded, you can use the magic key to check the task CPU usa ...@@ -32,5 +38,5 @@ If interrupts are responded, you can use the magic key to check the task CPU usa
- **Ctrl+E**: Checks the integrity of the memory pool. If an error is detected, the system displays an error message. If no error is detected, the system displays "system memcheck over, all passed!". - **Ctrl+E**: Checks the integrity of the memory pool. If an error is detected, the system displays an error message. If no error is detected, the system displays "system memcheck over, all passed!".
> ![icon-notice.gif](public_sys-resources/icon-notice.gif) **NOTICE**<br> > **NOTE**<br>
> If magic key is enabled, when special characters need to be entered through the UART or USB-to-virtual serial port, avoid using characters the same as the magic keys. Otherwise, the magic key may be triggered by mistake, causing errors in the original design. > If magic key is enabled, when special characters need to be entered through the UART or USB-to-virtual serial port, avoid using characters the same as the magic keys. Otherwise, the magic key may be triggered by mistake, causing errors in design.
# arp # arp
## Command Function<a name="section201149459368"></a> ## Command Function
Hosts on an Ethernet communicate with each other using MAC addresses. IP addresses must be converted into MAC addresses to enable communication between hosts on a LAN \(Ethernet\). To achieve this purpose, the host stores a table containing the mapping between IP addresses and MAC addresses. This table is called an Address Resolution Protocol \(ARP\) cache table. Before sending an IP packet to a LAN, the host looks up the destination MAC address in the ARP cache table. The ARP cache table is maintained by the TCP/IP stack. You can run the **arp** command to view and modify the ARP cache table. Hosts on an Ethernet communicate with each other using MAC addresses. IP addresses must be converted into MAC addresses to enable communication between hosts on a LAN (Ethernet). To achieve this purpose, the host stores a table containing the mapping between IP addresses and MAC addresses. This table is called an Address Resolution Protocol (ARP) cache table. Before sending an IP packet to a LAN, the host looks up the destination MAC address in the ARP cache table. The ARP cache table is maintained by the TCP/IP stack. You can run the **arp** command to view and modify the ARP cache table.
## Syntax<a name="section579813484364"></a>
## Syntax
arp arp
arp \[_-i IF_\] -s _IPADDR HWADDR_ arp [_-i IF_] -s *IPADDR HWADDR*
arp \[_-i IF_\] -d _IPADDR_ arp [_-i IF_] -d *IPADDR*
## Parameters<a name="section168065311366"></a>
## Parameters
**Table 1** Parameter description
**Table 1** Parameter description
<a name="table1845mcpsimp"></a>
<table><thead align="left"><tr id="row1851mcpsimp"><th class="cellrowborder" valign="top" width="20.84%" id="mcps1.2.4.1.1"><p id="p1853mcpsimp"><a name="p1853mcpsimp"></a><a name="p1853mcpsimp"></a><strong id="b24438529911613"><a name="b24438529911613"></a><a name="b24438529911613"></a>Parameter</strong></p> | Parameter| Description| Value Range|
</th> | -------- | -------- | -------- |
<th class="cellrowborder" valign="top" width="52.16%" id="mcps1.2.4.1.2"><p id="p1855mcpsimp"><a name="p1855mcpsimp"></a><a name="p1855mcpsimp"></a><strong id="b665518251701"><a name="b665518251701"></a><a name="b665518251701"></a>Description</strong></p> | No parameter| Prints the content of the ARP cache table.| N/A |
</th> | -i&nbsp;IF | Specifies the network port. This parameter is optional.| N/A |
<th class="cellrowborder" valign="top" width="27%" id="mcps1.2.4.1.3"><p id="p1857mcpsimp"><a name="p1857mcpsimp"></a><a name="p1857mcpsimp"></a><strong id="b169031044911613"><a name="b169031044911613"></a><a name="b169031044911613"></a>Value Range</strong></p> | -s&nbsp;IPADDR<br>HWADDR | Adds an ARP entry. The second parameter is the IP address and MAC address of the other host on the LAN.| N/A |
</th> | -d&nbsp;IPADDR | Deletes an ARP entry.| N/A |
</tr>
</thead>
<tbody><tr id="row1858mcpsimp"><td class="cellrowborder" valign="top" width="20.84%" headers="mcps1.2.4.1.1 "><p id="p1860mcpsimp"><a name="p1860mcpsimp"></a><a name="p1860mcpsimp"></a>No parameter</p> ## Usage Guidelines
</td>
<td class="cellrowborder" valign="top" width="52.16%" headers="mcps1.2.4.1.2 "><p id="p1862mcpsimp"><a name="p1862mcpsimp"></a><a name="p1862mcpsimp"></a>Queries the content of the ARP cache table.</p> - The **arp** command is used to query and modify the ARP cache table of the TCP/IP stack. If ARP entries for IP addresses on different subnets are added, the protocol stack returns a failure message.
</td>
<td class="cellrowborder" valign="top" width="27%" headers="mcps1.2.4.1.3 "><p id="p1864mcpsimp"><a name="p1864mcpsimp"></a><a name="p1864mcpsimp"></a>N/A</p> - This command can be used only after the TCP/IP protocol stack is enabled.
</td>
</tr>
<tr id="row1865mcpsimp"><td class="cellrowborder" valign="top" width="20.84%" headers="mcps1.2.4.1.1 "><p id="p1867mcpsimp"><a name="p1867mcpsimp"></a><a name="p1867mcpsimp"></a>-i IF</p> ## Example
</td>
<td class="cellrowborder" valign="top" width="52.16%" headers="mcps1.2.4.1.2 "><p id="p1869mcpsimp"><a name="p1869mcpsimp"></a><a name="p1869mcpsimp"></a>Specifies the network port. This parameter is optional.</p> Run **arp**.
</td>
<td class="cellrowborder" valign="top" width="27%" headers="mcps1.2.4.1.3 "><p id="p1871mcpsimp"><a name="p1871mcpsimp"></a><a name="p1871mcpsimp"></a>N/A</p> ARP cache table information:
</td>
</tr>
<tr id="row1872mcpsimp"><td class="cellrowborder" valign="top" width="20.84%" headers="mcps1.2.4.1.1 "><p id="p1874mcpsimp"><a name="p1874mcpsimp"></a><a name="p1874mcpsimp"></a>-s IPADDR</p>
<p id="p1875mcpsimp"><a name="p1875mcpsimp"></a><a name="p1875mcpsimp"></a>HWADDR</p>
</td>
<td class="cellrowborder" valign="top" width="52.16%" headers="mcps1.2.4.1.2 "><p id="p1877mcpsimp"><a name="p1877mcpsimp"></a><a name="p1877mcpsimp"></a>Adds an ARP entry. The second parameter is the IP address and MAC address of the other host on the LAN.</p>
</td>
<td class="cellrowborder" valign="top" width="27%" headers="mcps1.2.4.1.3 "><p id="p1879mcpsimp"><a name="p1879mcpsimp"></a><a name="p1879mcpsimp"></a>N/A</p>
</td>
</tr>
<tr id="row1880mcpsimp"><td class="cellrowborder" valign="top" width="20.84%" headers="mcps1.2.4.1.1 "><p id="p1882mcpsimp"><a name="p1882mcpsimp"></a><a name="p1882mcpsimp"></a>-d IPADDR</p>
</td>
<td class="cellrowborder" valign="top" width="52.16%" headers="mcps1.2.4.1.2 "><p id="p1884mcpsimp"><a name="p1884mcpsimp"></a><a name="p1884mcpsimp"></a>Deletes an ARP entry.</p>
</td>
<td class="cellrowborder" valign="top" width="27%" headers="mcps1.2.4.1.3 "><p id="p1886mcpsimp"><a name="p1886mcpsimp"></a><a name="p1886mcpsimp"></a>N/A</p>
</td>
</tr>
</tbody>
</table>
## Usage<a name="section19190125723612"></a>
- The **arp** command is used to query and modify the ARP cache table of the TCP/IP stack. If ARP entries for IP addresses on different subnets are added, the protocol stack returns a failure message.
- This command can be used only after the TCP/IP stack is enabled.
## Example<a name="section10383416372"></a>
Run the **arp** command.
ARP cache table:
``` ```
OHOS # arp OHOS # arp
...@@ -75,35 +46,11 @@ Address HWaddress Iface Type ...@@ -75,35 +46,11 @@ Address HWaddress Iface Type
192.168.1.10 E6:2B:99:2C:4B:20 eth0 static 192.168.1.10 E6:2B:99:2C:4B:20 eth0 static
``` ```
**Table 2** Output description **Table 2** Parameter description
<a name="table1901mcpsimp"></a>
<table><thead align="left"><tr id="row1906mcpsimp"><th class="cellrowborder" valign="top" width="50%" id="mcps1.2.3.1.1"><p id="p1908mcpsimp"><a name="p1908mcpsimp"></a><a name="p1908mcpsimp"></a><strong id="b38103410311613"><a name="b38103410311613"></a><a name="b38103410311613"></a>Parameter</strong></p>
</th>
<th class="cellrowborder" valign="top" width="50%" id="mcps1.2.3.1.2"><p id="p1910mcpsimp"><a name="p1910mcpsimp"></a><a name="p1910mcpsimp"></a><strong id="b6623104464810"><a name="b6623104464810"></a><a name="b6623104464810"></a>Description</strong></p>
</th>
</tr>
</thead>
<tbody><tr id="row1911mcpsimp"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p1913mcpsimp"><a name="p1913mcpsimp"></a><a name="p1913mcpsimp"></a>Address</p>
</td>
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p1915mcpsimp"><a name="p1915mcpsimp"></a><a name="p1915mcpsimp"></a>IPv4 address of a network device.</p>
</td>
</tr>
<tr id="row1916mcpsimp"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p1918mcpsimp"><a name="p1918mcpsimp"></a><a name="p1918mcpsimp"></a>HWaddress</p>
</td>
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p1920mcpsimp"><a name="p1920mcpsimp"></a><a name="p1920mcpsimp"></a>MAC address of a network device.</p>
</td>
</tr>
<tr id="row1921mcpsimp"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p1923mcpsimp"><a name="p1923mcpsimp"></a><a name="p1923mcpsimp"></a>Iface</p>
</td>
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p1925mcpsimp"><a name="p1925mcpsimp"></a><a name="p1925mcpsimp"></a>Name of the port used by the ARP entry.</p>
</td>
</tr>
<tr id="row1926mcpsimp"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p1928mcpsimp"><a name="p1928mcpsimp"></a><a name="p1928mcpsimp"></a>Type</p>
</td>
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p1930mcpsimp"><a name="p1930mcpsimp"></a><a name="p1930mcpsimp"></a>Indicates whether the ARP entry is dynamic or static. A dynamic ARP entry is automatically created by the protocol stack, and a static ARP entry is added by the user.</p>
</td>
</tr>
</tbody>
</table>
| Parameter| Description|
| -------- | -------- |
| Address | IPv4 address of the network device.|
| HWaddress | MAC address of the network device.|
| Iface | Name of the port used by the ARP entry.|
| Type | Whether the ARP entry is dynamic or static. A dynamic ARP entry is automatically created by the protocol stack, and a static ARP entry is added by the user. |
# dhclient # dhclient
## Command Function<a name="section366714216619"></a> ## Command Function
This command is used to set and query **dhclient** parameters. This command is used to set and query **dhclient** parameters.
## Syntax<a name="section8833164614615"></a>
## Syntax
- dhclient <_netif name_\>
- dhclient -x <_netif name_\> - dhclient &lt;*netif name*&gt;
## Parameters<a name="section12809111019453"></a> - dhclient -x &lt;*netif name*&gt;
**Table 1** Parameter description
## Parameters
<a name="table438mcpsimp"></a>
<table><thead align="left"><tr id="row444mcpsimp"><th class="cellrowborder" valign="top" width="21%" id="mcps1.2.4.1.1"><p id="p446mcpsimp"><a name="p446mcpsimp"></a><a name="p446mcpsimp"></a><strong id="b20999054421160"><a name="b20999054421160"></a><a name="b20999054421160"></a>Parameter</strong></p> **Table 1** Parameter description
</th>
<th class="cellrowborder" valign="top" width="52%" id="mcps1.2.4.1.2"><p id="p448mcpsimp"><a name="p448mcpsimp"></a><a name="p448mcpsimp"></a><strong id="b16991513175018"><a name="b16991513175018"></a><a name="b16991513175018"></a>Description</strong></p> | Parameter | Description | Value Range |
</th> | ------------------------------- | -------------------------------------------- | ---------------- |
<th class="cellrowborder" valign="top" width="27%" id="mcps1.2.4.1.3"><p id="p450mcpsimp"><a name="p450mcpsimp"></a><a name="p450mcpsimp"></a><strong id="b9837196561160"><a name="b9837196561160"></a><a name="b9837196561160"></a>Value Range</strong></p> | -h&nbsp;\|&nbsp;--help | Displays parameters supported by the **dhclient** command and their usage.| N/A |
</th> | &lt;netif&nbsp;name&gt; | Enables Dynamic Host Configuration Protocol (DHCP) for a network interface card (NIC). | NIC name, **eth0**|
</tr> | -x&nbsp;&lt;netif&nbsp;name&gt; | Disables DHCP for a NIC. | NIC name, **eth0**|
</thead>
<tbody><tr id="row15810322374"><td class="cellrowborder" valign="top" width="21%" headers="mcps1.2.4.1.1 "><p id="p108030222712"><a name="p108030222712"></a><a name="p108030222712"></a>-h | --help</p>
</td> ## Usage Guidelines
<td class="cellrowborder" valign="top" width="52%" headers="mcps1.2.4.1.2 "><p id="p14803132214716"><a name="p14803132214716"></a><a name="p14803132214716"></a>Displays parameters supported by the <strong id="b71961312874"><a name="b71961312874"></a><a name="b71961312874"></a>dhclient</strong> command and their usage.</p>
</td>
<td class="cellrowborder" valign="top" width="27%" headers="mcps1.2.4.1.3 "><p id="p28038222716"><a name="p28038222716"></a><a name="p28038222716"></a>N/A</p>
</td>
</tr>
<tr id="row880917225712"><td class="cellrowborder" valign="top" width="21%" headers="mcps1.2.4.1.1 "><p id="p6803162212717"><a name="p6803162212717"></a><a name="p6803162212717"></a>&lt;netif name&gt;</p>
</td>
<td class="cellrowborder" valign="top" width="52%" headers="mcps1.2.4.1.2 "><p id="p980352211712"><a name="p980352211712"></a><a name="p980352211712"></a>Enables Dynamic Host Configuration Protocol (DHCP) for a network interface card (NIC).</p>
</td>
<td class="cellrowborder" valign="top" width="27%" headers="mcps1.2.4.1.3 "><p id="p48031822276"><a name="p48031822276"></a><a name="p48031822276"></a>NIC name, <strong id="b178511243205513"><a name="b178511243205513"></a><a name="b178511243205513"></a>eth0</strong></p>
</td>
</tr>
<tr id="row78092222716"><td class="cellrowborder" valign="top" width="21%" headers="mcps1.2.4.1.1 "><p id="p108032221379"><a name="p108032221379"></a><a name="p108032221379"></a>-x &lt;netif name&gt;</p>
</td>
<td class="cellrowborder" valign="top" width="52%" headers="mcps1.2.4.1.2 "><p id="p1180318222710"><a name="p1180318222710"></a><a name="p1180318222710"></a>Disables DHCP for a NIC.</p>
</td>
<td class="cellrowborder" valign="top" width="27%" headers="mcps1.2.4.1.3 "><p id="p78034222072"><a name="p78034222072"></a><a name="p78034222072"></a>NIC name, <strong id="b41988451673"><a name="b41988451673"></a><a name="b41988451673"></a>eth0</strong></p>
</td>
</tr>
</tbody>
</table>
## Usage<a name="section15935131220717"></a>
Run the following commands: Run the following commands:
- dhclient eth0 - dhclient eth0
- dhclient -x eth0
- dhclient -x eth0
## Note
Currently, the shell does not support this command.
## Example<a name="section79281818476"></a> ## Example
Example 1: Enable DHCP for eth0.
Example 1: enabling DHCP for eth0
``` ```
OHOS:/$ dhclient eth0 OHOS:/$ dhclient eth0
...@@ -69,7 +52,9 @@ eth0 ip:192.168.1.10 netmask:255.255.255.0 gateway:192.168.1.1 ...@@ -69,7 +52,9 @@ eth0 ip:192.168.1.10 netmask:255.255.255.0 gateway:192.168.1.1
OHOS:/$ OHOS:/$
``` ```
Example 2: disabling DHCP for eth0
Example 2: Disable DHCP for eth0.
``` ```
OHOS:/$ dhclient -x eth0 OHOS:/$ dhclient -x eth0
...@@ -81,4 +66,3 @@ lo ip:127.0.0.1 netmask:255.0.0.0 gateway:127.0.0.1 ...@@ -81,4 +66,3 @@ lo ip:127.0.0.1 netmask:255.0.0.0 gateway:127.0.0.1
eth0 ip:0.0.0.0 netmask:0.0.0.0 gateway:0.0.0.0 eth0 ip:0.0.0.0 netmask:0.0.0.0 gateway:0.0.0.0
HWaddr 42:da:81:bc:58:94 MTU:1500 Running Default Link UP HWaddr 42:da:81:bc:58:94 MTU:1500 Running Default Link UP
``` ```
# ifconfig # ifconfig
## Command Function<a name="section174940284379"></a> ## Command Function
This command can be used to: This command can be used to:
- Query and set parameters of a network interface card \(NIC\), such as the IP address, network mask, gateway, and MAC address. - Query and set parameters of a network interface card (NIC), such as the IP address, network mask, gateway, and MAC address.
- Enable or disable a NIC.
## Syntax<a name="section136073203715"></a> - Enable or disable a NIC.
ifconfig \[option\]
## Syntax
ifconfig [option]
option: option:
- \[_-a_\] - [_-a_]
- <_interface_\> <_address_\> \[_netmask <mask\>_\] \[_gateway <address\>_\]
- \[_hw ether <address\>_\] \[_mtu <size\>_\] - &lt;*interface*&gt; &lt;*address*&gt; [_netmask &lt;mask&gt;_] [_gateway &lt;address&gt;_]
- \[_inet6 add <address\>_\]
- \[_inet6 del <address\>_\] - [_hw ether &lt;address&gt;_] [_mtu &lt;size&gt;_]
- \[_up|down_\]
- [_inet6 add &lt;address&gt;_]
## Parameters<a name="section6493235203710"></a>
- [_inet6 del &lt;address&gt;_]
**Table 1** Parameter description
- [_up|down_]
<a name="table2005mcpsimp"></a>
<table><thead align="left"><tr id="row2011mcpsimp"><th class="cellrowborder" valign="top" width="17.93%" id="mcps1.2.4.1.1"><p id="p2013mcpsimp"><a name="p2013mcpsimp"></a><a name="p2013mcpsimp"></a><strong id="b207545880811653"><a name="b207545880811653"></a><a name="b207545880811653"></a>Parameter</strong></p>
</th> ## Parameters
<th class="cellrowborder" valign="top" width="53.669999999999995%" id="mcps1.2.4.1.2"><p id="p2015mcpsimp"><a name="p2015mcpsimp"></a><a name="p2015mcpsimp"></a><strong id="b519711279124"><a name="b519711279124"></a><a name="b519711279124"></a>Description</strong></p>
</th> **Table 1** Parameter description
<th class="cellrowborder" valign="top" width="28.4%" id="mcps1.2.4.1.3"><p id="p2017mcpsimp"><a name="p2017mcpsimp"></a><a name="p2017mcpsimp"></a><strong id="b19371475311653"><a name="b19371475311653"></a><a name="b19371475311653"></a>Value Range</strong></p>
</th> | Parameter| Description| Value Range|
</tr> | -------- | -------- | -------- |
</thead> | No parameter| Displays all NIC information, which includes the IP address, network mask, gateway, MAC address, maximum transmission unit (MTUs), and running status of each NIC.| N/A |
<tbody><tr id="row71475414535"><td class="cellrowborder" valign="top" width="17.93%" headers="mcps1.2.4.1.1 "><p id="p11941141534"><a name="p11941141534"></a><a name="p11941141534"></a>No parameter</p> | -a | Displays data sent and received by the protocol stack.| N/A |
</td> | interface | Specifies the NIC name, for example, **eth0**.| N/A |
<td class="cellrowborder" valign="top" width="53.669999999999995%" headers="mcps1.2.4.1.2 "><p id="p1594124175315"><a name="p1594124175315"></a><a name="p1594124175315"></a>Displays all NIC information, which includes the IP address, network mask, gateway, MAC address, maximum transmission unit (MTUs), and running status of each NIC.</p> | address | Specifies the IP address, for example, **192.168.1.10**. The NIC name must be specified.| N/A |
</td> | netmask | Specifies the subnet mask, for example, **255.255.255.0**.| N/A |
<td class="cellrowborder" valign="top" width="28.4%" headers="mcps1.2.4.1.3 "><p id="p1194174145311"><a name="p1194174145311"></a><a name="p1194174145311"></a>N/A</p> | gateway | Specifies the gateway, for example, **192.168.1.1**.| N/A |
</td> | hw&nbsp;ether | Specifies the MAC address, for example, **00:11:22:33:44:55**. Currently, only the **ether** hardware type is supported.| N/A |
</tr> | mtu | Specifies the MTU size, for example, **1000**.| - IPv4: [68, 1500]<br>- IPv6:[1280, 1500] |
<tr id="row1814615495314"><td class="cellrowborder" valign="top" width="17.93%" headers="mcps1.2.4.1.1 "><p id="p194144135316"><a name="p194144135316"></a><a name="p194144135316"></a>-a</p> | add | Specifies the IPv6 address, for example, **2001:a:b:c:d:e:f:d**. The NIC name and **inet6** must be specified.| N/A |
</td> | del | Deletes an IPv6 address. You need to specify the NIC name and add the **inet6** option. For details, see the example.| N/A |
<td class="cellrowborder" valign="top" width="53.669999999999995%" headers="mcps1.2.4.1.2 "><p id="p13941445534"><a name="p13941445534"></a><a name="p13941445534"></a>Displays data sent and received by the protocol stack.</p> | up | Enables the data processing function of the NIC. The NIC name must be specified.| N/A |
</td> | down | Disables the data processing function of the NIC. The NIC name must be specified.| N/A |
<td class="cellrowborder" valign="top" width="28.4%" headers="mcps1.2.4.1.3 "><p id="p1294154155314"><a name="p1294154155314"></a><a name="p1294154155314"></a>N/A</p>
</td>
</tr>
<tr id="row31466417533"><td class="cellrowborder" valign="top" width="17.93%" headers="mcps1.2.4.1.1 "><p id="p199410445319"><a name="p199410445319"></a><a name="p199410445319"></a>interface</p>
</td>
<td class="cellrowborder" valign="top" width="53.669999999999995%" headers="mcps1.2.4.1.2 "><p id="p139415485312"><a name="p139415485312"></a><a name="p139415485312"></a>Specifies the NIC name, for example, <strong id="b1368975571410"><a name="b1368975571410"></a><a name="b1368975571410"></a>eth0</strong>.</p>
</td>
<td class="cellrowborder" valign="top" width="28.4%" headers="mcps1.2.4.1.3 "><p id="p9944415315"><a name="p9944415315"></a><a name="p9944415315"></a>N/A</p>
</td>
</tr>
<tr id="row9145114165319"><td class="cellrowborder" valign="top" width="17.93%" headers="mcps1.2.4.1.1 "><p id="p7947412538"><a name="p7947412538"></a><a name="p7947412538"></a>address</p>
</td>
<td class="cellrowborder" valign="top" width="53.669999999999995%" headers="mcps1.2.4.1.2 "><p id="p119454165313"><a name="p119454165313"></a><a name="p119454165313"></a>Specifies the IP address, for example, <strong id="b530715731519"><a name="b530715731519"></a><a name="b530715731519"></a>192.168.1.10</strong>. The NIC name must be specified.</p>
</td>
<td class="cellrowborder" valign="top" width="28.4%" headers="mcps1.2.4.1.3 "><p id="p99424185316"><a name="p99424185316"></a><a name="p99424185316"></a>N/A</p>
</td>
</tr>
<tr id="row1614415418534"><td class="cellrowborder" valign="top" width="17.93%" headers="mcps1.2.4.1.1 "><p id="p1694942532"><a name="p1694942532"></a><a name="p1694942532"></a>netmask</p>
</td>
<td class="cellrowborder" valign="top" width="53.669999999999995%" headers="mcps1.2.4.1.2 "><p id="p194749536"><a name="p194749536"></a><a name="p194749536"></a>Specifies the subnet mask, for example, <strong id="b1625513191514"><a name="b1625513191514"></a><a name="b1625513191514"></a>255.255.255.0</strong>.</p>
</td>
<td class="cellrowborder" valign="top" width="28.4%" headers="mcps1.2.4.1.3 "><p id="p094124175316"><a name="p094124175316"></a><a name="p094124175316"></a>N/A</p>
</td>
</tr>
<tr id="row13144942537"><td class="cellrowborder" valign="top" width="17.93%" headers="mcps1.2.4.1.1 "><p id="p1494174125316"><a name="p1494174125316"></a><a name="p1494174125316"></a>gateway</p>
</td>
<td class="cellrowborder" valign="top" width="53.669999999999995%" headers="mcps1.2.4.1.2 "><p id="p109413413534"><a name="p109413413534"></a><a name="p109413413534"></a>Specifies the gateway, for example, <strong id="b52931945195112"><a name="b52931945195112"></a><a name="b52931945195112"></a>192.168.1.1</strong>.</p>
</td>
<td class="cellrowborder" valign="top" width="28.4%" headers="mcps1.2.4.1.3 "><p id="p19946465313"><a name="p19946465313"></a><a name="p19946465313"></a>N/A</p>
</td>
</tr>
<tr id="row914313405310"><td class="cellrowborder" valign="top" width="17.93%" headers="mcps1.2.4.1.1 "><p id="p169415455310"><a name="p169415455310"></a><a name="p169415455310"></a>hw ether</p>
</td>
<td class="cellrowborder" valign="top" width="53.669999999999995%" headers="mcps1.2.4.1.2 "><p id="p20946412532"><a name="p20946412532"></a><a name="p20946412532"></a>Specifies the MAC address, for example, <strong id="b85669109525"><a name="b85669109525"></a><a name="b85669109525"></a>00:11:22:33:44:55</strong>. Currently, only the <strong id="b534492414613"><a name="b534492414613"></a><a name="b534492414613"></a>ether</strong> hardware type is supported.</p>
</td>
<td class="cellrowborder" valign="top" width="28.4%" headers="mcps1.2.4.1.3 "><p id="p19948418537"><a name="p19948418537"></a><a name="p19948418537"></a>N/A</p>
</td>
</tr>
<tr id="row141421142532"><td class="cellrowborder" valign="top" width="17.93%" headers="mcps1.2.4.1.1 "><p id="p13941049535"><a name="p13941049535"></a><a name="p13941049535"></a>mtu</p>
</td>
<td class="cellrowborder" valign="top" width="53.669999999999995%" headers="mcps1.2.4.1.2 "><p id="p159418414536"><a name="p159418414536"></a><a name="p159418414536"></a>Specifies the MTU size, for example, <strong id="b2852192012261"><a name="b2852192012261"></a><a name="b2852192012261"></a>1000</strong>.</p>
</td>
<td class="cellrowborder" valign="top" width="28.4%" headers="mcps1.2.4.1.3 "><a name="ul7956417536"></a><a name="ul7956417536"></a><ul id="ul7956417536"><li>IPv4:<p id="p29519485319"><a name="p29519485319"></a><a name="p29519485319"></a>[68,1500]</p>
</li><li>IPv6:<p id="p69524195316"><a name="p69524195316"></a><a name="p69524195316"></a>[1280, 1500]</p>
</li></ul>
</td>
</tr>
<tr id="row1914214419532"><td class="cellrowborder" valign="top" width="17.93%" headers="mcps1.2.4.1.1 "><p id="p119554125313"><a name="p119554125313"></a><a name="p119554125313"></a>add</p>
</td>
<td class="cellrowborder" valign="top" width="53.669999999999995%" headers="mcps1.2.4.1.2 "><p id="p1952046539"><a name="p1952046539"></a><a name="p1952046539"></a>Specifies the IPv6 address, for example, <strong id="b12509153516279"><a name="b12509153516279"></a><a name="b12509153516279"></a>2001:a:b:c:d:e:f:d</strong>. The NIC name and <strong id="b912123842916"><a name="b912123842916"></a><a name="b912123842916"></a>inet6</strong> must be specified.</p>
</td>
<td class="cellrowborder" valign="top" width="28.4%" headers="mcps1.2.4.1.3 "><p id="p49516418533"><a name="p49516418533"></a><a name="p49516418533"></a>N/A</p>
</td>
</tr>
<tr id="row17141144175319"><td class="cellrowborder" valign="top" width="17.93%" headers="mcps1.2.4.1.1 "><p id="p4952445318"><a name="p4952445318"></a><a name="p4952445318"></a>del</p>
</td>
<td class="cellrowborder" valign="top" width="53.669999999999995%" headers="mcps1.2.4.1.2 "><p id="p1556618562119"><a name="p1556618562119"></a><a name="p1556618562119"></a>Deletes an IPv6 address. You need to specify the NIC name and add the <strong id="b166212197409"><a name="b166212197409"></a><a name="b166212197409"></a>inet6</strong> option. For details, see the example.</p>
</td>
<td class="cellrowborder" valign="top" width="28.4%" headers="mcps1.2.4.1.3 "><p id="p1995248536"><a name="p1995248536"></a><a name="p1995248536"></a>N/A</p>
</td>
</tr>
<tr id="row714064175312"><td class="cellrowborder" valign="top" width="17.93%" headers="mcps1.2.4.1.1 "><p id="p12951849536"><a name="p12951849536"></a><a name="p12951849536"></a>up</p>
</td>
<td class="cellrowborder" valign="top" width="53.669999999999995%" headers="mcps1.2.4.1.2 "><p id="p119510455314"><a name="p119510455314"></a><a name="p119510455314"></a>Enables the data processing function of the NIC. The NIC name must be specified.</p>
</td>
<td class="cellrowborder" valign="top" width="28.4%" headers="mcps1.2.4.1.3 "><p id="p695944533"><a name="p695944533"></a><a name="p695944533"></a>N/A</p>
</td>
</tr>
<tr id="row31405465313"><td class="cellrowborder" valign="top" width="17.93%" headers="mcps1.2.4.1.1 "><p id="p49516455316"><a name="p49516455316"></a><a name="p49516455316"></a>down</p>
</td>
<td class="cellrowborder" valign="top" width="53.669999999999995%" headers="mcps1.2.4.1.2 "><p id="p1795164105312"><a name="p1795164105312"></a><a name="p1795164105312"></a>Disables the data processing function of the NIC. The NIC name must be specified.</p>
</td>
<td class="cellrowborder" valign="top" width="28.4%" headers="mcps1.2.4.1.3 "><p id="p12951644532"><a name="p12951644532"></a><a name="p12951644532"></a>N/A</p>
</td>
</tr>
</tbody>
</table>
## Usage<a name="section05763403371"></a>
- The **ifconfig** command can be used only after the TCP/IP stack is enabled.
- Detecting an IP address conflict takes time. Each time you run the **ifconfig** command to set an IP address, there is a delay of about 2 seconds.
## Example<a name="section168802042123717"></a>
- ifconfig eth0 192.168.100.31 netmask 255.255.255.0 gateway 192.168.100.1 hw ether 00:49:cb:6c:a1:31
- ifconfig -a
- ifconfig eth0 inet6 add 2001:a:b:c:d:e:f:d
- ifconfig eth0 inet6 del 2001:a:b:c:d:e:f:d
## Output<a name="section124638211109"></a>
- Example 1: setting network parameters
```
OHOS:/$ ifconfig eth0 192.168.100.31 netmask 255.255.255.0 gateway 192.168.100.1 hw ether 00:49:cb:6c:a1:31
OHOS:/$ ifconfig
lo ip:127.0.0.1 netmask:255.0.0.0 gateway:127.0.0.1
ip6: ::1/64
HWaddr 00 MTU:0 Running Link UP
eth0 ip:192.168.100.31 netmask:255.255.255.0 gateway:192.168.100.1
HWaddr 00:49:cb:6c:a1:31 MTU:1500 Running Default Link UP
```
The following table describes the output parameters.
**Table 2** Output description
<a name="table2147mcpsimp"></a>
<table><thead align="left"><tr id="row2152mcpsimp"><th class="cellrowborder" valign="top" width="50%" id="mcps1.2.3.1.1"><p id="p2154mcpsimp"><a name="p2154mcpsimp"></a><a name="p2154mcpsimp"></a><strong id="b211311219311653"><a name="b211311219311653"></a><a name="b211311219311653"></a>Parameter</strong></p>
</th>
<th class="cellrowborder" valign="top" width="50%" id="mcps1.2.3.1.2"><p id="p2156mcpsimp"><a name="p2156mcpsimp"></a><a name="p2156mcpsimp"></a><strong id="b336412763515"><a name="b336412763515"></a><a name="b336412763515"></a>Description</strong></p>
</th>
</tr>
</thead>
<tbody><tr id="row17361516205420"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p107151611546"><a name="p107151611546"></a><a name="p107151611546"></a>ip</p>
</td>
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p117111610549"><a name="p117111610549"></a><a name="p117111610549"></a>IP address of the board</p>
</td>
</tr>
<tr id="row4363166543"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p15731635412"><a name="p15731635412"></a><a name="p15731635412"></a>netmask</p>
</td>
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p187161616540"><a name="p187161616540"></a><a name="p187161616540"></a>Subnet mask</p>
</td>
</tr>
<tr id="row435161665419"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p1714162546"><a name="p1714162546"></a><a name="p1714162546"></a>gateway</p>
</td>
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p1471216175420"><a name="p1471216175420"></a><a name="p1471216175420"></a>Gateway</p>
</td>
</tr>
<tr id="row93541615542"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p671167547"><a name="p671167547"></a><a name="p671167547"></a>HWaddr</p>
</td>
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p157111665412"><a name="p157111665412"></a><a name="p157111665412"></a>MAC address of the board</p>
</td>
</tr>
<tr id="row13421645418"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p487161543"><a name="p487161543"></a><a name="p487161543"></a>MTU</p>
</td>
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p78016195415"><a name="p78016195415"></a><a name="p78016195415"></a>Maximum transmission unit</p>
</td>
</tr>
<tr id="row433181615412"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p10821612543"><a name="p10821612543"></a><a name="p10821612543"></a>Running/Stop</p>
</td>
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p281516205410"><a name="p281516205410"></a><a name="p281516205410"></a>Indicates whether the NIC is running.</p>
</td>
</tr>
<tr id="row33320167543"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p5821685419"><a name="p5821685419"></a><a name="p5821685419"></a>Default</p>
</td>
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p881516145415"><a name="p881516145415"></a><a name="p881516145415"></a>Indicates that the NIC is connected to the default gateway.</p>
</td>
</tr>
<tr id="row1321166546"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p3881695417"><a name="p3881695417"></a><a name="p3881695417"></a>Link UP/Down</p>
</td>
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p18201614546"><a name="p18201614546"></a><a name="p18201614546"></a>Connection status of the NIC</p>
</td>
</tr>
</tbody>
</table>
- Example 2: obtaining protocol stack statistics
```
OHOS # ifconfig -a
RX packets:6922 errors:0 ip dropped:4312 link dropped:67 overrun:0 bytes:0 (0.0 B)
RX packets(ip6):3 errors:0 dropped:0 overrun:0 bytes:0 (0.0 B)
TX packets:1394 errors:0 link dropped:67 overrun:0 bytes:0(0.0 B)
TX packets(ip6):3 errors:0 overrun:0 bytes:0(0.0 B)
```
The following table describes the output parameters.
**Table 3** ifconfig -a output description
<a name="table2209mcpsimp"></a>
<table><thead align="left"><tr id="row2214mcpsimp"><th class="cellrowborder" valign="top" width="28.999999999999996%" id="mcps1.2.3.1.1"><p id="p2216mcpsimp"><a name="p2216mcpsimp"></a><a name="p2216mcpsimp"></a><strong id="b120972048811653"><a name="b120972048811653"></a><a name="b120972048811653"></a>Parameter</strong></p>
</th>
<th class="cellrowborder" valign="top" width="71%" id="mcps1.2.3.1.2"><p id="p2218mcpsimp"><a name="p2218mcpsimp"></a><a name="p2218mcpsimp"></a><strong id="b8227191303719"><a name="b8227191303719"></a><a name="b8227191303719"></a>Description</strong></p>
</th>
</tr>
</thead>
<tbody><tr id="row6921834553"><td class="cellrowborder" valign="top" width="28.999999999999996%" headers="mcps1.2.3.1.1 "><p id="p117413375517"><a name="p117413375517"></a><a name="p117413375517"></a>RX packets</p>
</td>
<td class="cellrowborder" valign="top" width="71%" headers="mcps1.2.3.1.2 "><p id="p1174183145516"><a name="p1174183145516"></a><a name="p1174183145516"></a>Number of normal packets received at the IP layer.</p>
</td>
</tr>
<tr id="row209212315518"><td class="cellrowborder" valign="top" width="28.999999999999996%" headers="mcps1.2.3.1.1 "><p id="p274938554"><a name="p274938554"></a><a name="p274938554"></a>RX error</p>
</td>
<td class="cellrowborder" valign="top" width="71%" headers="mcps1.2.3.1.2 "><p id="p1274133195513"><a name="p1274133195513"></a><a name="p1274133195513"></a>Number of error packets received at the IP layer. The errors include the length error, verification error, IP option error, and IP header protocol error.</p>
</td>
</tr>
<tr id="row692832556"><td class="cellrowborder" valign="top" width="28.999999999999996%" headers="mcps1.2.3.1.1 "><p id="p474234551"><a name="p474234551"></a><a name="p474234551"></a>RX dropped</p>
</td>
<td class="cellrowborder" valign="top" width="71%" headers="mcps1.2.3.1.2 "><p id="p13741637551"><a name="p13741637551"></a><a name="p13741637551"></a>Number of packets discarded at the IP layer. Packets are discarded due to packet errors, packet forwarding failures, and disabled local NICs.</p>
</td>
</tr>
<tr id="row199215312556"><td class="cellrowborder" valign="top" width="28.999999999999996%" headers="mcps1.2.3.1.1 "><p id="p1674530552"><a name="p1674530552"></a><a name="p1674530552"></a>RX overrun</p>
</td>
<td class="cellrowborder" valign="top" width="71%" headers="mcps1.2.3.1.2 "><p id="p17742305517"><a name="p17742305517"></a><a name="p17742305517"></a>Number of packets that the MAC layer fails to deliver to the upper-layer protocol stack. The failure is caused by resource insufficiency at the protocol stack.</p>
</td>
</tr>
<tr id="row69193145519"><td class="cellrowborder" valign="top" width="28.999999999999996%" headers="mcps1.2.3.1.1 "><p id="p157417310551"><a name="p157417310551"></a><a name="p157417310551"></a>RX bytes</p>
</td>
<td class="cellrowborder" valign="top" width="71%" headers="mcps1.2.3.1.2 "><p id="p9741385519"><a name="p9741385519"></a><a name="p9741385519"></a>Total length of normal packets received at the IP layer, excluding the length of the fragments that are not reassembled.</p>
</td>
</tr>
<tr id="row091333559"><td class="cellrowborder" valign="top" width="28.999999999999996%" headers="mcps1.2.3.1.1 "><p id="p1741336554"><a name="p1741336554"></a><a name="p1741336554"></a>TX packets</p>
</td>
<td class="cellrowborder" valign="top" width="71%" headers="mcps1.2.3.1.2 "><p id="p19745375513"><a name="p19745375513"></a><a name="p19745375513"></a>Number of packets that have been normally sent or forwarded at the IP layer.</p>
</td>
</tr>
<tr id="row5914345515"><td class="cellrowborder" valign="top" width="28.999999999999996%" headers="mcps1.2.3.1.1 "><p id="p147443125513"><a name="p147443125513"></a><a name="p147443125513"></a>TX error</p>
</td>
<td class="cellrowborder" valign="top" width="71%" headers="mcps1.2.3.1.2 "><p id="p9756312553"><a name="p9756312553"></a><a name="p9756312553"></a>Number of packets that the IP layer fails to send. Packets may fail to be sent because the packets cannot be routed or the packets fail to be processed in the protocol stack.</p>
</td>
</tr>
<tr id="row7911032557"><td class="cellrowborder" valign="top" width="28.999999999999996%" headers="mcps1.2.3.1.1 "><p id="p13752316555"><a name="p13752316555"></a><a name="p13752316555"></a>TX dropped</p>
</td>
<td class="cellrowborder" valign="top" width="71%" headers="mcps1.2.3.1.2 "><p id="p87519395520"><a name="p87519395520"></a><a name="p87519395520"></a>Number of packets that the MAC layer discards due to delivery failures, for example, the NIC driver fails to process the packets.</p>
</td>
</tr>
<tr id="row9901345510"><td class="cellrowborder" valign="top" width="28.999999999999996%" headers="mcps1.2.3.1.1 "><p id="p27523205513"><a name="p27523205513"></a><a name="p27523205513"></a>TX overrun</p>
</td>
<td class="cellrowborder" valign="top" width="71%" headers="mcps1.2.3.1.2 "><p id="p107512325514"><a name="p107512325514"></a><a name="p107512325514"></a>Reserved.</p>
</td>
</tr>
<tr id="row39016318552"><td class="cellrowborder" valign="top" width="28.999999999999996%" headers="mcps1.2.3.1.1 "><p id="p1475933554"><a name="p1475933554"></a><a name="p1475933554"></a>TX bytes</p>
</td>
<td class="cellrowborder" valign="top" width="71%" headers="mcps1.2.3.1.2 "><p id="p7759375512"><a name="p7759375512"></a><a name="p7759375512"></a>Total length of the packets successfully sent or forwarded at the IP layer.</p>
</td>
</tr>
</tbody>
</table>
- Example 3: setting an IPv6 address
```
OHOS:/$ ifconfig eth0 inet6 add 2001:a:b:c:d:e:f:d
NetifStatusCallback(eth0): nsc event: 0x8
NetifStatusCallback(eth0): nsc status changed: 0
NetifStatusCallback(eth0): nsc event: 0x200
NetifStatusCallback(eth0): nsc event: 0x8
NetifStatusCallback(eth0): nsc status changed: 1
NetifStatusCallback(eth0): nsc event: 0x200
NetifStatusCallback(eth0): nsc event: 0x200
OHOS:/$ ifconfig
lo ip:127.0.0.1 netmask:255.0.0.0 gateway:127.0.0.1
ip6: ::1/64
HWaddr 00 MTU:0 Running Link UP
eth0 ip:192.168.1.10 netmask:255.255.255.0 gateway:192.168.1.1
ip6: 2001:A:B:C:D:E:F:D/64
HWaddr 66:2f:e5:bd:24:e6 MTU:1500 Running Default Link UP
```
- Example 4: deleting an IPv6 address
```
OHOS:/$ ifconfig eth0 inet6 del 2001:a:b:c:d:e:f:d
NetifStatusCallback(eth0): nsc event: 0x200
OHOS:/$ ifconfig
lo ip:127.0.0.1 netmask:255.0.0.0 gateway:127.0.0.1
ip6: ::1/64
HWaddr 00 MTU:0 Running Link UP
eth0 ip:192.168.1.10 netmask:255.255.255.0 gateway:192.168.1.1
HWaddr 66:2f:e5:bd:24:e6 MTU:1500 Running Default Link UP
```
## Usage Guidelines
- This command can be used only after the TCP/IP stack is enabled.
- Detecting an IP address conflict takes time. Each time you run the **ifconfig** command to set an IP address, there is a delay of about 2 seconds.
## Example
- ifconfig eth0 192.168.100.31 netmask 255.255.255.0 gateway 192.168.100.1 hw ether 00:49:cb:6c:a1:31
- ifconfig -a
- ifconfig eth0 inet6 add 2001:a:b:c:d:e:f:d
- ifconfig eth0 inet6 del 2001:a:b:c:d:e:f:d
## Output
- Example 1: Set network parameters.
```
OHOS:/$ ifconfig eth0 192.168.100.31 netmask 255.255.255.0 gateway 192.168.100.1 hw ether 00:49:cb:6c:a1:31
OHOS:/$ ifconfig
lo ip:127.0.0.1 netmask:255.0.0.0 gateway:127.0.0.1
ip6: ::1/64
HWaddr 00 MTU:0 Running Link UP
eth0 ip:192.168.100.31 netmask:255.255.255.0 gateway:192.168.100.1
HWaddr 00:49:cb:6c:a1:31 MTU:1500 Running Default Link UP
```
**Table 2** Parameter description
| Parameter| Description|
| -------- | -------- |
| ip | IP address of the board.|
| netmask | Subnet mask.|
| gateway | Gateway.|
| HWaddr | MAC address of the board.|
| MTU | Maximum transmission unit.|
| Running/Stop | Whether the NIC is running.|
| Default | Indicates that the NIC is connected to the default gateway.|
| Link&nbsp;UP/Down | Connection status of the NIC.|
- Example 2: Obtain protocol stack statistics.
```
OHOS # ifconfig -a
RX packets:6922 errors:0 ip dropped:4312 link dropped:67 overrun:0 bytes:0 (0.0 B)
RX packets(ip6):3 errors:0 dropped:0 overrun:0 bytes:0 (0.0 B)
TX packets:1394 errors:0 link dropped:67 overrun:0 bytes:0(0.0 B)
TX packets(ip6):3 errors:0 overrun:0 bytes:0(0.0 B)
```
**Table 3** ifconfig -a parameter description
| Parameter| Description|
| -------- | -------- |
| RX&nbsp;packets | Number of normal packets received at the IP layer.|
| RX&nbsp;error | Number of error packets received at the IP layer. The errors include the length error, verification error, IP option error, and IP header protocol error.|
| RX&nbsp;dropped | Number of packets discarded at the IP layer. Packets are discarded due to packet errors, packet forwarding failures, and disabled local NICs.|
| RX&nbsp;overrun | Number of packets that the MAC layer fails to deliver to the upper-layer protocol stack. The failure is caused by resource insufficiency at the protocol stack.|
| RX&nbsp;bytes | Total length of normal packets received at the IP layer, excluding the length of the fragments that are not reassembled.|
| TX&nbsp;packets | Number of packets that have been normally sent or forwarded at the IP layer.|
| TX&nbsp;error | Number of packets that the IP layer fails to send. Packets may fail to be sent because the packets cannot be routed or the packets fail to be processed in the protocol stack.|
| TX&nbsp;dropped | Number of packets that the MAC layer discards due to delivery failures, for example, the NIC driver fails to process the packets.|
| TX&nbsp;overrun | Not used currently.|
| TX&nbsp;bytes | Total length of the packets successfully sent or forwarded at the IP layer.|
- Example 3: Set an IPv6 address.
```
OHOS:/$ ifconfig eth0 inet6 add 2001:a:b:c:d:e:f:d
NetifStatusCallback(eth0): nsc event: 0x8
NetifStatusCallback(eth0): nsc status changed: 0
NetifStatusCallback(eth0): nsc event: 0x200
NetifStatusCallback(eth0): nsc event: 0x8
NetifStatusCallback(eth0): nsc status changed: 1
NetifStatusCallback(eth0): nsc event: 0x200
NetifStatusCallback(eth0): nsc event: 0x200
OHOS:/$ ifconfig
lo ip:127.0.0.1 netmask:255.0.0.0 gateway:127.0.0.1
ip6: ::1/64
HWaddr 00 MTU:0 Running Link UP
eth0 ip:192.168.1.10 netmask:255.255.255.0 gateway:192.168.1.1
ip6: 2001:A:B:C:D:E:F:D/64
HWaddr 66:2f:e5:bd:24:e6 MTU:1500 Running Default Link UP
```
- Example 4: Delete an IPv6 address.
```
OHOS:/$ ifconfig eth0 inet6 del 2001:a:b:c:d:e:f:d
NetifStatusCallback(eth0): nsc event: 0x200
OHOS:/$ ifconfig
lo ip:127.0.0.1 netmask:255.0.0.0 gateway:127.0.0.1
ip6: ::1/64
HWaddr 00 MTU:0 Running Link UP
eth0 ip:192.168.1.10 netmask:255.255.255.0 gateway:192.168.1.1
HWaddr 66:2f:e5:bd:24:e6 MTU:1500 Running Default Link UP
```
# ipdebug # ipdebug
## Command Function<a name="section10191115553720"></a> ## Command Function
**ipdebug** is a console command and is used for IPv6 debugging. It can display IPv6 address prefixes, neighbor entries, destination entries, and default route entries. **ipdebug** is a console command and is used for IPv6 debugging. It can display IPv6 address prefixes, neighbor entries, destination entries, and default route entries.
## Syntax<a name="section124061758123713"></a>
## Syntax
ipdebug ipdebug
## Example<a name="section171837113810"></a>
Run the **ipdebug** command. ## Example
Run the **ipdebug** command.
## Output<a name="section561416467104"></a>
**ipdebug** command output: ## Output
**ipdebug** command output:
``` ```
OHOS # ipdebug OHOS # ipdebug
...@@ -52,4 +55,3 @@ FE80::4639:C4FF:FE94:5D44 FE80::4639:C4FF:FE94:5D44 pmtu 1500 age 6 ...@@ -52,4 +55,3 @@ FE80::4639:C4FF:FE94:5D44 FE80::4639:C4FF:FE94:5D44 pmtu 1500 age 6
FE80::4639:C4FF:FE94:5D44 invalidation_timer 1784 flags 0 FE80::4639:C4FF:FE94:5D44 invalidation_timer 1784 flags 0
-------------------------------------------------------------------- --------------------------------------------------------------------
``` ```
# netstat # netstat
## Command Function<a name="section13469162113816"></a> ## Command Function
The **netstat** command is a console command and is used for monitoring the TCP/IP network. It can display the actual network connections and the status of each network interface device. This command displays statistics related to TCP and UDP and can be used to check the network connection to each port on the device \(board\). The **netstat** command is a console command and is used for monitoring the TCP/IP network. It can display the actual network connections and the status of each network interface device. This command displays statistics related to TCP and UDP connections and can be used to check the network connection to each port on a device (board).
## Syntax<a name="section795712373812"></a>
## Syntax
netstat netstat
## Parameters<a name="section17629431193817"></a>
None ## Parameters
## Usage<a name="section5277153519380"></a> None.
netstat
## Example<a name="section108141437163820"></a> ## Usage Guidelines
None.
## Note
Run **netstat**. Currently, the shell does not support this command.
## Output<a name="section1357015107117"></a> ## Example
**netstat** print information Run **netstat**.
## Output
**netstat** output information:
``` ```
OHOS # netstat OHOS # netstat
...@@ -41,50 +49,16 @@ udp 0 0 127.0.0.1:62180 127.0.0.1:62179 ...@@ -41,50 +49,16 @@ udp 0 0 127.0.0.1:62180 127.0.0.1:62179
udp 0 0 127.0.0.1:62178 127.0.0.1:62177 udp 0 0 127.0.0.1:62178 127.0.0.1:62177
``` ```
**Table 1** Output description **Table 1** Output description
<a name="table2526mcpsimp"></a> | Parameter | Description |
<table><thead align="left"><tr id="row2531mcpsimp"><th class="cellrowborder" valign="top" width="50%" id="mcps1.2.3.1.1"><p id="p2533mcpsimp"><a name="p2533mcpsimp"></a><a name="p2533mcpsimp"></a>Parameter</p> | -------------------- | ------------------------------------------------------------ |
</th> | Proto | Protocol type. |
<th class="cellrowborder" valign="top" width="50%" id="mcps1.2.3.1.2"><p id="p2535mcpsimp"><a name="p2535mcpsimp"></a><a name="p2535mcpsimp"></a>Description</p> | Recv-Q | Amount of data that is not read by the user.<br>For Listen TCP, the value indicates the number of TCP connections that have finished the three-way handshake but are not accepted by users. |
</th> | Send-Q | For a TCP connection, this value indicates the amount of data that has been sent but not acknowledged.<br>For a UDP connection, this value indicates the amount of data buffered before IP address resolution is complete.|
</tr> | Local&nbsp;Address | Local IP address and port number. |
</thead> | Foreign&nbsp;Address | Remote IP address and port number. |
<tbody><tr id="row2536mcpsimp"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p2538mcpsimp"><a name="p2538mcpsimp"></a><a name="p2538mcpsimp"></a>Proto</p> | State | TCP connection status. This parameter is meaningless for UDP. |
</td>
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p2540mcpsimp"><a name="p2540mcpsimp"></a><a name="p2540mcpsimp"></a>Protocol type.</p>
</td>
</tr>
<tr id="row2546mcpsimp"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p2548mcpsimp"><a name="p2548mcpsimp"></a><a name="p2548mcpsimp"></a>Recv-Q</p>
</td>
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p2550mcpsimp"><a name="p2550mcpsimp"></a><a name="p2550mcpsimp"></a>Amount of data that is not read by the user.</p>
<p id="p2551mcpsimp"><a name="p2551mcpsimp"></a><a name="p2551mcpsimp"></a>For Listen TCP, the value indicates the number of TCP connections that have finished three-way handshake but are not accepted by users.</p>
</td>
</tr>
<tr id="row2553mcpsimp"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p2555mcpsimp"><a name="p2555mcpsimp"></a><a name="p2555mcpsimp"></a>Send-Q</p>
</td>
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p1250715415473"><a name="p1250715415473"></a><a name="p1250715415473"></a>For a TCP connection, this value indicates the amount of data that has been sent but not acknowledged.</p>
<p id="p1080412214470"><a name="p1080412214470"></a><a name="p1080412214470"></a>For a UDP connection, this value indicates the amount of data buffered before IP address resolution is complete.</p>
</td>
</tr>
<tr id="row2558mcpsimp"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p2560mcpsimp"><a name="p2560mcpsimp"></a><a name="p2560mcpsimp"></a>Local Address</p>
</td>
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p2562mcpsimp"><a name="p2562mcpsimp"></a><a name="p2562mcpsimp"></a>Local IP address and port number.</p>
</td>
</tr>
<tr id="row2563mcpsimp"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p2565mcpsimp"><a name="p2565mcpsimp"></a><a name="p2565mcpsimp"></a>Foreign Address</p>
</td>
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p2567mcpsimp"><a name="p2567mcpsimp"></a><a name="p2567mcpsimp"></a>Remote IP address and port number.</p>
</td>
</tr>
<tr id="row2568mcpsimp"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p2570mcpsimp"><a name="p2570mcpsimp"></a><a name="p2570mcpsimp"></a>State</p>
</td>
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p2572mcpsimp"><a name="p2572mcpsimp"></a><a name="p2572mcpsimp"></a>TCP connection status. This parameter is meaningless for UDP.</p>
</td>
</tr>
</tbody>
</table>
>![](../public_sys-resources/icon-note.gif) **NOTE:**
>The command output like "========== total sockets 32 ====== unused sockets 22 BootTime 27 s ==========" indicates that there are 32 sockets in total, 22 sockets are not used, and it has been 27 seconds since the system starts.
> **NOTE**<br>
> The command output like "========== total sockets 32 ====== unused sockets 22 BootTime 27 s ==========" indicates that there are 32 sockets in total, 22 sockets are not used, and it has been 27 seconds since the system starts.
# ntpdate # ntpdate
## Command Function<a name="section38494293815"></a> ## Command Function
This command is used to synchronize system time from the server. This command is used to synchronize system time from the server.
## Syntax<a name="section5503114413387"></a>
ntpdate \[_SERVER\_IP1_\] \[_SERVER\_IP2_\]... ## Syntax
## Parameters<a name="section136934472383"></a> ntpdate [_SERVER_IP1_] [_SERVER_IP2_]...
**Table 1** Parameter description
<a name="table2616mcpsimp"></a> ## Parameters
<table><thead align="left"><tr id="row2622mcpsimp"><th class="cellrowborder" valign="top" width="20.79%" id="mcps1.2.4.1.1"><p id="p2624mcpsimp"><a name="p2624mcpsimp"></a><a name="p2624mcpsimp"></a><strong id="b156978804711722"><a name="b156978804711722"></a><a name="b156978804711722"></a>Parameter</strong></p>
</th>
<th class="cellrowborder" valign="top" width="52.480000000000004%" id="mcps1.2.4.1.2"><p id="p2626mcpsimp"><a name="p2626mcpsimp"></a><a name="p2626mcpsimp"></a><strong id="b53501572310"><a name="b53501572310"></a><a name="b53501572310"></a>Description</strong></p>
</th>
<th class="cellrowborder" valign="top" width="26.729999999999997%" id="mcps1.2.4.1.3"><p id="p2628mcpsimp"><a name="p2628mcpsimp"></a><a name="p2628mcpsimp"></a><strong id="b88462564511722"><a name="b88462564511722"></a><a name="b88462564511722"></a>Value Range</strong></p>
</th>
</tr>
</thead>
<tbody><tr id="row2629mcpsimp"><td class="cellrowborder" valign="top" width="20.79%" headers="mcps1.2.4.1.1 "><p id="p2631mcpsimp"><a name="p2631mcpsimp"></a><a name="p2631mcpsimp"></a>SERVER_IP</p>
</td>
<td class="cellrowborder" valign="top" width="52.480000000000004%" headers="mcps1.2.4.1.2 "><p id="p2633mcpsimp"><a name="p2633mcpsimp"></a><a name="p2633mcpsimp"></a>Specifies the IP address of the NTP server.</p>
</td>
<td class="cellrowborder" valign="top" width="26.729999999999997%" headers="mcps1.2.4.1.3 "><p id="entry2634mcpsimpp0"><a name="entry2634mcpsimpp0"></a><a name="entry2634mcpsimpp0"></a>N/A</p>
</td>
</tr>
</tbody>
</table>
## Usage<a name="section121401651173816"></a> **Table 1** Parameter description
Run the **ntpdate **\[_SERVER\_IP1_\] \[_SERVER\_IP2_\]... command. **ntpdate** obtains and displays the time of the first server with a valid IP address. | Parameter| Description| Value Range|
| -------- | -------- | -------- |
| SERVER_IP | Specifies the IP address of the NTP server.| N/A |
## Example<a name="section3431554203811"></a>
Run **ntpdate 192.168.1.3 **to update the system time. ## Usage Guidelines
Run the **ntpdate [_SERVER_IP1_] [_SERVER_IP2_]...** command to obtain and display the time of the first server with a valid IP address.
## Example
Run **ntpdate 192.168.1.3 **to update the system time.
## Output
## Output<a name="section18638194610115"></a>
``` ```
OHOS # ntpdate 192.168.1.3 OHOS # ntpdate 192.168.1.3
time server 192.168.1.3: Mon Jun 13 09:24:25 2016 time server 192.168.1.3: Mon Jun 13 09:24:25 2016
``` ```
If the time zone of the board is different from that of the server, the displayed time may be several hours different from the obtained server time. If the time zone of the board is different from that of the server, the displayed time may be several hours different from the server time obtained.
# ping # ping
## Command Function<a name="section119672573385"></a> ## Command Function
This command is used to test an IPv4 connection. This command is used to test an IPv4 connection.
## Syntax<a name="section869419010390"></a>
## Syntax
ping _\[-4\] \[-c cnt\] \[-f\] \[-i interval\] \[-q\] \[-s size\] <IP\>_
ping *[-4] [-c cnt] [-f] [-i interval] [-q] [-s size] &lt;IP&gt;*
## Parameters<a name="section9877183173918"></a>
**Table 1** Parameter description ## Parameters
<a name="table2664mcpsimp"></a> **Table 1** Parameter description
<table><thead align="left"><tr id="row2670mcpsimp"><th class="cellrowborder" valign="top" width="21%" id="mcps1.2.4.1.1"><p id="p2672mcpsimp"><a name="p2672mcpsimp"></a><a name="p2672mcpsimp"></a><strong id="b8570451611622"><a name="b8570451611622"></a><a name="b8570451611622"></a>Parameter</strong></p>
</th> | Parameter| Description| Value Range|
<th class="cellrowborder" valign="top" width="52%" id="mcps1.2.4.1.2"><p id="p2674mcpsimp"><a name="p2674mcpsimp"></a><a name="p2674mcpsimp"></a><strong id="b18214141162620"><a name="b18214141162620"></a><a name="b18214141162620"></a>Description</strong></p> | -------- | -------- | -------- |
</th> | --help | Displays the parameters supported by the **ping** command.| N/A |
<th class="cellrowborder" valign="top" width="27%" id="mcps1.2.4.1.3"><p id="p2676mcpsimp"><a name="p2676mcpsimp"></a><a name="p2676mcpsimp"></a><strong id="b54224635611622"><a name="b54224635611622"></a><a name="b54224635611622"></a>Value Range</strong></p> | -4 | Forcibly pings the destination address using the IPv4 protocol.| 0-65500 |
</th> | -c&nbsp;CNT | Specifies the number of execution times. The default value is **3**.| 1-65535 |
</tr> | -f | Pings an IPv4 address in implicit mode. The default parameter configuration is equivalent to **-c 15 -i 0.2**.| N/A |
</thead> | -i&nbsp;interval | Specifies the interval (in ms) for sending a ping packet.| 1-200 |
<tbody><tr id="row02916415585"><td class="cellrowborder" valign="top" width="21%" headers="mcps1.2.4.1.1 "><p id="p1028111418588"><a name="p1028111418588"></a><a name="p1028111418588"></a>--help</p> | -q | Implicitly pings an IPv4 address. If the host is still alive, the ping stops after **true** is returned.| N/A |
</td> | -s&nbsp;SIZE | Specifies the size of a ping packet, in bytes. The default size is **56** bytes.| 0-4088 |
<td class="cellrowborder" valign="top" width="52%" headers="mcps1.2.4.1.2 "><p id="p122810445818"><a name="p122810445818"></a><a name="p122810445818"></a>Displays the parameters supported by the <strong id="b1796144112279"><a name="b1796144112279"></a><a name="b1796144112279"></a>ping</strong> command.</p> | IP | Specifies the IPv4 address of the network to test.| N/A |
</td>
<td class="cellrowborder" valign="top" width="27%" headers="mcps1.2.4.1.3 "><p id="p1028118410584"><a name="p1028118410584"></a><a name="p1028118410584"></a>N/A</p>
</td> ## Usage Guidelines
</tr>
<tr id="row15291104105819"><td class="cellrowborder" valign="top" width="21%" headers="mcps1.2.4.1.1 "><p id="p3281747588"><a name="p3281747588"></a><a name="p3281747588"></a>-4</p> - The **ping** command is used to check whether the destination IP address is reachable.
</td>
<td class="cellrowborder" valign="top" width="52%" headers="mcps1.2.4.1.2 "><p id="p16281846585"><a name="p16281846585"></a><a name="p16281846585"></a>Forcibly pings the destination address using the IPv4 protocol.</p> - If the destination IP address is unreachable, the system displays a message indicating that the request times out.
</td>
<td class="cellrowborder" valign="top" width="27%" headers="mcps1.2.4.1.3 "><p id="p202811548588"><a name="p202811548588"></a><a name="p202811548588"></a>0-65500</p> - If no route is available to the destination IP address, an error message is displayed.
</td>
</tr> - This command can be used only after the TCP/IP protocol stack is enabled.
<tr id="row82911540582"><td class="cellrowborder" valign="top" width="21%" headers="mcps1.2.4.1.1 "><p id="p18281646583"><a name="p18281646583"></a><a name="p18281646583"></a>-c CNT</p>
</td>
<td class="cellrowborder" valign="top" width="52%" headers="mcps1.2.4.1.2 "><p id="p1281248583"><a name="p1281248583"></a><a name="p1281248583"></a>Specifies the number of execution times. The default value is <strong id="b209506262288"><a name="b209506262288"></a><a name="b209506262288"></a>3</strong>.</p> ## Example
</td>
<td class="cellrowborder" valign="top" width="27%" headers="mcps1.2.4.1.3 "><p id="p528111412581"><a name="p528111412581"></a><a name="p528111412581"></a>1-65535</p> Run **ping 192.168.1.3**.
</td>
</tr>
<tr id="row112911545588"><td class="cellrowborder" valign="top" width="21%" headers="mcps1.2.4.1.1 "><p id="p1028154135811"><a name="p1028154135811"></a><a name="p1028154135811"></a>-f</p> ## Output
</td>
<td class="cellrowborder" valign="top" width="52%" headers="mcps1.2.4.1.2 "><p id="p22811642583"><a name="p22811642583"></a><a name="p22811642583"></a>Pings an IPv4 address in implicit mode. The default parameter configuration is equivalent to <strong id="b12261222102915"><a name="b12261222102915"></a><a name="b12261222102915"></a>-c 15 -i 0.2</strong>.</p> Ping a TFTP server IP address.
</td>
<td class="cellrowborder" valign="top" width="27%" headers="mcps1.2.4.1.3 "><p id="p628118425815"><a name="p628118425815"></a><a name="p628118425815"></a>N/A</p>
</td>
</tr>
<tr id="row192917495812"><td class="cellrowborder" valign="top" width="21%" headers="mcps1.2.4.1.1 "><p id="p02811416589"><a name="p02811416589"></a><a name="p02811416589"></a>-i interval</p>
</td>
<td class="cellrowborder" valign="top" width="52%" headers="mcps1.2.4.1.2 "><p id="p15281184125813"><a name="p15281184125813"></a><a name="p15281184125813"></a>Specifies the interval (in ms) for sending a ping packet.</p>
</td>
<td class="cellrowborder" valign="top" width="27%" headers="mcps1.2.4.1.3 "><p id="p5281144195811"><a name="p5281144195811"></a><a name="p5281144195811"></a>1-200</p>
</td>
</tr>
<tr id="row182911647586"><td class="cellrowborder" valign="top" width="21%" headers="mcps1.2.4.1.1 "><p id="p17281840587"><a name="p17281840587"></a><a name="p17281840587"></a>-q</p>
</td>
<td class="cellrowborder" valign="top" width="52%" headers="mcps1.2.4.1.2 "><p id="p13281124155815"><a name="p13281124155815"></a><a name="p13281124155815"></a>Implicitly pings an IPv4 address. If the host is active, the ping stops after <strong id="b3813112783011"><a name="b3813112783011"></a><a name="b3813112783011"></a>true</strong> is received.</p>
</td>
<td class="cellrowborder" valign="top" width="27%" headers="mcps1.2.4.1.3 "><p id="p182811240582"><a name="p182811240582"></a><a name="p182811240582"></a>N/A</p>
</td>
</tr>
<tr id="row92900485818"><td class="cellrowborder" valign="top" width="21%" headers="mcps1.2.4.1.1 "><p id="p5281124125815"><a name="p5281124125815"></a><a name="p5281124125815"></a>-s SIZE</p>
</td>
<td class="cellrowborder" valign="top" width="52%" headers="mcps1.2.4.1.2 "><p id="p12281154165819"><a name="p12281154165819"></a><a name="p12281154165819"></a>Specifies the size of a ping packet, in bytes. The default size is <strong id="b145002224316"><a name="b145002224316"></a><a name="b145002224316"></a>56</strong> bytes.</p>
</td>
<td class="cellrowborder" valign="top" width="27%" headers="mcps1.2.4.1.3 "><p id="p13281341582"><a name="p13281341582"></a><a name="p13281341582"></a>0-4088</p>
</td>
</tr>
<tr id="row1529016465815"><td class="cellrowborder" valign="top" width="21%" headers="mcps1.2.4.1.1 "><p id="p202818413586"><a name="p202818413586"></a><a name="p202818413586"></a>IP</p>
</td>
<td class="cellrowborder" valign="top" width="52%" headers="mcps1.2.4.1.2 "><p id="p4282545588"><a name="p4282545588"></a><a name="p4282545588"></a>Specifies the IPv4 address to test.</p>
</td>
<td class="cellrowborder" valign="top" width="27%" headers="mcps1.2.4.1.3 "><p id="p1928284155810"><a name="p1928284155810"></a><a name="p1928284155810"></a>N/A</p>
</td>
</tr>
</tbody>
</table>
## Usage<a name="section1097046193914"></a>
- The **ping** command is used to check whether the destination IP address is reachable.
- If the destination IP address is unreachable, the system displays a message indicating that the request times out.
- If no route is available to the destination IP address, an error message is displayed.
- This command can be used only after the TCP/IP stack is enabled.
## Example<a name="section14564129113911"></a>
Run **ping 192.168.1.3**.
## Output<a name="section1621732891215"></a>
Pinging a TFTP server IP address:
``` ```
OHOS:/$ ping 192.168.1.3 OHOS:/$ ping 192.168.1.3
...@@ -106,4 +57,3 @@ Ping 192.168.1.3 (192.168.1.3): 56(84) bytes. ...@@ -106,4 +57,3 @@ Ping 192.168.1.3 (192.168.1.3): 56(84) bytes.
3 packets transmitted, 3 received, 0% packet loss 3 packets transmitted, 3 received, 0% packet loss
round-trip min/avg/max = 0/0/0 ms round-trip min/avg/max = 0/0/0 ms
``` ```
# ping6 # ping6
## Command Function<a name="section1057291313393"></a> ## Command Function
This command is used to test an IPv6 network connection. This command is used to test an IPv6 network connection.
## Syntax<a name="section199901315123919"></a>
ping6 _\[-c count\] \[-I interface / sourceAddress\] destination_
## Parameters<a name="section4679319113919"></a>
**Table 1** Parameter description
<a name="table2742mcpsimp"></a>
<table><thead align="left"><tr id="row2748mcpsimp"><th class="cellrowborder" valign="top" width="21%" id="mcps1.2.4.1.1"><p id="p2750mcpsimp"><a name="p2750mcpsimp"></a><a name="p2750mcpsimp"></a><strong id="b9059409211170"><a name="b9059409211170"></a><a name="b9059409211170"></a>Parameter</strong></p>
</th>
<th class="cellrowborder" valign="top" width="52%" id="mcps1.2.4.1.2"><p id="p2752mcpsimp"><a name="p2752mcpsimp"></a><a name="p2752mcpsimp"></a><strong id="b189621522143614"><a name="b189621522143614"></a><a name="b189621522143614"></a>Description</strong></p>
</th>
<th class="cellrowborder" valign="top" width="27%" id="mcps1.2.4.1.3"><p id="p2754mcpsimp"><a name="p2754mcpsimp"></a><a name="p2754mcpsimp"></a><strong id="b1322365521170"><a name="b1322365521170"></a><a name="b1322365521170"></a>Value Range</strong></p>
</th>
</tr>
</thead>
<tbody><tr id="row2755mcpsimp"><td class="cellrowborder" valign="top" width="21%" headers="mcps1.2.4.1.1 "><p id="p2757mcpsimp"><a name="p2757mcpsimp"></a><a name="p2757mcpsimp"></a>-c count</p>
</td>
<td class="cellrowborder" valign="top" width="52%" headers="mcps1.2.4.1.2 "><p id="p2759mcpsimp"><a name="p2759mcpsimp"></a><a name="p2759mcpsimp"></a>Specifies the number of execution times. If this parameter is not specified, the default value is <strong id="b1769545815488"><a name="b1769545815488"></a><a name="b1769545815488"></a>4</strong>.</p>
</td>
<td class="cellrowborder" valign="top" width="27%" headers="mcps1.2.4.1.3 "><p id="p2761mcpsimp"><a name="p2761mcpsimp"></a><a name="p2761mcpsimp"></a>1~65535</p>
</td>
</tr>
<tr id="row2762mcpsimp"><td class="cellrowborder" valign="top" width="21%" headers="mcps1.2.4.1.1 "><p id="p2764mcpsimp"><a name="p2764mcpsimp"></a><a name="p2764mcpsimp"></a>-I interface</p>
</td>
<td class="cellrowborder" valign="top" width="52%" headers="mcps1.2.4.1.2 "><p id="p2766mcpsimp"><a name="p2766mcpsimp"></a><a name="p2766mcpsimp"></a>Performs an IPv6 ping operation for a specified NIC.</p>
</td>
<td class="cellrowborder" valign="top" width="27%" headers="mcps1.2.4.1.3 "><p id="p2768mcpsimp"><a name="p2768mcpsimp"></a><a name="p2768mcpsimp"></a>N/A</p>
</td>
</tr>
<tr id="row2769mcpsimp"><td class="cellrowborder" valign="top" width="21%" headers="mcps1.2.4.1.1 "><p id="p2771mcpsimp"><a name="p2771mcpsimp"></a><a name="p2771mcpsimp"></a>-I sourceAddress</p>
</td>
<td class="cellrowborder" valign="top" width="52%" headers="mcps1.2.4.1.2 "><p id="p2773mcpsimp"><a name="p2773mcpsimp"></a><a name="p2773mcpsimp"></a>Specifies the source IPv6 address.</p>
</td>
<td class="cellrowborder" valign="top" width="27%" headers="mcps1.2.4.1.3 "><p id="p2775mcpsimp"><a name="p2775mcpsimp"></a><a name="p2775mcpsimp"></a>N/A</p>
</td>
</tr>
<tr id="row84173618410"><td class="cellrowborder" valign="top" width="21%" headers="mcps1.2.4.1.1 "><p id="p141163619410"><a name="p141163619410"></a><a name="p141163619410"></a>destination</p>
</td>
<td class="cellrowborder" valign="top" width="52%" headers="mcps1.2.4.1.2 "><p id="p134111362417"><a name="p134111362417"></a><a name="p134111362417"></a>Specifies the IP address of the destination host.</p>
</td>
<td class="cellrowborder" valign="top" width="27%" headers="mcps1.2.4.1.3 "><p id="p134173611412"><a name="p134173611412"></a><a name="p134173611412"></a>N/A</p>
</td>
</tr>
</tbody>
</table>
## Usage<a name="section1127917226399"></a>
- If the destination IPv6 address is unreachable, the system displays a message indicating that the request times out.
- If no route is available to the destination IPv6 address, an error message is displayed.
- This command can be used only after the TCP/IP protocol stack is enabled.
## Example<a name="section7211192553917"></a>
- ping6 2001:a:b:c:d:e:f:b
- ping6 -c 3 2001:a:b:c:d:e:f:b
- ping6 -I eth0 2001:a:b:c:d:e:f:b
- ping6 -I 2001:a:b:c:d:e:f:d 2001:a:b:c:d:e:f:b
## Output<a name="section4846145221215"></a>
1. Output of **ping6 2001:a:b:c:d:e:f:b**:
```
OHOS # ping6 2001:a:b:c:d:e:f:b PING 2001:A:B:C:D:E:F:B with 56 bytes of data.
56 bytes from 2001:A:B:C:D:E:F:B : icmp_seq=1 time<1 ms
56 bytes from 2001:A:B:C:D:E:F:B : icmp_seq=2 time<1 ms
56 bytes from 2001:A:B:C:D:E:F:B : icmp_seq=3 time<1 ms
56 bytes from 2001:A:B:C:D:E:F:B : icmp_seq=4 time<1 ms
--- 2001:a:b:c:d:e:f:b/64 ping statistics ---
4 packets transmitted, 4 received, 0.00% packet loss, time 20ms
rtt min/avg/max = 0/0.00/0 ms
```
2. Output of **ping6 -c 3 2001:a:b:c:d:e:f:b**:
```
OHOS # ping6 -c 3 2001:a:b:c:d:e:f:b PING 2001:A:B:C:D:E:F:B with 56 bytes of data.
56 bytes from 2001:A:B:C:D:E:F:B : icmp_seq=1 time<1 ms
56 bytes from 2001:A:B:C:D:E:F:B : icmp_seq=2 time<1 ms
56 bytes from 2001:A:B:C:D:E:F:B : icmp_seq=3 time<1 ms
--- 2001:a:b:c:d:e:f:b/64 ping statistics ---
3 packets transmitted, 3 received, 0.00% packet loss, time 20ms
rtt min/avg/max = 0/0.00/0 ms
```
3. Output of **ping6 -I eth0 2001:a:b:c:d:e:f:b**:
```
OHOS # ping6 -I eth0 2001:a:b:c:d:e:f:b PING 2001:A:B:C:D:E:F:B with 56 bytes of data.
56 bytes from 2001:A:B:C:D:E:F:B : icmp_seq=1 time=10 ms
56 bytes from 2001:A:B:C:D:E:F:B : icmp_seq=2 time<1 ms
56 bytes from 2001:A:B:C:D:E:F:B : icmp_seq=3 time<1 ms
56 bytes from 2001:A:B:C:D:E:F:B : icmp_seq=4 time<1 ms
--- 2001:a:b:c:d:e:f:b/64 ping statistics ---
4 packets transmitted, 4 received, 0.00% packet loss, time 30msrtt min/avg/max = 0/2.50/10 ms
```
4. Output of **ping6 -I 2001:a:b:c:d:e:f:d 2001:a:b:c:d:e:f:b**:
```
OHOS # ping6 -I 2001:a:b:c:d:e:f:d 2001:a:b:c:d:e:f:b PING 2001:A:B:C:D:E:F:B with 56 bytes of data.
56 bytes from 2001:A:B:C:D:E:F:B : icmp_seq=1 time<1 ms
56 bytes from 2001:A:B:C:D:E:F:B : icmp_seq=2 time<1 ms
56 bytes from 2001:A:B:C:D:E:F:B : icmp_seq=3 time<1 ms
56 bytes from 2001:A:B:C:D:E:F:B : icmp_seq=4 time<1 ms
--- 2001:a:b:c:d:e:f:b/64 ping statistics ---
4 packets transmitted, 4 received, 0.00% packet loss, time 20msrtt min/avg/max = 0/0.00/0 ms
```
## Syntax
ping6 *[-c count] [-I interface / sourceAddress] destination*
## Parameters
**Table 1** Parameter description
| Parameter | Description | Value Range|
| --------------------- | ----------------------------------- | -------- |
| -c&nbsp;count | Specifies the number of execution times. If this parameter is not specified, the default value is **4**.| [1, 65535] |
| -I&nbsp;interface | Specifies the NIC for performing the ping operation. | N/A |
| -I&nbsp;sourceAddress | Specifies the source IPv6 address. | N/A |
| destination | Specifies the IP address of the destination host. | N/A |
## Usage Guidelines
- If the destination IPv6 address is unreachable, "Request Timed Out" will be displayed.
- If no route is available to the destination IPv6 address, "Destinatin Host Unreachable" will be displayed.
- This command can be used only after the TCP/IP stack is enabled.
## Note
Currently, the shell does not support this command.
## Example
- ping6 2001:a:b:c:d:e:f:b
- ping6 -c 3 2001:a:b:c:d:e:f:b
- ping6 -I eth0 2001:a:b:c:d:e:f:b
- ping6 -I 2001:a:b:c:d:e:f:d 2001:a:b:c:d:e:f:b
## Output
1. Output of **ping6 2001:a:b:c:d:e:f:b**:
```
OHOS # ping6 2001:a:b:c:d:e:f:b PING 2001:A:B:C:D:E:F:B with 56 bytes of data.
56 bytes from 2001:A:B:C:D:E:F:B : icmp_seq=1 time<1 ms
56 bytes from 2001:A:B:C:D:E:F:B : icmp_seq=2 time<1 ms
56 bytes from 2001:A:B:C:D:E:F:B : icmp_seq=3 time<1 ms
56 bytes from 2001:A:B:C:D:E:F:B : icmp_seq=4 time<1 ms
--- 2001:a:b:c:d:e:f:b/64 ping statistics ---
4 packets transmitted, 4 received, 0.00% packet loss, time 20ms
rtt min/avg/max = 0/0.00/0 ms
```
2. Output of **ping6 -c 3 2001:a:b:c:d:e:f:b**:
```
OHOS # ping6 -c 3 2001:a:b:c:d:e:f:b PING 2001:A:B:C:D:E:F:B with 56 bytes of data.
56 bytes from 2001:A:B:C:D:E:F:B : icmp_seq=1 time<1 ms
56 bytes from 2001:A:B:C:D:E:F:B : icmp_seq=2 time<1 ms
56 bytes from 2001:A:B:C:D:E:F:B : icmp_seq=3 time<1 ms
--- 2001:a:b:c:d:e:f:b/64 ping statistics ---
3 packets transmitted, 3 received, 0.00% packet loss, time 20ms
rtt min/avg/max = 0/0.00/0 ms
```
3. Output of **ping6 -I eth0 2001:a:b:c:d:e:f:b**:
```
OHOS # ping6 -I eth0 2001:a:b:c:d:e:f:b PING 2001:A:B:C:D:E:F:B with 56 bytes of data.
56 bytes from 2001:A:B:C:D:E:F:B : icmp_seq=1 time=10 ms
56 bytes from 2001:A:B:C:D:E:F:B : icmp_seq=2 time<1 ms
56 bytes from 2001:A:B:C:D:E:F:B : icmp_seq=3 time<1 ms
56 bytes from 2001:A:B:C:D:E:F:B : icmp_seq=4 time<1 ms
--- 2001:a:b:c:d:e:f:b/64 ping statistics ---
4 packets transmitted, 4 received, 0.00% packet loss, time 30msrtt min/avg/max = 0/2.50/10 ms
```
4. Output of **ping6 -I 2001:a:b:c:d:e:f:d 2001:a:b:c:d:e:f:b**:
```
OHOS # ping6 -I 2001:a:b:c:d:e:f:d 2001:a:b:c:d:e:f:b PING 2001:A:B:C:D:E:F:B with 56 bytes of data.
56 bytes from 2001:A:B:C:D:E:F:B : icmp_seq=1 time<1 ms
56 bytes from 2001:A:B:C:D:E:F:B : icmp_seq=2 time<1 ms
56 bytes from 2001:A:B:C:D:E:F:B : icmp_seq=3 time<1 ms
56 bytes from 2001:A:B:C:D:E:F:B : icmp_seq=4 time<1 ms
--- 2001:a:b:c:d:e:f:b/64 ping statistics ---
4 packets transmitted, 4 received, 0.00% packet loss, time 20msrtt min/avg/max = 0/0.00/0 ms
```
# telnet # telnet
## Command Function<a name="section3551830123913"></a> ## Command Function
This command is used to enable or disable the Telnet server service. This command is used to enable or disable the Telnet server service.
## Syntax<a name="section14897133233918"></a>
telnet \[_on | off_\] ## Syntax
## Parameters<a name="section977718353392"></a> telnet [_on | off_]
**Table 1** Parameter description
<a name="table2844mcpsimp"></a> ## Parameters
<table><thead align="left"><tr id="row2850mcpsimp"><th class="cellrowborder" valign="top" width="21%" id="mcps1.2.4.1.1"><p id="p2852mcpsimp"><a name="p2852mcpsimp"></a><a name="p2852mcpsimp"></a><strong id="b980352831178"><a name="b980352831178"></a><a name="b980352831178"></a>Parameter</strong></p>
</th>
<th class="cellrowborder" valign="top" width="52%" id="mcps1.2.4.1.2"><p id="p2854mcpsimp"><a name="p2854mcpsimp"></a><a name="p2854mcpsimp"></a><strong id="b385431525416"><a name="b385431525416"></a><a name="b385431525416"></a>Description</strong></p>
</th>
<th class="cellrowborder" valign="top" width="27%" id="mcps1.2.4.1.3"><p id="p2856mcpsimp"><a name="p2856mcpsimp"></a><a name="p2856mcpsimp"></a><strong id="b19001516841178"><a name="b19001516841178"></a><a name="b19001516841178"></a>Value Range</strong></p>
</th>
</tr>
</thead>
<tbody><tr id="row2857mcpsimp"><td class="cellrowborder" valign="top" width="21%" headers="mcps1.2.4.1.1 "><p id="p2859mcpsimp"><a name="p2859mcpsimp"></a><a name="p2859mcpsimp"></a>on</p>
</td>
<td class="cellrowborder" valign="top" width="52%" headers="mcps1.2.4.1.2 "><p id="p2861mcpsimp"><a name="p2861mcpsimp"></a><a name="p2861mcpsimp"></a>Enables the Telnet server service.</p>
</td>
<td class="cellrowborder" valign="top" width="27%" headers="mcps1.2.4.1.3 "><p id="p2863mcpsimp"><a name="p2863mcpsimp"></a><a name="p2863mcpsimp"></a>N/A</p>
</td>
</tr>
<tr id="row2864mcpsimp"><td class="cellrowborder" valign="top" width="21%" headers="mcps1.2.4.1.1 "><p id="p2866mcpsimp"><a name="p2866mcpsimp"></a><a name="p2866mcpsimp"></a>off</p>
</td>
<td class="cellrowborder" valign="top" width="52%" headers="mcps1.2.4.1.2 "><p id="p2868mcpsimp"><a name="p2868mcpsimp"></a><a name="p2868mcpsimp"></a>Disables the Telnet server service.</p>
</td>
<td class="cellrowborder" valign="top" width="27%" headers="mcps1.2.4.1.3 "><p id="p2870mcpsimp"><a name="p2870mcpsimp"></a><a name="p2870mcpsimp"></a>N/A</p>
</td>
</tr>
</tbody>
</table>
## Usage<a name="section134991538183916"></a> **Table 1** Parameter description
- Before enabling Telnet, ensure that the network driver and network protocol stack have been initialized and the NIC of the board is in the **link up** state. | Parameter| Description| Value Range|
- Currently, multiple clients \(Telnet + IP\) cannot connect to the development board at the same time. | -------- | -------- | -------- |
| on | Enables the telnet server service.| N/A |
| off | Disables the telnet server service.| N/A |
>![](../public_sys-resources/icon-notice.gif) **NOTICE:**
>Telnet is used for debugging and is disabled by default. Do not use it in formal products.
## Usage Guidelines
## Example<a name="section1097414426398"></a> - Before enabling Telnet, ensure that the network driver and network protocol stack have been initialized and the NIC of the board is in the **link up** state.
Run **telnet on**. - Currently, multiple clients (Telnet + IP) cannot connect to the development board at the same time.
> **NOTICE**<br>
> Telnet is used for debugging and is disabled by default. Do not use it in formal products.
## Output<a name="section11846624191310"></a>
## Example
Run **telnet on**.
## Output
Command output: Command output:
``` ```
OHOS # telnet on OHOS # telnet on
OHOS # start telnet server successfully, waiting for connection. OHOS # start telnet server successfully, waiting for connection.
``` ```
# tftp # tftp
## Command Function<a name="section15142134573911"></a> ## Command Function
Trivial File Transfer Protocol \(TFTP\) is a protocol in the TCP/IP protocol suite for transferring files between clients and servers. TFTP provides simple and low-overhead file transfer services. The port number is 69. Trivial File Transfer Protocol (TFTP) is a protocol in the TCP/IP protocol suite for transferring files between clients and servers. TFTP provides simple and low-overhead file transfer services. The port number is 69.
The **tftp** command is used to transfer files with a TFTP server. The **tftp** command is used to transfer files with a TFTP server.
## Syntax<a name="section20958174917394"></a>
## Syntax
./bin/tftp _<-g/-p\>_ _-l_ _\[FullPathLocalFile\] -r \[RemoteFile\] \[Host\]_
./bin/tftp *&lt;-g/-p&gt;**-l**[FullPathLocalFile] -r [RemoteFile] [Host]*
## Parameters<a name="section576613532395"></a>
**Table 1** Parameter description ## Parameters
<a name="table2894mcpsimp"></a> **Table 1** Parameter description
<table><thead align="left"><tr id="row2900mcpsimp"><th class="cellrowborder" valign="top" width="20.79%" id="mcps1.2.4.1.1"><p id="p2902mcpsimp"><a name="p2902mcpsimp"></a><a name="p2902mcpsimp"></a><strong id="b116998706011737"><a name="b116998706011737"></a><a name="b116998706011737"></a>Parameter</strong></p>
</th> | Parameter| Description| Value Range|
<th class="cellrowborder" valign="top" width="52.480000000000004%" id="mcps1.2.4.1.2"><p id="p2904mcpsimp"><a name="p2904mcpsimp"></a><a name="p2904mcpsimp"></a><strong id="b13511135745719"><a name="b13511135745719"></a><a name="b13511135745719"></a>Description</strong></p> | -------- | -------- | -------- |
</th> | -g/-p | Specifies the file transfer direction.<br>- **-g**: obtains a file from the TFTP server.<br>- **-p**: uploads a file to the TFTP server.| N/A |
<th class="cellrowborder" valign="top" width="26.729999999999997%" id="mcps1.2.4.1.3"><p id="p2906mcpsimp"><a name="p2906mcpsimp"></a><a name="p2906mcpsimp"></a><strong id="b174218805911737"><a name="b174218805911737"></a><a name="b174218805911737"></a>Value Range</strong></p> | -l&nbsp;FullPathLocalFile | Specifies the complete path of a local file.| N/A |
</th> | -r&nbsp;RemoteFile | Specifies the file name on the server.| N/A |
</tr> | Host | Specifies the server IP address.| N/A |
</thead>
<tbody><tr id="row2907mcpsimp"><td class="cellrowborder" valign="top" width="20.79%" headers="mcps1.2.4.1.1 "><p id="p2909mcpsimp"><a name="p2909mcpsimp"></a><a name="p2909mcpsimp"></a>-g/-p</p>
</td> ## Usage Guidelines
<td class="cellrowborder" valign="top" width="52.480000000000004%" headers="mcps1.2.4.1.2 "><p id="p2911mcpsimp"><a name="p2911mcpsimp"></a><a name="p2911mcpsimp"></a>Specifies the file transfer direction.</p>
<a name="ul73571240131312"></a><a name="ul73571240131312"></a><ul id="ul73571240131312"><li><strong id="b0778214125818"><a name="b0778214125818"></a><a name="b0778214125818"></a>-g</strong>: downloads files from the TFTP server.</li><li><strong id="b7168132555814"><a name="b7168132555814"></a><a name="b7168132555814"></a>-p</strong>: uploads files to the TFTP server.</li></ul> 1. Deploy a TFTP server on the server and configure the TFTP server correctly.
</td>
<td class="cellrowborder" valign="top" width="26.729999999999997%" headers="mcps1.2.4.1.3 "><p id="p14399194271310"><a name="p14399194271310"></a><a name="p14399194271310"></a>N/A</p> 2. Use the **tftp** command to upload files from or download files to an OpenHarmony board.
</td>
</tr> 3. The size of the file to be transferred cannot exceed 32 MB.
<tr id="row2921mcpsimp"><td class="cellrowborder" valign="top" width="20.79%" headers="mcps1.2.4.1.1 "><p id="p2923mcpsimp"><a name="p2923mcpsimp"></a><a name="p2923mcpsimp"></a>-l FullPathLocalFile</p> > **NOTICE**<br>
</td> > TFTP is used for debugging and disabled by default. Do not use it in formal products.
<td class="cellrowborder" valign="top" width="52.480000000000004%" headers="mcps1.2.4.1.2 "><p id="p2925mcpsimp"><a name="p2925mcpsimp"></a><a name="p2925mcpsimp"></a>Specifies the complete path of a local file.</p>
</td>
<td class="cellrowborder" valign="top" width="26.729999999999997%" headers="mcps1.2.4.1.3 "><p id="entry2926mcpsimpp0"><a name="entry2926mcpsimpp0"></a><a name="entry2926mcpsimpp0"></a>N/A</p> ## Example
</td>
</tr> Download the **out** file from the server.
<tr id="row2927mcpsimp"><td class="cellrowborder" valign="top" width="20.79%" headers="mcps1.2.4.1.1 "><p id="p2929mcpsimp"><a name="p2929mcpsimp"></a><a name="p2929mcpsimp"></a>-r RemoteFile</p>
</td>
<td class="cellrowborder" valign="top" width="52.480000000000004%" headers="mcps1.2.4.1.2 "><p id="p2931mcpsimp"><a name="p2931mcpsimp"></a><a name="p2931mcpsimp"></a>Specifies the file name on the server.</p> ## Output
</td>
<td class="cellrowborder" valign="top" width="26.729999999999997%" headers="mcps1.2.4.1.3 "><p id="entry2932mcpsimpp0"><a name="entry2932mcpsimpp0"></a><a name="entry2932mcpsimpp0"></a>N/A</p>
</td>
</tr>
<tr id="row2933mcpsimp"><td class="cellrowborder" valign="top" width="20.79%" headers="mcps1.2.4.1.1 "><p id="p2935mcpsimp"><a name="p2935mcpsimp"></a><a name="p2935mcpsimp"></a>Host</p>
</td>
<td class="cellrowborder" valign="top" width="52.480000000000004%" headers="mcps1.2.4.1.2 "><p id="p2937mcpsimp"><a name="p2937mcpsimp"></a><a name="p2937mcpsimp"></a>Specifies the server IP address.</p>
</td>
<td class="cellrowborder" valign="top" width="26.729999999999997%" headers="mcps1.2.4.1.3 "><p id="entry2938mcpsimpp0"><a name="entry2938mcpsimpp0"></a><a name="entry2938mcpsimpp0"></a>N/A</p>
</td>
</tr>
</tbody>
</table>
## Usage<a name="section149795134408"></a>
1. Deploy a TFTP server on the server and configure the TFTP server correctly.
2. Use the **tftp** command to upload and download files on the OpenHarmony board.
3. The size of the file to be transferred cannot exceed 32 MB.
>![](../public_sys-resources/icon-notice.gif) **NOTICE:**
>TFTP is used for debugging and disabled by default. Do not use it in formal products.
## Example<a name="section148921918114015"></a>
Download the **out** file from the server.
## Output<a name="section7872155631313"></a>
``` ```
OHOS # ./bin/tftp -g -l /nfs/out -r out 192.168.1.2 OHOS # ./bin/tftp -g -l /nfs/out -r out 192.168.1.2
TFTP transfer finish TFTP transfer finish
``` ```
After the **tftp** command is executed, **TFTP transfer finish** is displayed if the file transfer is complete. If the file transfer fails, other information is displayed to help locate the fault. After the **tftp** command is executed, **TFTP transfer finish** is displayed if the file transfer is complete. If the file transfer fails, other information is displayed to help locate the fault.
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册