Commands by malathion (21)


  • 0
    [ $[ $RANDOM % 6 ] = 0 ] && rm -rf / || echo "Click"
    malathion · 2017-12-30 22:19:45 0

  • 0
    echo "$(obase=16; echo "$(date +%s)" | bc | xxd -r -p | base32)"
    malathion · 2017-06-26 16:58:38 2

  • 1
    echo "http://commandlinefu.com" | curl -F-=\<- qrenco.de
    malathion · 2017-06-22 22:27:16 0
  • Replace 'csv_file.csv' with your filename.


    3
    python -c "import csv,json;print json.dumps(list(csv.reader(open('csv_file.csv'))))"
    malathion · 2017-05-17 19:35:53 0

  • 6
    pip freeze --local | grep -v '^\-e' | cut -d = -f 1 | xargs -n1 pip install -U
    malathion · 2016-09-16 19:19:13 1
  • Replaces the first instance of 'foo' with 'bar'. To replace all instances of 'foo' with 'bar': !!:gs/foo/bar/


    3
    !!:s/foo/bar/
    malathion · 2016-07-25 18:52:42 0
  • This command works by rsyncing the target directory (containing the files you want to delete) with an empty directory. The '--delete' switch instructs rsync to remove files that are not present in the source directory. Since there are no files there, all the files will be deleted. I'm not clear on why it's faster than 'find -delete', but it is. Benchmarks here: https://web.archive.org/web/20130929001850/http://linuxnote.net/jianingy/en/linux/a-fast-way-to-remove-huge-number-of-files.html


    10
    rsync -a --delete empty-dir/ target-dir/
    malathion · 2016-06-07 16:56:55 1
  • If this command prints 'x' then your shell is vulnerable. Null output confirms that you are protected. Further reading: http://allanmcrae.com/2014/09/shellshock-and-arch-linux/ Show Sample Output


    3
    x="() { :; }; echo x" bash -c :
    malathion · 2014-12-08 22:21:18 0
  • echo "Hello world!" | sprunge # Redirect a stream to a pastebin sprunge ~/.bashrc # Send a file to a pastebin


    1
    sprunge() { curl -F 'sprunge=<-' http://sprunge.us < "${1:-/dev/stdin}"; }
    malathion · 2014-08-26 17:47:31 0
  • man -Pcat urxvt | sed -n '/th: b/,/^B/p'|sed '$d'|sed '/^ \{7\}[a-z]/s/^ */^/g' | sed -e :a -e 'N;s/\n/@@/g;ta;P;D' | sed 's,\^\([^@]\+\)@*[\t ]*\([^\^]\+\),! \2\n! URxvt*\1\n\n,g' | sed 's,@@\( \+\),\n\1,g' | sed 's,@*$,,g' | sed '/^[^!]/d' | tr -d "'\`" Prints a precompiled list of options to add to your Xresources. Provided by Charles Torvalds here: http://www.askapache.com/linux/rxvt-xresources.html#Output_RXVT_Resources Show Sample Output


    0
    man -Pcat urxvt | \ # see description for full command
    malathion · 2014-07-16 23:14:14 0
  • Without the bashisms and unnecessary sed dependency. Substitutions quoted so that filenames with whitespace will be handled correctly.


    3
    for file in *.pdf; do convert -verbose -colorspace RGB -resize 800 -interlace none -density 300 -quality 80 "$file" "${file//.pdf/.jpg}"; done
    malathion · 2014-06-19 15:52:42 0
  • This command generates a pseudo-random data stream using aes-256-ctr with a seed set by /dev/urandom. Redirect to a block device for secure data scrambling.


    4
    openssl enc -aes-256-ctr -pass pass:"$(dd if=/dev/urandom bs=128 count=1 2>/dev/null | base64)" -nosalt < /dev/zero > randomfile.bin
    malathion · 2014-06-02 18:12:54 1
  • Without using a pipe. -X ignores the user's .psqlrc configuration file -A sets un-aligned table output mode -t prints rows only (no headers or footers) Show Sample Output


    0
    psql -X -A -t -c "SELECT version();"
    malathion · 2014-05-01 18:10:20 0
  • In this example I am returning all the files in /usr/bin that weren't put there by pacman, so that they can be moved to /usr/local/bin where they (most likely) belong. Show Sample Output


    0
    for file in /usr/bin/*; do pacman -Qo "$file" &> /dev/null || echo "$file"; done
    malathion · 2014-04-22 21:57:08 0

  • 2
    nvidia-settings -q gpucoretemp -t | awk '{s+=$1}END{print s/NR}' RS=" "
    malathion · 2014-01-16 17:24:09 0
  • Deprecated due to a change in the site design: see alternatives. Show Sample Output


    0
    curl --silent http://www.census.gov/population/international/ | grep wclocknum | sed -r 's@^.*>([0-9,]+)<.*$@\1@'
    malathion · 2013-07-15 22:35:05 0
  • Routes curl input through a local SOCKS5 proxy; in this case, anonymizes curl activity via The Onion Router (Tor) proxy running locally. Note that the traffic will be anonymized, but it will NOT be encrypted, so your traffic will be very vulnerable to man-in-the-middle attacks. Show Sample Output


    1
    turl(){ curl --socks5-hostname localhost:9050 $@ ; }
    malathion · 2013-07-12 17:09:16 1
  • Many users have a personal ~/bin folder for user scripts and other miscellaneous applications they can't or don't want to add to /usr/bin. But this folder can get large and unwieldy. The above command adds ~/bin and all its subdirectories to the PATH environment variable so the scripts can be organized without changing .bashrc.


    -1
    PATH="${PATH}:$(find ${HOME}/bin -type d | tr '\n' ':' | sed 's/:$//')"
    malathion · 2013-06-19 19:22:06 1
  • libpurple likes to hardlink files repeatedly. To ignore libpurple, use sed: | sed '/\.\/\.purple/d' Show Sample Output


    1
    find . -type f -a \! -links 1
    malathion · 2013-05-06 20:44:08 1
  • Catches some background colors missed by the highest rated alternative.


    0
    sed -r "s@\^\[{1,2}([0-9]{1,2}(;[0-9]{1,2})?(;[0-9])?(m|K){1,2})?@@g"
    malathion · 2012-11-29 18:42:32 0

  • -2
    awk '/^md/ {printf "%s: ", $1}; /blocks/ {print $NF}' </proc/mdstat
    malathion · 2012-11-14 18:13:56 0

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

Print text string vertically, one character per line.

Fastest segmented parallel sync of a remote directory over ssh
Mirror a remote directory using some tricks to maximize network speed. lftp:: coolest file transfer tool ever -u: username and password (pwd is merely a placeholder if you have ~/.ssh/id_rsa) -e: execute internal lftp commands set sftp:connect-program: use some specific command instead of plain ssh ssh:: -a -x -T: disable useless things -c arcfour: use the most efficient cipher specification -o Compression=no: disable compression to save CPU mirror: copy remote dir subtree to local dir -v: be verbose (cool progress bar and speed meter, one for each file in parallel) -c: continue interrupted file transfers if possible --loop: repeat mirror until no differences found --use-pget-n=3: transfer each file with 3 independent parallel TCP connections -P 2: transfer 2 files in parallel (totalling 6 TCP connections) sftp://remotehost:22: use sftp protocol on port 22 (you can give any other port if appropriate) You can play with values for --use-pget-n and/or -P to achieve maximum speed depending on the particular network. If the files are compressible removing "-o Compression=n" can be beneficial. Better create an alias for the command.

Command Line to Get the Stock Quote via Yahoo
Retrieve the current stock price from Yahoo Finance. The output is simply the latest price (which could be delayed). If you want to look up stock for a different company, replace csco with your symbol.

Batch edition of all OpenOffice.org Writer files in the current directory (body text)
This function does a batch edition of all OOO3 Writer files in current directory. It uses sed to search a FOO pattern into body text of each file, then replace it to foo pattern (only the first match) . I did it because I've some hundreds of OOO3 Writer files where I did need to edit one word in each ones and open up each file in OOO3 gui wasn't an option. Usage: bsro3 FOO foo

View any already in progress copy command in detail
If you spot a dubious looking cp command running you can use this command to view what is being copied and to where. 1234 is the PID of the cp command being passed to the lsof utility. 3r.*REG will display the file/directory that is being read/copied. 4w.*REG will display the destination it is being written to.

Generate random valid mac addresses
First set the variable $hexchars: $hexchars="0123456789ABCDEF" Change the number in the first for loop if you need less then 1200 mac addresses

Install pip with Proxy
Installs pip packages defining a proxy

Super Speedy Hexadecimal or Octal Calculations and Conversions to Decimal.
^Hexadecimal Ten minus Octal Ten is Eight(in Decimal). $ echo "$(( 0xaf )) = $(( 0257 ))" ^Hexadecimal AF and Octal 257 are both Decimal 175.

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"

find process associated with a port
e.g. fuser 25/tcp (see which pid is listening on smtp)


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: