Embedded Development Software Layers #
Embedded systems are divided into application layer, kernel layer, and hardware layer.
Development Tech Stack #
Reserve Knowledge: Linux System Basics
- Main Content:
- Linux File System Structure
- Commonly Used Shell System Commands
- User and Permission Management
- VIM Text Editing
- Shared Environment Setup
Installation Issues #
- Issues encountered when installing virtual machine image ISO on Mac version
According to the server image version address: https://old-releases.ubuntu.com/releases/ Install the latest version, there will be no screen adaptation issues.
First install the server version of Ubuntu, then use sudo apt install ubuntu-desktop for the desktop version, after execution, use sudo reboot to restart.
Mac ARM version cannot use VMware 3D hardware acceleration.
Linux Basics #
File Structure #
Linux system file structure:
| Directory | Purpose and Description |
|---|---|
/bin | Basic Command Library: Stores basic commands that all users can use (such as ls, cp). |
/sbin | Privileged Command Library: Stores system management commands mainly used by superuser (root) (such as reboot, fdisk). |
/dev | Device Files: Stores hardware device files (such as hard drives, keyboards, terminals), hardware is also treated as files in Linux. |
/etc | Configuration Center: Stores configuration files for systems and applications (such as network configuration, user information). |
/home | User Home Directory: Home directory for ordinary users, usually named after the username (such as /home/lucy). |
/lib | Shared Library Files: Stores library files that programs depend on for running (similar to Windows .dll files). |
/mnt | Mount Point: Temporary directory for system administrators to manually mount file systems (such as external hard drives, CDs). |
/proc | Virtual File System: Stores mapping information in memory, including running processes and kernel information. |
/root | Superuser Home Directory: Exclusive home directory for system administrator (root), separated from ordinary users’ /home. |
/usr | Application Directory: Stores user-installed applications and tools, similar to Windows Program Files. |
/var | Dynamic Data: Stores frequently changing files, such as system logs (/var/log), mail, and cache. |
/tmp | Temporary Files: Stores temporary files generated by program execution, usually cleared after system restart. |
/boot | Boot Files: Stores core files needed for system startup, such as Linux kernel and bootloader. |
File Command Instructions #
Quick Reference: https://wangchujiang.com/reference/docs/linux-command.html
- ls -a Show all files
- ls -l Show file details File types: d directory l link (shortcut) s socket link b block device i index p pipe c character device

