> For the complete documentation index, see [llms.txt](https://book.bsdcn.org/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://book.bsdcn.org/ask/flat/chapter-18-linux-compatibility-layer/di-18.10-jie-gu-zhang-pai-chu-yu-wei-jing-shi-yi.md).

# 18.10 Troubleshooting and Remaining Issues

This section summarizes common issues and solutions for the Linux compatibility layer.

## Sound in the Linux Compatibility Layer

If there is no sound output inside the Linux compatibility layer entered via chroot, you usually need to run the Linux program directly in FreeBSD rather than using chroot.

Ubuntu compatibility layer:

Edit the **/compat/ubuntu/etc/asound.conf** file and write the following two lines. Please note the distinction between the English exclamation mark `!` and the number `1`.

```sh
pcm.!sysdefault pcm.plug:oss
pcm.!default pcm.sysdefault
```

## Running Software from the FreeBSD Command Line (Based on Ubuntu Compatibility Layer)

A method to run software directly from the FreeBSD command line without chroot:

Method 1

```sh
# sysctl compat.linux.emul_path=/compat/ubuntu # Takes effect immediately
# echo compat.linux.emul_path=/compat/ubuntu >> /etc/sysctl.conf # Persistent
```

Method 2

> **Warning**
>
> This operation will move and replace `ld-linux-x86-64.so.2`, which may cause the Ubuntu compatibility layer to fail to start or run properly. Before executing, please ensure that you have backed up the relevant files and fully understand the impact of this operation. **This operation is irreversible; please proceed with caution.**

```sh
# mv /compat/ubuntu/lib64/ld-linux-x86-64.so.2  /compat/ubuntu/lib64/ld-linux-x86-64.so.2.back
# ln -s /compat/ubuntu/lib/x86_64-linux-gnu/ld-linux-x86-64.so.2 /compat/ubuntu/lib64/ld-linux-x86-64.so.2
```

Without chroot, you can run Linux programs directly in the terminal (only some programs), but you must specify the absolute path.

**Arch and openSUSE compatibility layers only require Method 1; Method 2 is not needed.**

### References

* Micski D K. FREEBSD, SYSTEM ADMINISTRATION Install Ubuntu base system into FreeBSD's Linux Binary Compatibility\[EB/OL]. (2021-12-21)\[2026-03-25]. <https://www.micski.dk/2021/12/21/install-ubuntu-base-system-into-freebsds-linux-binary-compatibility/>. This article provides a detailed introduction to the complete technical process of building an Ubuntu compatibility layer on FreeBSD, serving as an important reference for the practices in this chapter.

## Running QQ with Regular User Privileges

There is a UID mapping relationship between compatibility layer users and FreeBSD users.

Assuming the regular username on FreeBSD is ykla with UID 1001 (normally the default is 1001):

```sh
# useradd --uid 1001 --gid 0 -m ykla # This step is executed inside the compatibility layer
```

> **Warning**
>
> After creating the user ykla in Arch, this user cannot be used to install software with yay; you still need to use the test user created by default in the Shell script.

## Launching Programs from Icons

* Edit the `QQ.desktop` file and write the following content (using the Ubuntu compatibility layer as an example):

```ini
[Desktop Entry]
Name=QQ
Exec=/compat/ubuntu/opt/QQ/qq --no-sandbox --in-process-gpu %U
Terminal=false
Type=Application
Icon=/compat/ubuntu/usr/share/icons/hicolor/512x512/apps/qq.png
StartupWMClass=QQ
Categories=Network;
Comment=QQ
MimeType=x-scheme-handler/tencent;
```

* Edit the `Chrome.desktop` file and write the following content (using the Ubuntu compatibility layer as an example):

```ini
[Desktop Entry]
Version=1.0
Type=Application
Name=Chrome
Comment=
Exec=/compat/ubuntu/opt/google/chrome/chrome --no-sandbox --in-process-gpu
Icon=/compat/ubuntu/opt/google/chrome/product_logo_256.png
Path=
Terminal=false
StartupNotify=false
```

After granting executable permissions to the above files, they will display as normal icon styles and can be clicked to launch the corresponding software.

## Running Chrome (Using Ubuntu Compatibility Layer as an Example)

Download Chrome:

```sh
# wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb # Can be downloaded directly without a proxy. At this point, you are already in the Ubuntu compatibility layer
```

Install Chrome:

```bash
# apt install ./google-chrome-stable_current_amd64.deb # At this point, you are already in the Ubuntu compatibility layer
```

Launch Chrome:

```sh
# /usr/bin/google-chrome-stable --no-sandbox --no-zygote --in-process-gpu  # At this point, you are already in the Ubuntu compatibility layer
```

## Linux Compatibility Layer Networking (Linux QQ Has No Network)

When the machine has both an Ethernet card em0 and a wireless card wlan0, but only wlan0 is actually in use, the Linux compatibility layer may not be able to connect to the network properly. FreeBSD's em0 corresponds to the compatibility layer's eth0, wlan0 corresponds to eth1, and so on. The Linux compatibility layer cannot automatically detect which interface has network access and defaults to using eth0.

When using wlan0 instead of em0, you need to assign an unused IP to em0:

* Temporary setting (lost on reboot): `# ifconfig em0 192.168.11.1`
* Permanent setting: add the following to the FreeBSD **/etc/rc.conf** file (this does not affect the normal operation of this network card):

```sh
# ifconfig_em0_alias0="inet 192.168.11.1 netmask 255.255.255.0"
```

The above **192.168.11.1** is an unused IP; you can set it to any other value.

## Chinese Input Method

Place the `.profile` file from the **/home** path into the **/** directory of the compatibility layer:

```sh
export LANG=zh_CN.UTF-8
export LANGUAGE=zh_CN.UTF-8
export LC_ALL=zh_CN.UTF-8

export XMODIFIERS='@im=fcitx'
export GTK_IM_MODULE=fcitx
export QT_IM_MODULE=fcitx
```

If you encounter an error like "sh: warning: setlocale: LC\_ALL: cannot change locale (zh\_CN.UTF-8)", you should install the missing language packs and re-enter the compatibility layer after exiting. For other systems, you can search for similar packages; for example, for the Rocky Linux compatibility layer, you should install `glibc-locale-source` and `glibc-langpack-zh`.

## sysctl Variables

```sh
# sysctl -a -d  | grep -E "linux|compat.linux"
```

This can list commonly used variables.

## `403 Forbidden` Prompt When Downloading Software Using Command Line

Some domestic mirror sites may, for reasons such as traffic restrictions, only allow software packages to be obtained through the specified package manager. When using other methods to fetch packages, a "403 Forbidden" error will be displayed.

This is typically implemented by restricting the package manager's UA (User-Agent). In this case, the simplest method is to switch to an unrestricted mirror site, such as TUNA/USTC Mirror.

## systemd and Wine

systemd is not available, but the `service xxx start` command can be used as a replacement.

Additionally, attempts were made to use the <https://github.com/zq1997/deepin-wine> repository to install software such as deepin-qq and deepin-wechat, but all resulted in "segmentation fault" errors. All Wine programs fail to run properly. If readers can solve this problem, please submit an issue or PR.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://book.bsdcn.org/ask/flat/chapter-18-linux-compatibility-layer/di-18.10-jie-gu-zhang-pai-chu-yu-wei-jing-shi-yi.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
