commandlinefu.com is the place to record those command-line gems that you return to again and again.
Delete that bloated snippets file you've been using and share your personal repository with the world. 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.
If you have a new feature suggestion or find a bug, please get in touch via http://commandlinefu.uservoice.com/
You can sign-in using OpenID credentials, or register a traditional username and password.
First-time OpenID users will be automatically assigned a username which can be changed after signing in.
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
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:
Maybe not clean with big package and too long argument. But return every file who can be executed.
I wanted to view only executables installed by a package. This seemed to work.
There's got to be easier way, please share.
Note:
(1) Replace iptables with the package name of your interest
(2) The command will trash any existing environment variable named 'lst'
(3) Instead if you are interested in viewing just .ko or .so files installed by this package, then
that would be easy:
$ dpkg -L iptables | grep "\.[sk]o$"
This script compares the modification date of /var/lib/dpkg/info/${package}.list and all the files mentioned there.
It could be wrong on noatime partitions.
Here is non-oneliner:
#!/bin/sh
package=$1;
list=/var/lib/dpkg/info/${package}.list;
inst=$(stat "$list" -c %X);
cat $list |
(
while read file; do
if [ -f "$file" ]; then
acc=$(stat "$file" -c %X);
if [ $inst -lt $acc ]; then
echo used $file
exit 0
fi;
fi;
done
exit 1
)
This should do the same thing and is about 70 chars shorter.
This will remove all installed kernels on your debian based install, except the one you're currently using.
From:
http://tuxtweaks.com/2009/12/remove-old-kernels-in-ubuntu/comment-page-1/#comment-1590
The ^python$ is a package name patten. You can change whatever you want.
Very handy if you have done a package selection mistake in aptitude.
Note that it's better to do a Ctrl+U (undo) in aptitude if possible, because the keep-all will clear some package states (like the 'hold' state).
dpigs is in the package debian-goodies (debian/ubuntu)
Use the hold space to preserve lines until data is needed.
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.
This helped me find a botnet that had made into my system. Of course, this is not a foolproof or guarantied way to find all of them or even most of them. But it helped me find it.
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
extracts the debian-package $debfile to $extractdir, including all packaging-information. to repack the package, just type:
dpkg-deb -b $extractdir
In Debian based distros, this command will list 'binutils' package details which contains 'nm' command. You can replace 'nm' to any other command.
will show:
installed linux headers, image, or modules: /^ii/!d
avoiding current kernel: /'"$(uname -r | sed "s/\(.*\)-\([^0-9]\+\)/\1/")"'/d
only application names: s/^[^ ]* [^ ]* \([^ ]*\).*/\1/
avoiding stuff without a version number: /[0-9]/!d
will purge:
only installed apps: /^ii/!d
avoiding current kernel stuff: /'"$(uname -r | sed "s/\(.*\)-\([^0-9]\+\)/\1/")"'/d
using app names: s/^[^ ]* [^ ]* \([^ ]*\).*/\1/
avoiding stuff without a version number: /[0-9]/!d
Useful for removes a package and its depends, for example to remove the gnome desktop environment, also configuration files will be removed, you should be carefully and sure that you want to do this.
'dpkg -S' just matches the string you supply it, so just using 'ls' as an argument matches any file from any package that has 'ls' anywhere in the filename. So usually it's a good idea to use an absolute path. You can see in the second example that 12 thousand files that are known to dpkg match the bare string 'ls'.
This command is useful when you want to install the same packages on another fresh OS install for example. To do that, use:
sudo dpkg --set-selections < LIST_FILE