Launching the Linux command line on iOS

Did you know you can run the Linux command line on an iOS device? You may be asking, “Why would I use text apps on my iPhone?” Fair question. But if you read, you probably know the answer: Linux users want to be able to work with it on any device and want to use their own settings.

But most of all they yearn for solving difficult problems.

I have a seven-year-old iPad 2 Mini that is still quite good for e-book reading and other tasks. However, I want to use it to access the command line of applications with my set of programs and scripts, without which I cannot work. I need an environment that I’m used to, as well as my default development environment. And here’s how I managed to achieve it.

Connect to keyboard

Working with the command line for programming via the on-screen keyboard of a phone or tablet is rather inconvenient. I recommend connecting an external keyboard, either via Bluetooth or using the camera connection adapter to connect a wired keyboard (I chose the latter). Connecting a Kinesis Advantage split keyboard to iPhone 6 produces a strange device that looks like corporate cyberdeck from the classic role play Shadowrun.

Installing the shell on iOS

There are two options for running a fully functional Linux system on iOS:

  • Secure shell (SSH) connected to a Linux computer
  • Running a virtual system using Alpine Linux with iSH, which is open source but must be installed using Apple’s proprietary TestFlight app

Alternatively, there are two open source terminal emulator applications that provide the ability to work with open-source tools in a limited environment. This is the most stripped-down option – in fact, this is not how you run Linux, but Linux tools. There are severe limitations when working with these applications, but you get partial command line functionality.

Before moving on to complex solutions, I will consider the simplest way.

Option 1: sandbox shell

One of the easiest ways is to install the iOS app LibTerm… it open source a sandboxed command shell with support for over 80 commands at a price of zero dollars. It comes bundled with Python 2.7, Python 3.7, Lua, C, Clang, and more.

Approximately the same functionality has a-Shell, described by the developers as “a test user interface for a screen-based platform.” A-Shell sources uploaded open source, it is under active development, provides file system access, and ships with Lua, Python, Tex, Vim, JavaScript, C and C ++, as well as Clang and Clang ++. It even allows you to pip install Python packages.

Option 2: SSH

Another step forward compared to downloading the app is setting up an SSH client. For a long time now, we have been able to use any of the many iOS SSH client applications to connect to a server running Linux or BSD. The advantage of using SSH is that any distribution with any software can run on the server. You work remotely and the results of your work are simply transferred to the terminal emulator on the iOS device.

Blink shell Is a popular paid SSH application in open source… Aside from the small screen of the device, using this software is like connecting to a server through any other command line. Terminal Blink looks great, has many pre-built themes and the ability to create your own, including the ability to customize and add new fonts.

Option 3: running Linux

Using SSH to connect to a Linux server is a great way to access the command line, but it requires an external server and network connection. This is not the biggest hurdle, but it cannot be completely ignored, so you may need to work with Linux without a server.

If this is your case, then you will need to take it one step further. TestFlight Is a proprietary service for installing developed applications even before they are released in the Apple App Store. You can install the TestFlight app from the App Store and then use the test apps. Applications in TestFlight allow a limited number of beta testers (usually up to 10,000) to work with them for a limited time. To download the test application, you need to follow the link from your device, which is usually found on the website of the developer of the test application.

Running Alpine Linux with iSH

iSH Is an open-source TestFlight application that launches a virtual machine with a ready-made distribution Alpine Linux (with a little work, you can run other distributions as well).

Important Feature: experimental application… Since iSH is currently a test application, don’t expect constant and reliable work. TestFlight apps are time limited. My current build will only run for 60 days. This means that after 60 days I will be expelled and will have to rejoin the next round of iSH testing. Moreover, I will lose all my files unless I export them using Files on iOS or copy them to the Git host or via SSH… In other words: Don’t hope that all of this will continue to work! Don’t put anything important to the system! Back up to a separate location!

Installing iSH

Start by installing TestFlight from the App Store. Then install iSH, getting the link to install from the application website. There is another installation method using AltStore, but I have not tried it. Or, if you have a paid developer account, you can download the iSH repository from GitHub and install it yourself.

