added 10 new cheat sheets: finger git hdparm hexdump jot lynx rs sox sudo xev
parent
e2bf4320ab
commit
b9481c41cc
@ -0,0 +1,9 @@
|
||||
# Produces a multi-line format displaying all of the information described for
|
||||
# the -s option as well as the user's home directory, home phone number, login
|
||||
# shell, mail status, and the contents of the files “.plan”, “.project”,
|
||||
# “.pgpkey” and “.forward” from the user's home directory.
|
||||
finger -s username
|
||||
|
||||
# weather report in console (for nuremberg in this case)
|
||||
finger nuremberg@graph.no
|
||||
|
@ -0,0 +1,168 @@
|
||||
# To set your identity:
|
||||
git config --global user.name "John Doe"
|
||||
git config --global user.email johndoe@example.com
|
||||
|
||||
# To set your editor:
|
||||
git config --global core.editor emacs
|
||||
|
||||
# To enable color:
|
||||
git config --global color.ui true
|
||||
|
||||
# To stage all changes for commit:
|
||||
git add --all
|
||||
|
||||
# To stash changes locally, this will keep the changes in a separate changelist
|
||||
# called stash and the working directory is cleaned. You can apply changes
|
||||
# from the stash anytime
|
||||
git stash
|
||||
|
||||
# To stash changes with a message
|
||||
git stash save "message"
|
||||
|
||||
# To list all the stashed changes
|
||||
git stash list
|
||||
|
||||
# To apply the most recent change and remove the stash from the stash list
|
||||
git stash pop
|
||||
|
||||
# To apply any stash from the list of stashes. This does not remove the stash
|
||||
# from the stash list
|
||||
git stash apply stash@{6}
|
||||
|
||||
# To commit staged changes
|
||||
git commit -m "Your commit message"
|
||||
|
||||
# To edit previous commit message
|
||||
git commit --amend
|
||||
|
||||
# Git commit in the past
|
||||
git commit --date="`date --date='2 day ago'`"
|
||||
git commit --date="Jun 13 18:30:25 IST 2015"
|
||||
# more recent versions of Git also support --date="2 days ago" directly
|
||||
|
||||
# To change the date of an existing commit
|
||||
git filter-branch --env-filter \
|
||||
'if [ $GIT_COMMIT = 119f9ecf58069b265ab22f1f97d2b648faf932e0 ]
|
||||
then
|
||||
export GIT_AUTHOR_DATE="Fri Jan 2 21:38:53 2009 -0800"
|
||||
export GIT_COMMITTER_DATE="Sat May 19 01:01:01 2007 -0700"
|
||||
fi'
|
||||
|
||||
# To removed staged and working directory changes
|
||||
git reset --hard
|
||||
|
||||
# To go 2 commits back
|
||||
git reset --hard HEAD~2
|
||||
|
||||
# To remove untracked files
|
||||
git clean -f -d
|
||||
|
||||
# To remove untracked and ignored files
|
||||
git clean -f -d -x
|
||||
|
||||
# To push to the tracked master branch:
|
||||
git push origin master
|
||||
|
||||
# To push to a specified repository:
|
||||
git push git@github.com:username/project.git
|
||||
|
||||
# To delete the branch "branch_name"
|
||||
git branch -D branch_name
|
||||
|
||||
# To make an exisiting branch track a remote branch
|
||||
git branch -u upstream/foo
|
||||
|
||||
# To see who commited which line in a file
|
||||
git blame filename
|
||||
|
||||
# To sync a fork with the master repo:
|
||||
git remote add upstream git@github.com:name/repo.git # Set a new repo
|
||||
git remote -v # Confirm new remote repo
|
||||
git fetch upstream # Get branches
|
||||
git branch -va # List local - remote branches
|
||||
git checkout master # Checkout local master branch
|
||||
git checkout -b new_branch # Create and checkout a new branch
|
||||
git merge upstream/master # Merge remote into local repo
|
||||
git show 83fb499 # Show what a commit did.
|
||||
git show 83fb499:path/fo/file.ext # Shows the file as it appeared at 83fb499.
|
||||
git diff branch_1 branch_2 # Check difference between branches
|
||||
git log # Show all the commits
|
||||
git status # Show the changes from last commit
|
||||
|
||||
# Commit history of a set of files
|
||||
git log --pretty=email --patch-with-stat --reverse --full-index -- Admin\*.py > Sripts.patch
|
||||
|
||||
# Import commits from another repo
|
||||
git --git-dir=../some_other_repo/.git format-patch -k -1 --stdout <commit SHA> | git am -3 -k
|
||||
|
||||
# View commits that will be pushed
|
||||
git log @{u}..
|
||||
|
||||
# View changes that are new on a feature branch
|
||||
git log -p feature --not master
|
||||
git diff master...feature
|
||||
|
||||
# Interactive rebase for the last 7 commits
|
||||
git rebase -i @~7
|
||||
|
||||
# Diff files WITHOUT considering them a part of git
|
||||
# This can be used to diff files that are not in a git repo!
|
||||
git diff --no-index path/to/file/A path/to/file/B
|
||||
|
||||
# To pull changes while overwriting any local commits
|
||||
git fetch --all
|
||||
git reset --hard origin/master
|
||||
|
||||
# Update all your submodules
|
||||
git submodule update --init --recursive
|
||||
|
||||
# Perform a shallow clone to only get latest commits
|
||||
# (helps save data when cloning large repos)
|
||||
git clone --depth 1 <remote-url>
|
||||
|
||||
# To unshallow a clone
|
||||
git pull --unshallow
|
||||
|
||||
# Create a bare branch (one that has no commits on it)
|
||||
git checkout --orphan branch_name
|
||||
|
||||
# Checkout a new branch from a different starting point
|
||||
git checkout -b master upstream/master
|
||||
|
||||
# Remove all stale branches (ones that have been deleted on remote)
|
||||
# So if you have a lot of useless branches, delete them on Github and then run this
|
||||
git remote prune origin
|
||||
|
||||
# The following can be used to prune all remotes at once
|
||||
git remote prune $(git remote | tr '\n' ' ')
|
||||
|
||||
# Revisions can also be identified with :/text
|
||||
# So, this will show the first commit that has "cool" in their message body
|
||||
git show :/cool
|
||||
|
||||
# Undo parts of last commit in a specific file
|
||||
git checkout -p HEAD^ -- /path/to/file
|
||||
|
||||
# Revert a commit and keep the history of the reverted change as a separate revert commit
|
||||
git revert <commit SHA>
|
||||
|
||||
# Pich a commit from a branch to current branch. This is different than merge as
|
||||
# this just applies a single commit from a branch to current branch
|
||||
git cherry-pick <commit SHA1>
|
||||
|
||||
# Undo last commit
|
||||
# If you want to nuke commit C and never see it again
|
||||
# (F)
|
||||
# A-B-C
|
||||
# ↑
|
||||
# master
|
||||
git reset --hard HEAD~1
|
||||
|
||||
# Undo last commit
|
||||
# If you want to undo the commit but keep your changes
|
||||
# (F)
|
||||
# A-B-C
|
||||
# ↑
|
||||
# master
|
||||
git reset HEAD~1
|
||||
|
@ -0,0 +1,6 @@
|
||||
# get information about hard disks
|
||||
hdparm -I /dev/sda
|
||||
|
||||
# perform timings of device/cache reads for benchmark and comparison purposes
|
||||
hdparm -tT /dev/sda
|
||||
|
@ -0,0 +1,12 @@
|
||||
# side-by-side hexadecimal and ascii view of the first 128 bytes of a file
|
||||
hexdump -C -n128 /etc/passwd
|
||||
|
||||
# Convert a binary file to C Array
|
||||
hexdump -v -e '16/1 "0x%02X, "' -e '"\n"' file.bin > hexarray.h
|
||||
|
||||
# Convert a binary file to Shell code
|
||||
hexdump -v -e '"\\""x" 1/1 "%02x" ""'
|
||||
|
||||
# Generate random MAC address
|
||||
hexdump -n6 -e '/1 ":%02X"' /dev/random|sed s/^://g
|
||||
|
@ -0,0 +1,32 @@
|
||||
# prints 21 evenly spaced numbers increasing from -1 to 1
|
||||
jot 21 -1 1.00
|
||||
|
||||
# Show the ASCII character set
|
||||
jot -c 128 0
|
||||
|
||||
# strings xaa through xaz with
|
||||
jot -w xa%c 26 a
|
||||
|
||||
# 20 random 8-letter strings are produced with
|
||||
jot -r -c 160 a z | rs -g 0 8
|
||||
|
||||
# Infinitely many yes's may be obtained through
|
||||
jot -b yes 0
|
||||
|
||||
# thirty ed(1) substitution commands applying to lines 2, 7, 12, etc.
|
||||
jot -w %ds/old/new/ 30 2 - 5
|
||||
|
||||
# The stuttering sequence 9, 9, 8, 8, 7, etc. can be produced by suitable
|
||||
# choice of precision and step size, as in
|
||||
jot 0 9 - -.5
|
||||
|
||||
# Generate a file containing exactly 1024 bytes is created with
|
||||
jot -b x 512 > block
|
||||
|
||||
# set tabs four spaces apart starting from column 10 and
|
||||
# ending in column 132
|
||||
expand -`jot -s, - 10 132 4`
|
||||
|
||||
# print all lines 80 characters or longer
|
||||
grep `jot -s "" -b . 80`
|
||||
|
@ -0,0 +1,10 @@
|
||||
# Dump $url, do not show links urls
|
||||
lynx -dump -nolist $url
|
||||
|
||||
# Use lynx to run repeating website actions
|
||||
# For creating your keystroke file, use:
|
||||
# lynx -cmd_log yourfile
|
||||
lynx -accept_all_cookies -cmd_script=/your/keystroke-file
|
||||
|
||||
# convert html to text
|
||||
lynx -force_html -stdin -dump -nolist
|
@ -0,0 +1,9 @@
|
||||
# reshape data: number of rows and columns
|
||||
jot 36 | rs 4 9
|
||||
|
||||
# 0 is a dummy value for either the row or column count
|
||||
# (4 columns)
|
||||
jot 36 | rs 0 4
|
||||
|
||||
# transpose output
|
||||
jot 36 | rs -t 0 4
|
@ -0,0 +1,39 @@
|
||||
# sox
|
||||
# Sound eXchange: play, record and convert audio files.
|
||||
# Audio formats are identified by the extension.
|
||||
|
||||
# Merge two audio files into one:
|
||||
sox -m ${input_audiofile1} ${input_audiofile2} ${output_audiofile}
|
||||
|
||||
# Trim an audio file to the specified times:
|
||||
sox ${input_audiofile} ${output_audiofile} trim ${start} ${end}
|
||||
|
||||
# Normalize an audio file (adjust volume to the maximum peak level, without clipping):
|
||||
sox --norm ${input_audiofile} ${output_audiofile}
|
||||
|
||||
# Reverse and save an audio file:
|
||||
sox ${input_audiofile} ${output_audiofile} reverse
|
||||
|
||||
# Print statistical data of an audio file:
|
||||
sox ${input_audiofile} -n stat
|
||||
|
||||
# Increase the volume of an audio file by 2x:
|
||||
sox -v 2.0 ${input_audiofile} ${output_audiofile}
|
||||
|
||||
# Changing sample rate of a file
|
||||
sox ${input_file} -r 16000 ${output_file}
|
||||
|
||||
# Changing the Number of Channels
|
||||
# For example: convert mono audio files to stereo
|
||||
sox ${mono_wav} -c 2 ${stereo_wav}
|
||||
|
||||
# Generate Different Types of Sounds
|
||||
# ${len} - length of audio to synthesize, hh:mm:ss.frac
|
||||
# ${freq} - frequencies at the beginning/end of synthesis in Hz
|
||||
# ${type} is one of sine, square, triangle, sawtooth, trapezium, exp,
|
||||
# [white]noise, pinknoise, brown-noise
|
||||
# sox -n synth ${len} ${type} ${freq}
|
||||
sox -r 8000 -n output.wav synth 3 sine 300-3300
|
||||
|
||||
# Speed up the Sound in an Audio File
|
||||
sox input.wav output.wav speed 2.0
|
@ -0,0 +1,29 @@
|
||||
# sudo
|
||||
# Execute a command as another user.
|
||||
|
||||
# List of an unreadable directory:
|
||||
sudo ls /usr/local/scrt
|
||||
|
||||
# To edit a file as user www:
|
||||
sudo -u www vi /var/www/index.html
|
||||
|
||||
# To shutdown the machine:
|
||||
sudo shutdown -h +10 "Cya soon!"
|
||||
|
||||
# To repeat the last command as sudo:
|
||||
sudo !!
|
||||
|
||||
# Save a file you edited in vim
|
||||
:w !sudo tee > /dev/null %
|
||||
|
||||
# Make sudo forget password instantly
|
||||
sudo -K
|
||||
|
||||
# List your sudo rights
|
||||
sudo -l
|
||||
|
||||
# Add a line to a file using sudo
|
||||
echo "foo bar" | sudo tee -a /path/to/some/file
|
||||
|
||||
# run root shell
|
||||
sudo -i
|
@ -0,0 +1,3 @@
|
||||
# Show keycodes used by Xorg
|
||||
# start xev and show only the relevant parts:
|
||||
xev | awk -F'[ )]+' '/^KeyPress/ { a[NR+2] } NR in a { printf "%-3s %s\n", $5, $8 }'
|
Loading…
Reference in New Issue