pysyslimit.api¶
chmod¶
-
pysyslimit.api.chmod(path: str, mod, recursive: bool = False)[source]¶ - Overview:
Set the permission of file.
- Arguments:
path (
str): Path of the file going to set permission.mod (
object): Permission information object.recursive (
bool): Recursively set the subdirectories or not, default isFalsewhich means only apply to the current file.
- Examples::
>>> from pysyslimit import chmod >>> chmod('my_file', '777') # chmod 777 my_file >>> chmod('my_dir', '777', recursive=True) # chmod -R 777 my_dir
chmod_add¶
-
pysyslimit.api.chmod_add(path, mod, recursive: bool = False)[source]¶ - Overview:
Append the permission of file.
- Arguments:
path (
str): Path of the file going to append permission.mod (
object): Permission information object.recursive (
bool): Recursively set the subdirectories or not, default isFalsewhich means only apply to the current file.
- Examples::
>>> from pysyslimit import chmod_add >>> chmod_add('my_file', '600') # chmod +600 my_file >>> chmod_add('my_dur', '600', recursive=True) # chmod -R +600 my_dir
chmod_del¶
-
pysyslimit.api.chmod_del(path, mod, recursive: bool = False)[source]¶ - Overview:
Remove the permission of file.
- Arguments:
path (
str): Path of the file going to remove permission.mod (
object): Permission information object.recursive (
bool): Recursively set the subdirectories or not, default isFalsewhich means only apply to the current file.
- Examples::
>>> from pysyslimit import chmod_del >>> chmod_del('my_file', '600') # chmod -600 my_file >>> chmod_del('my_dur', '600', recursive=True) # chmod -R -600 my_dir
chown¶
-
pysyslimit.api.chown(path, user=None, group=None, recursive: bool = False)[source]¶ - Overview:
Set the owner of file.
- Arguments:
path (
str): Path of the file going to set owner.user (
object): User object of the user going to be set, default isNonewhich means do not change user.group (
object): Group object of the group going to be set, default isNonewhich means do not change group.recursive (
bool): Recursively set the subdirectories or not, default isFalsewhich means only apply to the current file.
- Examples::
>>> from pysyslimit import chown >>> chown('my_file', 'myself', 'mygroup') # chown myself:mygroup my_file >>> chown('my_dir', 'myself', 'mygroup', recursive=True) # chown -R myself:mygroup my_dir
groupadd¶
-
pysyslimit.api.groupadd(group_name, force=False, gid=None, non_unique=False, password=None, system=False, chroot_dir=None, extra_users=False, safe=False)[source]¶ - Overview:
Create a new group.
- Arguments:
group_name: Name of the new group.
force: Foce create this group.
gid: Gid of this group.
non_unique: Not unique group.
password: Password of the group.
system: Create as system-leveled group.
chroot_dir: Root entry directory.
extra_users: Use extra user database.
safe: Safe mode (no error information when error)
- Returns:
group: Created group object.
- Examples::
>>> from pysyslimit import groupadd >>> groupadd('mygroup') # groupadd mygroup
GroupaddExecuteException¶
-
class
pysyslimit.api.GroupaddExecuteException(return_code, stdout, stderr)[source]¶ - Overview:
Exception class of
groupaddcommand, inherited frompysyslimit.utils.ExecuteException.
-
__init__(return_code, stdout, stderr)¶ - Overview:
Constructor of class
pysyslimit.utils.ExecuteException.- Arguments:
return_code: Return code.
stdout: Stdout content.
stderr: Stderr content.
-
property
message¶ - Overview:
Message of this command.
-
property
return_code¶ - Overview:
Return code of this command.
-
property
stderr¶ - Overview:
Stderr content of this command.
-
property
stdout¶ - Overview:
Stdout content of this command.
-
property
title¶ - Overview:
Title of this command.
groupdel¶
-
pysyslimit.api.groupdel(group_name, chroot_dir=None, force=False, safe=False)[source]¶ - Overview:
Delete an existing group.
- Arguments:
group_name: Name of the group.
chroot_dir: Root entry directory.
force: Force delete.
safe: Safe mode (no error information when error)
- Returns:
success: Delete success or not.
- Examples::
>>> from pysyslimit import groupdel >>> groupdel('mygroup') # groupdel mygroup
GroupdelExecuteException¶
-
class
pysyslimit.api.GroupdelExecuteException(return_code, stdout, stderr)[source]¶ - Overview:
Exception class of
groupdelcommand, inherited frompysyslimit.utils.ExecuteException.
-
__init__(return_code, stdout, stderr)¶ - Overview:
Constructor of class
pysyslimit.utils.ExecuteException.- Arguments:
return_code: Return code.
stdout: Stdout content.
stderr: Stderr content.
-
property
message¶ - Overview:
Message of this command.
-
property
return_code¶ - Overview:
Return code of this command.
-
property
stderr¶ - Overview:
Stderr content of this command.
-
property
stdout¶ - Overview:
Stdout content of this command.
-
property
title¶ - Overview:
Title of this command.
useradd¶
-
pysyslimit.api.useradd(user_name, uid=None, primary_group=None, groups=None, password=None, system=None, comment=None, user_group=None, no_user_group=None, create_home=None, no_create_home=None, home_dir=None, base_dir=None, shell=None, chroot_dir=None, selinux_user=None, extra_users=None, safe=False)[source]¶ - Overview:
Create a new user.
- Arguments:
user_name: Name of the user.
uid: Uid of the user.
primary_group: Primary group of the user.
groups: Append groups of the user.
password: Password of the user.
system: Create as system user or not.
comment: Comment information of the user.
user_group: Create a user group with the same name or not.
no_user_group: Do not create a user group.
create_home: Create a home path.
no_create_home: Do not create home path.
home_dir: Directory of the home path.
base_dir: Base directory of the user.
shell: User’s shell.
chroot_dir: User’s chroot path.
selinux_user: Remove linux mapping user.
extra_users: Use extra user database.
safe: Safe mode (no error message when error)
- Returns:
user: Created user object.
- Examples::
>>> from pysyslimit import useradd >>> useradd("myself") # useradd myself
UseraddExecuteException¶
-
class
pysyslimit.api.UseraddExecuteException(return_code, stdout, stderr)[source]¶ - Overview:
Exception class of
useraddcommand, inherited frompysyslimit.utils.ExecuteException.
-
__init__(return_code, stdout, stderr)¶ - Overview:
Constructor of class
pysyslimit.utils.ExecuteException.- Arguments:
return_code: Return code.
stdout: Stdout content.
stderr: Stderr content.
-
property
message¶ - Overview:
Message of this command.
-
property
return_code¶ - Overview:
Return code of this command.
-
property
stderr¶ - Overview:
Stderr content of this command.
-
property
stdout¶ - Overview:
Stdout content of this command.
-
property
title¶ - Overview:
Title of this command.
userdel¶
-
pysyslimit.api.userdel(user_name, force=False, remove_dir=False, chroot_dir=None, selinux_user=False, safe=False)[source]¶ - Overview:
Delete an existing user.
- Arguments:
user_name: Name of the user.
force: Force delete.
remove_dir: Remove the directory of user or not.
chroot_dir: Root entry path.
selinux_user: Remove the mapping user.
safe: Safe mode (no error information when error)
- Returns:
success: Delete success or not.
- Examples::
>>> from pysyslimit import userdel >>> userdel('myself') # userdel myself
UserdelExecuteException¶
-
class
pysyslimit.api.UserdelExecuteException(return_code, stdout, stderr)[source]¶ - Overview:
Exception class of
userdelcommand, inherited frompysyslimit.utils.ExecuteException.
-
__init__(return_code, stdout, stderr)¶ - Overview:
Constructor of class
pysyslimit.utils.ExecuteException.- Arguments:
return_code: Return code.
stdout: Stdout content.
stderr: Stderr content.
-
property
message¶ - Overview:
Message of this command.
-
property
return_code¶ - Overview:
Return code of this command.
-
property
stderr¶ - Overview:
Stderr content of this command.
-
property
stdout¶ - Overview:
Stdout content of this command.
-
property
title¶ - Overview:
Title of this command.