Package Description
License
—
Deps
3
Install Size
—
Vulns
✓ 0
Published
Jul 29, 2023
$ dotnet add package AlinSpace.LinuxAlinSpace Linux abstractions.
Scripts are annoying. So why not instead have beautiful crafted C# interfaces to interact with the system?
The following code gets all users on the system and prints their fullnames:
var userService = UserService.Instance;
var users = await userService.GetAllAsync();
foreach(var user in users)
{
Console.WriteLine(user.Fullname);
// More data available:
//Console.WriteLine(user.Username);
//Console.WriteLine(user.Uid);
//Console.WriteLine(user.Guid);
//Console.WriteLine(user.HomeDirectory);
//Console.WriteLine(user.Shell);
}
Print the fullname of a specific user:
var userService = UserService.Instance;
var user = await userService.GetOrDefaultByNameAsync("myuser");
if (user == null)
throw new Exception("User does not exist.");
Console.WriteLine(user.Fullname);
Retrieve all all groups on the system:
var groupService = GroupService.Instance;
var groups = await groupService.GetAllAsync();