commandline

commandlinefu.com

http://www.commandlinefu.com/commands/browse/sort-by-votes

  • OS-X ctrl + l (alternative: clear) it is not really clean screen, it just move log up out current screen so you still able to scroll it.  When you press command + k it really clear console.
  • cd -; get back to the directory u were previously in.
  • echo; kind of printf
  • (cd /tmp && ls)
    Jump to a directory, execute a command and jump back to current dir
  • tail – output the last part of files (default is 10 lines)
  • ps aux | grep firefox; http://superuser.com/questions/117913/ps-aux-output-meaning
  • ps aux | sort -b -k  +4 | tail; Display the top ten running processes – sorted by memory usage
  • ps aux | sort -b -k  +3 | tail; Display the top ten running processes – sorted by CPU usage;
  • sort -k position (start with 1)
  • echo “!!” > foo.sh; Create a script of the last executed command
  • http://www.thegeekstuff.com/2008/08/15-examples-to-master-linux-command-line-history/
  • history; list of history commands
  • !5; run the 5th command in the history list
  • rm !(*.foo|*.bar|*.baz)
  • pgrep firefox = Get the PID of a process by name
  • ls -R | grep “:$” | sed -e ‘s/:$//’ -e ‘s/[^-][^\/]*\//–/g’ -e ‘s/^/ /’ -e ‘s/-/|/’;  same as tree command, but there is no “tree” command on mac OS;
  • mkdir -p a/long/directory/path
    Make directory including intermediate directories;you can also use the list notation:mkdir -p root/child0/child1/{ab,cd,de,ef}will create 4 directories named ‘ab’, ‘cd’, ‘de’, ‘ef’ in root/child0/child1.

  • cat ~/.ssh/id_rsa.pub | ssh user@machine “mkdir ~/.ssh; cat >> ~/.ssh/authorized_keys”; Copy your SSH public key on a remote machine for passwordless login; Copy your ssh public key to a server from a machine that doesn’t have ssh-copy-id

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s