# AllInOne: Update what packages are available, upgrade to new versions, remove unneeded packages # (some are no longer needed, replaced by the ones from ap upgrade), check for dependencies # and clean local cached packages (saved on disk but not installed?,some are needed? [this only cleans unneeded unlike ap clean]). # aliases (copy into ~/.bashrc file): alias a='alias' a ap='apt-get' a r='ap autoremove -y' a up='ap update' a u='up && ap upgrade -y --show-progress && r && ap check && ap autoclean' # && means "and run if the previous succeeded", you can change it to ; to "run even if previous failed". I'm not sure if ap check should be before or after ap upgrade -y, you can also change the alias names. # To expand aliases in bash use ctrl alt e or see this ow.ly/zBKHs # For more useful aliases go to ow.ly/zBMOx
Send a text message to an Kodi (XBMC) device. Uses curl to post a JSON request to the Kodi JSON-RPC API.
Its possible to user a simple regex to extract de username from the finger command. The final echo its optional, just for remove the initial space Show Sample Output
This command will use grep to read the shortcut (which in the above examle is file.url), and filter out all but the only important line, which contains the website URL, and some extra characters that will need to be removes (for example, URL=http://example.com). The cut command is then used to get rid of the URL= at the beginning. The output is then piped into Firefox, which should interpret the it as a web URL to be opened. Of course, you can replace Firefox with any other broswer. Tested in bash and sh.
Google Cloud SDK comes with a package manager `gcloud components` but it needs a bit of `sed` to work. Modify the "^| Not" bit to change the package selection. (The gcloud --format option is currently broken) Show Sample Output
Allows you to have a list of the domains on the server.
Easiest way to get the external IP address.
http://ifconfig.me is a web site which shows your public iP address. If you want use your own code, you can use PHP code such as: function getip() { return "".$_SERVER["REMOTE_ADDR"]; } echo getip(); ?> Then, you'll get your IP by 'curl yourfile.php'. Show Sample Output
Poor email reputation got you down? Perhaps you're unknowingly forwarding every spam email that makes it through to info@website.com to website@gmail.com. This command outputs every forwarding address set up within a Zimbra installation.
rename all dirs with "?" char in name, leave spaces and () in place Show Sample Output
List all dependencies manifests so you can install them. In a scenario where you want to deploy a number of web applications and run their dependency managers, how could you run all of them in a systematic order. One of the complexity is to ensure you get only your own top level dependencies. That way, you don recursively call development dependencies of your own dependencies. Otherwise you might end up discovering dependency management manifests that are already been pulled by your own projects. # Using this command This command helps me find them and I can then run what?s required to pull them from their respective sources. This command assumes the following: 1. Your code checkouts are in a flat repository layout (i.e. not nested). 2. Finds manifests for: - NPM (nodejs), - Composer (php), - bower, - requirements.txt (Python), and - git submodules Show Sample Output
Show top apps that use internet, sorted by count connections and grouped by TYPE and Protocol Show Sample Output
"$PWD" (in quotes) accounts for spaces and other characters normally escaped in file or folder names
Given a list of filenames, one per line, in /tmp/filelist, calculate the total sum disk usage.
OSX users as well as linux users with copy/paste buffer commands can remove duplicate items from their copy buffer with this command. I use this often when I have to copy a long list of items that I didn't generate, but I need to paste elsewhere in a list that's unique. If retaining the original order of lines isn't important to you, use the following command which is easier to remember. pbpaste | sort | uniq | pbcopy
Use tee -a to append.
If you are on machine 1 and want to ssh into machine 3, but you can only do so from machine 2, this will do it all in one go. Note that once you are on machine 3 and exit () it will take you directly back to machine 1
Use this command to execute the contents of http://www.example.com/automation/remotescript.sh in the local environment. The parameters are optional.
Alterrnatives to wget:
CURL:
curl -s http://www.example.com/automation/remotescript.sh | bash /dev/stdin param1 param2
W3M:
w3m -dump http://www.example.com/automation/remotescript.sh | bash /dev/stdin [param1] [param2]
LYNX:
lynx -source http://www.example.com/automation/remotescript.sh | bash /dev/stdin [param1] [param2]
Removes directories which are less than 1028KB total. This works for systems where blank directories are 4KB. If a directory contains 1 MB (1024KB) or less, it will remove the directory using a path relative to the directory where the command was initially executed (safer than some other options I found).
Adjust the 1028 value for your needs.
It would be helpful to test the results before proceeding with the removal. Simply run all but the last two commands to see a list of what will be removed:
du | awk '{if($1<1028)print;}' | cut -d $'\t' -f 2-
If you're unsure what size a blank folder is, test it like this:
mkdir test; du test; rmdir test
Useful for sending as ARD command as root. Official apple sanctioned method for getting logged in user below: loggedInUser="$(python -c 'from SystemConfiguration import SCDynamicStoreCopyConsoleUser; import sys; username = (SCDynamicStoreCopyConsoleUser(None, None, None) or [None])[0]; username = [username,""][username in [u"loginwindow", None, u""]]; sys.stdout.write(username + "\n");')" Show Sample Output
Get an approximation of who the workstation is assigned to. You can wrap it in su - "$()" if you want to log into a shell as that user. 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: