Skip to main content
linux-utils: Linux system administration tools for Python
=========================================================

.. image:: https://travis-ci.org/xolox/python-linux-utils.svg?branch=master
:target: https://travis-ci.org/xolox/python-linux-utils

.. image:: https://coveralls.io/repos/xolox/python-linux-utils/badge.svg?branch=master
:target: https://coveralls.io/r/xolox/python-linux-utils?branch=master

The Python package `linux-utils` provides utility functions that make it easy
to script system administration tasks on Linux_ systems in Python. The
following functionality is currently implemented:

- Parsing of the `/etc/fstab`_ and `/etc/crypttab`_ configuration files.
- A basic Python API for cryptsetup_ and a Python implementation of
cryptdisks_start_ and cryptdisks_stop_.

The package is currently tested on cPython 2.6, 2.7, 3.4, 3.5, 3.6 and PyPy
(2.7) on Ubuntu Linux (using `Travis CI`_).

.. contents::
:local:

Installation
------------

The `linux-utils` package is available on PyPI_ which means installation should
be as simple as:

.. code-block:: sh

$ pip install linux-utils

There's actually a multitude of ways to install Python packages (e.g. the `per
user site-packages directory`_, `virtual environments`_ or just installing
system wide) and I have no intention of getting into that discussion here, so
if this intimidates you then read up on your options before returning to these
instructions ;-).

Usage
-----

Please refer to the API documentation available on `Read the Docs`_.

History
-------

Back in 2015 I wrote some Python code to parse the Linux configuration files
`/etc/fstab`_ and `/etc/crypttab`_ for use in crypto-drive-manager_. Fast
forward to 2017 and I found myself wanting to use the same functionality
in rsync-system-backup_. Three options presented themselves to me:

1. **Copy/paste the relevant code.** Having to maintain the same code in
multiple places causes lower quality code because having to duplicate the
effort of writing documentation, developing tests and fixing bugs is a very
demotivating endeavor.

In fact sometime in 2016 I *did* copy/paste parts of this code into a
project at work, because I needed similar functionality there. Of course
since then the two implementations have started diverging :-p.

2. **Make crypto-drive-manager a dependency of rsync-system-backup.** Although
this approach is less ugly than copy/pasting the code, it still isn't
exactly elegant because the two projects have nothing to do with each other
apart from working with LUKS encrypted disks on Linux.

3. **Extract the functionality into a new package.** In my opinion this is
clearly the most elegant approach, unfortunately it also requires the most
work from me :-). On the plus side I'm publishing the new package with a
test suite which means less untested code remains in crypto-drive-manager_
(which doesn't have a test suite at the time of writing).

While extracting the code I shortly considered integrating the functionality
into debuntu-tools_, however the `/etc/fstab`_ and `/etc/crypttab`_ parsing
isn't specific to Debian or Ubuntu at all and debuntu-tools_ has several
dependencies that aren't relevant to Linux configuration file parsing.

Since then it has become clear that this was a good choice (not merging the
functionality into debuntu-tools_) because the package now provides a Python
implementation of cryptdisks_start_ and cryptdisks_stop_, which is mostly
useful on Linux systems that *aren't* based on Debian :-).

Contact
-------

The latest version of `linux-utils` is available on PyPI_ and GitHub_. The
documentation is hosted on `Read the Docs`_. For bug reports please create an
issue on GitHub_. If you have questions, suggestions, etc. feel free to send me
an e-mail at `peter@peterodding.com`_.

License
-------

This software is licensed under the `MIT license`_.

© 2017 Peter Odding.

.. External references:

.. _/etc/crypttab: https://manpages.debian.org/crypttab
.. _/etc/fstab: https://manpages.debian.org/fstab
.. _crypto-drive-manager: https://pypi.python.org/pypi/crypto-drive-manager
.. _debuntu-tools: https://pypi.python.org/pypi/debuntu-tools
.. _GitHub: https://github.com/xolox/python-linux-utils
.. _Linux: https://en.wikipedia.org/wiki/Linux
.. _MIT license: http://en.wikipedia.org/wiki/MIT_License
.. _per user site-packages directory: https://www.python.org/dev/peps/pep-0370/
.. _peter@peterodding.com: peter@peterodding.com
.. _PyPI: https://pypi.python.org/pypi/linux-utils
.. _Python Package Index: https://pypi.python.org/pypi/linux-utils
.. _Python: https://www.python.org/
.. _Read the Docs: https://linux-utils.readthedocs.org
.. _rsync-system-backup: https://pypi.python.org/pypi/rsync-system-backup
.. _Travis CI: https://travis-ci.org/xolox/python-linux-utils/builds
.. _virtual environments: http://docs.python-guide.org/en/latest/dev/virtualenvs/


Release files for linux-utils 0.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for linux-utils 0.3
File Size Uploaded
linux-utils-0.3.tar.gz 14.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for linux-utils 0.3
File Interpreter ABI Platform
linux_utils-0.3-py2.py3-none-any.whl Python 3, Python 2 none any Details

Total release size: 34.8 kB

Release files / linux-utils-0.3.tar.gz

Download URL linux-utils-0.3.tar.gz
Size 14.6 kB
Tags Source
SHA-256 checksum
How to use checksums
73c3c16588534b1bbb0a53d07ea95a755575d44422b15cb5f8e5234c830c5148
BLAKE2b-256 checksum
How to use checksums
cb65818fb3938dafb75aba26446da33a57eff0a3b6de1c08e21ae5be27a43dd0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / linux_utils-0.3-py2.py3-none-any.whl

Download URL linux_utils-0.3-py2.py3-none-any.whl
Size 20.1 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
d4dce56e1a1bb66cf6addd3b27c9b11d4746e060d26e6e149f64e7cfefbf596d
BLAKE2b-256 checksum
How to use checksums
ff0cbba222bd3addd272d62d998de4096771bf637a116f3348a9463733d7a3da
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

0.7

2 release files

0.6

2 release files

0.5

2 release files

0.4.1

2 release files

0.4

2 release files

This release

0.3 This release

2 release files

0.2

2 release files

0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page