Skip to content

Instantly share code, notes, and snippets.

Last active Jun 11, 2021
What would you like to do?
Cheat Sheets
Searching ---------------------------------------------------------------------
Find all files that has full filename pattern "YYY" in this rdirectory, recursive:
find . -wholename "YYY"
Find all matches of regexp "XXX" in file YYY:
grep -n -E "XXX" YYY
Find all occurences of "XXX" in all files with name "YYY" in this directory, recursive:
find . -name "YYY" -print0 | xargs -0 grep -n -F "XXX"
Archives ----------------------------------------------------------------------
Unzip to YYY:
unzip -d YYY
Zip YYY and ZZZ to
Untar XXX.tar.gz to current directory:
tar xzf XXX.tar.gz
Tar YYY and ZZZ to
tar czf XXX.tar.gz YYY ZZZ
Untar (or XXX.tar.bz2) to current directory:
tar xjf
Untar XXX.tar to current directory:
tar xf XXX.tar
Unrar XXX.rar to current directory:
unrar e XXX.rar
Extract XXX.7z to current directory:
7za e XXX.7z
ssh ---------------------------------------------------------------------------
Copy XXX to remote host (save as ~/XXX):
scp -r XXX USER@HOST:.
Copy ~/XXX from remote host:
scp -r USER@HOST:XXX .
Mount ~/XXX from remote host to YYY
Unmount XXX previously mounted with sshfs
fusermount -u XXX
screen ------------------------------------------------------------------------
Create window:
^a c
Next/previous window:
^a n
^a p
^a d
Kill window:
^a K
^a H
View sessions:
screen -ls
Reattach to session SESSION:
screen -r SESSION
Debian package management -----------------------------------------------------
Add XXX PPA and sync package index:
add-apt-repository XXX
apt-get update
Resolve dependencies and install XXX.deb:
gdebi XXX.deb
Remove XXX and unused packageges it depends on (also removes configs):
apt-get autoremove --purge XXX
List packages providing file
dpkg --search
Show info about package XXX:
apt-cache show XXX
Red Hat package management ----------------------------------------------------
List packages providing file
yum whatprovides
Show info about package XXX:
yum info XXX
C/C++ -------------------------------------------------------------------------
List explicit dynamic dependencies for XXX:
readelf -d XXX
List resolved dynamic dependencies for XXX:
ldd -v XXX
MySQL -------------------------------------------------------------------------
Dump DB to DB.sql (log in as "USER" on
mysqldump -uUSER -h127.0.0.1 -p DB > DB.sql
Flush DB.sql into DB (log in as "USER" on
mysql -uUSER -h127.0.0.1 -p DB < DB.sql
vim (TODO) -------------------------------------------------------------------------
Search for XXX (append \C to make case sensitive), next, previous, first, last:
h move one character left
j move one row down
k move one row up
l move one character right
:q! quit without saving
:x save and quit
Git -------------------------------------------------------------------------
Make local branch LOCAL_BRANCH_NAME from GitHub pull request with PULL_REQUEST_ID:
git fetch origin pull/PULL_REQUEST_ID/head:LOCAL_BRANCH_NAME
Clone svn repo at URL to DIR (fetch svn history from REVISION):
git svn init URL DIR
cd DIR
git svn fetch -r REVISION:HEAD
Fetch changes from remote svn repo and rebase on top of them:
git svn rebase
Commit from master remote svn repo:
git svn dcommit --rmdir
Docker ----------------------------------------------------------------------
Detach from tty
Ctrl+p Ctrl+q
Create notebook container:
docker run -it -d -p 8888:8888 -v /c/Users/Leo/workspace/:/home/jovyan/workspace/ --name notebook jupyter/scipy-notebook jupyter notebook --NotebookApp.token=''
Android ----------------------------------------------------------------------
Linux: ~/Android/Sdk
Mac: ~/Library/Android/sdk
Windows: %LOCALAPPDATA%\Android\sdk
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment