Tuesday, May 21, 2013
Edit history command line in Linux
Wednesday, April 24, 2013
Monday, February 04, 2013
touch command
touch filename1 filename2
Wednesday, November 28, 2012
Monday, November 19, 2012
setup svn on my linux machine
2. enable SSL sudo a2enmod ssl sudo gedit /etc/apache2/ports.conf
3. generate SSL certification 4. create virtual host In svnserver
5. enable site
6. create svn repos
Choose System > Administration > Users and Groups from your Ubuntu menu.
Click the 'Manage Groups' button.
Click the 'Add' button. Name the group 'subversion'
Add yourself and www-data (the Apache user) as users to this group (Note: in order to see www-data you may need to see FixShowAllUsers)
Click 'OK', then click 'Close' twice to commit your changes and exit the app.
7. add users
8. test with
some contents are from: https://help.ubuntu.com/community/Subversion
Friday, May 20, 2011
Monday, March 08, 2010
Priority inversion, priority inheritance, and priority ceiling
Priority inversion: a high priority task is indirectly preempted by a medium priority task. (a medium priority task preempts a low priority task, the low priority task is using a shared resource on which the high priority task is pending). The process from wiki is:
- There are 3 tasks A, B, and C, with priority from high to low. A and C share the resource
- C successfully locks the resource
- A attempts to acquire resource, being blocked and wait for C to release resource
- B became runnable before C release resource
- Now you don't know when C can release resource, and A is still blocked
- reversion happens: B is running and A is not
Solution 2: Priority ceiling - each resource is assigned a priority ceiling, which equals to the highest priority of an task which may lock the resource. Once a task finishes with the resource, its priority returns to normal.
The link is a good read for this topic.
Difference between mutex and binary semaphore
- If mutex is locked by some thread, only that thread can unlock it. The binary semaphore can be unlocked by any other threads. For instance, if thread A locks the mutex and returns before release the lock, then you are in a deadlock and cannot recover it (in C). With semaphore it is a bit different. You can still release the lock even the thread A leaves early.
- You can use recursive mutex (although you may not want to use it). This feature is not available in semaphore.
- Priority inversion (see last post) is possible with mutex, but not applicable in binary semaphore ( I think is similar with the 1st listed item).
Synchronization
It multithreading programming, it refers to relationships among threads: any number of threads, and any kind of relationship (before, after, during). Such like:
Serialization - thread A must happen before thread B.
Mutual exclusion - thread A and B must not happen at the same time.
Monday, January 25, 2010
Cut, copy, and paste block in vi
cut: dd or 4dd, then paste with p or P
copy: yy or 4yy, then past with p
if you know the start line number and end line number (Ctrl+g):
:10,25y
then p to paste. (this is copy-paste, replace y with d to cut-paste)
or set marks in both start and end lines with ma, mb
:'a,'by
then p to paste
Thursday, November 05, 2009
Use wired connection in ubuntu vmware
- disconnect wireless
- in vmware ‘network adapter’, choose ‘Bridged’
- in ubuntu ‘System Preferences-Netwrok connections’, Edit ‘Auto eth0’ and apply…
Wednesday, October 28, 2009
Get a short prompt in linux terminal
The default ubuntu linux prompt shows the all the directories:
user@user~desktop:~/home/user/work/project$
To make it shorter, add following two lines:
PS1="[\W]\\$ "
PS2="> "
to .bashrc file. Don't forget to 'source ~/.bashrc'
Tuesday, October 27, 2009
Search and install packages in ubuntu
dpkg -l | grep package
dpkg-query --show package
apt-cache search package (this one may return lots of results)
and the easy one (GUI):
synaptic
apt-get install package
Friday, October 23, 2009
save file in vi when you forget 'sudo'
This issue happened to me a lot of times.
After you made some changes in vi and want to save, suddenly you find you don't have the permission~.
Others:
> file.txt
empty the file (or create a new empty file)
Alt-.
place the argument of most recent command (keep pressing for older ones)
-- from commandlinefu.com
Wednesday, October 21, 2009
Some keyboard shortcuts in linux command line
Some are the same with emacs:
| ctrl-a | move to beginning/end of the line |
| ctrl-e | |
| ctrl-u | cut from cursor to beginning/end |
| ctrl-k | |
| ctrl-w | cut from cursor to beginning/end of word |
| ctrl-y | yank |
| ctrl-] n | move to next/previous character ‘n’ |
| ctrl-alt-] n | |
| ctrl-x ctrl u | undo last change |
| alt-r | undo current line |
| ctrl-n | next/previous command |
| ctrl-p | |
| ctrl-L | clean screen |
| ctrl-r | incremental/non- history search |
| alt-p |
Friday, October 09, 2009
Basic SVN commands
svn help [ … ]
svn co http://svn.abc.org/repos/svn/trunk /home/usr
svn st
svn st –v (verbose, show details)
svn diff
svn diff abc.c
svn diff > patchfile (save output to a file)
svn diff | vi -
svn diff -r 2269:2210 main.c
vi <(svn diff)
svn up
svn ci
svn ci abc.c –m “fixed xxx bug”
svn add abc.c (then you need to check in)
svn revert
svn log
svn list (display all files)
svn cat –r 2165 abc.c > abc.c.2165 (show an old version and save it)
Wednesday, October 07, 2009
Check current Linux version
cat /etc/*release... and check memory, CPU
cat /etc/*version
cat /etc/issue
cat /proc/version
uname -a
cat /proc/meminfo
cat /proc/cpuinfo
check how much hard disk:
df -h
Tuesday, October 06, 2009
Access folders in vmware Linux from Windows machine
Install samba (ubuntu example):
sudo apt-get install samba
sudo smbpasswd -a your_user_name
In Windows machine:
File explorer->Tools->Map Network Driver: folder is “\\10.10.1.1\usr_ubuntu”, then input your_user_name and password
[update: 2/5/2013] you don't need the step of "Share folder: right-click...."
Monday, October 05, 2009
set up tftp
I got some troubles when setting up the tftp server, here is a note:
install packages: (if in ubuntu)
sudo apt-get install xinetd tftpd tftp
service tftp
{
disable = no
socket_type = dgram
protocol = udp
wait = yes
user = root
server = /usr/sbin/in.tftpd
server_args = -p /tftpboot
per_source = 11
cps = 100 2
flags = IPv4
}
create a directory named ‘/tftpboot’
start tftp with:
sudo /etc/init.d/xinetd restart
tftp 10.10.1.1
put abc.txt
get xxx.txt
If tftp is still not working, try to disable "Firewall" and "SELinux" (use command 'getenforce' to check current status of SELinux).
Wednesday, September 23, 2009
search for inside all files in current directory with grep
grep -RnisI <pattern> *-R: recurse to subdir
-n: show line number
-i: ignore case
-s: suppress “doesn’t exist” and “cannot read” message
-I: ignore binary files
another one:
find . -type f | xargs grep -RnisI <pattern>
--[update: 11/3/09]
grep --color -RnisIH 'pattern' .
-H: show file name
--color: highlight the word (or use --color=auto, --color=always)
find . -type f -name '*.c' -print0 | xargs -0 --color -RnisIH 'search_pattern'
--if we want to find all 'oldstring' and replace with 'newstring':
grep -Rl 'oldstring' . | sed -i -e 's/oldstring/newstring/'
-l: only list the file name with containing matches.
Refer former post
