Posts Tagged ‘Linux’
[zz]Converting JPG Images to EPS
from: http://fclose.com/b/linux/3549/converting-jpg-images-to-eps/
I write a lot latex documents and most of the documents have images in it. Latex deals EPS very well, while sometimes we need to add JPG / PNG images to it. I find converting the JPG images to EPS ones is the most convenient way to embed JPG images to latex documents. On Linux, this is quit easy with ImageMagick.
You need to install ImageMagick if it is not already installed in the system:
# yum install ImageMagick
Convert image image.jpg from JPG to EPS format:
$ convert image.jpg image.eps
For other image formats, the command is similar.
[zz]关闭Linux下不必要的系统服务以加快速度
from: http://server.zdnet.com.cn/server/2008/0617/931251.shtml
Linux系统在/etc/rc.d/init.d下定义了很多的系统服务向用户提供,默认情况下这些服务大多都是随机启动,但是很多服务是一般不需要的,或者是你没有进行配置就根本不起作用的,但由于设置成随机启动,在内核加载进内存开始运行后会花时间启动这些服务相应的进程从而大大降低开机速度,所以你可以通过关闭这些服务从而加快开机速度。
不同的GNU Linux版本的系统服务大都一样,但是也会有一些小区别,一般都提供50个左右的服务。
以redhat9为例,下面的系统服务一般情况下大都可以关闭:
Cron(看情况,有时会需要)
Anancron
Apmd
Atd
Autofs
Cups(有打印机可以不关)
How to check the version of Linux (Fedora, Ubuntu, or other issues)
If we want to check whether a Linux is a Fedora, or Ubuntu, or SuSE or whatever, in command line, we can simply do like this:
1. go to /etc, search for the file with string “issue” or “release”
$cd /etc
$ls *issue* (ls *release*)
2. read the found file, e.g.:
$more issue
$more lsb-release
Note: This method applies in Fedora, Ubuntu. For other systems the blogger has not verified.
SSH Tunnel in Linux
It is easy in Windows to create SSH tunnel with the help of many tools (e.g. putty). How to do it in Linux? It is easier. 🙂
Suppose mike has an account on remote machine sshserver.com, which is used to be the one to connect.
Open an terminal, type command:
$ssh -N mike@sshserver.com -D 7070
Input the password, and now you have created the SSH tunnel. To use it as a proxy, just config your browser, add a socks 5 proxy, with the proxy as: “127.0.0.1:7070”.
OK, now you can surf the Internet with the proxy.
Note.
Some articles use -L parameter in the SSH commands, please refer to [1].
Preference:
[1] http://blog.fredrikbostrom.net/2009/04/10/ssh-tunnel-from-the-command-line
Count number of lines of all files in a directory
In Linux, given a directory “dir”, if you want to count number of lines of all files (e.g. .txt files) in the directory (inclucing sub-directory), simply type this command:
find ./ -name ‘*.txt’ | xargs wc -l
NOTE: This method works in Fedora 12
[zz]用grep查找文件内容
from: http://hi.baidu.com/zengzhaonong/blog/item/468a06d88ebb113532fa1c62.html
使用grep搜索文件内容——快捷、方便
(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
-e PATTERN, –regexp=PATTERN
Use PATTERN as the pattern; useful to protect patterns beginning with -.
注:有c的时候n将失效
Set Up CVS Server on Linux
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)
Steps:
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
Compress and Decompress in Linux
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