
List of Tags
Table of Contents
How can I compress an image?
How can I change the resolution of a JPG?
How can I convert and combine JPG to PDF?
How can I remove MP3 tags?
How can I install glog?
How can I fix docker permission denied?
How can I disable IntelliJ popup documentations?
How can I debug a test run by Maven in IntelliJ IDEA?
How can I import Scala code to Eclipse?
How can I codesign gdb in OS X?
How can I use vi key mappings in bash?
How can I install gdb on OS X?
How can I run Eclipse on OS X?
How can I install third party brew formula?
How can I install the Opera browser on Ubuntu?
How can I install a recent version of gcc?
How can I install Ubuntu from USB?
How can I import a Mercurial repository to GitHub?
How can I replace a page of a PDF?
How can I resize and convert an image?
How can I install the missing dependency of Acrobat Reader?
How can I insert LaTeX formula in inkscape?
How can I view Subversion diffs in colors?
How can I install an R package?
How can I install R?
How can I trace bitmap images to vector ones?
How can I rename Git branches?
How can I diff two revisions in Mercurial?
How can I install Ruby in Linux?
How can I find the Git commit corresponding to a Subversion revision?
How can I commit a subset of the modified files of a Mercurial repository?
How can I create a patch from uncommitted changes to a Git repository?
How can I apply a patch to a Git repository?
How can I set my username for all Mercurial projects?
How can I set the editor for all Mercurial projects?
How can I get the list of branches?
How can I create a new branch?
How can I update to the tip revision?
How can I switch to an existing branch?
How can I update to a specific revision?
How can I update to the latest revision at a specific date?
How can I find the revision of the working folder?
How can I tell whether a file is ignored or not committed at all?
How can I colorize hg?
How can I push changes to a different remote repository?
How can I pull changes from a remote repository?
How can I pull changes from a remote repository?
How can I browse the history of a Mercurial repository graphically?
How can I discard uncommitted changes?
How can I apply a commit to another branch?
How can I discard my last commit?
How can I discard a given commit?
How can I set up Mercurial to use meld as its merge tool?
How can I create a patch of my uncommitted changes?
How can I set my username and email address in my Git client?
How can I change the text editor used by Git?
How can I check out a remote branch?
How can I check out a specific commit of a repository?
How can I check out a specific tag of a repository?
How can I retrieve the state of a repository before a specific date?
How can I track all remote Git branches?
How can I push a local branch to a remote Git repository?
How can I push a local Git branch and automatically track it?
How can I unstage something from the Git staging area?
How can I merge Git branches?
How can I tell if a Git branch has not been merged into the master branch?
How can I destroy my last Git commit but keep its changes?
How can I destroy my last Git commit and its changes?
How can I do a pull while my Git repository has outstanding changes?
How can I edit my last Git commit message?
How can I squash two local Git commits into one?
How can I apply a commit from one Git branch to another?
How can I view a particular revision of a file in my Git repository without checking it out?
How can I get the list of tags in a Git repository?
How can I tag a Git commit?
How can I remove a remote Git tag?
How can I delete a remote Git branch?
How can I archive a Git branch?
How can I delete a remote Git commit?
How can I include or exclude certain files from Git?
How can I more easily view diffs from Git?
How can I resolve Git merge conflicts visually?
How can I colorize Git output?
How can I restore a particular version of a file from a Git repository?
How can I create shorthands for Git commands?
How can I create a patch for my last Git stash?
How can I find the common ancestor of two Git branches?
How can I delete all Git branches that have been merged?
How can I add a submodule to a Git repository?
How can I remove a submodule from a Git repository?
How can I check out a Git repository with submodules?
How can I pull changes to submodules?
How can I commit changes to submodules?
How can I specify the folder containing the generated Jekyll site?
How can I tell if a JVM is 32 or 64 bits?
How can I tell if a binary is 32 or 64 bits?
How can I install Orcale JDK 7?
How can I set the editor that Subversion opens to compose commit messages?
How can I make a user a sudoer?
How can I extract a page from a PDF?
How can I install Citrix?
How can I find the distribution of the running Linux?
How can I install ant without GCJ?
How can I revert the display settings?
How can I redirect stderr and stdout to a file?
How can I follow what gets appended to a file online?
How can I install an SSH server?
How can I configure my SSH client to connect to a server?
How can I copy the SSH public key to a remote host?
How can I scroll in the screen program?
How can I rename a screen window?
How can I reorder screen windows?
How can I recover Grub after installing Windows?
How can I set environment variables during startup?
How can I install Dropbox?
How can I install Alpine?
How can I install and uninstall TeXLive in Ubuntu?
How can I update my TeXLive installation?
How can I install vanilla TeXLive to satisfy APT dependencies?
How can I install hevea on top of vanilla TeXLive?
How can I set the number of floating point digits in bc?
How can I type right to left?
How can I recover deleted files?
How can I generate a LaTeX diff of two LaTeX files?
How can I pass the results of a command to another?
How can I install the latest stable release of Git?
How can I install Ubuntu repository public keys?
How can I open a terminal from within nautilus?
How can I update the database used by the locate command?
How can I fix the background color of Eclipse tooltips?
How can I clear the bash history?
How can I get the specifications of the installed RAM?
How can I monitor the health of a hard disk?
How can I install the latest release of Mercurial?
How can I open a shell within Vim?
How can I compress an image?
22 Feb 2022
-
linux
convert -density 150x150 -quality 20 -compress jpeg one.pdf two.pdf
How can I change the resolution of a JPG?
02 Jun 2019
-
linux
Open the JPG file using GIMP. Then, open the Image
menu and select Scale
Image...
Next, set the X and Y resolution to the desired resolution and save
the file.
How can I convert and combine JPG to PDF?
01 Jun 2019
-
linux
convert *.jpg output.pdf
If convert
returns a not authorized
error, edit
/etc/ImageMagick-6/policy.xml
and change the PDF rights from none
to
read|write
.
References
How can I remove MP3 tags?
06 Jun 2018
-
linux
id3v2 -D filename.mp3
References
How can I install glog?
31 Jul 2016
-
linux
git clone https://github.com/google/glog.git
cd glog
./configure && make
sudo make install
Compile with flag -lglog
References
How can I fix docker permission denied?
01 Aug 2015
-
linux
Docker may give you the permission deniend
error on Linux:
$ docker run busybox date
2015/08/01 15:37:42 Post
http:///var/run/docker.sock/v1.12/containers/create: dial unix
/var/run/docker.sock: permission denied
Run the following command and log out to fix the above error.
sudo usermod -a -G docker ${USER}
References
How can I disable IntelliJ popup documentations?
26 Nov 2014
-
intellij
By default, when you hover the mouse over a variable, IntelliJ shows a popup documentation view, which often hides the popup that shows the value of the variable in debug mode.
To disable the documentation popup, locate the option “Show quick doc on mouse move” in Settings and disable it.
References
How can I debug a test run by Maven in IntelliJ IDEA?
24 Nov 2014
-
intellij
Open the Maven Projects view, and then open the Lifecycle tree item. Next,
right-click on the test goal to creat a configuration. Add the command-line
option -DforkMode=never
or -DforkCount=0
to the configuration. Finally, run
the configuration in debug mode.
References
How can I import Scala code to Eclipse?
22 Nov 2014
-
eclipse,
scala
Add sbteclipse to your plugin definition file. For sbt version 0.13 and up, add
the following to ~/.sbt/0.13/plugins/plugins.sbt
.
addSbtPlugin("com.typesafe.sbteclipse" % "sbteclipse-plugin" % "2.5.0")
References
How can I codesign gdb in OS X?
21 Nov 2014
-
osx
- Use the Keychain Access application to create a certificate with the following properties: self signed root, code signing, system, and always trust.
- Run the
command codesign -f -s "gdb-cert" $(which gdb)
.
References
How can I use vi key mappings in bash?
18 Nov 2014
-
linux
Include following in ~/.bashrc
:
set -o vi
References
How can I install gdb on OS X?
18 Nov 2014
-
osx
brew install homebrew/dupes/gdb
References
How can I run Eclipse on OS X?
15 Nov 2014
-
osx,
eclipse
- Run
/usr/libexec/java_home -V
to find the location of an installed JDK. - To launch Eclipse from Finder, follow the instructions at
http://stackoverflow.com/a/25486012/130224
to set the
-vm
flag ofEclipse.app/Contents/Info.plist
. - To run Eclipse from the command line, run
Eclipse.app/Contents/MacOS/eclipse
.
References
How can I install third party brew formula?
14 Nov 2014
-
osx
Run brew install URL
. For instance, run the following command to install
jad
:
brew install https://raw.githubusercontent.com/Homebrew/homebrew-binary/master/jad.rb
References
How can I install the Opera browser on Ubuntu?
05 May 2014
-
linux
sudo bash -c 'echo "deb http://deb.opera.com/opera/ stable non-free" > /etc/apt/sources.list.d/opera.list'
sudo apt-get install debian-archive-keyring
wget -O - http://deb.opera.com/archive.key | sudo apt-key add -
sudo apt-get update
sudo apt-get install opera
References
How can I install a recent version of gcc?
04 May 2014
-
linux
sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt-get update
sudo apt-get install gcc-4.8
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.8 50
Similar instructions work for installing other versions of gcc and g++.
References
How can I install Ubuntu from USB?
03 May 2014
-
ubuntu
Use usb-creator-gtk
to write an ISO file onto a USB stick.
References
How can I import a Mercurial repository to GitHub?
21 Apr 2014
-
mercurial,
git
Run the following commands to install git remote hg.
wget https://raw.github.com/felipec/git/fc/master/git-remote-hg.py -O ~/apps/git-remote-hg
chmod +x ~/apps/git-remote-hg
export PATH=$PATH:~/apps
Clone the mercurial repository as a bare git repository.
git clone --bare "hg::https://code.google.com/p/jsr308-langtools/" bare-jsr308-langtools
Create an empty GitHub repository
git push --mirror https://github.com/reprogrammer/jsr308-langtools.git
Mirror the bare git repository on github.
cd bare-jsr308-langtools
git push --mirror https://github.com/reprogrammer/jsr308-langtools.git
References
- https://github.com/felipec/git/wiki/git-remote-hg
- https://help.github.com/articles/importing-an-external-git-repository
How can I replace a page of a PDF?
23 Mar 2014
-
linux
pdftk A=f1.pdf B=f2.pdf cat A1-14 B A16-21 output f3.pdf
References
How can I resize and convert an image?
22 Mar 2014
-
linux
convert -resize 50% image.jpg image.pdf
References
How can I install the missing dependency of Acrobat Reader?
28 Feb 2014
-
linux
Install Adobe Reader 9 using its .deb file.
If you run Adobe Reader, you may get the following error message:
/opt/Adobe/Reader9/Reader/intellinux/bin/acroread: error while loading shared
libraries: libxml2.so.2: cannot open shared object file: No such file or
directory
If you get the above error message, run the following command:
sudo apt-get install libxml2:i386 libstdc++6:i386
References
How can I insert LaTeX formula in inkscape?
09 Feb 2014
-
tex
Install ps2edit.
Relaunch inkscape and go to “Extensions > Render > LaTeX formula…”
References
How can I view Subversion diffs in colors?
07 Feb 2014
-
subversion
svn diff | view -
svn diff <file> | vim -R -
References
How can I install an R package?
02 Jan 2014
-
R
install.packages("package-name")
References
How can I install R?
01 Jan 2014
-
R,
linux
sudo apt-get install r-base
References
How can I trace bitmap images to vector ones?
21 Dec 2013
-
linux
- Use xsane to scan your document as a PNM image.
- Use potrace to covert your image to a vector image, e.g., PDF or EPS.
References
How can I rename Git branches?
13 Dec 2013
-
git
The following command renames a local branch from b1
to b2
.
git branch -m b1 b2
The following command removes the remote branch b1
.
git push origin --delete :b1
Before running the above command, make sure that b1
is not the default branch
of your repository; otherwise, git will give you an error like the following.
remote: error: refusing to delete the current branch: refs/heads/b1
To https://github.com/user/repo.git
! [remote rejected] b1 (deletion of the current branch prohibited)
error: failed to push some refs to 'https://github.com/user/repo.git'
The following command gives b2
the new remote.
git push -u origin b2
References
- http://stackoverflow.com/a/7084316
- http://sebgoo.blogspot.com/2012/04/git-rename-branch-local-and-remote.html
- http://stackoverflow.com/a/2003515
How can I diff two revisions in Mercurial?
05 Dec 2013
-
mercurial
hg diff -r <rev1> -r <rev2>
References
How can I install Ruby in Linux?
27 Nov 2013
-
linux
Run the following command to install RVM.
\curl -sSL https://get.rvm.io | bash -s stable --ruby
The above command should report a message of the form below at the end:
To start using RVM you need to run
source $HOME/.rvm/scripts/rvm
in all your open shell windows, in rare cases you need to reopen all shell windows.
References
How can I find the Git commit corresponding to a Subversion revision?
26 Nov 2013
-
git,
subversion
Let S be the URL of a Subversion repository that has been migrated to a Git repository at URL G using git-svn. Given the revision number R of a revision of S, the problem is to find a commit C in G that corresponds to R.
For example, let S = http://svn.apache.org/repos/asf/1309183/tomcat/trunk/, G = https://github.com/apache/tomcat.git, and R = 1309183.
The first step is find the largest revision number R2 such that R2 <= R and S is affected by R2. The following command will return R2.
svn list --verbose S@R | grep "\./" | awk '{split($0,a," "); print a[1]}'
In this case, the above command would look as follows.
svn list --verbose http://svn.apache.org/repos/asf/tomcat/trunk/@1309183 | grep "\./" | awk '{split($0,a," "); print a[1]}'
Next, use a command of the form below to find C.
git log | grep "@R2" -C 10
In this case, the above command should be instantiated as follows.
git log | grep "@1307597" -C 10
References
How can I commit a subset of the modified files of a Mercurial repository?
19 Oct 2013
-
mercurial
Run the following command to commit only file1
and file2
.
hg commit file1 file2
References
How can I create a patch from uncommitted changes to a Git repository?
07 Oct 2013
-
git
git diff --cached > patch.diff
References
How can I apply a patch to a Git repository?
06 Oct 2013
-
git
git apply patch.diff
References
How can I set my username for all Mercurial projects?
05 Oct 2013
-
mercurial
Add the following piece of code to your .hgrc
file.
[ui]
username = FirstName LastName <username@domain.com>
How can I set the editor for all Mercurial projects?
04 Oct 2013
-
mercurial
Add the following piece of code to your .hgrc
file.
[ui]
editor = vim
How can I get the list of branches?
03 Oct 2013
-
mercurial
hg branches
How can I create a new branch?
02 Oct 2013
-
mercurial
hg branch <branch-name>
References
How can I update to the tip revision?
01 Oct 2013
-
mercurial
hg update
How can I switch to an existing branch?
30 Sep 2013
-
mercurial
hg update <branch-name>
How can I update to a specific revision?
29 Sep 2013
-
mercurial
hg update REV
References
How can I update to the latest revision at a specific date?
28 Sep 2013
-
mercurial
hg update -d yyyy-mm-dd
References
How can I find the revision of the working folder?
27 Sep 2013
-
mercurial
hg parent
References
How can I tell whether a file is ignored or not committed at all?
26 Sep 2013
-
mercurial
hg status --all
References
How can I colorize hg?
25 Sep 2013
-
mercurial
Add the following piece of code to your .hgrc
file.
[extensions]
color =
[color]
mode = auto
References
How can I push changes to a different remote repository?
24 Sep 2013
-
mercurial
First, add the path to the remote repository to .hg/hgrc
.
[paths]
remote-name = http://path/to/remote-name
Then, push the changes in your local repository to the remote repository:
hg push remote-name
If your changes belong to new branches, use the following command:
hg push --new-branch remote-name
References
How can I pull changes from a remote repository?
23 Sep 2013
-
mercurial
hg pull remote-name
If you use the -u
option, the pulled changes will be applied on your branch:
hg pull -u remote-name
How can I pull changes from a remote repository?
22 Sep 2013
-
mercurial
hg addremove
References
How can I browse the history of a Mercurial repository graphically?
21 Sep 2013
-
mercurial
Enable the hgk
extension by adding the following to your .hgrc
file.
[extensions]
hgk =
Then, invoke the following command inside the directory of your mercurial repository:
hg view
References
How can I discard uncommitted changes?
20 Sep 2013
-
mercurial
hg up -C
How can I apply a commit to another branch?
19 Sep 2013
-
mercurial
Run the following command to apply change set <change-set>
to the current
branch.
hg graft <changeset>
References
How can I discard my last commit?
18 Sep 2013
-
mercurial
hg rollback
How can I discard a given commit?
17 Sep 2013
-
mercurial
hg strip <changeset>
References
How can I set up Mercurial to use meld as its merge tool?
16 Sep 2013
-
mercurial
Add the following to ~/.hgrc
:
[ui]
merge = meld
[merge-tools]
meld.priority = 1
meld.premerge = False
meld.args = $local $other $base
[merge-patterns]
** = meld
When meld opens the local (the working copy version), other (the remove version,
which is being merged into local), and base (common parent of local and other)
versions of the file, edit the middle pane (other), for this is the file in your
repository. The other two are kept in /tmp
.
References
How can I create a patch of my uncommitted changes?
15 Sep 2013
-
mercurial
hg diff -g > uncommited.patch
References
How can I set my username and email address in my Git client?
14 Sep 2013
-
git
git config --global user.email "username@domain.com"
git config --global user.name "First Last"
References
- https://help.github.com/articles/setting-your-email-in-git
- https://help.github.com/articles/setting-your-username-in-git
How can I change the text editor used by Git?
13 Sep 2013
-
git
git config --global core.editor "vim"
References
How can I check out a remote branch?
12 Sep 2013
-
git
git checkout -b branch-name origin/branch-name
References
How can I check out a specific commit of a repository?
11 Sep 2013
-
git
git checkout -b new-branch SHA1
References
How can I check out a specific tag of a repository?
10 Sep 2013
-
git
git checkout -b new-branch tags/<tag-name>
How can I retrieve the state of a repository before a specific date?
09 Sep 2013
-
git
git checkout `git rev-list -n 1 --before="2009-07-27 13:37" master`
References
How can I track all remote Git branches?
08 Sep 2013
-
git
First, get a list of all remote branches:
git branch -r
Then, check out each of remote branch:
git checkout -t origin/branch1
References
How can I push a local branch to a remote Git repository?
07 Sep 2013
-
git
git push <remote_repository> <local_branch_name>
How can I push a local Git branch and automatically track it?
06 Sep 2013
-
git
git push -u origin <name_of_branch>
Git will by default push all branches that have the same name on the remote. To limit this behavior to just the current branch, set this configuration option:
git config --global push.default tracking
References
How can I unstage something from the Git staging area?
05 Sep 2013
-
git
git reset <file_name>
How can I merge Git branches?
04 Sep 2013
-
git
git merge <branch_1> <branch_2>
The order which you specify the branch has some consequence on how it is done
internally. Graphically it will try to merge <branch_1>
first and then
<branch_2>
even if <branch_2>
is earlier time-wise. So, if you want to have
a nice ordering, try to specify the earlier branch as an earlier argument.
How can I tell if a Git branch has not been merged into the master branch?
03 Sep 2013
-
git
git cherry -v master branch-name
References
How can I destroy my last Git commit but keep its changes?
02 Sep 2013
-
git
git reset --soft HEAD^
References
How can I destroy my last Git commit and its changes?
01 Sep 2013
-
git
git reset --hard ORIG_HEAD
Basically, ORIG_HEAD
is short for the commit before your last commit. It’s
automatically set by pull and merge (but not necessarily other git commands).
It’s also equivalent to HEAD@{1}
meaning the previous commit from head.
References
How can I do a pull while my Git repository has outstanding changes?
31 Aug 2013
-
git
git stash
git pull
git stash pop
How can I edit my last Git commit message?
30 Aug 2013
-
git
git commit --amend
How can I squash two local Git commits into one?
29 Aug 2013
-
git
Use the following commit to start rebase
in the interactive mode. You should
use a <SHA>
that is a ascendant of the commits you want to manipulate.
git rebase -i <SHA>
The interactive rebase
lets you perform a command on each commit that it
lists. If you want to squash commit 2
into commit 1
, you should make sure
that the rebase
editor shows you only the two commits, then you have to use
the pick command on commit 1
and the squash
command on the line of commit
2
.
If for any reason, you have to quit the rebase, close the editor and execute the following command.
git rebase --abort
How can I apply a commit from one Git branch to another?
28 Aug 2013
-
git
Let s
be the SHA of the commit you’d like to apply to branch b
. Execute the
following commands to add commit s
to branch b
.
git checkout b
git cherry-pick s
How can I view a particular revision of a file in my Git repository without checking it out?
27 Aug 2013
-
git
The following command shows the contents of /path/to/file.txt
from 4 revisions
ago.
git show HEAD~4:/path/to/file.txt
References
How can I get the list of tags in a Git repository?
26 Aug 2013
-
git
git tag -l
References
How can I tag a Git commit?
25 Aug 2013
-
git
git tag <tag-name> <commit-sha>
git push --tags
How can I remove a remote Git tag?
24 Aug 2013
-
git
git tag -d <tag-name>
git push origin :refs/tags/<tag-name>
References
How can I delete a remote Git branch?
23 Aug 2013
-
git
git push origin :<branch-name-to-delete>
How can I archive a Git branch?
22 Aug 2013
-
git
Instead of just deleting a branch, it might be a good idea to keep a tag to the old branch.
# Get remote branches verbosely (with SHA and some description)
git branch -a -v
# Pick the old branch that you want to archive and note its SHA
git tag archive/<old-branch-name> <old-branch-SHA>
# Delete the local branch
git branch -d <old-branch-name>
# Push the tag to remote repository
git push --tags
# Delete the remote branch
git push origin :<old-branch-name>
# (Optional for other people monitoring the remote repository)
# This removes outdated branches from their local repository
git remote prune origin
References
How can I delete a remote Git commit?
21 Aug 2013
-
git
If you push a commit to the remote repository. You can remove it from the remote repository using the following command.
git push -f origin HEAD^:master
I’ve tried this command on github and made sure that it works. As a result of this command, your commit on the remote repository doesn’t get actually deleted. Rather, it becomes dangling. And, it seems that Github garbage collects dangling commits every so often.
References
How can I include or exclude certain files from Git?
20 Aug 2013
-
git
Sometimes, you want to exclude all the (for instance) .class
or .jar
files
from git. In that case, you would create a .gitignore
folder at the top of
your repository with contains like this:
*.class
*.jar
On the other hand, sometimes you also want to include certain .class
or .jar
files in only several directories. In that case, you would create a .gitignore
in those particular directories like this:
!*.class
!*.jar
The key symbol here is the !
symbol.
Git operates by reading the repository-level .gitignore
but will override any
settings upon reading a directory-level .gitignore
.
How can I more easily view diffs from Git?
19 Aug 2013
-
git
Say that you want to see what has changed between two different commits. You can do
git diff sha1..sha2
The above command will give you all the differences between sha1 (exclusive) to sha2 (inclusive). However, textual diffs can be hard to understand sometimes, so how would you specify a visual diff tool? The easiest way would be to specify the name of the visual diff tool directly to git difftool i.e.
git difftool -t path_to_tool sha1..sha2
If you find yourself using a particular visual diff tool pretty often, then you
should add it to your global git config file, shown with a hypothetical tool
called awesometool
:
git config --global diff.tool awesometool
git config --global difftool.awesometool.cmd "path/to/awesometool \$LOCAL \$REMOTE"
# The following gets rid of having to hit enter when you run git difftool
git config --global difftool.prompt false
which will create the following entries in your global .gitconfig
[diff]
tool = awesometool
[difftool "awesometool"]
cmd = path/to/awesometool \"$LOCAL\" \"$REMOTE\"
[difftool]
prompt = false
Popular visual diff tools are vimdiff, kdiff3, meld, etc. You can specify several programs (not just a single one) that you use frequently through the global git config.
git difftool sha1..sha2
Once you add your visual diff tool to git configurations, you can simply invoke
git difftool
as follows.
References
How can I resolve Git merge conflicts visually?
18 Aug 2013
-
git
You can use a visual merge tool like
diffmerge. You would use the same
command to git visual diff except that you use git mergetool
instead of git
difftool
.
git config --global merge.tool awesometool
git config --global mergetool.awesometool.cmd "path/to/awesometool --merge --result=\"$MERGED\" \"$LOCAL\" \"$BASE\" \"$REMOTE\""
git config --global mergetool.awesometool.trustExitCode true
References
How can I colorize Git output?
17 Aug 2013
-
git
git config --global color.ui true
The above command adds the following item to your git configuration files.
[color]
ui = true
How can I restore a particular version of a file from a Git repository?
16 Aug 2013
-
git
The following command will replace the current version with the older version.
If you just want to see the older version of the file, use git show
.
git checkout SHA1 path/to/file
References
How can I create shorthands for Git commands?
15 Aug 2013
-
git
Set up aliases in your global ~/.gitconfig
. Here’s a set of useful examples
that you can add to your ~/.gitconfig
file:
[alias]
st = status
ci = commit
br = branch
co = checkout
df = diff
lg = log -p
Now, you can use git st
instead of git status
.
References
How can I create a patch for my last Git stash?
14 Aug 2013
-
git
git stash show -p
References
How can I find the common ancestor of two Git branches?
13 Aug 2013
-
git
There isn’t a command to find the common ancestor per-se, but there is a
plumbing command, git-merge-base
in Git for finding the best ancestor for use
in a three-way merge. Given a series of branches, git-merge-base
attempts to
find the best ancestor to merge. When you provide it with two branches as
arguments, git-merge-base
will naturally locate their common ancestor, if one
exists. This can be useful sometimes when you are trying to trace the common
ancestor between branches.
git-merge-base branchA branchB
How can I delete all Git branches that have been merged?
12 Aug 2013
-
git
git branch -r --merged | \
grep origin | \
grep -v '>' | \
grep -v master | \
xargs -L1 | \
awk '{split($0,a,"/"); print a[2]}' | \
xargs git push origin --delete
References
How can I add a submodule to a Git repository?
11 Aug 2013
-
git
The following commands checkouts the git repository at subproject-url
into the
subproject-path
and updates the .gitmodules
file.
git submodule add subproject-url subproject-path
How can I remove a submodule from a Git repository?
10 Aug 2013
-
git
- Delete the relevant section from the
.gitmodules
file. - Delete the relevant section from
.git/config
. - Run
git rm --cached subproject-path
(no trailing slash). - Commit and delete the now untracked submodule files.
References
How can I check out a Git repository with submodules?
09 Aug 2013
-
git
# to add the subproject to .git/config.
git submodule init
# to pull down the latest changes to the submodule.
git submodule update
References
How can I pull changes to submodules?
08 Aug 2013
-
git
You have to go to the submodule and switch to a specific branch to be able to pull changes.
cd subproject-path
git checkout branch-name
git pull
References
How can I commit changes to submodules?
07 Aug 2013
-
git
If you make changes to the submodule, you have to fist commit and push them. Then, you have to commit and push the changes to the superproject.
How can I specify the folder containing the generated Jekyll site?
17 Jul 2013
-
linux
New command:
jekyll serve -d _new_site
Deprecated command:
jekyll _new_site --server
References
How can I tell if a JVM is 32 or 64 bits?
16 May 2013
-
linux
If the running JVM is not 64 bits, the following command will report an error message:
java -d64 -version
References
How can I tell if a binary is 32 or 64 bits?
15 May 2013
-
linux
file /path/to/binary
References
How can I install Orcale JDK 7?
06 May 2013
-
linux
sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java7-installer
sudo update-java-alternatives
References
How can I set the editor that Subversion opens to compose commit messages?
30 Apr 2013
-
subversion
- Open
~/.subversion/config
. - Uncomment the line containing the phrase
editor-cmd
. - Set
editor-cmd = vim
.
How can I make a user a sudoer?
26 Apr 2013
-
linux
sudo usermod -a -G sudo username
References
How can I extract a page from a PDF?
21 Apr 2013
-
linux
pdftk A=in.pdf cat A1 output out.pdf
References
How can I install Citrix?
03 Apr 2013
-
linux
- Install OpenMotif.
- Install Citrix.
- Download linuxx86-11.100.158406.
- Extract the downloaded archive.
- Run
sudo ./setupwfc
.
- Run Citrix.
/usr/lib/ICAClient/wfcmgr
References
How can I find the distribution of the running Linux?
21 Mar 2013
-
linux
cat /etc/*-release
How can I install ant without GCJ?
20 Mar 2013
-
linux
sudo apt-get install --no-install-recommends ant
When trying to use ant to build the X10 compiler, ant complained about a missing
JAR. It looked like the build.xml
file used javah
targets. So, I installed
ant-optional using the following command.
sudo apt-get install --no-install-recommends ant-optional
How can I revert the display settings?
19 Mar 2013
-
linux
While tweaking the display resolution, it got messed up. So, I went and reverted
/etc/X11/xorg.conf
to a previous version. There was a command mentioned in
this config file on how to force X11 update itself according to the new
configurations.
How can I redirect stderr and stdout to a file?
18 Mar 2013
-
linux
process >file 2>&1
How can I follow what gets appended to a file online?
17 Mar 2013
-
linux
tail -f file
How can I install an SSH server?
16 Mar 2013
-
linux
sudo apt-get install openssh-server
When an old client tries to connect to the server, it complains that the server
has changed its identity. Remove the ~/.ssh/known_hosts
to have the client
receive the new identity of the server.
References
https://help.ubuntu.com/6.06/ubuntu/serverguide/C/openssh-server.html
How can I configure my SSH client to connect to a server?
15 Mar 2013
-
linux
ssh-keygen -C "key-identifier" (without quotes)
scp ~/.ssh/id_rsa.pub server.example.org
cat ~/id_rsa.pub >> ~/.ssh/authorized_keys
Create or open the file at ~/.ssh/config
Add the following lines:
Host server.example.org
User git
Hostname server.example.org
PreferredAuthentications publickey
IdentityFile [local path to private key half of the public key you provided]
The main ssh config file is at /etc/ssh/ssh_config
.
How can I copy the SSH public key to a remote host?
14 Mar 2013
-
linux
ssh-copy-id remote-host
How can I scroll in the screen program?
13 Mar 2013
-
linux
Press C-a [
to enter the copy mode. Then, press ESC
to exit the copy mode.
How can I rename a screen window?
12 Mar 2013
-
linux
Press CTRL-a A
in each active window to get prompted for entering a new name.
References
http://nathan.chantrell.net/old-stuff/linux/an-introduction-to-screen/
How can I reorder screen windows?
11 Mar 2013
-
linux
Switch to the window you’d like to move and press CTRL-a
followed by :number
x
, where x
is the new location of the window.
References
http://www.snowfrog.net/2007/11/07/howto-move-windows-in-gnu-screen/
How can I recover Grub after installing Windows?
10 Mar 2013
-
linux
grub
sudo grub
Tell Grub which partition to tell the MBR your Grub is on by entering:
root (hd0,3)
If Ubuntu was installed on the second partition of the first hard-drive. Tell GRUB which drive’s MBR to fix:
setup (hd0)
quit
grub2
References
https://wiki.ubuntu.com/Grub2#Recover%20Grub%202%20via%20LiveCD
How can I set environment variables during startup?
09 Mar 2013
-
linux
If you want to make an environment variable visible system-wide, you should set
it in /etc/environment
. To set environment variables per user, you have to
modify ~/.pam_environment
.
The following is a sample ~/.pam_environment
file contents.
JAVA_HOME OVERRIDE=/path/to/java/home
PATH OVERRIDE=${PATH}:${JAVA_HOME}/bin
I’ve always had problems with ~/.pam_environment
for it duplicates my entries
in PATH
. So, I use the system-wide configuration file, i.e.,
/etc/environment
.
References
- https://help.ubuntu.com/community/EnvironmentVariables
man pam_env
/etc/security/pam_env.conf
How can I install Dropbox?
08 Mar 2013
-
linux
First, run the following command to add the Dropbox repository.
sudo add-apt-repository "deb http://linux.dropbox.com/ubuntu $(lsb_release -sc) main"
Next, run the command sudo apt-get update
. You should get an error message
similar to the following:
W: GPG error: http://linux.dropbox.com precise Release: The following signatures couldn’t be verified because the public key is not available: NO_PUBKEY FC918B335044912E
Follow the instructions at
http://reprogrammer.github.io/faq/2013/02/24/how-can-i-install-ubuntu-repository-public-keys/
to add the necessary keys. While following the instruction, note that the
Dropbox’s key server is pgp.mit.edu
.
Finally, run the following commands to install Dropbox.
sudo apt-get update
sudo apt-get install dropbox python-gpgme
The command sudo apt-get update
reports the following problem:
W: Duplicate sources.list entry http://linux.dropbox.com/ubuntu/ precise/main amd64 Packages (/var/lib/apt/lists/linux.dropbox.com_ubuntu_dists_precise_main_binary-amd64_Packages) W: Duplicate sources.list entry http://linux.dropbox.com/ubuntu/ precise/main i386 Packages (/var/lib/apt/lists/linux.dropbox.com_ubuntu_dists_precise_main_binary-i386_Packages) W: You may want to run apt-get update to correct these problems
I need to figure out how to resolve the duplicate entry problem.
References
How can I install Alpine?
07 Mar 2013
-
linux
sudo apt-get install alpine
Alpine stores its mails in $HOME/mail
.
How can I install and uninstall TeXLive in Ubuntu?
06 Mar 2013
-
linux,
tex
Installation
sudo apt-get install perl-tk
wget http://mirror.ctan.org/systems/texlive/tlnet/install-tl-unx.tar.gz
tar xvfz install-tl-unx.tar.gz
sudo ./install-tl<tab>/install-tl -gui
Select the following two options:
- Use the letter size instead of the default A4 size.
- Create symlinks in system directories.
The installer asks about the following directories. Leave the default settings.
TEXDIR=/usr/local/texlive/<year>
TEXMFLOCAL=/usr/local/texlive/texmf-local
TEXMFSYSVAR=/usr/local/texlive/<year>/texmf-var
TEXMFSYSCONFIG=/usr/local/texlive/<year>/texmf-config
TEXMFHOME=~/texmf
The installer says the following, but the symlinks are enough.
Add
/usr/local/texlive/20xy/texmf/doc/man
toMANPATH
.Add
/usr/local/texlive/20xy/texmf/doc/info
toINFOPATH
.Most importantly, add
/usr/local/texlive/20xy/bin/x86_64-linux
.
Uninstallation
sudo tlmgr uninstall
rm -rf /usr/local/texlive
References
How can I update my TeXLive installation?
05 Mar 2013
-
linux,
tex
Updating the updater itself
sudo tlmgr update --self
Updating the updater itself and all the packages
sudo tlmgr update --self --all
Updating the TeXLive distribution
sudo tlmgr -gui
You can check if a package is installed by using the locate
command.
Sometimes, a package is installed but the symlink to it in system directories is
missing. You can update the symlinks through the tlmgr
program.
How can I install vanilla TeXLive to satisfy APT dependencies?
04 Mar 2013
-
linux,
tex
I used
texlive.ctl to
create a vanilla TexLive package. I removed tex-common
from
texlive.ctl
because the original texlive.ctl file didn’t have it and I had to remove it to
install hevea. The hevea package is not included in TeXLive. And, I had to
install tex-common
in order to install hevea. Also, to let my own installation
of TeXLive locate the style files of the hevea package installed through Ubuntu,
I had to set the following environment variable.
export TEXMFHOME=/usr/share/texmf/
I used the following command to set the “Standards-Version” field in
texlive.ctl
.
apt-cache show debian-policy | grep Version
Then, I executed the following commands to create and install my vanilla package.
equivs-build texlive.ctl sudo dpkg -i texlive-vanilla_2010-1~1_all.deb
Finally, I used the following command to install kile.
sudo apt-get --no-install-recommends install kile
See http://manpages.ubuntu.com/manpages/maverick/man5/deb-control.5.html to learn more about the format of Ubuntu package control files. Specifically, the “Provides” section lists virtual packages that could be provided by the normal package.
References
- http://www.tug.org/texlive/debian.html
- http://superuser.com/questions/134125/vanilla-tex-live-2009-on-ubuntu
- http://tex.stackexchange.com/questions/1092/how-to-install-vanilla-texlive-on-debian-or-ubuntu/1094#1094
How can I install hevea on top of vanilla TeXLive?
03 Mar 2013
-
linux,
tex
I installed texlive-vanilla (2010-1~1). And, tried to install hevea with the following command.
sudo apt-get --no-install-recommends install hevea
But, I got the following message.
The following NEW packages will be installed:
hevea ocaml-base-nox tex-common
So, I checked the dependencies of the hevea in Ubuntu. The hevea package requires “tex-common (>=2.00)”. The “provides” section of the control file of vanilla-texlive doesn’t specify the versions of the virtual packages. So, I thought all of the virtual packages get the version number 2010-1~1 automatically. Then, I used the following command to verify that “2010-1~1” is indeed greater than “2.00” according to Ubuntu package formate rules.
dpkg --compare-versions 2010-1~1 gt 2.00 ; echo $?
And, I got the value “0” on the console, which confirms that 2010-1~1 is greater than 2.00. At this point, I concluded that the version number of the virtual packages is unspecified. So, I decided to create my own version of tex-common. I created a control file for my tex-common package called tex-common.ctl and executed the following commands.
equivs-build tex-common.ctl sudo dpkg -i tex-common_2010-1~1_all.deb
Having installed my own tex-common package, I was able to successfully install hevea using the following command.
sudo apt-get --no-install-recommends install hevea
How can I set the number of floating point digits in bc?
02 Mar 2013
-
linux
The following command sets the precision of floating point operations to 2 digits.
scale = 2
How can I type right to left?
01 Mar 2013
-
linux
To write right-to-left in Linux, press Right-ALT+]
and end by ALT+P
.
To write left-to-right in Linux, press Right-ALT+[
.
Use RLE
and PDF
to begin and end a right-to-left embedding. The unicode for
LRE
is U+202A
, the unicode for RLE
is U+202B
and the unicode for PDF
is U+202C
. In Ubuntu, hold CTRL-SHIFT
to type a unicode character. For
example, to type an RLE
, press the following keys: CTRL SHIFT U + 2 0 2 B
.
Hold the left ALT and the right SHIFT keys to switch the Ubuntu keyboard layout.
References
How can I recover deleted files?
28 Feb 2013
-
linux
The best tool that I found for recovering files was Photorec.
References
How can I generate a LaTeX diff of two LaTeX files?
27 Feb 2013
-
linux,
tex
Make sure old.tex
and new.tex
have a place to insert the preamble.
latexdiff --type=UNDERLINE --subtype=SAFE --floattype=FLOATSAFE old.tex new.tex > difference.tex
How can I pass the results of a command to another?
26 Feb 2013
-
linux
The xargs
program passes the outputs of one command as arguments to another
one.
The following is an example of processing the results of find using xargs
:
find . -name <pattern> -print0 | xargs -0 -I {} <command with {} as an argument>
find -print0
and xargs -0
make find
and xargs
handle files with unusual
characters in their names properly.
References
- http://linux.byexamples.com/archives/80/xargs-use-stardard-output-as-parameter-for-another-command
- http://www.cyberciti.biz/faq/linux-unix-bsd-xargs-construct-argument-lists-utility/
- http://www.gnu.org/software/findutils/manual/html_mono/find.html#Unusual-Characters-in-File-Names
How can I install the latest stable release of Git?
25 Feb 2013
-
linux,
git
The following commands install the latest stable release of git.
sudo add-apt-repository ppa:git-core/ppa
sudo aptitude update
sudo aptitude upgrade
References
- http://superuser.com/questions/56134/how-to-upgrade-git-on-ubuntu-hardy
- https://launchpad.net/~git-core/+archive/ppa
How can I install Ubuntu repository public keys?
24 Feb 2013
-
linux
If you get an error like the following from apt
:
W: GPG error: http://ppa.launchpad.net lucid Release: The following signatures couldn’t be verified because the public key is not available: NO_PUBKEY A6DCF7707EBC211F
Take the last 8 characters of the string in the error message and use it in the following two commands:
gpg --keyserver keyserver --recv 7EBC211F
The keyserver in the above commands may be a server like
keyserver.ubuntu.com
or pgp.mit.edu
.
The above command will generate an output similar to the following:
gpg: requesting key 7EBC211F from hkp server keyserver.ubuntu.com gpg: key 7EBC211F: public key “Launchpad PPA for Ubuntu Mozilla Security Team” imported gpg: no ultimately trusted keys found gpg: Total number processed: 1 gpg: imported: 1 (RSA: 1)
Next, run the following command:
gpg --export --armor 7EBC211F | sudo apt-key add -
The above command should generate the following output:
OK
Note the post at http://askubuntu.com/a/127187 suggest that the above two steps can be performed in a single steps. I need to try out this command.
sudo apt-key adv --keyserver keyserver --recv-keys 7EBC211F
References
How can I open a terminal from within nautilus?
23 Feb 2013
-
linux
To open a terminal from within nautilus, install the nautilus-open-terminal package using the following command:
sudo aptitude install nautilus-open-terminal
References
How can I update the database used by the locate command?
22 Feb 2013
-
linux
sudo updatedb
How can I fix the background color of Eclipse tooltips?
21 Feb 2013
-
linux,
eclipse
Open the file at /usr/share/themes/Ambiance/gtk-2.0/gtkrc
. Locate
tooltip_fg_color
and tooltip_bg_color
in the file and change their values as
follows:
tooltip_fg_color:#000000
tooltip_bg_color:#f5f5c5
References
- http://www.vogella.com/blog/2012/12/04/eclipse-papercut-10-eclipse-on-ubuntu-fixing-the-black-background-color-in-hover/
- http://wiki.eclipse.org/IRC_FAQ#Black_background_color_for_tooltips_on_Linux.2FUbuntu.2FGTK
How can I clear the bash history?
20 Feb 2013
-
linux
history -c && rm -f ~/.bash_history
References
How can I get the specifications of the installed RAM?
19 Feb 2013
-
linux
dmidecode --type memory
References
How can I monitor the health of a hard disk?
18 Feb 2013
-
linux
Use S.M.A.R.T.
References
How can I install the latest release of Mercurial?
17 Feb 2013
-
linux,
mercurial
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-key 323293EE
sudo add-apt-repository ppa:mercurial-ppa/releases
sudo apt-get update
sudo apt-get upgrade
References
How can I open a shell within Vim?
16 Feb 2013
-
linux
Get the latest tar.gz of conque from http://code.google.com/p/conque/downloads/list.
Extract the tar.gz file to get the directory conque_x.y
. Execute the command
cp -r conque_x.y/* ~/.vim/
to install Conque on your vim.