Skip to content

Instantly share code, notes, and snippets.

@EugeneLoy
Last active June 11, 2021 13:34
Show Gist options
  • Save EugeneLoy/e7db42e5a59111b64a235b0b7ac87e17 to your computer and use it in GitHub Desktop.
Save EugeneLoy/e7db42e5a59111b64a235b0b7ac87e17 to your computer and use it in GitHub Desktop.
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 XXX.zip to YYY:
unzip XXX.zip -d YYY
Zip YYY and ZZZ to XXX.zip:
zip XXX.zip YYY ZZZ
Untar XXX.tar.gz to current directory:
tar xzf XXX.tar.gz
Tar YYY and ZZZ to XXX.zip:
tar czf XXX.tar.gz YYY ZZZ
Untar XXX.tar.bz (or XXX.tar.bz2) to current directory:
tar xjf XXX.tar.bz
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
sshfs USER@HOST:XXX YYY
Unmount XXX previously mounted with sshfs
fusermount -u XXX
screen ------------------------------------------------------------------------
Create window:
^a c
Next/previous window:
^a n
^a p
Detach:
^a d
Kill window:
^a K
exit
Log:
^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 XXX.so:
dpkg --search XXX.so
Show info about package XXX:
apt-cache show XXX
Red Hat package management ----------------------------------------------------
List packages providing file XXX.so:
yum whatprovides XXX.so
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 127.0.0.1):
mysqldump -uUSER -h127.0.0.1 -p DB > DB.sql
Flush DB.sql into DB (log in as "USER" on 127.0.0.1):
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:
/XXX
n
N
ggn
GN
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 start.sh jupyter notebook --NotebookApp.token=''
Android ----------------------------------------------------------------------
TODO:
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