- cd - Go back to previous directory
- mkdir -p Create directory recursively
- touch Create file modify file time create multiple files using {} separated by , {1…10}
- rm -rf Delete file -i ask before delete rmdir -p Delete directory
- cp -R Copy directory -r copy -f force overwrite -i ask
Here is a quick reference table for commonly used file operations, text processing, and Vim editor commands in Linux systems.
File Operations and Text Processing #
1. File Viewing (Read) #
Used to read and browse file contents.
| Command | Options | Description |
|---|---|---|
cat | -n | Continuous display: Read file content and display line numbers. |
> | Create/Overwrite: cat > file.txt Create file or empty write. | |
>> | Append: cat >> file.txt Append content to end of file. | |
more | Paged view: Space to page, Enter next line, q to exit. | |
less | Enhanced paging: Supports up/down scrolling, more powerful than more. | |
head | -n 10 | Head display: Show first 10 lines of file (default first 10). |
tail | -n 10 | Tail display: Show last 10 lines of file (commonly used for logs). |
2. File Writing (Write) #
Quickly generate or append text content.
| Command | Syntax | Description |
|---|---|---|
echo | echo "text" > file | Overwrite write: Write text to file, clears original content. |
echo "text" >> file | Append write: Append text to end of file. |
3. File Search (Search) #
Locate files in the system or filter content.
| Command | Options/Parameters | Description |
|---|---|---|
grep | "pattern" file | Text filter: Search for specified string in file. |
-n | Show line numbers of matching lines. | |
-c | Count number of matching lines. | |
-i | Ignore case in search. | |
find | . -name "*.txt" | Search by name: Find .txt files in current directory and subdirectories. |
-size +10M | By size: Find files larger than 10M. | |
-type d/f/l... | By type: d(directory) f(file) l(link) b(block device) etc. | |
locate | filename | Quick locate: Quickly find file path based on database (need updatedb first). |
Vim Editor Commands #
Core Modes #
- Command Mode (Command): Default state after starting Vim, used for executing operation commands.
- Insert Mode (Insert): Enter by typing
i,a,oetc., used for inputting text. - Last Line Mode (Last Line): Enter by typing
:, used for save, exit, or find/replace.
1. Cursor Movement and Jumping #
| Shortcut | Description |
|---|---|
G | Jump to last line of file. |
gg | Jump to first line of file. |
vim file +n | Open file and jump directly to line n. |
0 / ^ | Move to beginning of line (0 absolute, ^ first non-space). |
$ | Move to end of line. |
2. Editing Operations (Command Mode) #
| Shortcut | Description |
|---|---|
dd | Delete current line. |
:n,nd | Delete from current line to line n. |
dG | Delete from current line to end of file. |
yy | Copy current line. |
yG | Copy from current line to end of file. |
p | Paste after cursor. |
P | Paste before cursor. |
u | Undo last operation. |
Ctrl + r | Redo. |
r | Replace one character at cursor. |
R | Enter replace mode, replace multiple characters (until Esc). |
3. Search and Replace (Last Line Mode) #
| Command | Description |
|---|---|
/string | Downward search for string. n next, N previous. |
?string | Upward search for string. |
:s/old/new/g | In current line, replace all old with new. |
:%s/old/new/g | In entire file, replace all old with new. |
:n,ms/old/new/g | Between lines n to m, replace all old with new. |
:set nu | Show line numbers (Set Number). |
:set nonu | Hide line numbers. |
4. Save and Exit (Last Line Mode) #
| Command | Description |
|---|---|
:w | Save (Write). |
:q | Exit (Quit). |
:wq | Save and exit. |
:q! | Force exit, no save. |
Other Commands #
These commands are usually entered in Vim’s Command Mode (after pressing Esc).
| Command | Description |
|---|---|
:set nu | Show line numbers: Display line numbers on the left side of the editor. |
:set nonu | Hide line numbers: Hide line number display. |
:.= | Current line number: Show the line number where the cursor is. |
:= | Total lines: Show total number of lines in the file. |
Ctrl + g | File status: Show filename, current line number, total lines, and position percentage. |
User and Permission Management #
1. User Switching #
Switch between different user identities.
sudo -i: Switch to root user (requires current user to have sudo permissions).exit: Exit current user, return to previous logged-in user.su -: Switch user (usually followed by username, likesu - username,-loads target user’s environment variables).
2. User Management #
Manage system login users.
| Command | Options | Description |
|---|---|---|
| useradd | -m | Add user and create home directory. |
-d | Specify home directory path (e.g., -d /opt/myuser). | |
-g | Specify initial user group (primary group). | |
-G | Specify additional user groups (can join multiple groups). | |
| userdel | -r | Delete user, and delete user’s home directory and mail spool. |
| usermod | -d | Modify user home directory. |
-g | Modify user primary group. | |
-G | Modify user additional groups. |
3. Password Management #
Use passwd command to manage user passwords.
| Options | Description |
|---|---|
| (no option) | Set/Modify password: Run passwd directly to modify current user password, or passwd username to modify specified user password. |
-l | Lock password: Prohibit user from logging in with password. |
-u | Unlock password: Restore locked user password. |
-d | Delete password: Clear user password (make account passwordless). |
-e | Force change: Make password expire immediately, user must change password on next login. |
4. User Group Management #
Manage user group memberships.
groupadd: Add a new user group.groupdel: Delete an existing user group.groups: View all groups a user belongs to.groupmod: Modify user group attributes (such as group name-nor group ID-g).chgrp: Modify the group ownership of a file or directory. -R recursive modificationchown: Modify the user ownership of a file or directory. chown -R [username][:groupname] [filename]chmod: Modify file or directory permissions. -R recursive modification chmod -R [permissions] [filename]
Text description: agu; numeric description, 4210
| Permission Combination | Numeric Calculation | Meaning |
|---|---|---|
rwx | 4+2+1 = 7 | Read, write, execute |
rw- | 4+2 = 6 | Read, write |
r-x | 4+1 = 5 | Read, execute |
r-- | 4 = 4 | Read only |
--- | 0 = 0 | No permissions |
Note: For newly added users, re-authorization is needed. For sudo authorization, add to configuration file ./etc/sudoers.d/username Use visudo command for user privilege authorization.
