Snippets

Last updated 3 months ago

Snippets are a set of predefined commands that you can run with a single click or tap, saving you considerable time. Before a snippet can be used, it must be added in the Snippets section in Termius.

Snippets can be one command or a series of commands separated on new lines.

Adding Snippets

Mobile
Desktop

Tap Snippets, then tap the + icon.

You'll be asked for a Label - use any memorable name to call your snippet. In the Script text box, enter the commands.

Tap Save.

Click Snippets in the left-hand menu, then click the Add Snippet button.

You'll be asked for a Label - use any memorable name to call your snippet. In the Script text box, enter the commands.

Click Save.

Editing Snippets

Mobile
Desktop

Touch and briefly hold the snippet, then tap the Edit icon in the top-left corner of the screen.

Change the details as you wish and tap Save in the upper-right corner of the screen.

Right-click the snippet and click Edit.

Change the details as you wish and tap Save in the upper-right corner of the screen.

Using Snippets

Mobile
Desktop

When connected to a server, click the {} icon immediately above the keyboard and select the snippet you wish to run.

If you don't wish to run the snippet immediately but would rather it wait for further input after inputting the commands, toggle the Run Snippet Immediately option on the snippet selection screen.

While connected, a list of snippets will appear in a pane to the right. Double-clicking on a snippet will paste and run it on the remote host.

To paste but not run a snippet, click the green PASTE button when hovering over a snippet or right click and select paste.

Running Snippets on Multiple Hosts

On the iOS and Android versions of Termius you may run snippets on multiple hosts at once. To do this, tap Snippets, tap the snippet you wish to use, tap the circle next to each host to execute your snippet, then tap the Run button at the bottom of the screen. You may optionally close the session(s) after running the snippet.

Example Snippets

Snippets are incredibly powerful. There are many commands that you may run on a day-to-day basis that are either cumbersome to type (especially on a mobile device) or require command line switches you may not remember. Instead of constantly searching or referencing a sheet for these things, snippets allow you store this knowledge and save time in your daily server tasks.

To help get you started, we've created a few for you to use:

Find All Files Created or Modified Within 30 Days

find -type f -mtime -30

Find All Files Created or Modified Within 30 Days and Run a Command

find -type f -mtime -30 -exec

The -exec at the end allows you to specify a command. This snippet is intended to be run without pressing enter so that you can type the command to run on those matching files.

Obtain Disk Usage and Free Space Statistics

du -ch

List Listening Ports and Owning Processes

netstat -tolpn

Display Kernel Log

sudo dmesg

List All Running Processes

ps auxw

Search for a Running Process

ps aux | grep

This snippet is meant to be run without pressing enter. After using the snippet, type the name of the program you are searching for (i.e. "apache2"), and the process list will be searched for this name.