https://github.com/hansbug/pysyslimit
A system limitor of linux system build by python.
https://github.com/hansbug/pysyslimit
linux permission python3
Last synced: about 1 month ago
JSON representation
A system limitor of linux system build by python.
- Host: GitHub
- URL: https://github.com/hansbug/pysyslimit
- Owner: HansBug
- License: apache-2.0
- Created: 2022-01-14T07:03:54.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2022-01-14T13:38:09.000Z (over 4 years ago)
- Last Synced: 2025-05-21T14:21:56.771Z (about 1 year ago)
- Topics: linux, permission, python3
- Language: Python
- Homepage: https://hansbug.github.io/pysyslimit/
- Size: 6.06 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
# pysyslimit
[](https://pypi.org/project/pysyslimit/)
[](https://pypi.org/project/pysyslimit/)


[](https://github.com/HansBug/pysyslimit/actions?query=workflow%3A%22Docs+Deploy%22)
[](https://github.com/HansBug/pysyslimit/actions?query=workflow%3A%22Code+Test%22)
[](https://github.com/HansBug/pysyslimit/actions?query=workflow%3A%22Badge+Creation%22)
[](https://github.com/HansBug/pysyslimit/actions?query=workflow%3A%22Package+Release%22)
[](https://codecov.io/gh/HansBug/pysyslimit)
[](https://github.com/HansBug/pysyslimit/stargazers)
[](https://github.com/HansBug/pysyslimit/network)

[](https://github.com/HansBug/pysyslimit/issues)
[](https://github.com/HansBug/pysyslimit/pulls)
[](https://github.com/HansBug/pysyslimit/graphs/contributors)
[](https://github.com/HansBug/pysyslimit/blob/master/LICENSE)
`pysyslimit` is a light-weight library which can manage the permission in linux system.
## Installation
Just install this package with the pip command
```bash
pip install pysyslimit
```
For further information, take a look at the [Installation Page](https://hansbug.github.io/pysyslimit/main/tutorials/installation/index.html).
## Quick Start
**Please attention that many function in this library need root permission, so It is strongly recommended to run this with root.**
### Take a look at who I am
```python
from pysyslimit import *
if __name__ == "__main__":
print("current user:", SystemUser.current())
print("current user's groups:", SystemUser.current().groups)
print("current group:", SystemGroup.current())
```
The output should be
```text
current user: root
current user's groups: []
current group: root
```
### Get and update the permission of files
```python
from pysyslimit import *
if __name__ == "__main__":
print(FilePermission.load_from_file("test_file"))
chmod_del("test_file", "004")
print(FilePermission.load_from_file("test_file"))
chmod_add("test_file", "014")
print(FilePermission.load_from_file("test_file"))
```
The output shall be
```text
rw-rw-r--
rw-rw----
rw-rwxr--
```
### Do calculation between permissions
```python
from pysyslimit import *
if __name__ == "__main__":
print(FilePermission.loads('463') + FilePermission.loads('615'))
print(FilePermission.loads('463') | FilePermission.loads('615')) # the same as +
print(FilePermission.loads('463') - FilePermission.loads('615'))
print(FilePermission.loads('463') & FilePermission.loads('615'))
```
The output shall be
```text
rw-rwxrwx
rw-rwxrwx
---rw--w-
r-------x
```
# Contributing
We appreciate all contributions to improve `pysyslimit` ,both logic and system designs. Please refer to CONTRIBUTING.md for more guides.
# License
`pysyslimit` released under the Apache 2.0 license.