Commands using apt (50)

  • That command installs "most" and make this command as the default man reader. The "most" works like "less" (the current man reader), but it render colors for manpages and may do more things. Read "man most". You can see a preview here:

    apt-get install most && update-alternatives --set pager /usr/bin/most
    aurium · 2010-01-04 14:13:55 4

  • 12
    apt-get install `ssh root@host_you_want_to_clone "dpkg -l | grep ii" | awk '{print $2}'`
    TuxOtaku · 2011-05-10 13:33:51 3
  • Bash's here string

    sudo -s <<< 'apt update -y && apt upgrade -y'
    metropolis · 2019-08-07 14:03:30 6

  • 7
    apt-get moo
    vavincavent · 2009-02-15 21:15:38 5
  • Requires: imagemagick and graphviz On Debian systems, displays a graph of package dependencies. Works also with other image formats, like svg : apt-cache dotty bash | dot -T svg | display

    apt-cache dotty apache2 | dot -T png | display
    raphink · 2009-02-18 14:27:31 0
  • search ubuntu's remote package source repositories for a specific program to see which package contains it Show Sample Output

    apt-file find bin/programname
    nickleus · 2009-11-10 10:21:45 2

  • 5
    apt-file search iostat
    tersmitten · 2011-07-24 11:56:31 3
  • Shows all configurations to apt and dpkg, rarely changed, you probably still have the default configuration. Go ahead and explore your configuration if you dare, perhaps change your apt-cache directory, Dir::Cache "var/cache/apt/"; or the names of the log files. Show Sample Output

    apt-config dump
    LinuxMan · 2011-12-13 19:11:02 1

  • 4
    apt-cache stats
    0disse0 · 2009-09-03 19:29:17 0
  • This will take the packages matching a given `apt-cache search` query (a collection of AND'd words or regexps) and tell you how popular they are. This is particularly nice for those times you have to figure out which solution to use for e.g. a PDF reader or a VNC client. Substitute "" for "" if you want this to use Ubuntu's data instead. Everything else will work perfectly. Show Sample Output

    apt-popcon() { (echo \#rank; apt-cache search "$@" |awk '$1 !~ /^lib/ {print " "$1" "}') |grep -Ff- <(wget -qqO- |gunzip); }
    adamhotep · 2012-09-08 00:29:31 0
  • Create Debian package dependency graph using GraphViz

    apt-cache dotty PKG-NAME | dot -Tpng | display
    auriza · 2010-01-02 16:20:56 1

  • 3
    apt-get --just-print upgrade
    noqqe · 2010-02-18 11:19:05 5
  • if you don't want to show string "version?, then use awk or cut filter it: apt-cache show pkgname | grep -i "version:" | awk '{ print $2 }' we can also use regex to search many packages and show their versions: apt-cache search pkgregex | grep -i "version:" Show Sample Output

    apt-cache show pkgname | grep -i "version:"
    emacs · 2010-06-03 00:48:39 0
  • This let's you find out the total packages that have available upgrades. Usefull if you want to check or show the total available upgrades on your system. Show Sample Output

    apt-get -s upgrade | awk '/[0-9]+ upgraded,/ {print $1 " package updates are available"}'
    lpanebr · 2012-03-29 17:04:32 0
  • After, check if working by executing this command locally : git clone git@ Tutorial :

    apt-get -y install git-core gitosis; adduser --home /home/git --gecos "git user" git; su git -c "ssh-keygen -t rsa -f /home/git/.ssh/id_rsa; gitosis-init < ~/.ssh/id_rsa"
    strzel_a · 2010-12-19 20:37:12 0
  • Works for debian and ubuntu based distros. Show Sample Output

    apt list --upgradable | grep -v 'Listing...' | cut -d/ -f1 | tr '\r\n' ' ' | sed '$s/ $/\n/'
    bugmenot · 2019-12-13 16:16:19 8
  • An apt-get wrapper function which will run the command via sudo, but will run it normally if you're only downloading source files. This was a bit of an excuse to show off the framework of cmd && echo true || echo false ...but as you can see, you must be careful about what is in the "true" block to make sure it executes without error, otherwise the "false" block will be executed. To allow the apt-get return code to pass through, you need to use a more normal if/else block: apt-get () { if [ "$1" = source ]; then command apt-get "$@"; else sudo apt-get "$@"; fi }

    apt-get () { [ "$1" = source ] && (command apt-get "$@";true) || sudo apt-get "$@" }
    mulad · 2009-02-19 04:17:24 1
  • Taken from apticron and modified. Show Sample Output

    apt-get --ignore-hold --allow-unauthenticated -s dist-upgrade | grep ^Inst | cut -d ' ' -f2
    phunehehe · 2013-01-07 11:21:58 0
  • Usefull if you only want to see the package names, or if you want to use them in a script.

    apt-get -s upgrade | awk '/Inst.+/ {print $2}'
    lpanebr · 2013-03-25 21:23:11 0
  • 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

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

    apt-mark showmanual|xargs sudo apt-mark markauto
    DellDor · 2015-08-10 02:35:22 0
  • 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

    apt purge linux*{14..18}*
    ppq · 2016-04-20 07:44:55 0
  • This will also work with bash instead of sh shell sudo bash -c 'apt update -y && apt upgrade -y'

    sudo sh -c 'apt update -y && apt upgrade -y'
    ioshield · 2019-07-31 04:39:40 8
  • Search the names and descriptions of all available packages and prints out the name and the short description.

    apt-cache search someregex
    chrisdrew · 2009-02-07 09:15:19 2
  • For example: check the APT security keys to make sure the Google digital signature was imported correctly Show Sample Output

    apt-key list
    0disse0 · 2009-09-03 19:32:11 0
  •  1 2 > 

What's this? 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 strong, but easy to remember password
Why remember? Generate! Up to 48 chars, works on any unix-like system (NB: BSD use md5 instead of md5sum)

List your largest installed packages.
Calculates the size on disk for each package installed on the filesystem (or removed but not purged). This is missing the $ | sort -rn which would put the biggest packges on top. That was purposely left out as the command is slightly on the slow side Also you may need to run this as root as some files can only be checked by du if you can read them ;)

Extract public key from private
This will extract the public key that is stored in the private key using openssl.

Replace space in filename
This commands removes space from all the files with specific extension. I've specifed *.jpg as an example.

Check a server is up. If it isn't mail me.
This version uses netcat to check a particular service.

Alert visually until any key is pressed
I learned a few things reading this command. But I did run into a few issues: 1. On systems that don't use GNU echo (e.g. macOS 10.14.5 Mojave), the e option may not be supported. In this case ANSI escape codes will echoed as text and the terminal will not flash, like this: \e[?5h\e[38;5;1m A L E R T Thu Jun 20 16:31:29 PDT 2019 2. Since the read command strips\ignores leading backslashes, if a user types the backslash character once in the loop, it will not break. Typing backslash twice in a loop will break as expected. 3. The foreground color is set to red (\e[38;5;1m) on every loop. This could be set once before we call while, and then reset once when the loop breaks. 4. Instead of resetting the foreground color when it breaks, the video mode is set back to normal (\e[?5l). This has the effect of leaving the terminal text red until it is manually reset. The alternative I'm proposing here addresses these issues. I tested it on macOS and Arch Linux.

Execute a command, convert output to .png file, upload file to, then returning the address of the .png.
My key is the anonymous one, is good for 50 post an hour with a maximun number of uploads a day, probably will run out, if that happend you can get a free key at the site.

Break lines after, for example 78 characters, but don't break within a word/string
Per default, linux/unix shells are configured with a width of 80 characters. If you like to edit a phrase or string on a line with more than 80 characters it might take long to go there (for example a line with 1000 characters and you like to edit the 98th word which is character 598-603). Maybe you might wish to use 78 characters, because if you forward the text via mail and the text will be quoted (2 extra characters at the beginning to the line "> "), you use 80 characters, otherwise 82, which are lame.

Get AWS temporary credentials ready to export based on a MFA virtual appliance
You might want to secure your AWS operations requiring to use a MFA token. But then to use API or tools, you need to pass credentials generated with a MFA token. This commands asks you for the MFA code and retrieves these credentials using AWS Cli. To print the exports, you can use: `awk '{ print "export AWS_ACCESS_KEY_ID=\"" $1 "\"\n" "export AWS_SECRET_ACCESS_KEY=\"" $2 "\"\n" "export AWS_SESSION_TOKEN=\"" $3 "\"" }'` You must adapt the command line to include: * $MFA_IDis ARN of the virtual MFA or serial number of the physical one * TTL for the credentials

Stripping ^M at end of each line for files
just deletes to rogue CR from dos files, and tr is always available.

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.


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: