Apollo Connecting the World

Diligence and Intelligence

Posts Tagged ‘Linux


leave a comment »

from: http://hi.baidu.com/zengzhaonong/blog/item/468a06d88ebb113532fa1c62.html



(1) 在当前目录下的所有文件的文件内容中查找哪个文件的内容中有findcontents(大小写不敏感,列出findcontents所在文件的所在行)——适合于当前目录下的文件及目录数目比较少,如果查找后列出内容过多,将会失去查找意义。
grep -rin findcontents *

(2) 如果查找后列出内容过多,就需要用如下命令(只列出findcontents在所在文件的出现次数):
grep -ric findcontents * | grep -v :0

(3) 如果根本不知道文件所在目录,就需要在根目录下进行查找(查找整个硬盘空间),但是由于根目录下某些文件(bin、sbin、boot、dev、initrd、lib)没有查找价值,因而要将其排除在查找范围之外
# cd /
grep -rin findcontents `ls | grep -vE ‘bin|boot|dev|initrd|lib’`


-i, –ignore-case
-n, –line-number
-c, –count
-r, –recursive
-v, –invert-match
-E, –extended-regexp
Use PATTERN as the pattern; useful to protect patterns beginning with -.


Written by apollozhao

2011/01/15 at 16:31

Posted in grep, Linux

Tagged with , ,

Set Up CVS Server on Linux

leave a comment »

Assumption: server: s.com   client: c.com
Goal: user mike can use the CVS on s.com (assumption: mike has an account as “mike” on s.com)

1. install cvs and xinetd on the server
$yum install cvs
$yum install xinetd

NOTE: check whether cvs (or xinetd) has been installed:
$rpm -qa | grep cvs

2. set up cvs group and user on the server:
$groupadd cvs
$useradd -g cvs -G cvs -d /home/cvsroot cvsroot
$passwd cvsroot # set up password for cvsroot

Add mike to the cvs group:
$usermod -a -G mike cvs

Check whether mike is in the cvs group:
$groups mike

3. change owner of /home/cvsroot if necessary, chmod for /home/cvsroot:
$chown -R cvsroot:cvs /home/cvsroot
$chmod -R 775 /home/cvsroot

Read the rest of this entry »

Written by apollozhao

2011/01/06 at 16:35

Posted in CVS, CVS, Linux, Project Management

Tagged with , , ,

Compress and Decompress in Linux

leave a comment »

1. zip

zip aaa.zip -r aaa/
unzip aaa.zip

2. tar

tar -cvf aaa.tar aaa/
tar -xvf aaa.tar

3. tar gzip

tar -czvf aaa.tar.gz aaa/
tar -zxvf aaa.tar.gz


Written by apollozhao

2010/12/06 at 18:08

Posted in Linux, Softwares, tar, zip

Tagged with , , , , ,

Enable USB for VirtualBox Guest OS in Fedora

leave a comment »

It is sometimes necessary that you have to access a USB drive in the guest OS of VirtualBox virtual machine. But it is known a problem in Fedora that users cannot access USB by simply setting it in VirtualBox.

Here is a method to fix it.

Solution 1 (recommended):

1. add your user account to the group vboxusers (suppose you login to Linux as user1)
sudo usermod -G vboxusers  user1 #user1 is your Linux account

You can also do this step in GUI, “System->Administration->Users and Groups”

2. modify /etc/rc.d/rc.sysinit
sudo vim /etc/rc.d/rc.sysinit, and find
if [ ! -d /proc/bus/usb ]; then
modprobe usbcore >/dev/null 2>&1 && mount -n -t usbfs /proc/bus/usb /proc/bus/usb
mount -n -t usbfs /proc/bus/usb /proc/bus/usb

Comment them all.

3. Reboot. Open VirtualBox, in the virtual machine (eg. name as “VM1”)
Before running the VM, first edit its settings, in the “USB” panel, check “Enable USB controller” and “Enable USB 2.0 (EHCI) Controller”.
In the “USB Device Filters” (should be an empty list), press the small button “Add Empty Filter (Ins)”. Save the settings.

