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 diff --git a/sheets/apt-cache b/sheets/apt-cache new file mode 100644 index 0000000..6fa0f4c --- /dev/null +++ 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)' diff --git a/sheets/apt-get b/sheets/apt-get new file mode 100644 index 0000000..f5bf891 --- /dev/null +++ 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)}}'` diff --git a/sheets/dpkg-deb b/sheets/dpkg-deb new file mode 100644 index 0000000..5ea5c2a --- /dev/null +++ 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/ diff --git a/sheets/source b/sheets/source new file mode 100644 index 0000000..16d6a94 --- /dev/null +++ b/sheets/source @@ -0,0 +1,6 @@ +# 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 +# The above can be written in short-hand, for the same effect: +. FILE diff --git a/sheets/udisksctl b/sheets/udisksctl new file mode 100644 index 0000000..e98c3ba --- /dev/null +++ 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 diff --git a/sheets/umask b/sheets/umask new file mode 100644 index 0000000..57733ca --- /dev/null +++ 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