### Installing an example entry in inetd.conf Source: https://www.debian.org/doc/debian-policy/_sources/ch-customized-programs.rst.txt When installing an example entry into /etc/inetd.conf, it must be commented out with a hash. This prevents it from being activated during package updates. ```text # ftp ftp /usr/sbin/in.ftpd -l ``` -------------------------------- ### Debian Install File Example Source: https://www.debian.org/doc/manuals/debmake-doc/debmake-doc.en.txt A debian/install file specifying which files from the source tree should be installed and their destination directories in the package. ```text data/hello.desktop usr/share/applications data/hello.png usr/share/pixmaps scripts/hello usr/bin ``` -------------------------------- ### Log dpkg install action Source: https://www.debian.org/doc/manuals/debian-faq/uptodate.en.html Example log entry for a dpkg installation action. ```log 2005-12-30 18:10:33 install hello 1.3.18 2.1.1-4 ``` -------------------------------- ### Makefile Build and Install Example Source: https://www.debian.org/doc/manuals/debmake-doc/debmake-doc.en.txt Commands to build and install a C program using a Makefile. This is a precursor to packaging, showing the upstream build process. ```bash tar --xz -xmf debhello-1.4.tar.xz cd debhello-1.4 make make install ``` -------------------------------- ### LILO Bootloader Configuration Example Source: https://www.debian.org/doc/manuals/debian-handbook/sect.config-bootloader.en.html This is a simple example of a LILO configuration file (`/etc/lilo.conf`) for a standard setup. Remember to run the `lilo` command after any changes to this file. ```ini # /etc/lilo.conf # Simple configuration for a standard setup # Boot device (usually /dev/sda) boot = /dev/sda # Location of the map file map = /boot/map # Timeout in seconds before booting the default entry # timeout = 50 # Default boot entry default = Debian # Prompt the user to choose an entry prompt # Read all bootable partitions from the disk read-only # --- Bootable Linux Kernel Entries --- # Debian GNU/Linux image = /boot/vmlinuz-5.10.0-18-amd64 label = Debian root = /dev/sda2 initrd = /boot/initrd.img-5.10.0-18-amd64 # --- Other Bootable Entries (e.g., Windows) --- # Example for Windows (if installed on /dev/sda1) # other = /dev/sda1 # label = Windows # table = /dev/sda ``` -------------------------------- ### Installing Manual Pages Source: https://www.debian.org/doc/manuals/maint-guide/dother.en.html This example shows how to specify a manual page file to be installed by `dh_installman`. The path listed in the file will be installed as a manpage. ```text docs/gentoo.1 ``` -------------------------------- ### Example Build Process with CMake Source: https://www.debian.org/doc/manuals/debmake-doc/ch14.en.html Demonstrates the standard workflow for building a project with CMake, including configuration, compilation, and installation. ```bash [base_dir] $ tar --xz -xmf debhello-2.1.tar.xz [base_dir] $ cd debhello-2.1 [debhello-2.1] $ mkdir obj-x86_64-linux-gnu [debhello-2.1] $ cd obj-x86_64-linux-gnu [debhello-2.1] $ cmake .. [debhello-2.1] $ make [debhello-2.1] $ make install ``` -------------------------------- ### Install Custom File with Specific Destination Source: https://www.debian.org/doc/manuals/maint-guide/dother.en.html The 'install' file specifies files to be installed and their destinations. This example installs 'src/_bar_' to '/usr/bin/_bar_'. ```text src/_bar_ usr/bin ``` -------------------------------- ### Makefile for Installation Source: https://www.debian.org/doc/manuals/debmake-doc/ch14.en.html An example Makefile that correctly uses DESTDIR and prefix variables for installing files to their respective locations. This is crucial for Debian packaging. ```makefile prefix = /usr/local all: : # do nothing install: install -D scripts/hello \ $(DESTDIR)$(prefix)/bin/hello install -m 644 -D data/hello.desktop \ $(DESTDIR)$(prefix)/share/applications/hello.desktop install -m 644 -D data/hello.png \ $(DESTDIR)$(prefix)/share/pixmaps/hello.png install -m 644 -D man/hello.1 \ $(DESTDIR)$(prefix)/share/man/man1/hello.1 clean: : # do nothing distclean: clean uninstall: -rm -f $(DESTDIR)$(prefix)/bin/hello -rm -f $(DESTDIR)$(prefix)/share/applications/hello.desktop -rm -f $(DESTDIR)$(prefix)/share/pixmaps/hello.png -rm -f $(DESTDIR)$(prefix)/share/man/man1/hello.1 .PHONY: all install clean distclean uninstall ``` -------------------------------- ### Example of setting up a simple network listener Source: https://www.debian.org/doc/manuals/securing-debian-manual/securing-debian-manual.en.txt This example shows how to set up a basic network listener on a specific IP address and port using 'tcpserver'. It's used here to echo received data, demonstrating a simple network service setup. ```bash tcpserver -RHl localhost 23.0.0.1 8000 echo fnord ``` -------------------------------- ### Install Build Dependencies and Get Source Package Source: https://www.debian.org/doc/manuals/debian-reference/ch02.en.html Install necessary tools for compiling and downloading the source code of a package. This prepares the environment for backporting. ```bash # apt-get update # apt-get dist-upgrade # apt-get install fakeroot devscripts build-essential # apt-get build-dep foo $ apt-get source foo $ cd foo* ``` -------------------------------- ### LILO Configuration File Example Source: https://www.debian.org/doc/manuals/debian-handbook/sect.config-bootloader.el.html A basic configuration file for the LILO bootloader. This example assumes a setup with a single SATA disk, where the first partition is for Windows and the second is for Debian. ```ini # /etc/lilo.conf # Boot archive boot = /dev/sda # Timeout # The timeout for the boot menu, in tenths of a second # timeout = 50 # Default boot entry # default = debian # Compact # compact # Disk # disk = /dev/sda # bios = 0x80 # image = /boot/vmlinuz-2.6.26-1-amd64 # label = debian # root = /dev/sda2 # read-only # other = /dev/sda1 # label = windows # unsafe ``` -------------------------------- ### systemctl command examples Source: https://www.debian.org/doc/manuals/debian-handbook/unix-services.hr.html Demonstrates common systemctl commands for managing services, including checking status, starting, stopping, enabling, and disabling. ```bash systemctl status ntp.service ``` ```bash systemctl start _servicename_.service ``` ```bash systemctl stop _servicename_.service ``` ```bash systemctl enable _servicename_.service ``` ```bash systemctl disable _servicename_.service ``` ```bash systemctl is-enabled _servicename_.service ``` -------------------------------- ### Prepare for Package Backporting Source: https://www.debian.org/doc/manuals/debian-reference/debian-reference.en.txt Set up APT sources for unstable, install necessary build tools, and download the source package. Navigate into the source directory. ```bash deb-src http://deb.debian.org/debian unstable main contrib non-free ``` ```bash # apt-get update # apt-get dist-upgrade # apt-get install fakeroot devscripts build-essential # apt-get build-dep foo $ apt-get source foo $ cd foo* ``` -------------------------------- ### Clone Debian Installation Guide Git Repository Source: https://www.debian.org/doc/user-manuals Clone the Git repository for the latest XML source of the Debian Installation Guide. ```bash git clone https://salsa.debian.org/installer-team/installation-guide.git ``` -------------------------------- ### GRUB 2 Installation Error Example Source: https://www.debian.org/doc/manuals/debian-handbook/sect.config-bootloader.ar.html An example of an error message encountered during grub-pc package configuration, indicating a problem with the specified installation device. ```text Setting up grub-pc (2.02+dfsg1-20+deb10u4) ... /dev/disk/by-id/[..] does not exist, so cannot grub-install to it! You must correct your GRUB install devices before proceeding: DEBIAN_FRONTEND=dialog dpkg --configure grub-pc dpkg --configure -a dpkg: error processing package grub-pc (--configure): installed grub-pc package post-installation script subprocess returned error exit status 1 ``` -------------------------------- ### Create a Simple 'hello' Script for Debian Packaging Practice Source: https://www.debian.org/doc/manuals/maint-guide/first.en.html This snippet demonstrates the initial setup for a basic Debian package by creating a simple 'hello' shell script. It's intended for practicing packaging steps with a trivial upstream tarball. ```shell $ mkdir -p hello-sh/hello-sh-1.0; cd hello-sh/hello-sh-1.0 $ cat > hello < LIBRARY DESTINATION lib) #+install(TARGETS LIBRARY DESTINATION lib/${CMAKE_LIBRARY_ARC... ``` -------------------------------- ### Configuring and Building a Project Source: https://www.debian.org/doc/manuals/debmake-doc/debmake-doc.de.txt Shows the standard steps to configure and build a project using its configure script and make utility. ```bash [debhello-1.5] $ ./configure --with-math [debhello-1.5] $ make [debhello-1.5] $ make install ``` -------------------------------- ### Example Menu Entry Hints Source: https://www.debian.org/doc/packaging-manuals/menu.html/ch3.html Provides an example of how to use hints to influence menu structure and organization. This helps in grouping similar applications. ```bash ?package(emacs20):\ needs="x11"\ hints="Big,Expert,Featureful" \ section="Applications/Editors"\ title="Emacs 20"\ command="/usr/bin/emacs20"\ icon=/usr/share/emacs/20.3/etc/emacs.xbm ``` -------------------------------- ### Start NFS Kernel Server Service Source: https://www.debian.org/doc/manuals/debian-handbook/sect.nfs-file-server.el.html Starts the NFS kernel server service. Ensure the nfs-kernel-server package is installed. ```bash # systemctl start nfs-kernel-server ``` -------------------------------- ### Debian Rules File Example Source: https://www.debian.org/doc/manuals/debmake-doc/ch14.en.html This is an example of a debian/rules file used in Debian packaging. It specifies build and installation commands. ```makefile #!/usr/bin/make -f export DH_VERBOSE = 1 %: dh $@ override_dh_auto_install: dh_auto_install -- prefix=/usr ``` -------------------------------- ### Sample Firewall init.d Script Source: https://www.debian.org/doc/manuals/securing-debian-manual/firewall-setup.en.html This script provides a basic firewall configuration. It defines TCP and UDP services to allow or deny, and includes LSB headers for dependency-based boot sequencing. Adapt the service lists and network definitions to your specific needs. ```bash #!/bin/sh ### BEGIN INIT INFO # Provides: myfirewall # Required-Start: $local_fs # Required-Stop: $local_fs # Default-Start: S # Default-Stop: 0 6 # X-Start-Before: $network # X-Stop-After: $network # Short-Description: My custom firewall. ### END INIT INFO # # Simple example firewall configuration. # # Caveats: # - This configuration applies to all network interfaces # if you want to restrict this to only a given interface use # '-i INTERFACE' in the iptables calls. # - Remote access for TCP/UDP services is granted to any host, # you probably will want to restrict this using '--source'. # # chkconfig: 2345 9 91 # description: Activates/Deactivates the firewall at boot time # # You can test this script before applying with the following shell # snippet, if you do not type anything in 10 seconds the firewall # rules will be cleared. #--------------------------------------------------------------- # while true; do test=""; read -t 20 -p "OK? " test ; \ # [ -z "$test" ] && /etc/init.d/myfirewall clear ; done #--------------------------------------------------------------- PATH=/bin:/sbin:/usr/bin:/usr/sbin # Services that the system will offer to the network TCP_SERVICES="22" # SSH only UDP_SERVICES="" # Services the system will use from the network REMOTE_TCP_SERVICES="80" # web browsing REMOTE_UDP_SERVICES="53" # DNS # Network that will be used for remote mgmt # (if undefined, no rules will be setup) # NETWORK_MGMT=192.168.0.0/24 # If you want to setup a management network (i.e. you've uncommented # the above line) you will need to define the SSH port as well (i.e. # uncomment the below line.) Remember to remove the SSH port from the # TCP_SERVICES string. ``` -------------------------------- ### Example limits.conf configuration Source: https://www.debian.org/doc/manuals/securing-debian-manual/ch04s11.en.html This example demonstrates setting various resource limits for all users and specific limits for users in the 'adm' group. It includes limits for core files, memory, processes, and logins. ```bash * soft core 0 * hard core 0 * hard rss 1000 * hard memlock 1000 * hard nproc 100 * - maxlogins 1 * hard data 102400 * hard fsize 2048 @adm hard core 100000 @adm hard rss 100000 @adm soft nproc 2000 @adm hard nproc 3000 @adm hard fsize 100000 @adm - maxlogins 10 ``` -------------------------------- ### Getting Installer Selections Source: https://www.debian.org/doc/manuals/debian-handbook/sect.automated-installation.da.html Use this command to retrieve the answers to questions asked by the Debian installer for use in a preseed file. ```shell debconf-get-selections --installer ``` -------------------------------- ### Example "symbols" file with alternative dependencies Source: https://www.debian.org/doc/debian-policy/policy.txt Demonstrates how to use alternative dependency templates in a "symbols" file. This is useful when different symbols require different dependency versions or packages. ```text libGL.so.1 libgl1 | libgl1-mesa-glx #MINVER# publicGlSymbol@Base 6.3-1 implementationSpecificSymbol@Base 6.5.2-7 1 [...] ``` -------------------------------- ### Install and Enable nftables Service Source: https://www.debian.org/doc/manuals/debian-handbook/sect.firewall-packet-filtering.en.html Installs the nftables package and enables its service to start on boot. This is the default firewall framework in Debian Buster and later. ```bash # apt install -y nftables **Reading package lists... Done ... # **systemctl enable nftables.service** Created symlink /etc/systemd/system/sysinit.target.wants/nftables.service → /lib/systemd/system/nftables.service. ``` -------------------------------- ### SSH Client Connection Examples Source: https://www.debian.org/doc/manuals/debian-reference/ch06.en.html Demonstrates various ways to initiate an SSH connection from a client, including basic connection, debugging, forcing password authentication, and running a remote command. ```bash ssh username@hostname.domain.ext ``` ```bash ssh -v username@hostname.domain.ext ``` ```bash ssh -o PreferredAuthentications=password username@hostname.domain.ext ``` ```bash ssh -t username@hostname.domain.ext passwd ``` -------------------------------- ### Compiling and Running a C Example Program Source: https://www.debian.org/doc/manuals/debian-reference/debian-reference.en.txt This snippet shows the commands to compile a C program named 'example.c' using GCC, linking the math library, and then executing it with different arguments. ```bash $ gcc -Wall -g -o run_example example.c -lm $ ./run_example 1, 2.915, ./run_exam, (null) $ ./run_example 1234567890qwerty 2, 3.082, ./run_exam, 1234567890qwerty ``` -------------------------------- ### Install and Enable nftables Service Source: https://www.debian.org/doc/manuals/debian-handbook/sect.firewall-packet-filtering.hr.html Installs the nftables package and enables its service to start on boot. This is the recommended way to set up the default firewall in Debian. ```bash # apt install -y nftables **Reading package lists... Done ... # systemctl enable nftables.service Created symlink /etc/systemd/system/sysinit.target.wants/nftables.service → /lib/systemd/system/nftables.service. ``` -------------------------------- ### Example Debian Control File Source: https://www.debian.org/doc/manuals/debian-faq/pkg-basics.en.html A sample control file for the 'hello' Debian package, illustrating various fields. ```text Package: hello Version: 2.9-2+deb8u1 Architecture: amd64 Maintainer: Santiago Vila Installed-Size: 145 Depends: libc6 (>= 2.14) Conflicts: hello-traditional Breaks: hello-debhelper (<< 2.9) Replaces: hello-debhelper (<< 2.9), hello-traditional Section: devel Priority: optional Homepage: https://www.gnu.org/software/hello/ Description: example package based on GNU hello The GNU hello program produces a familiar, friendly greeting. It allows non-programmers to use a classic computer science tool which would otherwise be unavailable to them. . Seriously, though: this is an example of how to do a Debian package. It is the Debian version of the GNU Project's "hello world" program (which is itself an example for the GNU Project). ``` -------------------------------- ### Autotools Build Process Example Source: https://www.debian.org/doc/manuals/debmake-doc/ch14.en.html Standard steps to build and install a project using Autotools from a tarball. Assumes the project is configured with `--with-math`. ```bash [base_dir] $ tar --xz -xmf debhello-2.0.tar.xz [base_dir] $ cd debhello-2.0 [debhello-2.0] $ autoreconf -ivf # optional [debhello-2.0] $ ./configure --with-math [debhello-2.0] $ make [debhello-2.0] $ make install ``` -------------------------------- ### Install a Windows Application using Wine Source: https://www.debian.org/doc/manuals/debian-handbook/sect.windows-emulation.en.html Installs a Windows application by running its setup executable under Wine. The exact path to `setup.exe` may vary. ```bash wine _.../setup.exe_ ``` -------------------------------- ### APT Extra Package List Example Source: https://www.debian.org/doc/manuals/apt-guide/ch4.en.html Displays a list of extra packages that will be installed or upgraded beyond those explicitly requested on the command line. This list is generated for 'install' commands and often results from Auto Install. ```text The following extra packages will be installed: libdbd-mysql-perl xlib6 zlib1 xzx libreadline2 libdbd-msql-perl mailpgp xdpkg fileutils pinepgp zlib1g xlib6g perl-base bin86 libgdbm1 libgdbmg1 quake-lib gmp2 bcc xbuffy squake pgp-i python-base debmake ldso perl libreadlineg2 ssh ``` -------------------------------- ### APT sources.list for Testing/Unstable Users Source: https://www.debian.org/doc/manuals/debian-handbook/apt.el.html Example sources.list configuration for systems running Debian Testing or Unstable. Includes repositories for Unstable, Testing, Testing security, Stable, and Stable security updates. ```text # Unstable deb https://deb.debian.org/debian unstable main contrib non-free deb-src https://deb.debian.org/debian unstable main contrib non-free # Testing deb https://deb.debian.org/debian testing main contrib non-free deb-src https://deb.debian.org/debian testing main contrib non-free # Testing security updates deb http://security.debian.org/ testing-security main contrib non-free deb-src http://security.debian.org/ testing-security main contrib non-free # Stable deb https://deb.debian.org/debian stable main contrib non-free deb-src https://deb.debian.org/debian stable main contrib non-free # Stable security updates deb http://security.debian.org/ stable-security main contrib non-free deb-src http://security.debian.org/ stable-security main contrib non-free ``` -------------------------------- ### Install a package using an override specifier Source: https://www.debian.org/doc/manuals/aptitude/rn01re01.en.html Override specifiers can be used to change the default action for a package. This example installs 'wesnoth' by appending a '+' to its name. ```bash aptitude remove wesnoth+ ``` -------------------------------- ### Systemd Mount Timeout Example Source: https://www.debian.org/doc/manuals/debian-handbook/sect.config-misc.vi.html Example showing how to combine `nofail` with `x-systemd.device-timeout` in `/etc/fstab` to limit systemd's waiting time for a device during boot. ```text x-systemd.device-timeout=5s ``` -------------------------------- ### Basic GDB execution example Source: https://www.debian.org/doc/manuals/debian-reference/ch12.en.html Demonstrates setting breakpoints, running a program, stepping through code, printing variables, and quitting GDB. ```bash $ gdb program (gdb) b 1 # set break point at line 1 (gdb) run args # run program with args (gdb) next # next line ... (gdb) step # step forward ... (gdb) p parm # print parm ... (gdb) p parm=12 # set value to 12 ... (gdb) quit ``` -------------------------------- ### Example /etc/fstab Entries for Local Filesystems Source: https://www.debian.org/doc/manuals/debian-handbook/sect.config-misc.en.html These entries show how to configure local filesystems, including a hard drive partition, swap space, and removable media like CD-ROM and floppy drives. ```bash UUID=7a250fb8-c16d-4a4e-9808-ec08ae92b6c6 / ext4 errors=remount-ro 0 1 # swap was on /dev/sda5 during installation UUID=13f367ae-dbaf-40ed-85c0-4072a2ebe426 none swap sw 0 0 /dev/sr0 /media/cdrom0 udf,iso9660 user,noauto 0 0 /dev/fd0 /media/floppy auto rw,user,noauto 0 0 ``` -------------------------------- ### Mark packages in a section as automatically installed Source: https://www.debian.org/doc/manuals/aptitude/rn01re01.en.html The 'markauto' command can be used with patterns to mark multiple packages. This example marks all packages in the 'libs' section as automatically installed. ```bash aptitude markauto '~slibs' ```