Embedded Learning (Linux Module)
Apr 21. 2026

AI Summary
This AI-generated content is derived from the source article.
Loading.

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:
    1. Linux File System Structure
    2. Commonly Used Shell System Commands
    3. User and Permission Management
    4. VIM Text Editing
    5. 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:

DirectoryPurpose and Description
/binBasic Command Library: Stores basic commands that all users can use (such as ls, cp).
/sbinPrivileged Command Library: Stores system management commands mainly used by superuser (root) (such as reboot, fdisk).
/devDevice Files: Stores hardware device files (such as hard drives, keyboards, terminals), hardware is also treated as files in Linux.
/etcConfiguration Center: Stores configuration files for systems and applications (such as network configuration, user information).
/homeUser Home Directory: Home directory for ordinary users, usually named after the username (such as /home/lucy).
/libShared Library Files: Stores library files that programs depend on for running (similar to Windows .dll files).
/mntMount Point: Temporary directory for system administrators to manually mount file systems (such as external hard drives, CDs).
/procVirtual File System: Stores mapping information in memory, including running processes and kernel information.
/rootSuperuser Home Directory: Exclusive home directory for system administrator (root), separated from ordinary users’ /home.
/usrApplication Directory: Stores user-installed applications and tools, similar to Windows Program Files.
/varDynamic Data: Stores frequently changing files, such as system logs (/var/log), mail, and cache.
/tmpTemporary Files: Stores temporary files generated by program execution, usually cleared after system restart.
/bootBoot 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

  1. ls -a Show all files
  2. 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
  1. cd - Go back to previous directory
  2. mkdir -p Create directory recursively
  3. touch Create file modify file time create multiple files using {} separated by , {1…10}
  4. rm -rf Delete file -i ask before delete rmdir -p Delete directory
  5. 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.

CommandOptionsDescription
cat-nContinuous 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.
morePaged view: Space to page, Enter next line, q to exit.
lessEnhanced paging: Supports up/down scrolling, more powerful than more.
head-n 10Head display: Show first 10 lines of file (default first 10).
tail-n 10Tail display: Show last 10 lines of file (commonly used for logs).

2. File Writing (Write)

Quickly generate or append text content.

CommandSyntaxDescription
echoecho "text" > fileOverwrite write: Write text to file, clears original content.
echo "text" >> fileAppend write: Append text to end of file.

Locate files in the system or filter content.

CommandOptions/ParametersDescription
grep"pattern" fileText filter: Search for specified string in file.
-nShow line numbers of matching lines.
-cCount number of matching lines.
-iIgnore case in search.
find. -name "*.txt"Search by name: Find .txt files in current directory and subdirectories.
-size +10MBy size: Find files larger than 10M.
-type d/f/l...By type: d(directory) f(file) l(link) b(block device) etc.
locatefilenameQuick 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, o etc., used for inputting text.
  • Last Line Mode (Last Line): Enter by typing :, used for save, exit, or find/replace.

1. Cursor Movement and Jumping

ShortcutDescription
GJump to last line of file.
ggJump to first line of file.
vim file +nOpen 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)

ShortcutDescription
ddDelete current line.
:n,ndDelete from current line to line n.
dGDelete from current line to end of file.
yyCopy current line.
yGCopy from current line to end of file.
pPaste after cursor.
PPaste before cursor.
uUndo last operation.
Ctrl + rRedo.
rReplace one character at cursor.
REnter replace mode, replace multiple characters (until Esc).

3. Search and Replace (Last Line Mode)

CommandDescription
/stringDownward search for string. n next, N previous.
?stringUpward search for string.
:s/old/new/gIn current line, replace all old with new.
:%s/old/new/gIn entire file, replace all old with new.
:n,ms/old/new/gBetween lines n to m, replace all old with new.
:set nuShow line numbers (Set Number).
:set nonuHide line numbers.

4. Save and Exit (Last Line Mode)

CommandDescription
:wSave (Write).
:qExit (Quit).
:wqSave and exit.
:q!Force exit, no save.

Other Commands

These commands are usually entered in Vim’s Command Mode (after pressing Esc).

CommandDescription
:set nuShow line numbers: Display line numbers on the left side of the editor.
:set nonuHide 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 + gFile 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, like su - username, - loads target user’s environment variables).

2. User Management

Manage system login users.

CommandOptionsDescription
useradd-mAdd user and create home directory.
-dSpecify home directory path (e.g., -d /opt/myuser).
-gSpecify initial user group (primary group).
-GSpecify additional user groups (can join multiple groups).
userdel-rDelete user, and delete user’s home directory and mail spool.
usermod-dModify user home directory.
-gModify user primary group.
-GModify user additional groups.

3. Password Management

Use passwd command to manage user passwords.

OptionsDescription
(no option)Set/Modify password: Run passwd directly to modify current user password, or passwd username to modify specified user password.
-lLock password: Prohibit user from logging in with password.
-uUnlock password: Restore locked user password.
-dDelete password: Clear user password (make account passwordless).
-eForce 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 -n or group ID -g).
  • chgrp: Modify the group ownership of a file or directory. -R recursive modification
  • chown: 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 CombinationNumeric CalculationMeaning
rwx4+2+1 = 7Read, write, execute
rw-4+2 = 6Read, write
r-x4+1 = 5Read, execute
r--4 = 4Read only
---0 = 0No 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.

> comment on / twitter
>
CC BY-NC-SA 4.0 2021-PRESENT © RYANUO