|
|
| 4. sor: |
4. sor: |
| </syntaxhighlight>Procedural style<syntaxhighlight lang="php"> | | </syntaxhighlight>Procedural style<syntaxhighlight lang="php"> |
| lnxExistsUser ( string | int $user ): bool | | lnxExistsUser ( string | int $user ): bool |
| </syntaxhighlight>Examine that the linux user is exists. | | </syntaxhighlight>Examines whether the linux user exists. |
|
| |
|
| == Parameters == | | == Parameters == |
| 27. sor: |
27. sor: |
| $user = 'testUser'; | | $user = 'testUser'; |
|
| |
|
| # Add linux user | | # Examine if user exists |
|
| |
|
| if ( ! lnxAddUser( [ | | if ( lnxExistsUser( $user ) ) |
| | | |
| 'name' => $user, // Mantandory! Name of linux user. | | print( "'$user' user exists!" . PHP_EOL ); |
| 'password' => 'HelloNSA', // Mantandory! Password of linux user.
| |
| //'uid' => 1100, // Optional. User ID of linux user. The ID must not exist!
| |
| //'gid' => 1100, // Optional. Primary group of the linux user. The group must exist! If this parameter is not present the Group name will be the User name and the Group ID will be the User ID or the first free ID.
| |
| 'groups' => [ 'users' ], // Optional. Group membership of the linux user. It must be a simple indexed array what contains the groups in what the user will be member. The groups must exist.
| |
| //'nogroup' => true, // Optional. If true the Primary group will not be created. If 'gid' is present this parameter will be ineffective.
| |
| 'comment' => 'test user', // Optional. Comment (display name) of linux user.
| |
| //'home' => '/home/test',// Optional. Absolute path of Home directory of linux user.
| |
| //'createhome' => true, // Optional. If false the Home directory will not be created.
| |
| //'shell' => '/bin/bash', // Optional. Absolute path of shell for linux user.
| |
| //'inactive' => 90, // Optional. The number of days after password expires that account is disabled.
| |
| //'expire' => 1640995199, // Optional. Date when account will be disabled. Format: timestamp.
| |
| //'system' => true, // Optional. If true create a system account. User ID will be under 1000. If 'uid' is present this parameter will be ineffective.
| |
| //'nonunique' => true , // Optional. If true allow to create users with duplicate (non-unique) User ID.
| |
|
| |
| ] ) )
| |
|
| |
| print( "Something went wrong during Add user!" . PHP_EOL );
| |
|
| |
|
| else | | else |
| | | |
| print( "'$user' user is created." . PHP_EOL ); | | print( "'$user' user does not exists!" . PHP_EOL ); |
| | |
|
| |
|
| </syntaxhighlight> | | </syntaxhighlight> |
| [[Kategória:LnxUser]] | | [[Kategória:LnxUser]] |
Description
Object-oriented style
public lnxUser::existsUser ( string | int $user ): bool
Procedural style
lnxExistsUser ( string | int $user ): bool
Examines whether the linux user exists.
Parameters
- user
- Name or User ID of linux user.
Return Values
Returns true if user exists, false otherwise.
Changelog
Version (lnxUser)
|
Description
|
| 1.00
|
available
|
Examples
$user = 'testUser';
# Examine if user exists
if ( lnxExistsUser( $user ) )
print( "'$user' user exists!" . PHP_EOL );
else
print( "'$user' user does not exists!" . PHP_EOL );