### Example Environment Variable Setup Source: https://manpages.ubuntu.com/manpages/jammy/man5/environment.d.5.html Sets environment variables to allow access to a program installed in /opt/foo. Demonstrates basic assignment, PATH modification, and referencing existing variables with fallbacks. ```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 Project Configuration File Source: https://manpages.ubuntu.com/manpages/jammy/man1/man1/worklog.1.html This is an example of a project configuration file for worklog. Each line defines a project key and its name, with comments starting with '#'. ```shell # Worklog project file # note that projects appear in Worklog in REVERSE order B:BOWER consultation L:LIS consultation R:Research D:DEC system administration P:Problems email S:Sugar administration r:Reading NetNews ``` -------------------------------- ### Example Configuration for virtio-net Module Source: https://manpages.ubuntu.com/manpages/jammy/man5/modules-load.d.5.html This example shows a configuration file for loading the 'virtio-net' kernel module at boot. Empty lines and lines starting with '#' or ';' are ignored. ```shell # Load virtio-net.ko at boot virtio-net ``` -------------------------------- ### Display WMI status information Source: https://manpages.ubuntu.com/manpages/jammy/man4/acpi_wmi.4freebsd.html Read the WMI status device to get information about GUIDs found in the system. This output shows example data. ```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-0AE0-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 ``` -------------------------------- ### Basic Loop Device Setup and Usage Source: https://manpages.ubuntu.com/manpages/jammy/man8/losetup.8.html This example demonstrates the common workflow of creating a file, setting it up as a loop device, formatting it, mounting it, and then unmounting and 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 ``` -------------------------------- ### Initial Mount Points Setup Source: https://manpages.ubuntu.com/manpages/jammy/man7/mount_namespaces.7.html Sets up the initial mount points on the system before demonstrating the 'unbindable' mount example. This involves listing existing mounts. ```bash # **mount | awk '{print $1, $2, $3}'** /dev/sda1 on / /dev/sdb6 on /mntX /dev/sdb7 on /mntY ``` -------------------------------- ### Default Startup Applications Example Source: https://manpages.ubuntu.com/manpages/jammy/man1/xsm.1.html A sample startup file for xsm, listing applications to be launched when a session begins. ```bash twm smproxy xterm ``` -------------------------------- ### Perl Module Installation Example Source: https://manpages.ubuntu.com/manpages/jammy/skk/skk-faq.texi.html Example of installing a Perl module from CPAN for SKK customization. ```Perl CPAN modules/by-category/Development_Support/Make-1.00.tar.gz ``` -------------------------------- ### Example Usage of pktsetup Source: https://manpages.ubuntu.com/manpages/jammy/man8/pktsetup.8.html Demonstrates the typical workflow for setting up a packet device, mounting it, and then tearing down the association. ```bash cdrwtool -d /dev/sr0 -q pktsetup 0 /dev/sr0 mount -t udf /dev/pktcdvd0 /mnt ... umount /dev/pktcdvd0 pktsetup -d 0 ``` -------------------------------- ### Start SystemTap server for all installed kernels Source: https://manpages.ubuntu.com/manpages/jammy/man8/stap-server.8.html This command starts the SystemTap compile server and configures it to handle all kernel versions installed in the /lib/modules directory. ```bash [ service ] stap-server start -i ``` -------------------------------- ### Configuration File Example 2 Source: https://manpages.ubuntu.com/manpages/jammy/man1/curl.1.html Shows how to specify multiple URLs and referer headers within a configuration file. ```bash # and fetch another URL too url = "example.com/docs/manpage.html" -O referer = "http://nowhereatall.example.com/" # --- End of example file --- ``` -------------------------------- ### Get Language Example Source: https://manpages.ubuntu.com/manpages/jammy/MANUAL.ps.html This snippet shows how to get the language. ```PostScript get language (e ``` -------------------------------- ### Xsetup Script Example Source: https://manpages.ubuntu.com/manpages/jammy/man1/xdm.1.html A sample shell script for the Xsetup file, which runs after the server is reset but before the login window is offered. It includes commands to configure X color management and start a console window. ```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 & ``` -------------------------------- ### NFS mount pivot_root example Source: https://manpages.ubuntu.com/manpages/jammy/man8/pivot_root.8.html This example demonstrates mounting a new root over NFS and then using pivot_root to switch to it. It includes necessary setup like configuring the loopback interface, starting portmap, mounting the NFS share, and then executing init within the new root context. It also shows how to handle potential issues like portmap keeping the old root busy. ```bash ifconfig lo 127.0.0.1 up # for portmap # configure Ethernet or such portmap # for lockd (implicitly started by mount) mount -o ro 10.0.0.1:/my_root /mnt killall portmap # portmap keeps old root busy cd /mnt pivot_root . old_root exec chroot . sh -c 'umount /old_root; exec /sbin/init' \ dev/console 2>&1 ``` -------------------------------- ### Option Syntax Examples Source: https://manpages.ubuntu.com/manpages/jammy/man5/xorg.conf.d.5.html Illustrates equivalent ways to set or negate options using the 'Option' keyword. Useful for understanding flexible configuration settings. ```xorg.conf Option "Accel" "Off" Option "NoAccel" ``` ```xorg.conf Option "NoAccel" "On" Option "Accel" "false" ``` ```xorg.conf Option "Accel" "no" ``` -------------------------------- ### SKK Undo Kanji Conversion Example Source: https://manpages.ubuntu.com/manpages/jammy/skk/skk.texi.html Example of undoing a Kanji conversion in SKK. It shows inputting '333' and then pressing SPC to get '亜', and then pressing SPC again to get 'あ'. ```emacs-lisp @example ?$B$3$&$3$&?(B /?$B9b9;?(B/?$B9'9T?(B/?$B9R9T?(B/ @end example ``` -------------------------------- ### Get installed libcurl version Source: https://manpages.ubuntu.com/manpages/jammy/man1/curl-config.1.html This command displays the version information of the currently installed libcurl. ```bash curl-config --version ``` -------------------------------- ### Example usage of get_nprocs_conf and get_nprocs Source: https://manpages.ubuntu.com/manpages/jammy/man3/get_nprocs_conf.3.html This C code example demonstrates how to use `get_nprocs_conf()` to get the number of configured processors and `get_nprocs()` to get the number of available processors, printing the results to standard output. ```c #include #include #include int main(int argc, char *argv[]) { printf("This system has %d processors configured and " "%d processors available.\n", get_nprocs_conf(), get_nprocs()); exit(EXIT_SUCCESS); } ``` -------------------------------- ### execle Example Source: https://manpages.ubuntu.com/manpages/jammy/man3/execvp.3.html Shows how to use execle to replace the current process and specify a custom environment for the new process. Arguments are passed as a list. ```c int execle(const char *pathname, const char *arg, ... /*, (char *) NULL, char *const envp[] */); ``` -------------------------------- ### Example .pc file structure Source: https://manpages.ubuntu.com/manpages/jammy/man5/pc.5.html Demonstrates the basic structure of a .pc file, including comments, variable definitions, and various properties like Name, Version, Libs, and Cflags. ```pkgconfig # This is a comment prefix=/home/kaniini/pkg # this defines a variable exec_prefix=${prefix} # defining another variable with a substitution libdir=${exec_prefix}/lib includedir=${prefix}/include Name: libfoo # human-readable name Description: an example library called libfoo # human-readable description Version: 1.0 URL: http://www.pkgconf.org Requires: libbar > 2.0.0 Conflicts: libbaz <= 3.0.0 Libs: -L${libdir} -lfoo Libs.private: -lm Cflags: -I${includedir}/libfoo ``` -------------------------------- ### Install a custom SELinux module Source: https://manpages.ubuntu.com/manpages/jammy/man8/semanage-module.8.html Use this command to install a custom SELinux policy module. The example shows installing a module named 'myapache'. ```bash # semanage module -a myapache ``` -------------------------------- ### Pre-configured Options File Example Source: https://manpages.ubuntu.com/manpages/jammy/man1/keytool.1.html An example of a pre-configured options file for keytool, demonstrating how to set default options for all commands ('keytool.all') and specific commands ('keytool.list', 'keytool.genkeypair'). ```properties # A tiny pre-configured options file keytool.all = -keystore ${user.home}/ks keytool.list = -v keytool.genkeypair = -keyalg rsa ``` -------------------------------- ### Tmux String Truncation from Start Example Source: https://manpages.ubuntu.com/manpages/jammy/man1/tmux.1.html Limits the pane title to a maximum of 5 characters from the start. ```tmux #{=5:pane_title} ``` -------------------------------- ### Get Resource Start Address Source: https://manpages.ubuntu.com/manpages/jammy/man9/rman.9.html Retrieves the starting address of a resource. Requires a valid resource structure. ```c #include #include rman_res_t rman_get_start(struct resource *r); ``` -------------------------------- ### Setting up play directories for symlinks example Source: https://manpages.ubuntu.com/manpages/jammy/man1/tcsh.1.html This snippet demonstrates the setup of directories and a symbolic link for testing the 'symlinks' variable behavior. ```shell > cd /tmp > mkdir from from/src to > ln -s from/src to/dst ``` -------------------------------- ### Get Information About an Application Source: https://manpages.ubuntu.com/manpages/jammy/man1/flatpak-remote-info.1.html This example shows how to retrieve detailed information about the 'org.gnome.gedit' application from the 'flathub' remote repository using the user installation. The output includes the matched ref, application ID, architecture, branch, build date, commit details, size information, and the associated runtime. ```bash $ flatpak --user remote-info flathub org.gnome.gedit ``` -------------------------------- ### Compile and run key_instantiate example Source: https://manpages.ubuntu.com/manpages/jammy/man2/keyctl.2.html This snippet demonstrates how to compile the C example program 'key_instantiate.c' using GCC, link it with '-lkeyutils', and then use it to temporarily replace the system's 'request-key' program to instantiate a key. It also shows how to revert to the original 'request-key' program. ```shell $ **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 Configuration in files.arch Source: https://manpages.ubuntu.com/manpages/jammy/man9/firmware.9.html This example from sys/arm/xscale/ixp425/files.ixp425 shows how to embed firmware images. It requires tools like awk, make, compiler, and linker. ```makefile ixp425_npe_fw.c optional npe_fw \ compile-with "${AWK} -f $S/tools/fw_stub.awk IxNpeMicrocode.dat:npe_fw -mnpe -c${.TARGET}" \ no-implicit-rule before-depend local \ clean "ixp425_npe_fw.c" ``` ```makefile IxNpeMicrocode.fwo optional npe_fw \ dependency "IxNpeMicrocode.dat" \ compile-with "${LD} -b binary -d -warn-common \ -r -d -o ${.TARGET} IxNpeMicrocode.dat" \ no-implicit-rule \ clean "IxNpeMicrocode.fwo" ``` ```makefile IxNpeMicrocode.dat optional npe_fw \ dependency ".PHONY" \ compile-with "uudecode < $S/contrib/dev/npe/IxNpeMicrocode.dat.uu" \ no-obj no-implicit-rule \ clean "IxNpeMicrocode.dat" ``` -------------------------------- ### Run a Container Source: https://manpages.ubuntu.com/manpages/jammy/man1/docker-run.1.html Starts a new container in detached mode, interactive, and with a pseudo-TTY. This is a basic example to start a container. ```bash # docker run --name=link-test -d -i -t fedora/httpd ``` -------------------------------- ### List installed rlwrap filters Source: https://manpages.ubuntu.com/manpages/jammy/man1/rlwrap.1.html Use the -z option to get a list of all currently installed rlwrap filters. ```bash rlwrap -z listing ``` -------------------------------- ### Create Initial Files Source: https://manpages.ubuntu.com/manpages/jammy/man7/gitcore-tutorial.7.html Create two sample files in the working directory to begin tracking with Git. ```bash $ echo "Hello World" >hello $ echo "Silly example" >example ``` -------------------------------- ### pmrep.conf Example Configuration Source: https://manpages.ubuntu.com/manpages/jammy/man5/pmrep.conf.5.html This example demonstrates setting local options, defining global metrics using compact and verbose forms, and configuring metricsets for different data sources. It shows how to specify default reporting values and mimic existing tools. ```config [options] timestamp = yes interval = 2s extheader = yes repeat_header = auto space_scale = MB [global] kernel.all.sysfork = forks,,,,8 allcache = mem.util.allcache allcache.formula = mem.util.bufmem + mem.util.cached + mem.util.slab allcache.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 ``` -------------------------------- ### rpm Command Usage Examples Source: https://manpages.ubuntu.com/manpages/jammy/man1/busybox.1.html Manipulates RPM packages. Examples show installing a package and querying package information. ```bash rpm -i PACKAGE.rpm; rpm -qp[ildc] PACKAGE.rpm ``` -------------------------------- ### Implement -x Option Example Source: https://manpages.ubuntu.com/manpages/jammy/man1/hexdump.1.html Demonstrates how to implement the functionality of the -x option using format strings. ```shell "%07.7_Ax\n" "%07.7_ax " 8/2 "%04x " "\n" ``` -------------------------------- ### Filter Locales by Prefix Source: https://manpages.ubuntu.com/manpages/jammy/man8/zypper.8.html Retrieves locales that start with a specific language code. The example shows locales starting with 'en'. ```bash zypper locales en_ ``` ```bash zypper locales en * ``` -------------------------------- ### Example: Configuring and Verifying Hostnames Source: https://manpages.ubuntu.com/manpages/jammy/man3/SSL_add1_host.3.html This example demonstrates setting hostnames for verification, including primary and additional hostnames, and then checking the verification result. It retrieves the matched peername if verification is successful. ```c SSL_set_hostflags(ssl, X509_CHECK_FLAG_NO_PARTIAL_WILDCARDS); if (!SSL_set1_host(ssl, "smtp.example.com")) /* error */ if (!SSL_add1_host(ssl, "example.com")) /* error */ /* XXX: Perform SSL_connect() handshake and handle errors here */ if (SSL_get_verify_result(ssl) == X509_V_OK) { const char *peername = SSL_get0_peername(ssl); if (peername != NULL) /* Name checks were in scope and matched the peername */ } ``` -------------------------------- ### Example: Skip 'doc*' Directory Source: https://manpages.ubuntu.com/manpages/jammy/man1/git-svn.1.html An example of using the --ignore-paths option to skip any path starting with 'doc' during fetches. ```shell --ignore-paths="^doc" ``` -------------------------------- ### Extracting an afio archive from a specific track Source: https://manpages.ubuntu.com/manpages/jammy/man1/cdrskin.1.html This example demonstrates how to retrieve an afio archive from a specific track on a CD. It uses cdrskin to get the table of contents, then processes the output with grep, tail, and awk to find the track's starting LBA. Finally, it uses dd to extract the data and pipes it to afio. ```bash tracknumber=2 lba=$(cdrskin dev=/dev/cdrom -toc 2>&1 | \ grep '^track:[ ]*[ 0-9][0-9]' | \ tail +"$tracknumber" | head -1 | \ awk '{ print $4}') dd if=/dev/cdrom bs=2048 skip="$lba" | \ afi o -t - | less ``` -------------------------------- ### Example: setq for generating 'fortran' Source: https://manpages.ubuntu.com/manpages/jammy/MANUAL.ps.html Demonstrates the use of 'setq' to generate 'fortran'. This is a basic example of variable assignment and generation. ```ps <1>: (setq *gentran 'fortran) ``` -------------------------------- ### Start Process Accounting Source: https://manpages.ubuntu.com/manpages/jammy/man5/acct.5.html Example of how to start process accounting by calling the acct(2) system call with the path to the accounting file. ```c #include acct("/var/log/pacct"); ``` -------------------------------- ### Example /etc/nsswitch.conf configuration for nss-resolve Source: https://manpages.ubuntu.com/manpages/jammy/man8/nss-resolve.8.html This example demonstrates the recommended configuration for /etc/nsswitch.conf to enable nss-resolve. It shows the correct ordering of 'mymachines', 'resolve', 'files', 'myhostname', and 'dns' for host lookups. ```shell passwd: compat systemd group: compat [SUCCESS=merge] systemd shadow: compat 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 ``` -------------------------------- ### Example: setq for generating 'c' Source: https://manpages.ubuntu.com/manpages/jammy/MANUAL.ps.html Demonstrates using 'setq' to generate 'c'. This is a specific use case for generating C code. ```ps <1>: (setq *gentran 'c) ``` -------------------------------- ### Interactive Program Notice Example Source: https://manpages.ubuntu.com/manpages/jammy/man7/gpl.7.html Example of a notice to display when an interactive program starts, informing users about its warranty status and redistribution conditions. ```text Gnomovision version 69, Copyright (C) Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. ``` -------------------------------- ### Example usage of thin_rmap with a region Source: https://manpages.ubuntu.com/manpages/jammy/man8/thin_rmap.8.html An example of how to run the thin_rmap command to get the reverse map for a specific region of blocks on a metadata device. ```bash $ **thin_rmap** **--region** 5..45 /dev/pool-metadata ``` -------------------------------- ### Interactive Ethernet Connection Setup Source: https://manpages.ubuntu.com/manpages/jammy/man7/nmcli-examples.7.html This example demonstrates an interactive session for creating an Ethernet connection profile with static IP addressing and DNS configuration. ```bash nmcli> verify Verify connection: OK nmcli> save Connection 'ethernet-4' (de89cdeb-a3e1-4d53-8fa0-c22546c775f4) successfully saved. nmcli> quit ``` -------------------------------- ### Install and Initialize Prompt Themes Source: https://manpages.ubuntu.com/manpages/jammy/man1/zshcontrib.1.html Add custom prompt theme functions to fpath, autoload promptinit, and initialize the prompt system. Assumes functions are in ~/myfns. ```zsh fpath=(~/myfns $fpath) autoload -U promptinit promptinit ``` -------------------------------- ### Example Flatpak Installation Configuration Source: https://manpages.ubuntu.com/manpages/jammy/man5/flatpak-installation.5.html Defines an additional system-wide flatpak installation named 'extra' located at /location/of/sdcard, intended for use with an SD card. ```ini [Installation "extra"] Path=/location/of/sdcard DisplayName=Extra Installation StorageType=sdcard ``` -------------------------------- ### Conjunctive Flow Setup Example Source: https://manpages.ubuntu.com/manpages/jammy/man7/ovs-fields.7.html This example demonstrates setting up a conjunctive flow using the 'conjunction' action. It includes flows for matching IP source and destination, and a final flow matching the conjunctive ID. ```openflow conj_id=1234 actions=controller ip,ip_src=10.0.0.1 actions=conjunction(1234, 1/2) ip,ip_src=10.0.0.4 actions=conjunction(1234, 1/2) ip,ip_src=10.0.0.6 actions=conjunction(1234, 1/2) ip,ip_src=10.0.0.7 actions=conjunction(1234, 1/2) ip,ip_dst=10.0.0.2 actions=conjunction(1234, 2/2) ip,ip_dst=10.0.0.5 actions=conjunction(1234, 2/2) ip,ip_dst=10.0.0.7 actions=conjunction(1234, 2/2) ip,ip_dst=10.0.0.8 actions=conjunction(1234, 2/2) ``` -------------------------------- ### dracut --fscks example Source: https://manpages.ubuntu.com/manpages/jammy/man8/dracut.8.html Example of adding a list of fsck tools to the initramfs. The installation is opportunistic. Enclose multiple tool names in quotes. ```bash # dracut --fscks "fsck1 fsck2" ... ``` -------------------------------- ### Example: Starting a New Cookie Session with libcurl Source: https://manpages.ubuntu.com/manpages/jammy/man3/CURLOPT_COOKIESESSION.3.html Demonstrates how to use CURLOPT_COOKIESESSION to start a new cookie session and load non-session cookies from a file. ```c CURL *curl = curl_easy_init(); if(curl) { curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/foo.bin"); /* new "session", do not load session cookies */ curl_easy_setopt(curl, CURLOPT_COOKIESESSION, 1L); /* get the (non session) cookies from this file */ curl_easy_setopt(curl, CURLOPT_COOKIEFILE, "/tmp/cookies.txt"); ret = curl_easy_perform(curl); curl_easy_cleanup(curl); } ``` -------------------------------- ### Example GRUB Configuration with Serial Console Source: https://manpages.ubuntu.com/manpages/jammy/man8/dracut.8.html A complete example of a GRUB configuration file including serial console settings and kernel arguments. ```bash 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 ``` -------------------------------- ### Start pmdatxmon agent Source: https://manpages.ubuntu.com/manpages/jammy/man1/pmdatxmon.1.html pmdatxmon is launched by pmcd and should never be executed directly. The Install and Remove scripts notify pmcd when the agent is installed or removed. ```shell $PCP_PMDAS_DIR/txmon/pmdatxmon [ -d domain ] [ -l logfile ] [ -U username ] _tx_type ... ``` -------------------------------- ### Example: Output file list (current-output) Source: https://manpages.ubuntu.com/manpages/jammy/MANUAL.ps.html This example demonstrates how to manage the current output file list. It shows the basic structure for specifying output files. ```ps |current-output| v ++++++++++++++++++++ |t | ``` -------------------------------- ### Example: Starting git bisect for a bug fix Source: https://manpages.ubuntu.com/manpages/jammy/man1/git-bisect.1.html Start a bisect session to find the commit that fixed a bug, using 'fixed' and 'broken' as custom terms. ```bash git bisect start --term-new fixed --term-old broken ``` -------------------------------- ### Example: Setting an Executable to Spawn Source: https://manpages.ubuntu.com/manpages/jammy/man3/sd_bus_set_exec.3.html Configures a list of addresses for bus brokers to try connecting to. This example specifies an executable path and arguments to spawn. ```c int ret; ret = sd_bus_set_address(bus, "unixexec:path=/usr/bin/my-bus-daemon,argv1=--foreground,argv2=--log-level=debug"); ``` -------------------------------- ### Install SysV init script with default links Source: https://manpages.ubuntu.com/manpages/jammy/man8/update-rc.d.8.html Use this command to install a SysV init script with default start and stop dependencies and runlevel configurations. ```bash update-rc.d foobar defaults ``` -------------------------------- ### Key Instantiation Example (C) Source: https://manpages.ubuntu.com/manpages/jammy/man2/keyctl.2.html This C code demonstrates how to instantiate a key using the KEYCTL_INSTANTIATE operation. It logs various details about the key and its associated data to a file. Ensure the necessary headers are included and the program is executed with appropriate arguments. ```c #include #include #include #include #include #include #include #include #include #include #ifndef KEY_SPEC_REQUESTOR_KEYRING #define KEY_SPEC_REQUESTOR_KEYRING -8 #endif int main(int argc, char *argv[]) { FILE *fp; time_t t; char *operation; key_serial_t key_to_instantiate, dest_keyring; key_serial_t thread_keyring, process_keyring, session_keyring; uid_t uid; gid_t gid; char dbuf[256]; char auth_key_payload[256]; int akp_size; /* Size of auth_key_payload */ int auth_key; fp = fopen("/tmp/key_instantiate.log", "w"); if (fp == NULL) exit(EXIT_FAILURE); setbuf(fp, NULL); t = time(NULL); fprintf(fp, "Time: %s\n", ctime(&t)); /* * The kernel passes a fixed set of arguments to the program * that it execs; fetch them. */ operation = argv[1]; key_to_instantiate = atoi(argv[2]); uid = atoi(argv[3]); gid = atoi(argv[4]); thread_keyring = atoi(argv[5]); process_keyring = atoi(argv[6]); session_keyring = atoi(argv[7]); fprintf(fp, "Command line arguments:\n"); fprintf(fp, " argv[0]: %s\n", argv[0]); fprintf(fp, " operation: %s\n", operation); fprintf(fp, " key_to_instantiate: %jx\n", (uintmax_t) key_to_instantiate); fprintf(fp, " UID: %jd\n", (intmax_t) uid); fprintf(fp, " GID: %jd\n", (intmax_t) gid); fprintf(fp, " thread_keyring: %jx\n", (uintmax_t) thread_keyring); fprintf(fp, " process_keyring: %jx\n", (uintmax_t) process_keyring); fprintf(fp, " session_keyring: %jx\n", (uintmax_t) session_keyring); fprintf(fp, "\n"); /* * Assume the authority to instantiate the key named in argv[2] */ if (keyctl(KEYCTL_ASSUME_AUTHORITY, key_to_instantiate) == -1) { fprintf(fp, "KEYCTL_ASSUME_AUTHORITY failed: %s\n", strerror(errno)); exit(EXIT_FAILURE); } /* * Fetch the description of the key that is to be instantiated */ if (keyctl(KEYCTL_DESCRIBE, key_to_instantiate, dbuf, sizeof(dbuf)) == -1) { fprintf(fp, "KEYCTL_DESCRIBE failed: %s\n", strerror(errno)); exit(EXIT_FAILURE); } fprintf(fp, "Key description: %s\n", dbuf); /* * Fetch the payload of the authorization key, which is * actually the callout data given to request_key() */ akp_size = keyctl(KEYCTL_READ, KEY_SPEC_REQKEY_AUTH_KEY, auth_key_payload, sizeof(auth_key_payload)); if (akp_size == -1) { fprintf(fp, "KEYCTL_READ failed: %s\n", strerror(errno)); exit(EXIT_FAILURE); } auth_key_payload[akp_size] = '\0'; fprintf(fp, "Auth key payload: %s\n", auth_key_payload); /* * For interest, get the ID of the authorization key and * display it. */ auth_key = keyctl(KEYCTL_GET_KEYRING_ID, KEY_SPEC_REQKEY_AUTH_KEY); if (auth_key == -1) { fprintf(fp, "KEYCTL_GET_KEYRING_ID failed: %s\n", strerror(errno)); exit(EXIT_FAILURE); } fprintf(fp, "Auth key ID: %jx\n", (uintmax_t) auth_key); /* * Fetch key ID for the request_key(2) destination keyring. */ dest_keyring = keyctl(KEYCTL_GET_KEYRING_ID, KEY_SPEC_REQUESTOR_KEYRING); if (dest_keyring == -1) { fprintf(fp, "KEYCTL_GET_KEYRING_ID failed: %s\n", strerror(errno)); exit(EXIT_FAILURE); } fprintf(fp, "Destination keyring: %jx\n", (uintmax_t) dest_keyring); /* * Fetch the description of the authorization key. This * allows us to see the key type, UID, GID, permissions, * and description (name) of the key. Among other things, * we will see that the name of the key is a hexadecimal * string representing the ID of the key to be instantiated. */ if (keyctl(KEYCTL_DESCRIBE, KEY_SPEC_REQKEY_AUTH_KEY, dbuf, sizeof(dbuf)) == -1) { fprintf(fp, "KEYCTL_DESCRIBE failed: %s\n", strerror(errno)); exit(EXIT_FAILURE); } fprintf(fp, "Auth key description: %s\n", dbuf); /* * Instantiate the key using the callout data that was supplied * in the payload of the authorization key. */ if (keyctl(KEYCTL_INSTANTIATE, key_to_instantiate, auth_key_payload, akp_size + 1, dest_keyring) == -1) { fprintf(fp, "KEYCTL_INSTANTIATE failed: %s\n", strerror(errno)); exit(EXIT_FAILURE); } exit(EXIT_SUCCESS); } ``` -------------------------------- ### Setting Initial Heap Size Source: https://manpages.ubuntu.com/manpages/jammy/man1/java.1.html Examples demonstrating how to set the initial heap size using different units (bytes, kilobytes, megabytes). ```bash -XX:InitialHeapSize=6291456 ``` ```bash -XX:InitialHeapSize=6144k ``` ```bash -XX:InitialHeapSize=6m ```