Function to add a shebang to an existing script, handy if you forgot to add it in the first place. Show Sample Output
Returns the number of lines in a file, emulates "wc -l" behavior with grep.
Replaces "650" with "999" in simple.xml. xml used - http://www.w3schools.com/xml/simple.xml
In this case the current user has proxy variable set which allows access to the rpm on the internet but needs root privs to install it. Running sudo -E preserves the current user proxy var and allows the rpm install to be executed with sudo.
For times when netcat isn't available.
Will throw a Connection refused message if a port is closed.
Scriptable:
(: </dev/tcp/127.0.0.1/80) &>/dev/null && echo "OPEN" || echo "CLOSED"
ls
httpd.conf httpd.conf.2015-07-22@14:43:20
Copy both perms and owner group from one file to another.
Runs a local script over ssh assuming ssh keys are in place. -P argument prints results to stdout. # Uses - https://code.google.com/p/parallel-ssh/
Syntax: $ prepend content to add [filename] Uses ed, so no temp files created.
Analyze an Apache access log for the time period with most activity and display the hit count, requesting IP and the timestamp. May help detect a brute force dos attack.
Oneliner to run commands on multiple servers over ssh. - First parameter "$1" is the command you want to execute remotely. ( It can be multiple commands e.g. "hostname;uptime") - Second parameter "${@:2}" represents the remote host/s you want to run the command/s on. Show Sample Output
Bash function to change your default prompt to something simpler and restore it to normal afterwards. Show Sample Output
Awk replaces the value of a specific field while retaining the field separator "/" . Show Sample Output
This inserts an element as last child under /breakfast_menu/food in simple.xml. xml used - http://www.w3schools.com/xml/simple.xml Show Sample Output
This prints file access rights in octal - useful when "stat" is unavailable. Show Sample Output
You can push files to up to 32 servers at once assuming ssh keys are in place. Great tool, it is part of the pssh suite.
This is also handy for taking a look at resource usage of a remote box.
ssh -t remotebox top
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: