linux deploy is used to deploy a Linux environment on Android devices. The principle is probably to run a chroot or proot container on the Linux layer of Android, and then run what we prepared in the container. Another Linux system. You must obtain root permissions on your phone before you can use Linux Deploy.
Linux Deploy is an application that can deploy a Linux environment on Android devices. Its principle is to run a chroot or proot container on the Linux layer of Android, and then run it in the container when we are ready. Another Linux system. It is worth noting that this is different from the virtual machine technology we are familiar with. The new Linux system will run in parallel with the Android system (don’t delve into the explanation for non-professionals).
Before using Linux Deploy, we need to obtain the Root permission of the mobile phone (required) . After obtaining the Root permission, because the Linux command set that comes with the original machine is incomplete, we need Install Busybox to expand the Linux command set (you can not install it) .
Linux Deploy needs to be installed in the Google Store, which is not available in other Android app stores. The software mentioned below can only be installed in the Google Store
After the installation is completed, we will use Linux Deploy to deploy the Ubuntu system on the Android device:
Click the "Download" icon at the bottom right of the interface to enter the configuration file setting interface and make the following settings (I I don’t know why the developer would use such a "download" icon as the icon of the configuration file setting interface):
Containerization method:"chroot"
Distribution version:"Ubuntu"
Architecture: Keep the default value
Distribution version: "yakkety" (i.e. Ubuntu 16.10)
Source address: http://mirror.tuna.tsinghua.edu.cn/ubuntu -ports/(Here we use the default method of deployment, that is, download Linux components and necessary software packages from the software source. Because the default source speed is not good, in order not to download all day and night, we use the open source of Tsinghua University here. Mirror source, if you use Repository to deploy (will be discussed in a later article), the "source address" here should fill in the local or remote path of the Repository file (suffix is tgz/tar.gz) file)
Installation type: There are two suggestions for this option, "directory" and "file". If you are not familiar with Linux and the remaining space of the /data partition is ≥ 2g, it is recommended to use the "directory" installation method. If you are familiar with Linux Or if the remaining space of the /data partition is
Installation path: When "Installation Path" selects "Directory", this option will define the path in which the system is installed. The default path is ${ENV_DIR}/rootfs/linux
, that is, installation In the /data/user/0/ru.meefik.linuxdeploy/env/rootfs/linux
directory. When "Installation Type" selects "File", this option will define which image file the Linux system is installed in. The default value is External Storage/linux.img
.
Image size (MB) (available when the installation type "selects "File"): This option will define the size of the image file where the system is located. Before system installation, a file with the set image size will be created in the installation directory. Empty files are used to store system files and data (equivalent to the total disk space of the new Linux system). It is recommended not to use the default value, filling in 2048m is enough.
File system (available when the installation type "Select "File" ): Select "Auto".
Username: This option is the username when logging into the system. The default is "android" and can be changed at will.
User password: This option is the password of the user in the Ubuntu system, which can be filled in according to your own habits.
Privileged Users: Keep the default value
DNS server: You can keep the default value, or you can customize the DNS server address (such as 114.114.114.114, etc.)
Localization: It is recommended to keep the default value POSIX. If there are other requirements, such as making the ssh return result in Chinese or making the display language of the graphical interface Chinese, select "zh_CN.UTF8"
INIT/MOUNTS item: If necessary It can be set when required and can be ignored if not required.
Allow SSH server to start: turn on this option
SSH settings: Keep the default
Allow the graphical interface to start: You can set it if necessary, but this option will not be turned on here for the time being (the following article will introduce how to deploy the graphical interface).
After the setting is completed, press the return key to return to the main application interface, press the menu key, and select "Install" to start the Linux system. Installation, you need to maintain a network connection during the installation process (it is recommended to install under WIFI, which requires about a few hundred megabytes of traffic).
When you see the terminal output ">>>deploy", it means the installation has started:
## When you see the terminal output "< <Type in the terminal:
sudo passwd root
The terminal will prompt the user to enter the password of the root user and enter it again to confirm (the password will not be visible when entering the password, and even * will not be displayed). After the setting is completed, type the command su in the terminal and enter the root user you just set. Password to switch to the root user.
File management: If you deploy the Linux system through the "directory" method, then you can directly use the R.E. manager to access /data/user/0/ru.meefik.linuxdeploy/env/rootfs/linux
You can manage the files in the new system. If you deploy the Linux system through the "file" method, you have to rely on SFTP to manage files and other operations (of course there is no problem using SSH, but I still think SFTP is more convenient. ). When we log in to SFTP as a normal user, we do not have permission to operate most files due to permission reasons. So we need to log in to SFTP as superuser. However, the default configuration does not allow the root user to log in to SSH and SFTP, so we need to make the following settings:
Start the deployed system in Linux Deploy, log in to SSH as the android user, and execute in the terminal:
sudo apt-get install -y vim #Install vim editor
Of course, you can also use the vi editor that comes with the system. If you are familiar with the vi editor, you can also use it. vi editor to edit files. After the vim editor is installed, we continue to execute in the terminal:
vim /etc/ssh/sshd_config #Use the vim editor to open the /etc/ssh/sshd_config file
After opening the file, type i Enter the editing mode, click on any blank position of the terminal to pop up the special key keyboard, use the up and down cursors to scroll through the file, find the PermitRootLogin item in the #Authentication section of the file, change it to yes, after the change is completed, click on the special key keyboard "ESC" key to exit the editing mode, type: wq! on the keyboard to save and force exit the file to complete the editing operation of the file.
Open Linux Deploy, stop and then start the Linux system. Open "Turbo Client" - Sidebar - Create a new account - SFTP to create a new SFTP connection (some file managers, such as ES File Explorer (ESFile Explorer) and SE File Manager (Solid Explorer) also have SFTP functions, If you don’t want to install TurboFTP, you can use them instead):
## Where: Username: root The password is the password of the root user just set. The host name is: 127.0.0.1. Keep other items as default. Click the "Save" icon in the upper right corner to save the configuration. In the connection list in the sidebar, we will use The root user connects to SFTP and manages files: Of course, after modifying the sshd_config file and stopping and starting the Linux system, you can also Connect to SSH directly as root user. After introducing the installation, let’s introduce the uninstallation~ You can completely uninstall Linux Deploy through the following methods: 1. If you use the "directory" method to deploy the Linux system, then "stop" the Linux system in Linux Deploy , then directly uninstall Linux Deploy and restart the phone to completely uninstall; 2. If you use the "file (mirror)" method to deploy the Linux system, you need to "stop" the Linux system first, and then delete the image file placed in the built-in storage , the image file path is the "installation path" mentioned above before deploying the Linux system. If this item has not been modified, the image path isExternal storage/linux.img, and then uninstall Linux Deploy and restart your phone to completely uninstall.
Install the graphical environment
Modify the following configuration items: INIT: Check: Enable custom script execution (other configurations of INIT remain unchanged ) Graphical interface: Tick: Allow graphical interface to start Graphics subsystem: VNC Graphical interface settings: Keep the default configuration Desktop environment: Choose as needed, the one chosen here is LXDE# After the configuration is completed, return to the main interface, press the "Menu key", and select "Configuration" to make the settings we just made take effect:
After the configuration is completed, click the "Stop" button at the bottom to stop the Linux system, and then click the "Start" button to start Linux. System, then we log in to SSH and execute in the terminal: sudo apt-get install ttf-wqy-zenhei #Install Chinese font library After the Chinese font library is installed, execute the following command to start VNC: vncserver The terminal will return the following results:New 'X' desktop is localhost:1 Starting applications specified in /home/android/.vnc/xstartup Log file is /home/android/.vnc/localhost:1.logCopy
vncserver command, the system will ask you to set a VNC password less than 8 digits. You need to enter the password twice and submit it. , there will be a prompt after the VNC password setting is completed, ignore it, type
n to submit)
New 'X' desktop is localhost:1The desktop session number is specified as 1, so the port is 5900 1=5901. If we open multiple virtual desktops and their session numbers are 2, 3, 4..., then their respective ports are 5902, 5903, 5904... and so on. Moreover, the server address and port need to be separated by an English colon. The "Name" item is the address specified by the user for this VNC session. In order to distinguish it from other sessions, we fill in Localhost - Ubuntu@Xfce. In fact, you can fill in anything you want.
rm -rf /tmp/.X11-unix/X[1-9]After the execution is completed, execute
vncserver again, and the session number will be reset to 1. In order to prevent this problem caused by stopping and restarting the Linux system every time, we can edit the /etc/rc.local file and insert these two commands before
exit 0 in this file:
2. vncserver default The resolution is 1024×768, but the resolution of most mobile phone screens on the market is 720P (1280×720), 1080P (1920×1080), or even 2K (2560×1440). The default resolution of vncserver is 1024×768. It may be the case that the VNC image cannot fill the screen. At this time, we need to modify the VNC resolution to adapt to the screen. After testing, taking the 1080P screen as an example, setting the resolution to 720P can make the VNC image fill the screen and not fit the screen. affect the display effect. The adjustment method is to add the
-geometry parameter after each execution of the vncserver
command. For example, if I need to adjust the VNC resolution to 720P (1280×720), then start vncserver , execute: vncserver -geometry 1280x720
to set the screen resolution of the newly opened VNC virtual session to 1280×720. It is worth noting that thex
in 1280x720
in the command is the lowercase letter x
, not the multiplication sign ×
in mathematics. The following is a comparison between 1280×720 resolution and 1024×768 resolution (reducing the VNC Viewer screen to the minimum):
If you find it a bit troublesome to enter such a long list of commands every time you start vncserver, you can edit the
~/.bashrc file and add a line of alias definition at the location shown in the figure below: vim ~/.bashrc #Edit~/.bashrc
alias vncserver='vncserver -geometry 1280x720'Copy
command is executed, the resolution of the newly opened VNC session will be set to 1280×720. <h3><strong>Upgrading ubuntu</strong></h3>
<p data-pid="mGD1_aOi">You will find that ubuntu can only be installed to 18.04</p>
<p data-pid="VAMIrQXy">The way to upgrade is to install Ubuntu and then upgrade directly. </p>
<p data-pid="kkln5K-O">After logging into the desktop using VNC, use the terminal to install the updater</p><div class="code" style="position:relative; padding:0px; margin:0px;"><pre class="brush:php;toolbar:false">sudo apt install update-manager-core</pre><div class="contentsignin">Copy after login</div></div><p data-pid="60gRnUq3">Update all packages to the latest version</p><div class="code" style="position:relative; padding:0px; margin:0px;"><pre class="brush:php;toolbar:false">sudo apt update && sudo apt upgrade
sudo do-release-upgrade</pre><div class="contentsignin">Copy after login</div></div><p data-pid="vbrcayHf">If authenticate 'focal.tar.gz' against ' appears focal.tar.gz.gpg' Authentication failed error, first install gnupg and execute the following instructions: </p><div class="code" style="position:relative; padding:0px; margin:0px;"><pre class="brush:php;toolbar:false">sudo apt install gnupg gnupg1 gnupg2
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 871920D1991BC93C</pre><div class="contentsignin">Copy after login</div></div><h4>Execute sudo do-release-upgrade again, enter y to start updating the system, and follow the terminal instructions to update. </h4><p data-pid="AHGX18es">If prompted Please Install All Available Updates Before Upgrading</p><div class="code" style="position:relative; padding:0px; margin:0px;"><pre class="brush:php;toolbar:false">apt clean
apt autoclean
sudo apt update
sudo apt upgrade -y
sudo apt dist-upgrade</pre><div class="contentsignin">Copy after login</div></div><h4>Execute sudo do-release-upgrade again, enter y to start updating the system, and follow the terminal instructions to update. </h4><p data-pid="UIeefVlm">If nothing else goes wrong, the system has been upgraded normally. </p><p data-pid="sw0Qe6Hi">After the upgrade, you need to go back to the linux deploy configuration item and change the username to root. The password can remain unchanged. The reason is that after the upgrade, the original android username does not have root permissions</p><blockquote data-pid="Q8L66PKi">After modifying the user name, be sure to click the configuration option of linux deploy to reconfigure</blockquote><p data-pid="7_t4ca32"><strong># Updated on 2023.3.8 If you encounter "The required dependency 'apt (>= 2.0.4)' is not installed." Need to modify the /etc/apt/source.list file</strong></p><div class="code" style="position:relative; padding:0px; margin:0px;"><pre class="brush:php;toolbar:false">## /etc/apt/source.list
deb http://ports.ubuntu.com/ focal multiverse main universe
deb-src http://ports.ubuntu.com/ focal multiverse main universe
deb http://ports.ubuntu.com/ focal-updates main universe multiverse
deb-src http://ports.ubuntu.com/ focal-updates main universe multiverse
deb http://ports.ubuntu.com/ focal-security main universe multiverse
deb-src http://ports.ubuntu.com/ focal-security main universe multiverse</pre><div class="contentsignin">Copy after login</div></div>
The above is the detailed content of What is the function of linux deploy. For more information, please follow other related articles on the PHP Chinese website!