### Example: Establish TCP Connection Between Two Zsh Instances (Host 1 - Listener) Source: https://manpages.ubuntu.com/manpages/stonking/man1/zshmodules.1.html Demonstrates setting up a TCP connection. This snippet shows the listener setup on host1, including loading the module, starting a listener, and accepting an incoming connection. ```zsh zmodload zsh/net/tcp ztcp -l 5123 listenfd=$REPLY ztcp -a $listenfd fd=$REPLY ``` -------------------------------- ### Example: RPM installation script for radvd Source: https://manpages.ubuntu.com/manpages/stonking/man8/systemd-sysusers.service.8.html This example demonstrates how to use the --replace option to create a user and group during an RPM installation. The configuration is provided directly on the command line, simulating the presence of a configuration file. ```bash echo 'u radvd - "radvd daemon"' | \ systemd-sysusers --replace=/usr/lib/sysusers.d/radvd.conf - ``` -------------------------------- ### xsm default startup applications example Source: https://manpages.ubuntu.com/manpages/stonking/man1/xsm.1.html A sample startup file for xsm, listing applications to be started when a session begins. Each line should contain a command to start an application. ```shell twm smproxy xterm ``` -------------------------------- ### Basic Loop Device Setup and Usage Example Source: https://manpages.ubuntu.com/manpages/stonking/man8/losetup.8.html This example demonstrates the typical workflow for setting up a loop device: creating an image file, associating it with a loop device, formatting it, mounting it, and finally detaching it. ```bash # dd if=/dev/zero of=~/file.img bs=1024k count=10 # losetup --find --show ~/file.img /dev/loop0 # mkfs -t ext2 /dev/loop0 # mount /dev/loop0 /mnt ... # umount /dev/loop0 # losetup --detach /dev/loop0 ``` -------------------------------- ### Start a trial session Source: https://manpages.ubuntu.com/manpages/stonking/man1/tpm2_startauthsession.1.html This example demonstrates how to start a trial session and save the session data to a file named 'mysession.ctx'. ```APIDOC ## Start a trial session ### Description Starts a trial authorization session with the TPM and saves the session context to a file. ### Command tpm2_startauthsession ### Parameters #### Command Options - **-S** (string) - Required - Path to save the session context file. ### Example ```bash tpm2_startauthsession -S mysession.ctx ``` ``` -------------------------------- ### Example environment.d configuration file Source: https://manpages.ubuntu.com/manpages/stonking/man5/environment.d.5.html This example shows how to set environment variables for a program installed in /opt/foo, including PATH, LD_LIBRARY_PATH, and XDG_DATA_DIRS. It demonstrates variable expansion and default value assignment. ```shell FOO_DEBUG=force-software-gl,log-verbose PATH=/opt/foo/bin:$PATH LD_LIBRARY_PATH=/opt/foo/lib${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH} XDG_DATA_DIRS=/opt/foo/share:${XDG_DATA_DIRS:-/usr/local/share/:/usr/share/} ``` -------------------------------- ### Example: Loading a provider and getting build information Source: https://manpages.ubuntu.com/manpages/stonking/man3/OSSL_PROVIDER_get0_name.3.html This example demonstrates how to load a provider module named 'foo' and then retrieve its build information using OSSL_PROVIDER_get_params. ```APIDOC ## Example: Loading a provider and getting build information ### Description This example shows how to load the provider module "foo" and query for its build information. ### Code ```c #include #include #include OSSL_PROVIDER *prov = NULL; const char *build = NULL; OSSL_PARAM request[] = { { "buildinfo", OSSL_PARAM_UTF8_PTR, &build, 0, 0 }, { NULL, 0, NULL, 0, 0 } }; if ((prov = OSSL_PROVIDER_load(NULL, "foo")) != NULL && OSSL_PROVIDER_get_params(prov, request)) printf("Provider 'foo' buildinfo: %s\n", build); else ERR_print_errors_fp(stderr); ``` ### Usage This code snippet requires including the necessary OpenSSL headers and links against the OpenSSL library. It first attempts to load the provider named "foo". If successful, it then uses `OSSL_PROVIDER_get_params` with a request parameter for "buildinfo" to retrieve the build information string. Errors are printed to stderr. ``` -------------------------------- ### Basic warnquota.conf Example Source: https://manpages.ubuntu.com/manpages/stonking/man5/warnquota.conf.5.html A simple configuration example showing FROM, SUPPORT, and PHONE settings. Lines starting with '#' are comments and are ignored. ```shell # comment FROM = root@example.com SUPPORT = support@example.com PHONE = 1234 ``` -------------------------------- ### Starting and Managing a Kernel Process (bufdaemon) Source: https://manpages.ubuntu.com/manpages/stonking/man9/kproc.9freebsd.html This example demonstrates how to define a kernel process descriptor and start it using kproc_start. It also shows how to register a shutdown event handler and periodically check for suspension. ```c static struct proc *bufdaemonproc; static struct kproc_desc buf_kp = { "bufdaemon", buf_daemon, &bufdaemonproc }; SYSINIT(bufdaemon, SI_SUB_KTHREAD_BUF, SI_ORDER_FIRST, kproc_start, &buf_kp) static void buf_daemon() { ... /* * This process needs to be suspended prior to shutdown sync. */ EVENTHANDLER_REGISTER(shutdown_pre_sync, kproc_shutdown, bufdaemonproc, SHUTDOWN_PRI_LAST); ... for (;;) { kproc_suspend_check(bufdaemonproc); ... } } ``` -------------------------------- ### Oneshot Startup Container Example Source: https://manpages.ubuntu.com/manpages/stonking/man5/podman-systemd.unit.5.html Defines a oneshot container that runs a setup script before the main application starts. It remains active after exiting. ```ini [Service] Type=oneshot RemainAfterExit=yes [Container] Pod=test.pod Image=quay.io/centos/centos:latest Exec=sh -c "echo 'setup starting'; sleep 2; echo 'setup complete'" ``` -------------------------------- ### Starting a Transaction Block Source: https://manpages.ubuntu.com/manpages/stonking/man7/BEGIN.7.html A simple example demonstrating how to initiate a transaction block using the BEGIN command. ```sql BEGIN; ``` -------------------------------- ### Read WMI status information Source: https://manpages.ubuntu.com/manpages/stonking/man4/acpi_wmi.4freebsd.html This example shows how to read the WMI status device to get information about GUIDs found in the system. The output displays GUIDs along with their instance, expected method, method, string, event, and OID. ```shell # cat /dev/wmistat0 GUID INST EXPE METH STR EVENT OID {5FB7F034-2C63-45E9-BE91-3D44E2C707E4} 1 NO WMAA NO NO AA {95F24279-4D7B-4334-9387-ACCDC67EF61C} 1 NO NO NO 0x80+ - {2B814318-4BE8-4707-9D84-A190A859B5D0} 1 NO NO NO 0xA0 - {05901221-D566-11D1-B2F0-00A0C9062910} 1 NO NO NO NO AB {1F4C91EB-DC5C-460B-951D-C7CB9B4B8D5E} 1 NO WMBA NO NO BA {2D114B49-2DFB-4130-B8FE-4A3C09E75133} 57 NO NO NO NO BC {988D08E3-68F4-4C35-AF3E-6A1B8106F83C} 20 NO NO NO NO BD {14EA9746-CE1F-4098-A0E0-7045CB4DA745} 1 NO NO NO NO BE {322F2028-0F84-4901-988E-015176049E2D} 2 NO NO NO NO BF {8232DE3D-663D-4327-A8F4-E293ADB9BF05} 0 NO NO NO NO BG {8F1F6436-9F42-42C8-BADC-0E9424F20C9A} 0 NO NO NO NO BH {8F1F6435-9F42-42C8-BADC-0E9424F20C9A} 0 NO NO NO NO BI ``` -------------------------------- ### Creating and Mounting a Filesystem Source: https://manpages.ubuntu.com/manpages/stonking/man2/fsmount.2.html This example demonstrates opening a filesystem, configuring it, creating a mount object with specific attributes, performing operations on a file within the mount, and finally attaching the mount object to a directory. ```c int fsfd, mntfd, tmpfd; fsfd = fsopen("tmpfs", FSOPEN_CLOEXEC); fsconfig(fsfd, FSCONFIG_CMD_CREATE, NULL, NULL, 0); mntfd = fsmount(fsfd, FSMOUNT_CLOEXEC, MOUNT_ATTR_NODEV | MOUNT_ATTR_NOEXEC); /* Create a new file without attaching the mount object */ tmpfd = openat(mntfd, "tmpfile", O_CREAT | O_EXCL | O_RDWR, 0600); unlinkat(mntfd, "tmpfile", 0); /* Attach the mount object to "/tmp" */ move_mount(mntfd, "", AT_FDCWD, "/tmp", MOVE_MOUNT_F_EMPTY_PATH); ``` -------------------------------- ### Xsetup Script Example Source: https://manpages.ubuntu.com/manpages/stonking/man1/xdm.1.html A sample Xsetup script to configure the environment before the login window appears. It runs as root, so exercise caution with security. ```shell #!/bin/sh # Xsetup_0 - setup script for one workstation xcmsdb < /etc/X11/xdm/monitors/alex.0 xconsole -geometry 480x130-0-0 -notify -verbose -exitOnFail & ``` -------------------------------- ### Compiling and running the key_instantiate example Source: https://manpages.ubuntu.com/manpages/stonking/man2/keyctl.2.html This snippet shows the shell commands to compile the C example program, replace the standard request-key program with the example, run the example to request a key, and then restore the original request-key program. ```bash $ cc -o key_instantiate key_instantiate.c -lkeyutils $ sudo mv /sbin/request-key /sbin/request-key.backup $ sudo cp key_instantiate /sbin/request-key $ ./t_request_key user mykey somepayloaddata Key ID is 20d035bf $ sudo mv /sbin/request-key.backup /sbin/request-key ``` -------------------------------- ### Example: Start git bisect for performance regression Source: https://manpages.ubuntu.com/manpages/stonking/man1/git-bisect.1.html An example of starting a git bisect session with custom terms 'fast' and 'slow' to find a performance regression. ```bash git bisect start --term-old fast --term-new slow ``` -------------------------------- ### pmrep.conf Example Configuration Source: https://manpages.ubuntu.com/manpages/stonking/man5/pmrep.conf.5.html This example demonstrates setting global options, defining metrics in both compact and verbose forms, and configuring metricsets for different data sources. It shows how to specify metric formulas, widths, and source hosts. ```ini [options] timestamp = yes interval = 2s extheader = yes repeat_header = auto space_scale = MB [global] kernel.all.sysfork = forks,,,,8 cacheall = mem.util.allcache cacheall.formula = mem.util.bufmem + mem.util.cached + mem.util.slab cacheall.width = 12 [db1] source = db-host1.example.com set = postgresql [db2] source = db-host2.example.com set = postgresql [sar-w] header = yes unitinfo = no globals = no timestamp = yes precision = 2 delimiter = " " kernel.all.sysfork = proc/s,,,,12 kernel.all.pswitch = cswch/s,,,,9 ``` -------------------------------- ### RUN --network=none Example Source: https://manpages.ubuntu.com/manpages/stonking/man5/Containerfile.5.html This example demonstrates isolating external effects by running a pip install command with no network access. This ensures that only provided packages are installed. ```Containerfile FROM python:3.6 ADD mypackage.tgz wheels/ RUN --network=none pip install --find-links wheels mypackage ``` -------------------------------- ### Using a Pre-configured Options File Source: https://manpages.ubuntu.com/manpages/stonking/man1/keytool.1.html Demonstrates how a pre-configured options file can simplify keytool commands by providing default options. The example shows how options from the file are merged with command-line arguments. ```properties # A tiny pre-configured options file keytool.all = -keystore ${user.home}/ks keytool.list = -v keytool.genkeypair = -keyalg rsa ``` ```bash keytool -conf preconfig -list ``` ```bash keytool -keystore ~/ks -v -list ``` ```bash keytool -conf preconfig -genkeypair -alias me ``` ```bash keytool -keystore ~/ks -keyalg rsa -genkeypair -alias me ``` ```bash keytool -conf preconfig -genkeypair -alias you -keyalg ec ``` ```bash keytool -keystore ~/ks -keyalg rsa -genkeypair -alias you -keyalg ec ``` ```bash keytool -keystore ~/ks -genkeypair -alias you -keyalg ec ``` -------------------------------- ### Example: Start git bisect for bug fix Source: https://manpages.ubuntu.com/manpages/stonking/man1/git-bisect.1.html An example of starting a git bisect session with custom terms 'fixed' and 'broken' to find the commit that fixed a bug. ```bash git bisect start --term-new fixed --term-old broken ``` -------------------------------- ### Start a service Source: https://manpages.ubuntu.com/manpages/stonking/man8/initctl.8.html The 'start' command initiates a service by its name, with an optional ID. Example: 'initctl start tty:1'. ```bash initctl start NAME[:ID] ``` -------------------------------- ### Initialize Discovery Module and Setup Source: https://manpages.ubuntu.com/manpages/stonking/man3/pmDiscoverSetup.3.html Initialize the discovery module with an event loop, configuration, and metric registry, then set up the discovery process with the module, callbacks, and private data. Ensure all declared callbacks are implemented. ```c pmDiscoverSetEventLoop(&someapp_discover.module, myevents); pmDiscoverSetConfiguration(&someapp_discover.module, myconfig); pmDiscoverSetMetricRegistry(&someapp_discover.module, metric_registry); pmDiscoverSetup(&someapp_discover.module, &someapp_discover.callbacks, &privatedata); ``` -------------------------------- ### Get Session Start Time Source: https://manpages.ubuntu.com/manpages/stonking/man3/sd_session_get_class.3.html Retrieve the start time of a systemd session in microseconds. ```c int sd_session_get_start_time(const char ***_session_**, uint64_t ***_usec_**); ``` -------------------------------- ### Install a Package from an Archive Source: https://manpages.ubuntu.com/manpages/stonking/man1/dpkg.1.html Install a package from a .deb archive file. This example shows installing a specific version of vim from a media disc. ```bash dpkg -i /media/bdrom/pool/main/v/vim/vim_9.0.2018-1_amd64.deb ``` -------------------------------- ### io_uring Setup and Initialization Example Source: https://manpages.ubuntu.com/manpages/stonking/man7/io_uring.7.html This C code demonstrates how to set up and initialize an io_uring ring for asynchronous I/O operations. It includes system call wrappers and memory mapping for submission and completion queues. ```c #include #include #include #include #include #include #include #include #include #include #include #include #include #include #define QUEUE_DEPTH 1 #define BLOCK_SZ 1024 /* Macros for barriers needed by io_uring */ #define io_uring_smp_store_release(p, v) \ atomic_store_explicit((_Atomic typeof(*(p)) *)(p), (v), \ memory_order_release) #define io_uring_smp_load_acquire(p) \ atomic_load_explicit((_Atomic typeof(*(p)) *)(p), \ memory_order_acquire) int ring_fd; unsigned *sring_tail, *sring_mask, *sring_array, *cring_head, *cring_tail, *cring_mask; struct io_uring_sqe *sqes; struct io_uring_cqe *cqes; char buff[BLOCK_SZ]; off_t offset; /* * System call wrappers provided since glibc does not yet * provide wrappers for io_uring system calls. * */ int io_uring_setup(unsigned entries, struct io_uring_params *p) { int ret; ret = syscall(__NR_io_uring_setup, entries, p); return (ret < 0) ? -errno : ret; } int io_uring_enter(int ring_fd, unsigned int to_submit, unsigned int min_complete, unsigned int flags) { int ret; ret = syscall(__NR_io_uring_enter, ring_fd, to_submit, min_complete, flags, NULL, 0); return (ret < 0) ? -errno : ret; } int app_setup_uring(void) { struct io_uring_params p; void *sq_ptr, *cq_ptr; /* See io_uring_setup(2) for io_uring_params.flags you can set */ memset(&p, 0, sizeof(p)); ring_fd = io_uring_setup(QUEUE_DEPTH, &p); if (ring_fd < 0) { perror("io_uring_setup"); return 1; } /* * io_uring communication happens via 2 shared kernel-user space ring * buffers, which can be jointly mapped with a single mmap() call in * kernels >= 5.4. */ int sring_sz = p.sq_off.array + p.sq_entries * sizeof(unsigned); int cring_sz = p.cq_off.cqes + p.cq_entries * sizeof(struct io_uring_cqe); /* Rather than check for kernel version, the recommended way is to * check the features field of the io_uring_params structure, which is a * bitmask. If IORING_FEAT_SINGLE_MMAP is set, we can do away with the * second mmap() call to map in the completion ring separately. */ if (p.features & IORING_FEAT_SINGLE_MMAP) { if (cring_sz > sring_sz) sring_sz = cring_sz; cring_sz = sring_sz; } /* Map in the submission and completion queue ring buffers. * Kernels < 5.4 only map in the submission queue, though. */ sq_ptr = mmap(0, sring_sz, PROT_READ | PROT_WRITE, MAP_SHARED | MAP_POPULATE, ring_fd, IORING_OFF_SQ_RING); if (sq_ptr == MAP_FAILED) { perror("mmap"); return 1; } if (p.features & IORING_FEAT_SINGLE_MMAP) { cq_ptr = sq_ptr; } else { /* Map in the completion queue ring buffer in older kernels separately */ cq_ptr = mmap(0, cring_sz, PROT_READ | PROT_WRITE, MAP_SHARED | MAP_POPULATE, ring_fd, IORING_OFF_CQ_RING); if (cq_ptr == MAP_FAILED) { perror("mmap"); return 1; } } /* Save useful fields for later easy reference */ sring_tail = sq_ptr + p.sq_off.tail; sring_mask = sq_ptr + p.sq_off.ring_mask; sring_array = sq_ptr + p.sq_off.array; /* Map in the submission queue entries array */ sqes = mmap(0, p.sq_entries * sizeof(struct io_uring_sqe), PROT_READ | PROT_WRITE, MAP_SHARED | MAP_POPULATE, ring_fd, IORING_OFF_SQES); if (sqes == MAP_FAILED) { perror("mmap"); return 1; } /* Save useful fields for later easy reference */ cring_head = cq_ptr + p.cq_off.head; cring_tail = cq_ptr + p.cq_off.tail; cring_mask = cq_ptr + p.cq_off.ring_mask; cqes = cq_ptr + p.cq_off.cqes; return 0; } /* * Read from completion queue. * In this function, we read completion events from the completion queue. * We dequeue the CQE, update and head and return the result of the operation. * */ int read_from_cq() { struct io_uring_cqe *cqe; unsigned head; /* Read barrier */ ``` -------------------------------- ### Get installed libcurl version Source: https://manpages.ubuntu.com/manpages/stonking/man1/curl-config.1.html Displays the version information of the currently installed libcurl library. ```bash $ curl-config --version ``` -------------------------------- ### sysctl.conf Example Configurations Source: https://manpages.ubuntu.com/manpages/stonking/man5/sysctl.conf.5.html Illustrates how to set kernel parameters, including a domain name and a value containing spaces. ```shell # # kernel.domainname = example.com ; A value containing a space is written to the sysctl. kernel.modprobe = /sbin/mod probe ``` -------------------------------- ### Getting Maximum Buffer Size Source: https://manpages.ubuntu.com/manpages/stonking/man3/getgrgid.3.html Example of how to get the maximum suggested buffer size for reentrant functions. ```c sysconf(_SC_GETGR_R_SIZE_MAX) ``` -------------------------------- ### Setting up a D-Bus connection and publishing an interface Source: https://manpages.ubuntu.com/manpages/stonking/man3/sd_bus_set_watch_bind.3.html This example demonstrates initializing a new bus object, configuring it to wait for D-Bus, setting its address, and publishing an interface. It also shows how to request a well-known name and set up a signal handler for disconnections. The bus is then attached to an event loop. ```c r = sd_bus_new(o->bus); if (r < 0) return log_error(r, "sd_bus_new ()"); r = sd_bus_set_address(*o->bus, "unix:path=/run/dbus/system_bus_socket"); if (r < 0) return log_error(r, "sd_bus_set_address ()"); r = sd_bus_set_bus_client(*o->bus, 1); if (r < 0) return log_error(r, "sd_bus_set_bus_client ()"); r = sd_bus_negotiate_creds(*o->bus, 1, SD_BUS_CREDS_UID|SD_BUS_CREDS_EUID|SD_BUS_CREDS_EFFECTIVE_CAPS); if (r < 0) return log_error(r, "sd_bus_negotiate_creds ()"); r = sd_bus_set_watch_bind(*o->bus, 1); if (r < 0) return log_error(r, "sd_bus_set_watch_bind ()"); r = sd_bus_start(*o->bus); if (r < 0) return log_error(r, "sd_bus_start ()"); /* Publish an interface on the bus, specifying our well-known object access * path and public interface name. * https://www.freedesktop.org/software/systemd/man/sd_bus_add_object.html * https://dbus.freedesktop.org/doc/dbus-tutorial.html */ r = sd_bus_add_object_vtable(*o->bus, NULL, "/org/freedesktop/ReconnectExample", "org.freedesktop.ReconnectExample", vtable, o); if (r < 0) return log_error(r, "sd_bus_add_object_vtable ()"); /* By default, the service is only assigned an ephemeral name. Also add a * well-known one, so that clients know whom to call. This needs to be * asynchronous, as D-Bus might not be yet available. The callback will check * whether the error is expected or not, in case it fails. * https://www.freedesktop.org/software/systemd/man/sd_bus_request_name.html */ r = sd_bus_request_name_async(*o->bus, NULL, "org.freedesktop.ReconnectExample", 0, request_name_callback, o); if (r < 0) return log_error(r, "sd_bus_request_name_async ()"); /* When D-Bus is disconnected this callback will be invoked, which will set up * the connection again. This needs to be asynchronous, as D-Bus might not yet * be available. * https://www.freedesktop.org/software/systemd/man/sd_bus_match_signal_async.html */ r = sd_bus_match_signal_async(*o->bus, NULL, "org.freedesktop.DBus.Local", NULL, "org.freedesktop.DBus.Local", "Disconnected", on_disconnect, NULL, o); if (r < 0) return log_error(r, "sd_bus_match_signal_async ()"); /* Attach the bus object to the event loop so that calls and signals are * processed. * https://www.freedesktop.org/software/systemd/man/sd_bus_attach_event.html */ r = sd_bus_attach_event(*o->bus, *o->event, 0); if (r < 0) return log_error(r, "sd_bus_attach_event ()"); return 0; } ``` -------------------------------- ### Get String Length with tmux Formats Source: https://manpages.ubuntu.com/manpages/stonking/man1/tmux.1.html Expands to the length of the variable. Example gets the length of 'window_name'. ```tmux #{n:window_name} ``` -------------------------------- ### Live Image Boot Examples Source: https://manpages.ubuntu.com/manpages/stonking/man7/dracut.cmdline.7.html Specify the location of your squashed root filesystem for live booting using either a block device or a URL. ```bash root=live:_< path to blockdevice>_ ``` ```bash root=live:_< URL>_ ``` -------------------------------- ### FSCONFIG_CMD_CREATE Example Source: https://manpages.ubuntu.com/manpages/stonking/man2/fsconfig.2.html Use FSCONFIG_CMD_CREATE to instruct the filesystem driver to instantiate a filesystem instance. _key_ and _value_ must be NULL, and _aux_ must be 0. Requires CAP_SYS_ADMIN capability. ```c fsconfig(fd, FSCONFIG_CMD_CREATE, NULL, NULL, 0); ``` -------------------------------- ### rsync --info examples Source: https://manpages.ubuntu.com/manpages/stonking/man1/rsync.1.html Examples demonstrating the use of the --info option for controlling output levels. Use --info=help to see all available flags. ```bash rsync -a --info=progress2 src/ dest/ ``` ```bash rsync -avv --info=stats2,misc1,flist0 src/ dest/ ``` -------------------------------- ### Add Eshell to Load Path (Example) Source: https://manpages.ubuntu.com/manpages/stonking/eshell/eshell.texi.html Example of adding the Eshell installation directory to your load path in .emacs. ```Emacs Lisp (add-to-list 'load-path "/usr/local/share/emacs/site-lisp/eshell") ``` -------------------------------- ### newhelp Input Syntax Example Source: https://manpages.ubuntu.com/manpages/stonking/man1/newhelp.1.html This example demonstrates the basic input syntax for newhelp, showing how to define a performance metric and its description. ```text # # This is an example of newhelp's input syntax # @ kernel.all.cpu.idle CPU idle time A cumulative count of the number of milliseconds of CPU idle time, summed over all processors. ``` -------------------------------- ### Start a policy session Source: https://manpages.ubuntu.com/manpages/stonking/man1/tpm2_startauthsession.1.html This example shows how to start a policy session and save the session data to a file named 'mysession.ctx'. ```APIDOC ## Start a policy session ### Description Starts a policy authorization session with the TPM and saves the session context to a file. ### Command tpm2_startauthsession ### Parameters #### Command Options - **--policy-session** - Optional - Specifies that this is a policy session. - **-S** (string) - Required - Path to save the session context file. ### Example ```bash tpm2_startauthsession --policy-session -S mysession.ctx ``` ``` -------------------------------- ### Start Xdummy with startx Source: https://manpages.ubuntu.com/manpages/stonking/man8/Xdummy.8.html This example shows how to launch Xdummy with display number 2 and a color depth of 16 using startx. ```bash startx -e bash -- Xdummy :2 -depth 16 ``` -------------------------------- ### List available service configurations Source: https://manpages.ubuntu.com/manpages/stonking/man8/initctl.8.html Use 'initctl ls' or 'initctl list' to display all *.conf files present in the /etc/finit.d directory. ```bash initctl ls ``` -------------------------------- ### Get String Width with tmux Formats Source: https://manpages.ubuntu.com/manpages/stonking/man1/tmux.1.html Expands to the width of the variable when displayed. Example gets the display width of 'window_name'. ```tmux #{w:window_name} ``` -------------------------------- ### Example Chains and Bindings Source: https://manpages.ubuntu.com/manpages/stonking/x-symbol/x-symbol.texi.html Illustrates rotate, modify, horizontal, key chains, and their resulting bindings based on the example character description table. ```text Rotate chains: (1w,2w)-1e-1n @r{and} 3w-(2e,3e)-2n. Modify chains: 1w-2w-3w @r{and} 1e-2w-3w and 1n-2n. Horizontal chains: 1e-1w-2e-3e @r{(for modify context @samp{a})} 2w-3w @r{(for modify context @samp{b})} Key chains: 1e-1w-2e-3e @r{(for context @samp{a})} 1e-2w-2e-3w @r{(for context @samp{b})} 1n-1w-2n @r{(for context @samp{c})} 1n @r{(for context @samp{d})} ``` ```text Rotate-to: 1w->1e, 2w->1e, 1e->1n, 1n->1w 3w->2e, 2e->2n, 3e->2n, 2n->3w Modify-to: 1e->1w, 1w->2e, 2e->3e, 3e->1e @r{(horizontal chain)} 2w->3w, 3w->2w @r{(horizontal chain)} 1n->2n, 2n->1n @r{(modify chain with exclusive modify contexts)} CONTEXTS: `a'->1e, `b'->1e, `c'->1n, `d'->1n KEY: `a1'=1e, `a2'=1w, `a3'=2e, `a4'=3e, `b1'=1e, ..., `d'=1n ``` -------------------------------- ### Example GRUB Configuration with Serial Console Source: https://manpages.ubuntu.com/manpages/stonking/man8/dracut.8.html A complete example of a /boot/grub2/grub.cfg file configured for serial console logging. ```grub default=0 timeout=5 serial --unit=0 --speed=9600 terminal --timeout=5 serial console title Fedora (2.6.29.5-191.fc11.x86_64) root (hd0,0) kernel /vmlinuz-2.6.29.5-191.fc11.x86_64 ro root=/dev/mapper/vg_uc1-lv_root console=tty0 console=ttyS0,9600 initrd /dracut-2.6.29.5-191.fc11.x86_64.img ``` -------------------------------- ### Get Session Start Time Source: https://manpages.ubuntu.com/manpages/stonking/man3/sd_session_get_desktop.3.html Retrieve the session's start time in microseconds since the epoch using sd_session_get_start_time. ```c int sd_session_get_start_time(const char **_session_, uint64_t *_usec_); ``` -------------------------------- ### X-Symbol Installer Address and Package URL Source: https://manpages.ubuntu.com/manpages/stonking/x-symbol/x-symbol.texi.html Defines variables for the X-Symbol installer's email address and the package's URL, used for system-wide installation and package web access. ```texinfo @vtable @code @item x-symbol-installer-address E-mail address of the person who has installed package X-Symbol system-wide (@pxref{System-wide Installation}). @item x-symbol-package-url URL of package X-Symbol, used by @code{x-symbol-package-web}. @end vtable ``` -------------------------------- ### Start Image Editor Command Source: https://manpages.ubuntu.com/manpages/stonking/x-symbol/x-symbol.texi.html Starts the image editor and prompts for the image file to edit. ```Emacs Lisp M-x x-symbol-image-editor ``` -------------------------------- ### Displaying Convert Command Help Source: https://manpages.ubuntu.com/manpages/stonking/x-symbol/x-symbol.texi.html Show help for the 'convert' command, used to check ImageMagick installation. ```Shell convert -h ``` -------------------------------- ### Buildah Storage Options Example Source: https://manpages.ubuntu.com/manpages/stonking/man1/buildah.1.html Demonstrates how to specify storage driver options for Buildah. ```bash --storage-opt value ``` -------------------------------- ### Start a named screen window Source: https://manpages.ubuntu.com/manpages/stonking/man1/screen.1.html Use this command in .screenrc to start a specific command in a named window. This example starts 'nice top' in window 2 and names it 'top'. ```shell screen -t top 2 nice top ``` -------------------------------- ### Basic .containerignore Example Source: https://manpages.ubuntu.com/manpages/stonking/man5/containerignore.5.html This example demonstrates basic pattern matching for excluding files and directories. Lines starting with '#' are comments and are ignored. ```ignore # comment */temp* */*/temp* temp? ``` -------------------------------- ### Example of using cap_new_launcher and cap_launch Source: https://manpages.ubuntu.com/manpages/stonking/man3/cap_launch.3.html This example demonstrates creating a launcher for an external command, setting a shared memory detail pointer, invoking the launcher, and then cleaning up the memory. Ensure the detail pointer is correctly managed for inter-process communication. ```c const char *args[] = { "echo", "hello", NULL }; cap_launch_t cmd = cap_new_launcher("/usr/bin/echo", args, NULL); int *detail = mmap(NULL, sizeof(int), PROT_READ | PROT_WRITE, MAP_SHARED | MAP_ANONYMOUS, -1, 0); cap_launcher_callback(cmd, &answer_detail_fn); *detail = 41; pid_t pid = cap_launch(cmd, detail); printf("launcher callback set detail to %d\n", *detail); munmap(detail, sizeof(int)); ``` -------------------------------- ### Example /etc/nsswitch.conf configuration for nss-mymachines Source: https://manpages.ubuntu.com/manpages/stonking/man8/nss-mymachines.8.html This example shows how to correctly configure the /etc/nsswitch.conf file to enable nss-mymachines. It is recommended to place 'mymachines' before 'resolve' or 'dns' to ensure its mappings are preferred. ```shell passwd: files systemd group: files [SUCCESS=merge] systemd shadow: files systemd gshadow: files systemd hosts: **mymachines** resolve [!UNAVAIL=return] files myhostname dns networks: files protocols: db files services: db files ethers: db files rpc: db files netgroup: nis ``` -------------------------------- ### Get Dirname of Variable with tmux Formats Source: https://manpages.ubuntu.com/manpages/stonking/man1/tmux.1.html Returns the dirname (directory path) of a path-like variable. Example gets the dirname of 'some/path/variable'. ```tmux #{d:some/path/variable} ``` -------------------------------- ### Complete AFS File Read Example Source: https://manpages.ubuntu.com/manpages/stonking/man3/AFS%3A%3Aukernel.3.html A complete example demonstrating setup, argument parsing, running the AFS kernel module, opening a file, reading its content, closing the file, and shutting down the AFS environment. Error handling is included using die. ```perl use strict; use AFS::ukernel; use POSIX; my $path = "/afs/localcell/user/adeason/afile"; my $str; my $code; my $fd; $code = AFS::ukernel::uafs_Setup("/afs"); $code == 0 or die("uafs_Setup: $!\n"); $code = AFS::ukernel::uafs_ParseArgs("-afsdb -cachedir /tmp/mycache"); $code == 0 or die("uafs_ParseArgs: $!\n"); $code = AFS::ukernel::uafs_Run(); $code == 0 or due("uafs_Run: $!\n"); $fd = AFS::ukernel::uafs_open($path, POSIX::O_RDONLY); $fd >=0 or die("uafs_open: $fname: $!\n"); ($code, $str) = AFS::ukernel::uafs_read($fd, 4096); $code >= 0 or die("uafs_read: $!\n"); $code = AFS::ukernel::uafs_close($fd); $code == 0 or die("uafs_close: $!\n"); print "The first 4096 bytes of $path are:\n$str\n"; AFS::ukernel::uafs_Shutdown(); ``` -------------------------------- ### Get Basename of Variable with tmux Formats Source: https://manpages.ubuntu.com/manpages/stonking/man1/tmux.1.html Returns the basename (last component) of a path-like variable. Example gets the basename of 'some/path/variable'. ```tmux #{b:some/path/variable} ``` -------------------------------- ### Example Character Description Table Source: https://manpages.ubuntu.com/manpages/stonking/x-symbol/x-symbol.texi.html An example table illustrating character scores, aspects, and contexts. ```text An example: Modify Modify Rotate Rotate Modify Other Score Aspect Score Aspect Context Contexts -------------------------------------------------------------- charsym 1w 150 nil 100 west `a' `c' charsym 2w 200 nil 100 west `b' - charsym 3w 350 big 100 west (`b') (-) charsym 1e 100 nil 200 east (`a') (`b') charsym 2e 250 big 200 east `a' `b' charsym 3e 300 big 200 east `a' - charsym 1n 100 nil 300 north `d' `c' charsym 2n 200 big 300 north `c' - ``` -------------------------------- ### Initialize X-Symbol in Emacs Source: https://manpages.ubuntu.com/manpages/stonking/x-symbol/x-symbol.texi.html Add this line to your ~/.emacs file to initialize X-Symbol during Emacs startup. Ensure ImageMagick is installed for full image support. ```emacs-lisp (x-symbol-initialize) ``` -------------------------------- ### Run Minimal Emacs Configuration Source: https://manpages.ubuntu.com/manpages/stonking/x-symbol/x-symbol.texi.html Command to run Emacs with a specific Lisp file, used to test X-Symbol installations and isolate problems. ```Shell xemacs -no-site-file -q -l @var{my-problem}.el ``` -------------------------------- ### Logging Begin and End of Processing Example Source: https://manpages.ubuntu.com/manpages/stonking/man7/initramfs-tools.7.html Provides an example of using log_begin_msg and log_end_msg to bracket a block of processing, indicating its start and completion. ```sh log_begin_msg "Frobnication begun" # Do something log_end_msg ``` -------------------------------- ### io_setup() Source: https://manpages.ubuntu.com/manpages/stonking/man3/io_setup.3.html Creates an asynchronous I/O context for processing a specified number of operations concurrently. ```APIDOC ## io_setup() ### Description Creates an asynchronous I/O context suitable for concurrently processing _n_ operations. ### Library Asynchronous I/O library (_libaio_, _-laio_) ### Synopsis ```c #include long io_setup(unsigned int *_n_, io_context_t ***_ctx_idp_); ``` ### Return Value On success, **io_setup**() returns 0. On error, a negative error code is returned to indicate the error. ### Errors See **io_setup**(2). ### Standards libaio. ### History libaio. ``` -------------------------------- ### Load Kernel and Initfs with Command Line Source: https://manpages.ubuntu.com/manpages/stonking/man1/0xFFFF.1.html Load a kernel and initfs, then boot the device with a specified command line via USB. ```bash $ 0xFFFF -m initfs: -m kernel: -l -b "" ``` -------------------------------- ### Start an encrypted and bound policy session Source: https://manpages.ubuntu.com/manpages/stonking/man1/tpm2_startauthsession.1.html This example demonstrates starting an encrypted and bound policy session, requiring a primary context file. ```APIDOC ## Start an encrypted and bound policy session ### Description Starts an encrypted and bound policy authorization session with the TPM, using a primary context, and saves the session context to a file. ### Command tpm2_startauthsession ### Parameters #### Command Options - **--policy-session** - Optional - Specifies that this is a policy session. - **-c** (string) - Required - Path to the primary context file. - **-S** (string) - Required - Path to save the session context file. ### Example ```bash tpm2_createprimary -c primary.ctx tpm2_startauthsession --policy-session -c primary.ctx -S mysession.ctx ``` ``` -------------------------------- ### Check Message Log in Emacs Source: https://manpages.ubuntu.com/manpages/stonking/x-symbol/x-symbol.texi.html Type 'M-x show-message-log' to check for any problems or errors that occurred during file loading after installation. ```emacs-lisp M-x show-message-log ``` -------------------------------- ### nfacct accounting data example Source: https://manpages.ubuntu.com/manpages/stonking/man8/iptables-extensions.8.html Example output from 'nfacct get http-traffic', showing the packet and byte counts for the 'http-traffic' accounting object. ```json { "pkts" = 00000000000000000156, "bytes" = 00000000000000151786 } = http-traffic; ``` -------------------------------- ### Displaying Images in HTML Source: https://manpages.ubuntu.com/manpages/stonking/x-symbol/x-symbol.texi.html This example demonstrates the HTML img tag format recognized by X-Symbol for displaying images. The '@var{ext}' placeholder represents image file extensions like gif, png, or jpeg. ```HTML ``` -------------------------------- ### Example Character Definition Source: https://manpages.ubuntu.com/manpages/stonking/x-symbol/x-symbol.texi.html An example of defining a character with its score and associated symbols in a character table. ```lisp (aacute 225 (acute "a" Aacute)) ``` -------------------------------- ### Example cdrskin Startup File Content Source: https://manpages.ubuntu.com/manpages/stonking/man1/cdrskin.1.html Demonstrates the format of a cdrskin startup file, including device selection and other options. Lines starting with '#' are comments, and empty lines are ignored. ```shell # This is the default device dev=0,1,0 # Some more options fifo_start_at=0 fs=16m ``` -------------------------------- ### Multihead Configuration Example Source: https://manpages.ubuntu.com/manpages/stonking/man4/glide.4.html An example xorg.conf snippet demonstrating a multihead setup with the fbdev driver for the first monitor and the glide driver for the second. ```xorg.conf **Section "Monitor"** ** Identifier "Monitor 1"** ** VendorName "Unknown"** ** ModelName "Unknown"** ** HorizSync 30-70** ** VertRefresh 50-80** ``` -------------------------------- ### Example of checking thin provisioning metadata Source: https://manpages.ubuntu.com/manpages/stonking/man8/thin_check.8.html This example demonstrates how to analyze the thin provisioning metadata on a logical volume. Ensure the device is not actively used by the thin target during this operation. ```bash $ thin_check /dev/vg/metadata ``` -------------------------------- ### Start gpg-agent for SSH Agent Source: https://manpages.ubuntu.com/manpages/stonking/man1/gpg-agent.1.html Use this command to start the gpg-agent specifically for its Secure Shell Agent functionality. No additional setup is required. ```bash gpg-connect-agent /bye ``` -------------------------------- ### Querying Locale for Character Encoding Source: https://manpages.ubuntu.com/manpages/stonking/x-symbol/x-symbol.texi.html This example demonstrates how to query the system's locale settings to determine the character encoding. This information is used by X-Symbol to identify the normal file encoding, especially in environments without Mule support. ```Shell locale -ck code_set_name charmap ``` -------------------------------- ### Show a service configuration Source: https://manpages.ubuntu.com/manpages/stonking/man8/initctl.8.html Use 'initctl show' to display the content of a specified .conf file in /etc/finit.d/available. ```bash initctl show CONF ``` -------------------------------- ### Getting Server Info in ZenIRC Source: https://manpages.ubuntu.com/manpages/stonking/zenirc/zenirc.texi.html Use the /info command to get various details about a server, including version, compile date, and start time. ```irc /info [server] ``` -------------------------------- ### Get capture file start and end times Source: https://manpages.ubuntu.com/manpages/stonking/man1/mergecap.1.html Use capinfos to determine the start and end times of capture files, which are necessary for time adjustments. ```bash capinfos -aeS a.pcap b.pcap ``` -------------------------------- ### D-Bus Connection and Event Loop Setup in C Source: https://manpages.ubuntu.com/manpages/stonking/man8/systemd-soft-reboot.service.8.html This example demonstrates setting up a D-Bus connection and an event loop in C using systemd libraries. It includes signal handling for graceful termination and asynchronous D-Bus signal matching. Ensure proper initialization and cleanup of D-Bus and event loop resources. ```c int main(int argc, char **argv) { /* The bus should be relinquished before the program terminates. The cleanup * attribute allows us to do it nicely and cleanly whenever we exit the block. */ _cleanup_(sd_bus_flush_close_unrefp) sd_bus *bus = NULL; _cleanup_(sd_event_unrefp) sd_event *event = NULL; object o = { .example = "example", .bus = &bus, .event = &event, }; int r; /* Create an event loop data structure, with default parameters. * https://www.freedesktop.org/software/systemd/man/sd_event_default.html */ r = sd_event_default(&event); if (r < 0) return log_error(r, "sd_event_default()") ; /* By default, the event loop will terminate when all sources have disappeared, * so we have to keep it 'occupied'. Register signal handling to do so. * https://www.freedesktop.org/software/systemd/man/sd_event_add_signal.html */ r = sd_event_add_signal(event, NULL, SIGINT|SD_EVENT_SIGNAL_PROCMASK, NULL, NULL); if (r < 0) return log_error(r, "sd_event_add_signal(SIGINT)"); r = sd_event_add_signal(event, NULL, SIGTERM|SD_EVENT_SIGNAL_PROCMASK, NULL, NULL); if (r < 0) return log_error(r, "sd_event_add_signal(SIGTERM)"); r = setup(&o); if (r < 0) return EXIT_FAILURE; /* Enter the main loop, it will exit only on sigint/sigterm. * https://www.freedesktop.org/software/systemd/man/sd_event_loop.html */ r = sd_event_loop(event); if (r < 0) return log_error(r, "sd_event_loop()") ; /* https://www.freedesktop.org/software/systemd/man/sd_bus_release_name.html */ r = sd_bus_release_name(bus, "org.freedesktop.ReconnectExample"); if (r < 0) return log_error(r, "sd_bus_release_name()") ; return 0; } ``` -------------------------------- ### Start a container instance with sudo Source: https://manpages.ubuntu.com/manpages/stonking/man8/runc-spec.8.html Use this command when the runc process requires root privileges to start a container instance. Ensure you have sudo installed and configured. ```bash sudo runc start container1 ``` -------------------------------- ### Finit Templating Example Source: https://manpages.ubuntu.com/manpages/stonking/man5/finit.conf.5.html Demonstrates how to use Finit's templating feature, similar to systemd, to instantiate services with dynamic parameters. Use '%i' as a placeholder for the instance name. ```bash $ initctl show avahi-autoipd@ service :%i avahi-autoipd --syslog %i -- ZeroConf for %i ``` ```bash $ initctl enable avahi-autoipd@eth0.conf ``` ```bash $ initctl status avahi-autoipd:eth0 ``` -------------------------------- ### Start Image Editor with Mouse Button 2 Source: https://manpages.ubuntu.com/manpages/stonking/x-symbol/x-symbol.texi.html Initiates the image editor for a highlighted image using the second mouse button. If the image is in the search path, it edits the existing file; otherwise, it opens a new file in the first search path directory. ```Emacs Lisp @key{button2} ``` -------------------------------- ### iptables conntrack example: Match related connections Source: https://manpages.ubuntu.com/manpages/stonking/man8/iptables-extensions.8.html This example matches packets that are starting a new connection but are associated with an existing one, such as FTP data transfers. ```bash iptables -m conntrack --ctstate RELATED ``` -------------------------------- ### Example Input Definition for aacute Source: https://manpages.ubuntu.com/manpages/stonking/x-symbol/x-symbol.texi.html Defines the 'aacute' character with specific contexts and modifications to its score. It uses the 'acute' group and 'a' subgroup, with defined input sequences. ```lisp (acute 0 "%s'" t "'%s") ``` -------------------------------- ### iptables conntrack example: Match new connections Source: https://manpages.ubuntu.com/manpages/stonking/man8/iptables-extensions.8.html This example matches packets that are starting a new connection or are associated with a connection that has not yet seen packets in both directions. ```bash iptables -m conntrack --ctstate NEW ```