Platform-independent toolkit – Swiss File Knife
SwissArmy Knives
Swiss File Knife replaces more than 100 individual command-line tools at once, but it still fits on a USB stick and runs on all major operating systems.
If you work on the command line, you inevitably use many utilities and tools, all of which work differently, especially if you have to switch between operating systems. To simplify your life, take a look at Swiss File Knife (SFK) [1]: This tool replaces many conventional command-line programs with functions that operate consistently and follow the same syntax across operating systems. Additionally, SFK offers a way to combine individual commands in scripts. A short overview of the tool's many options is given in the "Swiss File Knife Capabilities" box.
Swiss File Knife Capabilities
Files and Directories
- Find files in the directory tree based on time, size, and name search and display in matching sort order.
- Find files in different ways and discover duplicates.
- Show differences between two directories.
- Run commands and programs against selected files or an entire directory tree.
- Create and verify MD5 checksums (fingerprints).
- Create hexdumps of binaries.
- Display the contents of ZIP, TAR, TAR.GZ, and TAR.BZ2 archives (commercial version only).
Text Files
- Display the beginning and end of files (like
head
andtail
). - Filter files and replace contents (partial).
- Quickly split and reassemble files.
- Remove tab stops.
- Replace Windows newlines (CRLF) with Unix newlines (LF).
Network
- Transfer files through the built-in FTP and HTTP servers.
- Download files using the built-in FTP and HTTP clients.
- Output/view data stream from a TCP, UDP, or HTTP connection.
SFK is available as a precompiled program with no dependencies, so you can take it anywhere you like on a USB stick and use it for on-site maintenance or rescue work. In addition to 32- and 64-bit binaries for Linux, you will find versions for the Raspberry Pi and other ARM machines, as well as Windows and Mac OS X, allowing you to work on all the major systems with the same tool.
Choosing your Weapons
All versions of SFK can be found on the tool's SourceForge page [2] below Files | 1-swissfileknife | <version> (v1.7.2 when this issue went to press). In the list, then click on the EXE file for your system, which you can identify by looking at the file name.
For the Raspberry Pi and other ARM computers, you will need ...-arm.exe
, whereas ...-linux.exe
and -linux-64.exe
are available for 32- and 64-bit Linux versions.
The file with the -linux-lib5
suffix is intended for older distributions that still use the libstdc++.so.5
library. The OS X versions for PPC and Intel machines are identified by the mac
name component. The Windows version is simply called sfk<version>.exe
.
A ZIP archive is available for download that contains, among other things, the Mac OS X, Windows, and Linux (32-bit) versions. After unpacking, you will find the Linux programs in the uxbin
subdirectory.
Don't let the .exe
suffix throw you with the Linux and Mac versions: It is still an executable binary. You can rename it to sfk
(no extension) and make it executable with:
chmod +x sfk
You can then use SFK directly, without having to install it. For computers on which you want to use SFK regularly, it makes sense to copy it to a suitable location such as ~/bin
or /usr/bin
.
In addition to the free version of Swiss File Knife under the BSD license, StahlWorks Technologies also offers a commercial "Extended Edition" [3] that lets you additionally search and filter the contents of .zip
, .tar.gz
, and .tar.bz2
archives and replace strings and byte sequences rapidly in text or binary files.
Moreover, the tool understands wildcards and special search patterns for find and replace actions (but still no regular expressions). The Extended Edition is only available as a 32-bit program and is not available at all for ARM machines; a license costs EUR30 (~$35).
Tricky
If you call SFK without any parameters, it presents you with its feature list. Options tell the program which task you need it to complete. For example, sfk list Music
lists all the files in the Music
subdirectory (Figure 1).
The first parameter basically always determines the action to perform. For example, list
tells SFK to output a list of files. The developers of Swiss File Knife refer to these functions as commands. The second parameter references the directory or file to which the command refers.
Following this pattern, you can call other functions in a similar way. Some commands can be fine-tuned using other parameters. For example,
$ sfk list -late=all Music
lists all the files from the Music
directory sorted by date and time stamps. If you replace all
with the number 3
, then SFK displays only the first three files.
If you specify parameters, they must follow the command name immediately. Just calling sfk list
will give you a list of all parameters. Calling most of the other commands without parameters also provides detailed information about the options. For example, typing sfk ftp
reveals how you can upload a file to an FTP server.
No Rules Without Exceptions
Some commands do not require parameters and get to work immediately. For example, sfk space
reveals how much free space is available on the current drive. For these commands, the -help
parameter returns a help page (Figure 2). To discover which commands do this, you again need to type sfk
: Swiss File Knife marks these commands, usually with the abbreviation [-h]
.
Output from SFK help pages is typically quite long. To consume the information thoughtfully, it makes sense to redirect the output to a text file:
$ sfk list > list_help.txt
It is a bit easier to search the reference on the SFK site at [1]. StahlWorks Technologies also sells a $2.95 PDF with a reference for all commands [4]. The first 20 pages can be read for free. Essentially, this is just the contents of the help pages that SFK outputs, so you can save yourself the expense of this purchase.
Buy this article as PDF
(incl. VAT)
Buy Linux Magazine
Subscribe to our Linux Newsletters
Find Linux and Open Source Jobs
Subscribe to our ADMIN Newsletters
Support Our Work
Linux Magazine content is made possible with support from readers like you. Please consider contributing when you’ve found an article to be beneficial.
News
-
Juno Computers Launches Another Linux Laptop
If you're looking for a powerhouse laptop that runs Ubuntu, the Juno Computers Neptune 17 v6 should be on your radar.
-
ZorinOS 17.1 Released, Includes Improved Windows App Support
If you need or desire to run Windows applications on Linux, there's one distribution intent on making that easier for you and its new release further improves that feature.
-
Linux Market Share Surpasses 4% for the First Time
Look out Windows and macOS, Linux is on the rise and has even topped ChromeOS to become the fourth most widely used OS around the globe.
-
KDE’s Plasma 6 Officially Available
KDE’s Plasma 6.0 "Megarelease" has happened, and it's brimming with new features, polish, and performance.
-
Latest Version of Tails Unleashed
Tails 6.0 is based on Debian 12 and includes GNOME 43.
-
KDE Announces New Slimbook V with Plenty of Power and KDE’s Plasma 6
If you're a fan of KDE Plasma, you'll be thrilled to hear they've announced a new Slimbook with an AMD CPU and the latest version of KDE Plasma desktop.
-
Monthly Sponsorship Includes Early Access to elementary OS 8
If you want to get a glimpse of what's in the pipeline for elementary OS 8, just set up a monthly sponsorship to help fund its continued existence.
-
DebConf24 to be Held in South Korea
Busan will be the location of the latest DebConf running July 28 through August 4
-
Fedora Unleashes Atomic Desktops
Fedora has combined its solid distribution with rpm-ostree system to make it possible to deliver a new family of Fedora spins, called Fedora Atomic Desktops.
-
Bootloader Vulnerability Affects Nearly All Linux Distributions
The developers of shim have released a version to fix numerous security flaws, including one that could enable remote control execution of malicious code under certain circumstances.