Using the link, TestFlight will install the iSH app on your device. As with any application, the icon will appear on the screen.

Package management

iSH runs an x86 emulator with Alpine Linux. Alpine is a tiny distro less than 5MB in size. This was the first time I worked with Alpine, so I thought this minimalism would be annoying, but in fact I really liked it.

Alpine uses a package manager apkwhich is simpler than even apt or pacman.

How to install the package:

apk add package

How to remove a package:

apk del package

How to find out other commands and information:

apk --help

Package manager update:

apk update
apk upgrade

Installing a text editor

Alpine’s default text editor is Vi, but I prefer Vim, so I installed it:

apk add vim

You can install Nano or Emacs if you want.

Shell change

I don’t know about you, but I needed fish shell… Other people prefer Bash or Zsh… However, Alpine uses ash! Ash is a fork of the Dash shell, which itself is a fork of the original ash, or Almquist shell… Her priority is speed. I decided to trade speed for built-in auto-completion, colors, Vim key control, and syntax highlighting, which I love and know from the fish shell.

Installing fish:

apk add fish

If you need Bash with its autocompletion and man pages, install them:

apk add bash bash-doc bash-completion

Alpine’s minimalist ideology usually means that some programs that are one package in other distributions will be split into several smaller packages. It also means that you can tweak and resize the system exactly the way you want.

You can learn more about installing Bash from this tutorial

Changing the default shell

After installing fish, you can temporarily switch to it by typing fish and going to the shell. But I want to make fish the default shell and the command chshwhich I used on other distributions didn’t work.

First, let’s find out where fish is installed:

which fish

Here’s what I got:


Next, let’s change the login shell to fish. You can use any editor you like. If newbie, then install Nano (with the command apk add nano) so that you can edit the configuration files and save them via CTRL + X, confirm and exit.

But I used Vim:

vim /etc/passwd

My first line was like this:


To make fish the default shell, change this line to the following:


Then save the file and exit.

I’m sure there is a good way to change the shell path so it can be used right away. But I don’t know him, so I recommend going back to the application browser, force exiting the shell, and for reliability, turn off and restart your iPad or iPhone. Open iSH again and now besides the message “Welcome to Alpine!” and information about starting from apk you will see the standard fish login welcome message: Welcome to fish, the friendly interactive shell… Hooray!

Setting up Python and pip

I decided to add Python (version 3.x), not only to write code, but also because I use multiple Python programs. Let’s install it:

apk add python3

Although Python 2.x is deprecated, you can install it as well:

apk add python

Let’s install a Python package manager called pip and setuptools:

python3 -m ensurepip --default-pip

It will take a while to install and configure the package manager, so just wait.

Then you can download the tool for transferring files over the network. curl:

apk add curl

Reading manuals

Fish uses built-in man page completion. Like other command line users, I use the manual manand it is not installed in Alpine. So I installed it with a terminal pager less:

apk add man man-pages less less-doc

In addition to man, I use the great tldr pages projectwhich provides simplified and community-driven man pages.

I installed it using pip:

pip install tldr

Command tldr connects to the web to get pages when it encounters a request for a new page. If you need to learn how to use a command, you can write something like tldr curl and get a plain english description and good examples on how to use the command.

Of course, all this installation work can be automated with dotfiles or an installation script, but in fact it does not really correspond to the Alpine ideology – setting the minimum installation clearly to your needs. Besides, it took so long, didn’t it?

Additional Information

The iSH Wiki has a page “what works“with reports on which packages are currently running. By the way, it looks like npm doesn’t work now

Another wiki page explains how access iSH files from the iOS Files app. This is one of the ways you can move and copy files.

You can also install Git (yes! apk add git ) and push your work to a remote repository or push it to the server via SSH. And of course, you can download and run any number of great open source projects from GitHub.

You can learn more about iSH by following these links:


Vdsina proposes virtual servers on Linux or Windows. We use exclusively branded equipment, the best-of-its-kind proprietary server control panel and one of the best data centers in Russia and the EU. Hurry up to order!

Similar Posts

Leave a Reply