Commands by adminzim (2)

  • This command uses the debugger to attach to a running process, and reassign a filehandle to a file. The two commands executed in gdb are p close(1) which closes STDOUT and p creat("/tmp/filename",0600) which creates a file and opens it for output. Since file handles are assigned sequentially, this command opens the file in place of STDOUT and once the process continues, new output to STDOUT will instead be written to our capture file. Show Sample Output


    8
    yes 'Y'|gdb -ex 'p close(1)' -ex 'p creat("/tmp/output.txt",0600)' -ex 'q' -p pid
    adminzim · 2009-02-20 17:36:57 16

  • 56
    vim scp://username@host//path/to/somefile
    adminzim · 2009-02-18 15:09:53 33

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

Echo the latest commands from commandlinefu on the console
A Quick variation to the latest commands list with the new-lines skipped. This is faster to read.

Search $PATH for a command or something similar
Searches your $PATH for whatever you substitute for bash, though not sure if this will work if you substitute a different shell for bash!

Colorize make, gcc, and diff output
Colorize output of make, gcc/g++ or diff, making it easier to read at a glance. They are not distributed with make, diff or gcc, but are usually available in the repositories.

Uptime in minute
Want to run scripts/programs in the system after starting X minute [ For letting the system to free ]? This will give uptime in minute.

Pull Total Memory Usage In Virtual Environment
This command basically adds up all of the individual instances processes and gives you a grand total for used memory in that instance alone.

tar.gz with gpg-encryption on the fly
Create a encrypted tar.gz file from a directory on the fly. The encryption is done by GPG with a public key. The resulting filename is tagged with the date of creation. Very usefull for encrypted snapshots of folders.

Which processes are listening on a specific port (e.g. port 80)
swap out "80" for your port of interest. Can use port number or named ports e.g. "http"

renames multiple files that match the pattern
Useful when you want to quickly rename a bunch of files.

Ping all hosts on 192.168.1.0/24
-b option takes the broadcast address.

Which processes are listening on a specific port (e.g. port 80)
swap out "80" for your port of interest. Can use port number or named ports e.g. "http"


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: