Commands by Flameeyes (7)

  • This is a quick replacement for lspci if you need to know what's in a given system but pciutils is not installed. You then need something that can look up the IDs from pci.ids if you want the verbose output. Show Sample Output


    4
    for device in /sys/bus/pci/devices/*; do echo "$(basename ${device} | cut -c '6-') $(cut -c '3-6' ${device}/class): $(cut -c '3-' ${device}/vendor):$(cut -c '3-' ${device}/device)"; done
    Flameeyes · 2012-04-13 03:26:02 16
  • This works in combination with http://www.commandlinefu.com/commands/view/10496/identify-exported-sonames-in-a-path as it reports the NEEDED entries present in the files within a given path. You can then compare it with the libraries that are exported to make sure that, when cross-building a firmware image, you're not bringing in dependencies from the build host. The short version of it as can be seen in the same output is scanelf -RBnq -F "+n#f" $1 | tr ',' '\n' | sort -u Show Sample Output


    1
    scanelf --nobanner --recursive --quiet --needed --format "+n#F" $1 | tr ',' '\n' | sort -u
    Flameeyes · 2012-03-29 18:30:45 3
  • This provides a list of shared object names (sonames) that are exported by a given tree. This is usually useful to make sure that a given required dependency (NEEDED entry) is present in a firmware image tree. The shorter (usable) version for it would be scanelf -RBSq -F "+S#f" But I used the verbose parameters in the command above, for explanation. Show Sample Output


    1
    scanelf --nobanner --recursive --quiet --soname --format "+S#f"
    Flameeyes · 2012-03-29 18:26:25 3
  • The command requires app-text/xmlstarlet but it otherwise self-contained. It extracts all the herds and all the maintainers' email for a given package and is what I'm using on the Tinderbox to make it easier for me to report bugs. Show Sample Output


    0
    xmlstarlet sel -t -m '/pkgmetadata/herd' -v . -n -t -m '/pkgmetadata/maintainer' -v email metadata.xml
    Flameeyes · 2010-08-09 22:37:19 3
  • This does almost the same thing as the original, but it runs the full backtrace for _all_ the threads, which is pretty important when reporting a crash for a multithreaded software, since more often than not, the signal handler is executed in a different thread than the crash happened.


    6
    gdb --batch --quiet -ex "thread apply all bt full" -ex "quit" ${exe} ${corefile}
    Flameeyes · 2010-07-06 14:49:03 10
  • The output is only partial because runtime dependencies should count in also commands executed via system() and libraries loaded with dlopen(), but at least it gives an idea of what a package directly links to. Note: this is meaningful *only* if you're using -Wl,--as-needed in your LDFLAGS, otherwise it'll bring you a bunch of false positives. Show Sample Output


    2
    qlist --exact "$pkg" | sudo scanelf --needed --quiet --format '%n#F' | tr ',' '\n' | sort -u | qfile --from -
    Flameeyes · 2010-07-06 14:39:15 94
  • Revised approach to and3k's version, using pipes and read rather than command substitution. This does not require fiddling with IFS when paths have whitespace, and does not risk hitting command-line size limits. It's less verbose on the missing files, but it stops iterating at the first file that's missing, so it should be definitely faster. I expanded all the qlist options to be more self-describing.


    3
    emerge -av1 `qlist --installed --nocolor | uniq | while read cp; do qlist --exact $cp | while read file; do test -e $file || { echo $cp; echo "$cp: missing $file (and maybe more)" 1>&2; break; }; done; done`
    Flameeyes · 2010-07-04 19:55:42 5

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

save stderr only to a file
taken from http://www.unix.com/shell-programming-scripting/158311-how-tee-stderr.html " What does it mean? The redirection operator n>&m makes file descriptor n to be a copy of file descriptor m. So, whe are: - Opening a new file descriptor, 3, that is a copy of file descriptor 1, the standard output; - Making file descriptor 1 a copy of file descriptor 2, the standard error output; - Making file descriptor 2 to be a copy of file descriptor 3 (the "backup" of the standard output) in a short: we swapped the standard output and the standard error output. "

Get your outgoing IP address

youtube2m3u
generate playlists from youtube ( or othre things that support yt-dlp)

Read info(1) pages using 'less' instead of GNU Texinfo
I like man pages, and I like using `less(1)` as my pager. However, most GNU software keeps the manual in the 'GNU Texinfo' format, and I'm not a fan of the info(1) interface. Just give me less. This command will print out the info(1) pages, using the familiar interface of less!

save your current environment as a bunch of defaults

Monitor all DNS queries seen by the local machine

delete files containing matching text
-r recursively -Z zero byte after each file name instead of the usual newline -l only filenames

a function to find the fastest DNS server
http://public-dns.info gives a list of online dns servers. you need to change the country in url (br in this url) with your country code. this command need some time to ping all IP in list.

Check the status of a network interface
no need for installing mii-tools, all generic tools working under archlinux.

sort lines by length


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: