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

Create a mirror of a local folder, on a remote server
Create a exact mirror of the local folder "/root/files", on remote server 'remote_server' using SSH command (listening on port 22) (all files & folders on destination server/folder will be deleted)

Perl One Liner to Generate a Random IP Address

Create thumbnails and a HTML page for listing them (with links to sources)
The input images are assume to have the "JPG" extension. Mogrify will overwrite any gif images with the same name! Will not work with names with spaces.

Download all PDFs from an authenificated website
Replace *** with the appropiate values

Alias for lazy tmux create/reattach
If a tmux session is already running attach it, otherwise create a new one. Useful if you often forget about running tmuxes (or just don't care)

Install a LAMP server in a Debian based distribution
The execution of this command will install a LAMP server (Linux, Apache, MySQL and PHP) in a Debian based distribution. For example, in Ubuntu.

find text in a file
this will find text in the directory you specify and give you line where it appears.

locating packages held back, such as with "aptitude hold "
locating packages held back, such as with "aptitude hold "

Readd all files is missing from svn repo
When working on a big proeject with SVN, you create quite much files, for now! Can just sit here and type svn add for all of them! svn status will return a list of all of file which get ?(not add), "M"(Modified), "D"(Deleted)! This code just grep "?" flag, then add it into SVN again!

Run a program transparently, but print a stack trace if it fails
For automated unit tests I wanted my program to run normally, but if it crashed, to add a stack trace to the output log. I came up with this command so I wouldn't have to mess around with core files. The one downside is that it does smoosh your program's stderr and stdout together.


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: