قالب وردپرس درنا توس
Home / Tips and Tricks / How to Run a Linux Shell on iOS – CloudSavvy IT

How to Run a Linux Shell on iOS – CloudSavvy IT



Illustration with the iSH icon

iSH is an active project to run a Linux shell on iOS. It offers an Alpine Linux environment complete with the apk package manager. The app relies on user mode x86 emulation.

You can download iSH from the App Store. New installations include a fully functioning apk standard. Existing app users may need to install manually apk by following the steps in the documentation.

To start

Start by installing iSH from the App Store. Launch the app and you will be taken directly to an Alpine Linux terminal environment.

You can start running known Linux commands! You can use all of BusyBox’s Unix utilities, including cat grep ls sed and wget

iSH offers its own keyboard icon strip to make using the touchscreen terminal easier. The four buttons on the left of the strip are Tab, Control, Escape, and Arrow keys respectively. Swipe the arrow key in the direction you want the cursor to navigate.

The three buttons on the right open the settings interface, paste text from the iOS clipboard and hide the keyboard. Tap anywhere to get the keyboard back after hiding it.

iSH settings

The Settings menu allows you to adjust some options. On the Appearance page you can set the font and switch between light and dark themes. On the App icon page, you can choose from different app icons. This choice allows you to match iSH with the visual style of the other apps on your iOS homescreen.

The external keyboard allows you to determine how iSH should deal with a physical keyboard connected via Bluetooth or a USB adapter. In addition to iOS’s built-in remapping options, you can remap the option and backtick keys to the iSH meta and escape keys. You can hide the iSH icon strip when using an external keyboard by enabling the “Hide with external keyboard” setting.

File systems

iSH supports the use of multiple file systems. Go to the “File Systems” page in the settings menu to manage them. For starters, you will see a single “standard” file system with the built-in Alpine installation.

Press “Browse Files” to open the file system in the iOS Files app. This helps you quickly copy files from iSH to other locations on your iOS device.

You can export the entire file system with the “Export” option. File systems can be imported into iSH using the “Import” button on the main File Systems page.

The practical use case for file systems is that you can run multiple standalone installations. At this point, only minimal Alpine images that resemble the iSH original will work.

You can try Alpine’s “Mini Root Filesystem” – download it, import it and hit “Boot From This Filesystem” to restart iSH with the file system. Switch back to the default file system by selecting the menu item and selecting “Boot From This Filesystem” again.

Add packages

You can use ordinary apk commands to manage packages in your iSH environment.

# Update the package lists
apk update

# Upgrade existing installed packages
apk upgrade

# Install SSH
apk add openssh

# Remove SSH
apk del openssh

Keep in mind that iSH uses its own package repositories by default. This allows the app to pass App Store Review by ensuring that it is completely self-contained.

You can switch to the official Alpine Linux repositories if you wish. This gives you access to the full list of Alpine software. Many packages will have newer versions in Alpine’s main repositories than those offered in the iSH repositories.

grep -v "file:///ish/apk/" /etc/apk/repositories | dd of=/etc/apk/repositories bs=4194304
echo https://dl-cdn.alpinelinux.org/alpine/v3.12/main >> /etc/apk/repositories
echo https://dl-cdn.alpinelinux.org/alpine/v3.12/community >> /etc/apk/repositories

Run the above commands to replace the contents of iSHs /ish/apk pseudo file system containing the repositories offered by Alpine Linux. You then have to run apk update to get the new package lists.

Using SSH

You can install OpenSSH with apk add openssh

The client will work immediately – try it ssh me@myserver

To use your iOS device as an SSH server, run the following commands:

ssh-keygen -A
passwd
echo "PermitRootLogin yes" >> /etc/ssh/sshd_config
sshd

This will generate SSH host keys and prompt you to set a password for the root user. The sshd executable is called to start the SSH server. You can now connect to your device as root user.

iSH does not support automatic start services by default. You can set this by changing the third line of /etc/inittab to ::sysinit:/sbin/openrcNext run rc-update add sshd to have the SSH server start automatically when you start an iSH session.

Running a web server

As seen in the SSH example, iSH uses the network stack of your device. You can host a web server that you can use on your other devices.

Run apk install apache2 to add Apache. Use httpd to start the Apache process. Then go to the IP address of your iOS device in a web browser – you should read Apache’s default “It works!” Must see. text.

Apache runs in iSH on iOS

iSH does not currently support running in the background. This means you cannot switch to Safari and browse your web pages while using an iPhone. On an iPad it is possible to open a browser in split view – iSH remains active on the side of the screen.

Apache can be configured in the usual way. You can find the configuration file at /etc/apache2/httpd.confThe default root of the document – where web pages come from – is /var/www/localhost/htdocs

What now?

You are now using an Alpine Linux environment on your iOS device. Add the packages that make sense for your work. There is a growing list of working software, including Unix staples and complete programming languages. Node.js, Python, PHP, Ruby and Git are all operational.

However, not every package will work. Software that makes system calls that are not translated crashes. Since iSH is an emulator, the performance can also be poor at times.

You can run a VNC server if you want to use graphics apps. Detailed steps are provided in the iSH wiki. The performance limitations will become apparent with a graphics workload, but it is technically possible. The process includes installing xorg-server, set a headless configuration, then set a .xinitrc file to define the window manager to use. You will get the best results with a lightweight window manager such as i3

Conclusion

iSH seems to be an indispensable iOS app for developers and system administrators. There are already quality apps like a-Shell that provide basic Unix tools, as well as SSH clients like Termius that allow you to connect to a remote Linux machine. However, iSH is the most complete solution to date, offering a Linux environment that supports a growing list of popular software.

With iSH on your iPhone or iPad, you can use trusted x86 Linux software wherever you are. Pair it with an external keyboard and you have a portable productivity device that could really replace your laptop.


Source link