Skip to content

Instantly share code, notes, and snippets.

@mgmilcher
Last active October 12, 2015 10:08
Show Gist options
  • Save mgmilcher/ca112118df797f885a4e to your computer and use it in GitHub Desktop.
Save mgmilcher/ca112118df797f885a4e to your computer and use it in GitHub Desktop.
Linux Crib Sheet

Linux Shortcuts

General Crib Sheet

Find a file

find / -name php.ini

Find Directory

find httpdocs -type d

Rsync folder

 rsync -avz -e ssh [email protected]:~/folder/ /local/folder/

Share SSH Key on server

cat ~/.ssh/id_rsa.pub | ssh [email protected] "mkdir -p ~/.ssh && cat >>  ~/.ssh/authorized_keys"

Clone Remote MySQL DB through SSH

ssh remoteserver.com -R 3307:localhost:3306 'mysqldump --all-databases -u<remote-user> -p<remote-pwd> | mysql --host=127.0.0.1 --port=3307 -u<local-user> -p<local-pwd>'

Dump MySQL into a file from Remote system (Backup)

mysqldump --opt --user=username --password=password --host=yourMySQLHostname dbname > output.sql

List of open files. Detect ports and processes.

lsof -Pni4 | grep LISTEN | grep TCP

Symbolic Link

ln -s {/path/to/file-name} {link-name}

RHEL / CentOs

Package Management - yum

Update all packages

yum update

Search for a package

yum search httpd<*>

Get info on a package

yum info any-package<*>

Remove an installed package

yum remove any-package<*>

List all installed packages

yum list installed|less

VIM

Search document

  • To find a word in VI / Vim, just type "/" or "?", followed by the word you're searching for.
  • Pressing the n key, will allow you to go directly to the next occurrence of the word.
  • Another feature is to launch a search on the word where the cursor is positioned. Place the cursor over the word to search for, then press * or # to to look it up.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment