Check These Out
Ever needed to test firewalls but didn't have netcat, telnet or even FTP?
Enter /dev/tcp, your new best friend. /dev/tcp/(hostname)/(port) is a bash builtin that bash can use to open connections to TCP and UDP ports.
This one-liner opens a connection on a port to a server and lets you read and write to it from the terminal.
How it works:
First, exec sets up a redirect for /dev/tcp/$server/$port to file descriptor 5.
Then, as per some excellent feedback from @flatcap, we launch a redirect from file descriptor 5 to STDOUT and send that to the background (which is what causes the PID to be printed when the commands are run), and then redirect STDIN to file descriptor 5 with the second cat.
Finally, when the second cat dies (the connection is closed), we clean up the file descriptor with 'exec 5>&-'.
It can be used to test FTP, HTTP, NTP, or can connect to netcat listening on a port (makes for a simple chat client!)
Replace /tcp/ with /udp/ to use UDP instead.
seq allows you to format the output thanks to the -f option. This is very useful if you want to rename your files to the same format in order to be able to easily sort for example:
$for i in `seq 1 3 10`; do touch foo$i ;done
And
$ls foo* | sort -n
foo1
foo10
foo4
foo7
But:
$for i in `seq -f %02g 1 3 10`; do touch foo$i ;done
So
$ls foo* | sort -n
foo01
foo04
foo07
foo10
Checks the apache configuration syntax, if is OK then restart the service otherwise opens the configuration file with VIM on the line where the configuration fails.
curl inet-ip.info -> 113.33.232.62\n
curl inet-ip.info/ip -> 113.33.232.62
curl inet-ip.info/json -> JSON print
curl inet-ip.info/json/indent -> JSON pretty print
curl inet-ip.info/yaml -> YAML format
curl inet-ip.info/toml -> TOML format
http://inet-ip.info
Create a exact mirror of the local folder "/root/files", on remote server 'remote_server' using SSH command (listening on port 22)
(all files & folders on destination server/folder will be deleted)
If you just executed some long command, like "ps -aefww | grep -i [m]yProcess", and if you don't want to retype it or cycle backwards in history and waste time quoting it, then you can use history substitution.
Replaces A with B in binary file "orig" and saves the result to "new". You must have the hex representations of A & B. Try od: echo -e "A\c" | od -An -x
For mac users !
I added -S to du so that you don't include /foo/bar/baz.iso in /foo, and change sorts -n to -h so that it can properly sort the human readable sizes.