{"id":19039417,"url":"https://github.com/xolox/python-linux-utils","last_synced_at":"2025-07-15T21:44:28.199Z","repository":{"id":137547143,"uuid":"94961944","full_name":"xolox/python-linux-utils","owner":"xolox","description":"Linux system administration tools for Python","archived":false,"fork":false,"pushed_at":"2020-02-09T17:02:33.000Z","size":84,"stargazers_count":8,"open_issues_count":0,"forks_count":4,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-07-07T02:04:31.695Z","etag":null,"topics":["crypttab","disk-encryption","fstab","linux","luks","python","system-administration"],"latest_commit_sha":null,"homepage":"https://linux-utils.readthedocs.io","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/xolox.png","metadata":{"files":{"readme":"README.rst","changelog":"CHANGELOG.rst","contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-06-21T04:13:46.000Z","updated_at":"2024-12-21T04:11:40.000Z","dependencies_parsed_at":null,"dependency_job_id":"f003db43-88c2-44d2-bcf8-8f84acb992ca","html_url":"https://github.com/xolox/python-linux-utils","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"purl":"pkg:github/xolox/python-linux-utils","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xolox%2Fpython-linux-utils","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xolox%2Fpython-linux-utils/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xolox%2Fpython-linux-utils/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xolox%2Fpython-linux-utils/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/xolox","download_url":"https://codeload.github.com/xolox/python-linux-utils/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xolox%2Fpython-linux-utils/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265462019,"owners_count":23769945,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["crypttab","disk-encryption","fstab","linux","luks","python","system-administration"],"created_at":"2024-11-08T22:12:51.561Z","updated_at":"2025-07-15T21:44:28.137Z","avatar_url":"https://github.com/xolox.png","language":"Python","readme":"linux-utils: Linux system administration tools for Python\n=========================================================\n\n.. image:: https://travis-ci.org/xolox/python-linux-utils.svg?branch=master\n   :target: https://travis-ci.org/xolox/python-linux-utils\n\n.. image:: https://coveralls.io/repos/xolox/python-linux-utils/badge.svg?branch=master\n   :target: https://coveralls.io/r/xolox/python-linux-utils?branch=master\n\nThe Python package `linux-utils` provides utility functions that make it easy\nto script system administration tasks on Linux_ systems in Python. The\nfollowing functionality is currently implemented:\n\n- Parsing of the `/etc/fstab`_ and `/etc/crypttab`_ configuration files.\n- A basic Python API for cryptsetup_ and a Python implementation of\n  cryptdisks_start_ and cryptdisks_stop_ (with a command line interface).\n- Atomic filesystem operations for Linux in Python.\n- Simple network location awareness / discovery.\n\nThe package is currently tested on cPython 2.7, 3.4, 3.5, 3.6, 3.7 and PyPy\n(2.7) on Ubuntu Linux (using `Travis CI`_).\n\n.. contents::\n   :local:\n\nInstallation\n------------\n\nThe `linux-utils` package is available on PyPI_ which means installation should\nbe as simple as:\n\n.. code-block:: console\n\n   $ pip install linux-utils\n\nThere's actually a multitude of ways to install Python packages (e.g. the `per\nuser site-packages directory`_, `virtual environments`_ or just installing\nsystem wide) and I have no intention of getting into that discussion here, so\nif this intimidates you then read up on your options before returning to these\ninstructions 😉.\n\nUsage\n-----\n\nFor details about the Python API please refer to the API documentation\navailable on `Read the Docs`_. The Python implementation of cryptdisks_start_\nand cryptdisks_stop_ is available on the command line as the following two\nprograms:\n\n.. contents::\n   :local:\n\nAs the names imply these programs are not functional equivalents of their\n\"official\" counterparts, because they only support LUKS encryption and a small\nsubset of the available encryption options.\n\ncryptdisks-start-fallback\n~~~~~~~~~~~~~~~~~~~~~~~~~\n\n.. A DRY solution to avoid duplication of the `cryptdisks-start-fallback --help' text:\n..\n.. [[[cog\n.. import cog\n.. from humanfriendly.text import dedent\n.. from humanfriendly.usage import render_usage\n.. from linux_utils.cli import cryptdisks_start_cli\n.. cog.out(\"\\n\" + render_usage(dedent(cryptdisks_start_cli.__doc__)) + \"\\n\")\n.. ]]]\n\n**Usage:** `cryptdisks-start-fallback NAME`\n\nReads /etc/crypttab and unlocks the encrypted filesystem with the given NAME.\n\nThis program emulates the functionality of Debian's cryptdisks_start program,\nbut it only supports LUKS encryption and a small subset of the available\nencryption options.\n\n.. [[[end]]]\n\ncryptdisks-stop-fallback\n~~~~~~~~~~~~~~~~~~~~~~~~\n\n.. A DRY solution to avoid duplication of the `cryptdisks-stop-fallback --help' text:\n..\n.. [[[cog\n.. import cog\n.. from humanfriendly.text import dedent\n.. from humanfriendly.usage import render_usage\n.. from linux_utils.cli import cryptdisks_stop_cli\n.. cog.out(\"\\n\" + render_usage(dedent(cryptdisks_stop_cli.__doc__)) + \"\\n\")\n.. ]]]\n\n**Usage:** `cryptdisks-stop-fallback NAME`\n\nReads /etc/crypttab and locks the encrypted filesystem with the given NAME.\n\nThis program emulates the functionality of Debian's cryptdisks_stop program,\nbut it only supports LUKS encryption and a small subset of the available\nencryption options.\n\n.. [[[end]]]\n\n.. _History:\n\nHistory\n-------\n\nBack in 2015 I wrote some Python code to parse the Linux configuration files\n`/etc/fstab`_ and `/etc/crypttab`_ for use in crypto-drive-manager_. Fast\nforward to 2017 and I found myself wanting to use the same functionality\nin rsync-system-backup_. Three options presented themselves to me:\n\n**Copy/paste the relevant code**\n Having to maintain the same code in multiple places causes lower quality code\n because having to duplicate the effort of writing documentation, developing\n tests and fixing bugs is a very demotivating endeavor. In fact sometime in\n 2016 I *did* copy/paste parts of this code into a project at work, because I\n needed similar functionality there. Of course since then the two\n implementations have started diverging 😛.\n\n**Make crypto-drive-manager a dependency of rsync-system-backup**\n Although this approach is less ugly than copy/pasting the code, it still isn't\n exactly elegant because the two projects have nothing to do with each other\n apart from working with LUKS encrypted disks on Linux.\n\n**Extract the functionality into a new package**\n In my opinion this is clearly the most elegant approach, unfortunately it also\n requires the most work from me 😇. On the plus side I'm publishing the new\n package with a test suite which means less untested code remains in\n crypto-drive-manager_ (which doesn't have a test suite at the time of\n writing).\n\nWhile extracting the code I shortly considered integrating the functionality\ninto debuntu-tools_, however the `/etc/fstab`_ and `/etc/crypttab`_ parsing\nisn't specific to Debian or Ubuntu at all and debuntu-tools_ has several\ndependencies that aren't relevant to Linux configuration file parsing.\n\nSince then it has become clear that this was a good choice (not merging the\nfunctionality into debuntu-tools_) because `linux-utils` now provides a Python\nimplementation of cryptdisks_start_ and cryptdisks_stop_, which is mostly\nuseful on Linux systems that *aren't* based on Debian 🙂.\n\nContact\n-------\n\nThe latest version of `linux-utils` is available on PyPI_ and GitHub_. The\ndocumentation is available on `Read the Docs`_ and includes a changelog_. For\nbug reports please create an issue on GitHub_. If you have questions,\nsuggestions, etc. feel free to send me an e-mail at `peter@peterodding.com`_.\n\nLicense\n-------\n\nThis software is licensed under the `MIT license`_.\n\n© 2020 Peter Odding.\n\n.. _/etc/crypttab: https://manpages.debian.org/crypttab\n.. _/etc/fstab: https://manpages.debian.org/fstab\n.. _changelog: https://linux-utils.readthedocs.org/en/latest/changelog.html\n.. _cryptdisks_start: https://manpages.debian.org/cryptdisks_start\n.. _cryptdisks_stop: https://manpages.debian.org/cryptdisks_stop\n.. _crypto-drive-manager: https://pypi.python.org/pypi/crypto-drive-manager\n.. _cryptsetup: https://manpages.debian.org/cryptsetup\n.. _debuntu-tools: https://pypi.python.org/pypi/debuntu-tools\n.. _GitHub: https://github.com/xolox/python-linux-utils\n.. _Linux: https://en.wikipedia.org/wiki/Linux\n.. _MIT license: http://en.wikipedia.org/wiki/MIT_License\n.. _per user site-packages directory: https://www.python.org/dev/peps/pep-0370/\n.. _peter@peterodding.com: peter@peterodding.com\n.. _PyPI: https://pypi.python.org/pypi/linux-utils\n.. _Python Package Index: https://pypi.python.org/pypi/linux-utils\n.. _Python: https://www.python.org/\n.. _Read the Docs: https://linux-utils.readthedocs.io/en/latest/\n.. _rsync-system-backup: https://pypi.python.org/pypi/rsync-system-backup\n.. _Travis CI: https://travis-ci.org/xolox/python-linux-utils/builds\n.. _virtual environments: http://docs.python-guide.org/en/latest/dev/virtualenvs/\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxolox%2Fpython-linux-utils","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fxolox%2Fpython-linux-utils","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxolox%2Fpython-linux-utils/lists"}