Skip to content

Instantly share code, notes, and snippets.

@hxmuller
hxmuller / show Debian automatically installed packages
Created October 21, 2016 10:00
show Debian automatically installed packages
# apt-mark - mark/unmark a package as bing automatically-installed
apt-mark showauto
@hxmuller
hxmuller / list Raspbian manually installed packages
Last active December 12, 2016 15:48
list Raspbian manually installed packages
apt-mark showmanual > filename
# NOTE: history.log does not capture the entire list of
# manually installed packages. To get the full list,
# use the command above. The below is retained for
# history.
#
## sed - stream editor for filtering and transforming text
## -n suppress automatic printing of pattern space
## awk - pattern ascanning and text processing language
@hxmuller
hxmuller / print Debian package summary for each package listed in file
Created October 20, 2016 18:20
print Debian package summary for each package listed in file
# cat - concatenate files and print on the standard output
# xargs - build and execute command lines from standard inpout
# dpkg-query - a tool to query the dpkg database
# -W list packages matching given pattern, output can be customized
# -f specifies the format of the output of -W
cat filename | xargs dpkg-query -W -f='${binary:Package}\n\t${binary:Summary}\n'
@hxmuller
hxmuller / list Raspbian bootstrapped packages
Created October 20, 2016 14:14
list Raspbian bootstrapped packages
# sed - stream editor for filtering and transforming text
# -n suppress automatic printing of pattern space
# cut - remove sections from each line of files
# -f select only these fields
# -d use DELIM instead of TAB for field delimiter
# awk - pattern scanning and text processing language
sed -n '/Setting up/p' /var/log/bootstrap.log | cut -f3 -d' ' | awk '!arr[$0]++' > filename
@hxmuller
hxmuller / verify integrity of all installed Debian packages
Last active October 20, 2016 14:03
verify integrity of all installed Debian packages
# dpkg - package manager for Debian
# -V Verifies the integrity of package-name or all packages if omitted
#
# The output format:
#
# SM5DLUGT c <file>
#
# Where:
# S is the file size.
# M is the file's mode.
@hxmuller
hxmuller / delete duplicate lines while keeping order
Last active October 20, 2016 14:01
delete duplicate lines while keeping order
# awk - pattern scanning and text processing language
# a) When the program is omitted, the default is { print $0 }
# b) Each line of filename is read by awk, one at a time.
# c) The line, or record, is stored into the field variable $0.
# d) If an array index consisting of the line is not (!) present
# in the array, then the line is printed.
# e) The array is incremented (current index added to the array).
awk '!array[$0]++' filename > filename2
@hxmuller
hxmuller / determine which Debian package provides an executable binary
Last active January 14, 2017 12:44
determine which Debian package provides an executable binary
# This does not work for packages not installed. '$(which COMMAND)'
# may be replaced with any /path/file. Replace COMMAND with binary
# of interest.
#
# dpkg - package manager for Debian
# -S Search for a filename from installed packages
# which - locate a command
# awk - process output of previous command
# gsub(r,s,[t]) - global subsitution, every match of regular expression
# r in variable t is replaced by string s. If t is omitted, $0 is used.
@hxmuller
hxmuller / find and remove duplicate files from the second of two directories
Last active October 20, 2016 14:04
find and remove duplicate files from the second of two directories
# modify directory1/ and directory2/ paths as appropriate
#
# diff - compare files line by line
# -s report when two files are the same
# -r recursively compare any subdirectories found
# sed - stream editor for filtering and transforming text
# -n suppress automatic printing of pattern space
# cut - remove sections from each line of files
# -f select only these fields
# -d use DELIM instead of TAB for field delimiter