Commands by anon1251 (1)

  • This command produces no output, but its exit status is 0 ("true") if $file is text, non-0 ("false") if $file is binary (or is not accessible). Explanation: -q suppresses all the output of grep -I is the trick: if a binary file is found, it is considered a non-match -m 1: limit "output" to first match (speed up for big files) .: the match string, "." stands for any character Usage: e.g. run editor only on text files grep -qIm 1 . $file && vi $file


    0
    grep -qIm1 . $file
    anon1251 · 2013-03-28 14:11:51 3

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

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"

Happy New Year!

Show current working directory of a process

take a look to command before action
add |sh when you agree the list, I often use that method to prevent typos in dangerous or long operations

Copy your ssh public key to a server from a machine that doesn't have ssh-copy-id
This one is a bit more robust -- the remote machine may not have an .ssh directory, and it may not have an authorized_keys file, but if it does already, and you want to replace your ssh public key for some reason, this will work in that case as well, without duplicating the entry.

Insert a line for each n lines

Get the IP address
gives u each configured IP in a seperate line.

Burn CD/DVD from an iso, eject disc when finished.
cdrecord -scanbus will tell you the (x,y,z) value of your cdr (for example, mine is 3,0,0)

Detect illegal access to kernel space, potentially useful for Meltdown detection
Based on capsule8 agent examples, not rigorously tested

Add the time to BASH prompt
Adds the time in 12hr AM/PM format to the beginning of a prompt. Change \@ to \t for 24-hour time or \T for 12hr without AM/PM. To keep the time the next time you open a terminal, edit ~/.bashrc and stick the command at the bottom.


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: