Category Archives: Bash

return external ip

By MrTux (http://www.ubuntu-vn.org) $ curl ipinfo.io Return IP information about your external ip address with JSON format View this command to comment, vote or add to favourites View all commands by MrTux Diff your entire server config at ScriptRock.com Source:: http://www.commandlinefu.com/commands/view/17722/return-external-ip

Nice weather forecast on your shell

By nordri (http://www.muspells.net) $ curl wttr.in/seville Change Seville for your prefered city. View this command to comment, vote or add to favourites View all commands by nordri Diff your entire server config at ScriptRock.com Source:: http://www.commandlinefu.com/commands/view/17709/nice-weather-forecast-on-your-shell

random git-commit message

By paulera (http://paulodev.com) $ git commit -m “$(curl -s http://whatthecommit.com/index.txt)”; Do a git commit using a random message. View this command to comment, vote or add to favourites View all commands by paulera Diff your entire server config at ScriptRock.com Source:: http://www.commandlinefu.com/commands/view/17250/random-git-commit-message

Read and write to TCP or UDP sockets with common bash tools

By tyzbit (http://qtosw.com) $ exec 5/dev/tcp/time.nist.gov/13; cat &5; exec 5>&- Ever needed to test firewalls but didn’t have netcat, telnet or FTP? Enter /dev/tcp, your new best friend. /dev/tcp/(hostname)/(port) is a virtual device that bash can use to talk to TCP ports First, exec sets up a redirect for /dev/tcp/$server/$host to file descriptor 5. Then, […]

drop first column of output by piping to this

By snaguber $ awk ‘{ $1=””;print}’ View this command to comment, vote or add to favourites View all commands by snaguber Diff your entire server config at ScriptRock.com Source:: http://www.commandlinefu.com/commands/view/14281/drop-first-column-of-output-by-piping-to-this

Search for a process by name

By pooderbill $ ps -fC PROCESSNAME ps and grep is a dangerous combination — grep tries to match everything on each line (thus the all too common: grep -v grep hack). ps -C doesn’t use grep, it uses the process table for an exact match. Thus, you’ll get an accurate list with: ps -fC sh […]

Simple multi-user encrypted chat server for 5 users

By snipertyler $ ncat -vlm 5 –ssl –chat 9876 Client ~$ ncat –ssl localhost 9876 Change localhost to the correct ip address. View this command to comment, vote or add to favourites View all commands by snipertyler by David Winterbottom (codeinthehole.com) Source:: http://www.commandlinefu.com/commands/view/13460/simple-multi-user-encrypted-chat-server-for-5-users

Silently ensures that a FS is mounted on the given mount point (checks if it’s OK, otherwise unmount, create dir and mount)

By tweet78 $ (mountpoint -q “/media/mpdr1” && df /media/mpdr1/* > /dev/null 2>&1) || ((sudo umount “/media/mpdr1” > /dev/null 2>&1 || true) && (sudo mkdir “/media/mpdr1” > /dev/null 2>&1 || true) && sudo mount “/dev/sdd1” “/media/mpdr1”) In my example, the mount point is /media/mpdr1 and the FS is /dev/sdd1 /mountpoint-path = /media/mpdr1 filesystem=/dev/sdd1 Why this command […]

sniff network traffic on a given interface and displays the IP addresses of the machines communicating with the current host (one IP per line)

By tweet78 $ sudo tcpdump -i wlan0 -n ip | awk ‘{ print gensub(/(.*)..*/,”\1″,”g”,$3), $4, gensub(/(.*)..*/,”\1″,”g”,$5) }’ | awk -F ” > ” ‘{print $1″n”$2}’ View this command to comment, vote or add to favourites View all commands by tweet78 by David Winterbottom (codeinthehole.com) Source: http://www.commandlinefu.com/commands/view/13324/sniff-network-traffic-on-a-given-interface-and-displays-the-ip-addresses-of-the-machines-communicating-with-the-current-host-one-ip-per-line

Given a file path, unplug the USB device on which the file is located (the file must be on an USB device !)

By tweet78 $ echo $(sudo lshw -businfo | grep -B 1 -m 1 $(df “/path/to/file” | tail -1 | awk ‘{print $1}’ | cut -c 6-8) | head -n 1 | awk ‘{print $1}’ | cut -c 5- | tr “:” “-“) | sudo tee /sys/bus/usb/drivers/usb/unbind You have an external USB drive or key. Apply […]