function::task_ns_uid - Linux


Overview

The function:task_ns_uid command allows users to interact with a namespace’s user ID (UID) mappings. It creates, modifies, and deletes mappings between user IDs in the specified namespace and UIDs in the host namespace.

Syntax

function:task_ns_uid [OPTIONS] SUBCOMMAND [ARGS]

Options/Flags

  • -h: Display help and exit.
  • --help-all: Display full help, including subcommand help.
  • -v: Set verbosity level.

Subcommands

create

Creates a new UID mapping for a namespace.
Syntax: function:task_ns_uid create [OPTIONS] NSID UID

delete

Deletes a UID mapping for a namespace.
Syntax: function:task_ns_uid delete [OPTIONS] NSID UID

get

Gets the UID mapping for a namespace.
Syntax: function:task_ns_uid get [OPTIONS] NSID UID

list

Lists all UID mappings for a namespace.
Syntax: function:task_ns_uid list [OPTIONS] NSID

Examples

Create a UID mapping:

# Create a mapping for UID 1000 in namespace 1 to UID 500 in the host
function:task_ns_uid create 1 1000 500

Get a UID mapping:

# Get the mapping for UID 1000 in namespace 1
function:task_ns_uid get 1 1000

List all UID mappings:

# List all mappings for namespace 1
function:task_ns_uid list 1

Common Issues

  • Ensure that you have root privileges to use this command.
  • Specify namespace ID correctly; using non-existent namespace IDs will result in an error.

Integration

This command can be used with other namespace management tools, such as function:task_ns, to manage namespaces and control UID mappings. Additionally, it can be integrated into scripts or automation frameworks for managing complex namespace configurations.

Related Commands

  • function:task_ns – Manage Linux namespaces.
  • unshare – Create a new namespace.
  • lsns – List active namespaces.