From f5ec296286a814bfa84a2d825817d578f3fb2b5a Mon Sep 17 00:00:00 2001 From: terminalforlife Date: Wed, 13 Nov 2019 14:55:27 +0000 Subject: [PATCH 01/13] Add 'udisksctl' file --- sheets/udisksctl | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 sheets/udisksctl diff --git a/sheets/udisksctl b/sheets/udisksctl new file mode 100644 index 0000000..e69de29 From 27c86e12f59344021979e1825c70da2f50dc30db Mon Sep 17 00:00:00 2001 From: terminalforlife Date: Wed, 13 Nov 2019 15:11:49 +0000 Subject: [PATCH 02/13] Add a number of examples for udisksctl --- sheets/udisksctl | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/sheets/udisksctl b/sheets/udisksctl index e69de29..e98c3ba 100644 --- a/sheets/udisksctl +++ b/sheets/udisksctl @@ -0,0 +1,20 @@ +# Output low-level information for the provided block device and partition. +udisksctl info -b /dev/sdd1 + +# Mount partition on the given block device. This will by default use '/media', and +# on typical systems won't even require root privileges. +udisksctl mount -b /dev/sd?? + +# Set up a loop device using 'imagefile'. This only sets it up, so you will +# probably also want to mount it thereafter, using the device given to you after +# executing this command. often, if not always, this is '/dev/loopX', where X is +# the loop device number. +udisksctl loop-setup -f image file + +# Like the above, except this will delete the loop device (assuming 'loop0' was +# previously created) but note that this will NOT delete the image file. Be sure to +# unmount the filesystem(s) on the device first, before deleting it. +udisksctl loop-delete -b /dev/loop0 + +# Power off a block device. May not work for all devices, and may vary in effect. +udisksctl power-off -b /dev/sdb From 4a67b1d9ad2c59d2eeb2c46224671554ee0626cb Mon Sep 17 00:00:00 2001 From: terminalforlife Date: Wed, 13 Nov 2019 15:14:04 +0000 Subject: [PATCH 03/13] Add file 'apt-get' --- sheets/apt-get | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 sheets/apt-get diff --git a/sheets/apt-get b/sheets/apt-get new file mode 100644 index 0000000..e69de29 From 9feb9d7ddf2fa22e4687c67e886cbc5ff056845a Mon Sep 17 00:00:00 2001 From: terminalforlife Date: Wed, 13 Nov 2019 15:44:46 +0000 Subject: [PATCH 04/13] Add a multitude of examples for apt-get --- sheets/apt-get | 53 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/sheets/apt-get b/sheets/apt-get index e69de29..f5bf891 100644 --- a/sheets/apt-get +++ b/sheets/apt-get @@ -0,0 +1,53 @@ +# Update the local database of available packages, as discovered from package index +# file found in their sources. This does not actually update your installed +# software! For that, keeping reading. +apt-get update + +# Upgrade installed packages, but there may be exceptions, such as important kernel +# packages. Also, packages will not be removed, like if they're deprecated, with +# this method. +apt-get upgrade + +# Unlike the above, this will upgrade all of the installed packages, and perform +# other actions required for a successful and thorough upgrade. This will also +# allow for upgrading to the next minor release of your distributions, such as from +# Ubuntu '16.04.1' to '16.04.2'. +apt-get dist-upgrade + +# Clean out (completely) the follow locations of saved DEB files: +# +# /var/cache/apt/archives/* /var/cache/apt/archives/partial/ +# /var/lib/apt/lists/partial/ +# /var/cache/apt/pkgcache.bin /var/cache/apt/srcpkgcache.bin +# +# This will also, thanks to the provided flag, be somewhat verbose. +sudo apt-get clean -s + +# View the changelog for the firefox package. Useful prior to or after upgrade. +apt-get changelog firefox + +# Download PKG (one or more) without actually installing or extracting them. A good +# use for this might be to upgrade an offline system, by downloading the packages +# on a system using an Internet-able machine. Files are downloaded into the CWD. +apt-get download PKG + +# Install PKG (one or more), bringing in dependencies and, provided settings allow +# it, install recommended and/or suggested packages. +apt-get install PKG + +# At times, dependencies won't be installed, yet you still need them; the following +# command will often fix this, and is usually suggested to the user. +apt-get -f install + +# Remove PKG, while also purging system-wide configuration files for it. +apt-get purge PKG +# Alternative syntax: +apt-get remove --purge PKG + +# Often used to first update the local database of packages, then, only if +# successful, a full system upgrade is started. +apt-get update && apt-get dist-upgrade + +# Download specified package (firefox, in this example) and all packages marked +# thereby as important or dependencies. Files are downloaded into the CWD. +apt-get download firefox `apt-cache --important depends firefox | awk '{if(NR>1){printf("%s ", $2)}}'` From be76804476309f7275f8121de4b2a53981c08d11 Mon Sep 17 00:00:00 2001 From: terminalforlife Date: Wed, 13 Nov 2019 15:46:30 +0000 Subject: [PATCH 05/13] Add file 'umask' --- sheets/umask | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 sheets/umask diff --git a/sheets/umask b/sheets/umask new file mode 100644 index 0000000..e69de29 From 2e4f7be1b878d33b30f2407124b3476e5ada2ef8 Mon Sep 17 00:00:00 2001 From: terminalforlife Date: Wed, 13 Nov 2019 16:04:30 +0000 Subject: [PATCH 06/13] Add examples and detailed explanation of `umask` --- sheets/umask | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/sheets/umask b/sheets/umask index e69de29..57733ca 100644 --- a/sheets/umask +++ b/sheets/umask @@ -0,0 +1,18 @@ +# Unless configured otherwise, this will set the umask ("user mask" or "file mode +# creation mask") for only the current user, and only his or her current session. +# The (one) leading zero is optional, unless you otherwise need it. +# +# This umask setting is actually recommended for security by RHEL, and is also +# mentioned and I believe recommended in the Arch Linux Wiki. +# +# The result of '0077' being -- and I'll use standard octal with which we're all +# probably familiar -- that all new files are created using the '600' +# permissions, and directories are '700'. +# +# Remember, the standard format means 4=read, 2=write, and 1=execute. However, the +# umask uses the same, but is inverted, so a umask of '077' would be 700, and +# correctly lowers to 600 when it's just a file. +umask 0077 + +# Akin to above, but instead, output the current umask setting. +umask From b83d187fee0dda0d3beb8ca360c60f4e5e36dbda Mon Sep 17 00:00:00 2001 From: terminalforlife Date: Wed, 13 Nov 2019 16:08:03 +0000 Subject: [PATCH 07/13] Add file 'source', and briefly show its usage --- sheets/source | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 sheets/source diff --git a/sheets/source b/sheets/source new file mode 100644 index 0000000..548f107 --- /dev/null +++ b/sheets/source @@ -0,0 +1,5 @@ +# The contents of FILE (assuming shell script) will be sourced into the current +# session, allowing external use of things like its functions and variables. +source FILE +# The above can be written in short-hand, for the same effect: +. FILE From 6955dd2709a185d1119237ac23507e52314f0aba Mon Sep 17 00:00:00 2001 From: terminalforlife Date: Wed, 13 Nov 2019 16:10:28 +0000 Subject: [PATCH 08/13] Add extra information on source --- sheets/source | 1 + 1 file changed, 1 insertion(+) diff --git a/sheets/source b/sheets/source index 548f107..16d6a94 100644 --- a/sheets/source +++ b/sheets/source @@ -1,3 +1,4 @@ +# This is a shell builtin available in bash, but not in the Bourne Shell (`sh`). # The contents of FILE (assuming shell script) will be sourced into the current # session, allowing external use of things like its functions and variables. source FILE From a388ee6534a166c5e4d4bf57defba135430bfd38 Mon Sep 17 00:00:00 2001 From: terminalforlife Date: Wed, 13 Nov 2019 16:11:17 +0000 Subject: [PATCH 09/13] Add file 'apt-cache' --- sheets/apt-cache | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 sheets/apt-cache diff --git a/sheets/apt-cache b/sheets/apt-cache new file mode 100644 index 0000000..e69de29 From e699f7c298c6faeb83504f2090b45955b5cc67cc Mon Sep 17 00:00:00 2001 From: terminalforlife Date: Wed, 13 Nov 2019 16:19:42 +0000 Subject: [PATCH 10/13] Add two examples for `apt-cache` --- sheets/apt-cache | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/sheets/apt-cache b/sheets/apt-cache index e69de29..6fa0f4c 100644 --- a/sheets/apt-cache +++ b/sheets/apt-cache @@ -0,0 +1,9 @@ +# Search for package PKG. Both package names and their descriptions are searched +# for a REGEX match; to avoid this behavior, you may use the `-n` flag, which will +# only look for a match in the package name. +apt-cache search 'PKG' + +# Regarding the above, although multiple package names may not be specified, it's +# possible to use ERE to easily and quickly get around this limitation. Here, all +# 3 packages (PKG1, PKG2, and PKG3) will be sought. +apt-cache search '(PKG1|PKG2|PKG3)' From 2c2a1f4fb61d8803d8a710cdc53e798122b3ef5e Mon Sep 17 00:00:00 2001 From: terminalforlife Date: Wed, 13 Nov 2019 16:20:34 +0000 Subject: [PATCH 11/13] Add file 'dpkg-deb' --- sheets/dpkg-deb | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 sheets/dpkg-deb diff --git a/sheets/dpkg-deb b/sheets/dpkg-deb new file mode 100644 index 0000000..e69de29 From 25f4ef1390e8e6d3d1bb0a177c8c5e4703f860ce Mon Sep 17 00:00:00 2001 From: terminalforlife Date: Wed, 13 Nov 2019 16:26:10 +0000 Subject: [PATCH 12/13] Add examples for `dpkg-deb` --- sheets/dpkg-deb | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/sheets/dpkg-deb b/sheets/dpkg-deb index e69de29..5ea5c2a 100644 --- a/sheets/dpkg-deb +++ b/sheets/dpkg-deb @@ -0,0 +1,10 @@ +# Build a DEB package using the provided directory. +dpkg-deb -b /path/to/directory + +# List out the contents of an existing DEB package. +dpkg-deb -c /path/to/package.deb + +# Extract the contents of an existing DEB package. If no destination is provided +# for the extracted files, then they will be extracted to the CWD. Will also create +# the specified directory if it's not found, but it won't create its parents. +dpkg-deb -x /path/to/package.deb /path/to/destination/ From c08786cb0eddcdf583afcec559c2cf4bb4d74ae0 Mon Sep 17 00:00:00 2001 From: terminalforlife Date: Wed, 13 Nov 2019 16:29:40 +0000 Subject: [PATCH 13/13] Added alternative syntax for easier reading --- sheets/_bash/forkbomb | 3 +++ 1 file changed, 3 insertions(+) diff --git a/sheets/_bash/forkbomb b/sheets/_bash/forkbomb index 80e3ce1..ed5c4af 100644 --- a/sheets/_bash/forkbomb +++ b/sheets/_bash/forkbomb @@ -6,3 +6,6 @@ # function definition and then calls the function to begin the chain reaction. # A very nasty trick, indeed. :(){ :|: & };: + +# A more-readable version of the fork bomb could be written as: +FORK(){ true | true & }; FORK