Developers CheatSheet: Linux

A collection of useful commands to get things done.

GIT

Display a formatted list of commits in a range for a specific user
git log --pretty=format: "%aD %an %s" -author="tom" --after="2015-02-08 00:00 --before="2015-03-15 23:59"

Linux/Unix/Mac OS

Add a soft symbolic link
symlink: sudo ln -s /opt/google/chrome/google-chromedriver /usr/bin/chromedriver
brace expansion
echo {aa,bb,cc}
echo file{0..10}.txt

    Getting help

  1. help
  2. man
  3. whatis/apropos
  4. which
  5. whereis
  6. locate

History

!! execute last command
!commandString reruns last command with commandString
!num rerun command by number
ctrl+r+string search command history for last command with string

Shell commands

Set background
setterm -background white -foreground white -store

Networking

connecting

Access remote machine
ssh username@server
Port forwarding
ssh -L <remote port>:<host name>:<host port> username@server

transferring files

copy remote file to local location
scp username@host:mydir/myfile local/dir
copy local file to remote location
scp local/dir username@host:mydir/myfile

web requests

Request data from a web page
curl -XGET -u username:password "http://hostname:port/path?params=value"
search response and count occurrences. Need 2>&1 to properly handle output. Drop the pipe to wc -l if only search is needed
curl -XGET -u username:password "http://hostname:port/path?params=value" 2>&1| grep -o 'searchterm' |wc -l
curl to elastic search. Simple filtered query
curl -XGET localhost:9200///_search -d ‘{"query": { "filtered": { "query": {"match_all": {}}, "filter": { "and": [ {"term": {"": “"}}, {"term":{"": “"}} ] } } }

This entry was posted in Uncategorized. Bookmark the permalink.

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