4. Run the VM1. Plug the USB disk in.
You may find USB disk yet not has been found in the VM. Don’s worry. In the menu of the virtual machine, go “Devices->USB Devices->”, check the USB disk.
You can find it in the guest VM OS now!

Solution 2 (Not verified by the author):

1. add a group “usbfs”. Add your Linux user name to this group, using the same way as described in solution 1.
Add your Linux user name to group “vboxusers”

After this step, you can type this command for a check:
grep usbfs /etc/group

You can also see the id for the group “vboxusers” by this command:
more /etc/group

2. sudo gedit /etc/fstab
Add this line:
none /sys/bus/usb/drivers usbfs devgid=1003,devmode=664 0 0

Here 1003 is the id of the group “vboxusers”.

3. Reboot your host OS.

This method works in Fedora 12 32-bit.

[1] http://hi.baidu.com/cyberniuniu/blog/item/275aab0f9c5e0b236059f3ac.html
[2] http://blog.chinaunix.net/u/31729/showart_2259504.html
[3] http://www.linuxdiyf.com/viewarticle.php?id=184692
[4] http://edu.kafan.cn/html/xuniji/10864.html

Written by apollozhao

2010/09/18 at 14:10

Posted in Fedora, Linux, Softwares, VirtualBox

Tagged with , ,

Add a .eps graph to an article in LaTeX, “unknown graphics extension” error

leave a comment »

When writing an article using LaTeX, sometimes one may be faced with an error when inserting a .eps graph, which says “unknown graphics extension”, while compling the .tex file.

Maybe it is because you use the “pdflatex” command to compile the .tex file. Since this command does not know .eps files, so the compilation fails.

To prevent that, you should compile the file in this way:
1. latex yourfile.tex
2. dvips yourfile.dvi
3. ps2pdf yourfile.ps

The command “latex” will recogonize the .eps files and compile without errors.

Written by apollozhao

2010/09/13 at 20:29

Posted in LaTeX, Linux

Tagged with , , , ,

Install local and network printer in Fedora 12

leave a comment »

Local Printer:
Printer: Fuji Xerox, DocuPrint 203A
1. download driver. (http://wiki.archlinux.org/index.php/FujiXerox_DocuPrint_203A)
2. install the two rpms. (e.g. sudo rpm -Uvh DocuPrint_203_A-lpr-1.1.2-4.i386.rpm )
3. sudo /etc/init.d/cups stop; sudo /etc/init.d/cups start. (restart the service)

To test the printer, go to “localhost::631” in a browser, in the “job” tab, you can print test page.

In daily use, you can type “lpr -P DocuPrint_203_A a.txt (can surely print .ps)” command to print a.txt

Network Printer:
Printer: Lexmark
1. In “System->Administration->Printing”
2. Click “Add”, in “New Printer”, choose “Network Printer -> Windows Printer via SAMBA”.
3. Type in the url (e.g. smb://nts27/pstsc), or type “smb://nts27/” to Browse (if password is needed, type like this: domain\username)
4. Forward, choose Generic as Driver
5. Forward, choose PostScript Printer
6. Printer setup completed. Right click the printer and choose the “Properties”, in “Printer Options”, you can choose “Media size” as “A4”.

This method applies in Fedora 12.

Written by apollozhao

2010/07/18 at 13:11

Content Assist and Word Completion in Eclipse

with one comment

In Linux, when using Eclipse, we can speed up programming with content assist/word completion. In Eclipse on Windows, we can use “Alt+/” to prompt the small window that provides information of content assist. However, in Eclipse on Linux, “Alt+/” will do word completion (Eclipse 3.5.1).

The difference between content assist and word completion is that: word completion is like “Ctrl+p” in vim, it will give you all the possible strings, as long as they have appeared in the file; content assist, however, is more intelligent in that it will give you the correct string, eg. variable name you need in this place.

To enable consist assist in Eclipse in Linux, go to “Eclipse->Window->Preferences->General->Keys”, search “content assist”, and give the command a Binding that you like.

Written by apollozhao

2010/05/17 at 15:19