Maybe not clean with big package and too long argument. But return every file who can be executed.
What do you do when nmap is not available and you want to see the hosts responding to an icmp echo request ? This one-liner will print all hosts responding with their ipv4 address.
GeoIP Needs to be installed. Can be done from some distro's or via MaxMind.com for free. There even is a free city database availabble. If the GeoLiteCity is downloaded and installed it will also find more information
geoiplookup -f /var/lib/GeoIP/GeoLiteCity.dat commandlinefu.com
GeoIP City Edition, Rev 1: US, NJ, Absecon, 08201, 39.420898, -74.497704, 504, 609
Show Sample Output
May be useful to get user's ip address over the phone, as users struggle to read through a long ipconfig result. Show Sample Output
Downloads Bluetack's level 1 IP blocklist in .p2p format, suitable for various Bittorrent clients.
Fir3net.com
Alternative, imho better, using the concat protocol
Better use iproute2 !
In the above example 'muspi merol' (the output of the first rev command) is sent to stderr and 'lorem ipsum' (the output of the second rev command) is sent to stdout. rev reverse lines of a file or files. This use of tee allows testing if a program correctly handles its input without using files that hold the data. Show Sample Output
This command will sort the contents of FILENAME by redirecting the output to individual .txt files in which 3rd column will be used for sorting. If FILENAME contents are as follows: foo foo A foo bar bar B bar lorem ipsum A lorem Then two files called A.txt and B.txt will be created and their contents will be: A.txt foo foo A foo lorem ipsum A lorem and B.txt will be bar bar B bar
Someone might attack on your system. You can drop attacker IP using IPtables. However, you can use route command to null route unwanted traffic. A null route (also called as blackhole route) is a network route or kernel routing table entry that goes nowhere. Matching packets are dropped (ignored) rather than forwarded, acting as a kind of very limited firewall. The act of using null routes is often called blackhole filtering. Show Sample Output
edit the /etc/sysconfig/iptables file and try to work whit this: -A INPUT -i (interface) -m mac (mac address) -j ACCEPT/DROP
can be used within a script to configure iptables for example: iface=$2 inet_ip=`ifconfig "$iface" | grep inet | cut -d: -f2 | cut -d ' ' -f1` ipt="sudo /sbin/iptables" ......................... ---------------------------------------------------------------------------------------------------------------- $ipt -A INPUT -i $iface ! -f -p tcp -s $UL -d $inet_ip --sport 1023: --dport 3306 -m state --state NEW,ESTABLISHED -j ACCEPT ---------------------------------------------------------------------------------------------------------------- ----------------------------------------------------------------------------------------------------------------- $ipt -A OUTPUT -o $iface -p tcp -s $inet_ip -d $UL --sport 3306 --dport 1023: -m state --state ESTABLISHED,RELATED -j ACCEPT ----------------------------------------------------------------------------------------------------------------- Show Sample Output
Then you can remove the specific entry: iptables -D INPUT 10 Just make sure these are set: IPTABLES_SAVE_ON_STOP="yes" IPTABLES_SAVE_ON_RESTART="yes" Else your changes won't stick when you restart iptables. Show Sample Output
For ipv6 use: grep -oE "\b([0-9A-Fa-f]{1,4}:){7}[0-9A-Fa-f]{1,4}\b"
Simple and easy. No regex, no search and replace. Just clean, built-in tools.
Combines wgzhao's grep | awk | sed into one awk command.
To show ipv6 instead, use [[ -6 ]] instead of [[ -4 ]]
ip -o -6 a s | awk -F'[ /]+' '$2!~/lo/{print $4}'
To show only the IP of a specific interface, in case you get more than one result:
ip -o -4 a s eth0 | awk -F'[ /]+' '$2!~/lo/{print $4}'
ip -o -4 a s wlan0 | awk -F'[ /]+' '$2!~/lo/{print $4}'
Show Sample Output
Sometimes it's useful to output just the ip address. Or some other information, changing the "ipv4.addresses" in command. The power of awk! Show all possible "greps" with
nmcli connection show [yourInterfaceNameHere]
Show Sample Output
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.
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
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: