Due to some reasons, it may be necessary to change the domain name specified in the hosts file to the corresponding IP address. Android is a Linux-based system. Similar to Linux, it is set up through the hosts file.
Under Android, /etc is the linux training link to /system/etc. We need to change /system/etc/hosts to achieve this. And this file is read-only and cannot be changed directly through the shell. This can be changed by connecting to a PC using adb. The steps are as follows:
1. Obtain root permissions: adbroot
2. Set /system to be readable and writable: adbremount
3. Copy the hosts file to PC: adbpull/system/etc/hosts
4. Modify files on PC
5. Copy the files on the PC to the mobile phone: adbpush/system/etc/hosts
If you want to check whether the change is successful, you can execute adbshell on the PC and run cat/system/etc/hosts; or run cat/system/etc/hosts on the mobile phone.
In the Android 1.6 system, the hosts file format is a little different from that of PC Linux: one IP cannot correspond to multiple domain names in one line Linux hosts file modification, for example:
127.0.0.1
It is legal on most PC Linux systems, but it does not work on Android 1.6. It needs to be split into one line for each domain name to use:
127.0.0.1
127.0.0.1
127.0.0.1
------------------------------------------------- ------------------------------------------
Solution to changing hosts file and outofmemory under android
You need to use the android emulator to access a website. Although it points to the linux hosts file modification on the development machine, you need to change the hosts file on the andorid,
The website below introduces the techniques
The specific steps are as follows
1. Obtain root permissions: adbroot
2. Set /system to be readable and writable: adbremount
3. Copy the hosts file to PC: adbpull/system/etc/hosts
4. Modify files on PC
5. Copy files from PC to mobile phone: adbpush
/システム/etc/hosts
しかし、Linux仮想ホストの5番目のステップでは、メモリ不足エラーを報告する人もいます
これはパラメータを追加せずにコマンドラインから直接起動したことが原因なので、次のコマンドを使用して起動してください
$emulator–avdyouravdname–パーティションサイズ128
出身者(ブロックされている可能性があります)
================================================ === ============================================== === ===============
Androidエミュレータでhostsファイルを変更する
Android エミュレーターをダウンロードし、解凍して android-sdk-linux_x86 フォルダーを取得します
android-sdk-linux_x86/tools/
にステップインします。./android を実行してテスト用の仮想電話を作成します
仮想電話を起動し、パーティションサイズを128Mに変更します
./emulator-avdtest-partition-size128
新しいターミナルを開き、現在のディレクトリで実行します
./adbpull/system/etc/hosts/home/jecelyin/
hostsファイルをPCに削除
後に実行
./adbrot
./アドレマウント
root権限を取得し、仮想電話上の/systemを書き込み可能として再マウントします
ラップトップ上の /home/jecelyin/hosts ファイルを変更します。ラップトップ上の Web サイトにアクセスするために仮想電話が必要な場合は、ホストの IP アドレスを 10.0.2.2 にする必要があります。
次のコマンドを実行して戻ります./adbpush/home/jecelyin/hosts/system/etc/hosts
エミュレータを再起動します
The above is the detailed content of Detailed steps and methods for modifying the hosts file in Android system. For more information, please follow other related articles on the PHP Chinese website!

The average annual salary of Linux administrators is $75,000 to $95,000 in the United States and €40,000 to €60,000 in Europe. To increase salary, you can: 1. Continuously learn new technologies, such as cloud computing and container technology; 2. Accumulate project experience and establish Portfolio; 3. Establish a professional network and expand your network.

The main uses of Linux include: 1. Server operating system, 2. Embedded system, 3. Desktop operating system, 4. Development and testing environment. Linux excels in these areas, providing stability, security and efficient development tools.

The Internet does not rely on a single operating system, but Linux plays an important role in it. Linux is widely used in servers and network devices and is popular for its stability, security and scalability.

The core of the Linux operating system is its command line interface, which can perform various operations through the command line. 1. File and directory operations use ls, cd, mkdir, rm and other commands to manage files and directories. 2. User and permission management ensures system security and resource allocation through useradd, passwd, chmod and other commands. 3. Process management uses ps, kill and other commands to monitor and control system processes. 4. Network operations include ping, ifconfig, ssh and other commands to configure and manage network connections. 5. System monitoring and maintenance use commands such as top, df, du to understand the system's operating status and resource usage.

Introduction Linux is a powerful operating system favored by developers, system administrators, and power users due to its flexibility and efficiency. However, frequently using long and complex commands can be tedious and er

Linux is suitable for servers, development environments, and embedded systems. 1. As a server operating system, Linux is stable and efficient, and is often used to deploy high-concurrency applications. 2. As a development environment, Linux provides efficient command line tools and package management systems to improve development efficiency. 3. In embedded systems, Linux is lightweight and customizable, suitable for environments with limited resources.

Introduction: Securing the Digital Frontier with Linux-Based Ethical Hacking In our increasingly interconnected world, cybersecurity is paramount. Ethical hacking and penetration testing are vital for proactively identifying and mitigating vulnerabi

The methods for basic Linux learning from scratch include: 1. Understand the file system and command line interface, 2. Master basic commands such as ls, cd, mkdir, 3. Learn file operations, such as creating and editing files, 4. Explore advanced usage such as pipelines and grep commands, 5. Master debugging skills and performance optimization, 6. Continuously improve skills through practice and exploration.


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

SublimeText3 English version
Recommended: Win version, supports code prompts!

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function