Thursday, December 29, 2011

add a default route in Linux

Sometimes, even after cmd "dhclient eth0", the machine still cannot ping outside machines.

Then, I use cmd "route" to check the current route, and get sth like this:

Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
192.168.1.0 * 255.255.255.0 U 0 0 0 ra0

So there is no default gatway. Next I use the following command to add a default route:

"route add default gw 192.168.2.1 eth0"
(The IP of the gateway could be the current IP address and change the last number to 1.)

Ref:
http://www.cyberciti.biz/faq/linux-setup-default-gateway-with-route-command/

Tuesday, December 27, 2011

A complete guide to RPM and source RPM

Maximum RPM

http://www.rpm.org/max-rpm-snapshot/

List all the rpms, etc:

http://www.cyberciti.biz/faq/howto-list-installed-rpm-package/

Wednesday, December 21, 2011

Miscellaneous Character Drivers

http://www.linuxjournal.com/article/2920?page=0,0

Wednesday, December 14, 2011

Tuesday, December 13, 2011

git discard changes to a file


git checkout -f -- "filename"
Note, there is a space between -- and "filename".

Other methods:
git checkout -f

=========================================
To discard local commits:

git reset --hard origin/master

Tuesday, December 6, 2011

git send-email

http://morefedora.blogspot.com/2009/02/configuring-git-send-email-to-use-gmail.html

http://felipec.wordpress.com/2009/10/25/git-send-email-tricks/

bash commands shortcuts

http://www.gnu.org/software/bash/manual/bashref.html#Commands-For-History

yank-nth-arg (M-C-y)
alt+ctrl+y

Insert the first argument to the previous command (usually the second word on the previous line) at point. With an argument n, insert the nth word from the previous command (the words in the previous command begin with word 0). A negative argument inserts the nth word from the end of the previous command. Once the argument n is computed, the argument is extracted as if the ‘!n’ history expansion had been specified.

yank-last-arg (M-. or M-_)

alt+-
Insert last argument to the previous command (the last word of the previous history entry). With an argument, behave exactly like yank-nth-arg. Successive calls to yank-last-arg move back through the history list, inserting the last argument of each line in turn. The history expansion facilities are used to extract the last argument, as if the ‘!$’ history expansion had been specified.





Monday, December 5, 2011

__releases and __acquires macros in Linux kernel

Is used for sparse (a static analysis tool) to check the lock unlock mismatches.



http://lists.linux-foundation.org/pipermail/linux-pm/2006-May/008346.html


http://marc.info/?l=linux-sparse&m=109865107109043&w=2

use netcat to transfer files between two machines

netcat is a very useful small program to communicate between two machines. If you just want to simply upload a file from one machine to another one, without setting up ftp, ssh server, then you can use netcat (it has many other functions).


commands:

1) listen on a port:

nc -l -p 2222 > log.txt
2) send file:
cat /etc/passwd  nc 192.168.0.50 2222