Commands tagged Debian (100)

  • This function returns TRUE if the application supports tcp-wrapping or FALSE if not by reading the shared libraries used by this application. Show Sample Output


    1
    supportsWrap(){ ldd `which ${1}` | grep "libwrap" &>/dev/null && return 0 || return 1; }
    cicatriz · 2010-12-01 15:22:29 15
  • If the first two letters are "ii", then the package is installed. You can also use wildcards. For example, . dpkg -l openoffice* . Note that dpkg will usually not report packages which are available but uninstalled. If you want to see both which versions are installed and which versions are available, use this command instead: . apt-cache policy python Show Sample Output


    1
    dpkg -l python
    hackerb9 · 2011-01-05 06:15:13 5
  • Trickle is here: http://monkey.org/~marius/pages/?page=trickle Trickle is a simple bandwidth limiter


    1
    trickle sudo apt-get update -y
    mrman · 2011-02-15 02:05:37 3
  • locating packages held back, such as with "aptitude hold "


    1
    aptitude search ~ahold
    pykler · 2012-04-29 15:02:32 4
  • The other commands were good, but they included packages that were installed and then removed. This command only shows packages that are currently installed, sorts smallest to largest, and formats the sizes to be human readable. Show Sample Output


    1
    dpkg-query --show --showformat='${Package;-50}\t${Installed-Size}\n' `aptitude --display-format '%p' search '?installed!?automatic'` | sort -k 2 -n | grep -v deinstall | awk '{printf "%.3f MB \t %s\n", $2/(1024), $1}'
    EvilDennisR · 2013-07-26 23:18:20 13
  • In this case, linux- is the prefix; simply running apt-cache pkgnames would list every package APT knows about. The default APT config assumes -g, --generate; to use the cache as/is, you could similarly run: apt-cache --no-generate pkgnames [prefix] Adding --all-names, like so: apt-cache --no-generate --all-names pkgnames [prefix] would print all the packages APT knows about, using the cache as/is, including virtual packages and missing dependencies. This command was shamelessly stolen from the apt-cache(8) man-page. Show Sample Output


    1
    apt-cache pkgnames linux-
    benjabean1 · 2014-12-14 06:48:57 8
  • An alternative without aptitude.


    1
    apt-mark showmanual|xargs sudo apt-mark markauto
    DellDor · 2015-08-10 02:35:22 12
  • If, for example, you want to remove all kernels and headers but the last three versions, you can't use one of that magic all-in-one "remove old stuff" commands. With this simple but elegant command you can remove a range of versions, or a list of versions with e.g. {14,16,20}. Show Sample Output


    1
    apt purge linux*{14..18}*
    ppq · 2016-04-20 07:44:55 11
  • Some command names are very different from the name of the package that installed them. Sometimes, you may want to find out the name of the package that provided a command on a system, so that you can install it on another system. Show Sample Output


    1
    dpkg -S "$(readlink -e $(which w))" | cut -d ':' -f 1
    Fox · 2016-05-18 09:41:29 11
  • The vaule is expressed in megabytes Show Sample Output


    1
    echo $[ ($(dpkg-query -s $(dpkg --get-selections | grep -oP '^.*(?=\binstall)') | grep -oP '(?<=Installed-Size: )\d+' | tr '\n' '+' | sed 's/+$//')) / 1024 ]
    acavagni · 2019-06-02 16:35:34 55
  • This is useful if you add sid, install some packages, then remove sid and want to work out which packages you installed from sid that should be removed (e.g. before an upgrade to the new stable). Alternatively you can think of this as "find installed packages that can no longer be installed."


    1
    aptitude search -F '%p %v %V %O' '?narrow(?not(?archive("^[^n][^o].*$")),?version(CURRENT))' | while IFS=' ' read -r pkg ver candidate origin; do if [[ $ver == "$candidate" ]] && [[ $origin == '(installed locally)' ]]; then echo "$pkg"; fi; done
    sorpigal · 2021-12-26 15:57:15 303
  • OS: Debian based (or those that use dpkg) Equivalent to doing a dpkg -S on each file in $PATH, but way faster. May report files generated though postinstall scripts and such. For example . It will report /usr/bin/vim .. which is not not a file installed directly by dpkg, but a link generated by alternatives hooks


    0
    echo -e "${PATH//://\n}" >/tmp/allpath; grep -Fh -f /tmp/allpath /var/lib/dpkg/info/*.list|grep -vxh -f /tmp/allpath >/tmp/installedinpath ; find ${PATH//:/ } |grep -Fxv -f /tmp/installedinpath
    kamathln · 2009-09-09 05:33:14 4
  • List packages and their disk usage in decreasing order. This uses the "Installed-Size" from the package metadata. It may differ from the actual used space, because e.g. data files (think of databases) or log files may take additional space. Show Sample Output


    0
    perl -ne '$pkg=$1 if m/^Package: (.*)/; print "$1\t$pkg\n" if m/^Installed-Size: (.*)/;' < /var/lib/dpkg/status | sort -rn | less
    hfs · 2009-10-19 12:55:59 7

  • 0
    dpkg-query -W -f='${Version}' package-name
    ohe · 2010-06-02 14:39:08 3
  • Supports regex pattern and very flexible output parameters and search options. Show Sample Output


    0
    aptitude -F '%p %v#' search <pattern>
    unixmonkey10157 · 2010-06-03 15:37:27 3
  • A replacement for 'apt-cache' that uses a Xapian to produce ranked results. Available in 'apt-xapian-index' 0.27 and higher. Show Sample Output


    0
    axi-cache search <searchterm>
    tarkasteve · 2010-07-05 00:16:03 3
  • Lists all packages in "rc" state and purge them one at a time.


    0
    dpkg -l | grep ^rc | cut -d' ' -f3 | xargs dpkg -P
    cyrusza · 2010-11-22 12:53:31 6

  • 0
    debconf-copydb configdb copydb --pattern=<PACKAGE> --config="Name: copydb" --config="Driver: File" --config="Filename: ~/copydebconf.dat"
    ohe · 2011-08-29 14:00:42 3

  • 0
    debconf-copydb copydb configdb --config="Name: copydb" --config ="Driver: File" --config="Filename: ~/copydebconf.dat"
    ohe · 2011-08-29 14:01:31 3
  • since awk was already there one can use it instead of the 2 greps. might not be faster, but fast enough


    0
    apt-get remove $(dpkg -l | awk "/^ii linux-(image|headers)/ && ! /`uname -r`/ {print \$2}")
    _john · 2011-10-09 13:58:47 4
  • after kernel build with make deb-pkg, I like to install the 4 newest packages that exist in the directory. Beware: might be fewer for you....


    0
    sudo dpkg -i `ls -tr *.deb | tail -n4`
    _john · 2011-10-09 14:20:11 3
  • This will print the name of every installed package on a Debian system.


    0
    aptitude search ~i -F %p
    dbbolton · 2011-10-15 00:31:10 8
  • # Search for an available package on Debian systems using a regex so it only matches packages starting with 'tin'.


    0
    aptitude search ^tin
    defiantredpill · 2011-10-20 17:51:36 3
  • Marks all manually installed deb packages as automatically installed. Usefull to combine with apt-get install <all manually packages that we want> to have a clean installed debian-based system.


    0
    aptitude -F "%p" search \!~M~i~T | xargs apt-mark markauto
    gspadari · 2012-03-09 13:44:00 7
  • also use: update-alternatives --config gnome-www-browser


    0
    update-alternatives --config x-www-browser
    gwd · 2012-07-08 20:27:42 4
  •  < 1 2 3 4 > 

What's this?

commandlinefu.com is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.

Share Your Commands


Check These Out

Watch active calls on an Asterisk PBX
Only the number of calls nothing else.

mirrors directory to a ftp server
http://lftp.yar.ru/

list files recursively by size

github push-ing behind draconian proxies!
If you are behind a restrictive proxy/firewall that blocks port 22 connections but allows SSL on 443 (like most do) then you can still push changes to your github repository. Your .ssh/config file should contain: Host * ForwardX11 no TCPKeepAlive yes ProtocolKeepAlives 30 ProxyCommand /usr/local/bin/proxytunnel -v -p -d %h:443 Host User git Hostname ssh.github.com ChallengeResponseAuthentication yes IdentityFile ~/.ssh/id_rsa IdentitiesOnly yes Basically proxytunnel "tunnels" your ssh connection through port 443. You could also use corkscrew or some other tunneling program that is available in your distro's repository. PS: I generally use "github.com" as the SSH-HOST so that urls of the kind git@github.com:USER/REPO.git work transparently :) You

list files recursively by size

list files recursively by size

Create QR codes from a URL.
QR codes are those funny square 2d bar codes that everyone seems to be pointing their smart phones at. Try the following... $ qrurl http://xkcd.com Then open qr.*.png in your favorite image viewer. Point your the bar code reader on your smart phone at the code, and you'll shortly be reading xkcd on your phone. URLs are not the only thing that can be encoded by QR codes... short texts (to around 2K) can be encoded this way, although this function doesn't do any URL encoding, so unless you want to do that by hand it won't be useful for that.

host - DNS lookup utility
host is a simple utility for performing DNS lookups. It is normally used to convert names to IP addresses and vice versa. When no arguments or options are given, host prints a short summary of its command line arguments and options.

power off system in X minutes
Replace 60 with the number of minutes until you want the machine to shut down. Alternatively give an absolute time in the format hh:mm (shutdown -h 9:30) Or shutdown right away (shutdown -h now)

Convert CSV to JSON
Replace 'csv_file.csv' with your filename.


Stay in the loop…

Follow the Tweets.

Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.

» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10

Subscribe to the feeds.

Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):

Subscribe to the feed for: