Tag Archives: Linux系统学习

centos 安装svn server( http https )


sudo yum install httpd subversion mod_dav_svn


sudo mkdir -p /var/lib/subversion/repositories
sudo chown -R apache:apache /var/lib/subversion


sudo svnadmin create --fs-type fsfs /var/lib/subversion/repositories/xxx
sudo chown -R apache:apache /var/lib/subversion/repositories/xxx
sudo chmod -R g+w /var/lib/subversion/repositories/xxx
sudo chmod g+s /var/lib/subversion/repositories/xxx/db


centos 6.3安装redmine

转载自: http://www.mylinuxguide.com/installing-redmine-with-passenger-and-apache-on-centos-6-3/

Installing Redmine with Passenger and Apache on Centos 6.3

1. Install prerequisite / dependencies :

yum install subversion make gcc gcc-c++ zlib-devel ruby-devel rubygems ruby-libs apr-devel apr-util-devel httpd-devel mysql-devel mysql-server automake autoconf ImageMagick ImageMagick-devel curl-devel


2. Go to the directory where you want to download Redmine Code and check out the files using svn command :

svn co http://svn.redmine.org/redmine/branches/2.1-stable redmine

3. Install the ruby gem named bundle :

gem install bundle

4. Now go to the redmine directory and  install the redmine’s ruby dependencies using the bundler :

bundle install --without postgresql sqlite test development




vim是我最喜欢的编辑器,也是linux下第二强大的编辑器。 虽然emacs是公认的世界第一,我认为使用emacs并没有使用vi进行编辑来得高效。 如果是初学vi,运行一下vimtutor是个聪明的决定。 (如果你的系统环境不是中文,而你想使用中文的vimtutor,就运行vimtutor zh)



This isn’t a blog about why you should use Vim. That’s obvious. If it isn’t, read Why
do those nutheads use Vi?
 Instead, this a tutorial about using Vim as a fully-fledged IDE, and specifically for PHP projects. Many Vim users would only use it for dipping in and out of the odd file on their computer, or maybe just on a remote server during
an SSH session. I’m here to tell you that it can be configured to be more efficient and productive than your favourite IDE.



This article is part of the FAQ series.



like ‘top’ often report a surprisingly small amount of free memory after
a system has been running for a while. For instance, after about 3 hours of uptime, the machine I’m writing this on reports under 60 MB of free memory, even though I have 512 MB of RAM on the system. Where does it all go?

The biggest place it’s being used is in the disk cache, which is currently over 290 MB. This is reported by top as “cached”. Cached memory is essentially free, in that it can be replaced quickly if a running (or newly starting) program needs the memory.

The reason

uses so much memory for disk cache is because the RAM is wasted if it isn’t used. Keeping the cache means that if something needs the same data again, there’s a good chance it will still be in the cache in memory. Fetching the information from there is around
1,000 times quicker than getting it from the hard disk. If it’s not found in the cache, the hard disk needs to be read anyway, but in that case nothing has been lost in time.

To see a better estimation of how much memory is really free for applications to use, run the command free -m:

Code: free -m
             total       used       free     shared    buffers     cached 
Mem:           503        451         52          0         14        293 
-/+ buffers/cache:        143        360 
Swap:         1027          0       1027

The -/+ buffers/cache line shows how much memory is used and free from the perspective of the applications. Generally speaking, if little swap is being used, memory usage isn’t impacting performance at all.

Notice that I have 512 MB of memory in my machine, but only 52 is listed as available by free. This is mainly because the kernel can’t be swapped out, so the memory it occupies could never be freed. There may also be regions of memory reserved for/by the
hardware for other purposes as well, depending on the system architecture. However, 360M are free for application consumption.

Virtual memory allows non-contiguous memory to be addressed as if it is contiguous. Each process
has a memory map made up of (at least):

  • Program’s executable code (called text)
  • Areas for data, that could be initialized (assigned value at the beginning of execution), uninitialized data (BSS), and the program stack.
  • One area for each active memory mapping

Let’s see how we can see the memory area of a process. We first have to identify the process we want to look at. We can use
ps -A for that:

# ps -A
  PID TTY          TIME CMD
    1 ?        00:00:00 init
    2 ?        00:00:00 ksoftirqd/0



Often search and replace is needed in multiple files. This tip uses the procedures from run a command in multiple buffers to show how a substitute may be executed multiple times using :argdo (all files in argument list), or :bufdo (all buffers), or :tabdo (all tabs), or :windo (all windows in the current tab).



All buffersEdit

The following performs a search and replace in all buffers (all those listed with the :ls command):

:bufdo %s/pattern/replace/ge | update
bufdo Apply the following commands to all buffers.
%s Search and replace all lines in the buffer.
pattern Search pattern.
replace Replacement text.
g Change all occurrences in each line (global).
e No error if the pattern is not found.
Separator between commands.
update Save (write file only if changes were made).

The command above uses :update to save each buffer, if it was changed. That is necessary because, by default, Vim will not switch away from a buffer if it has been changed.

One alternative is to set the 'autowriteall' option so changed buffers are automatically saved when required:

:set autowriteall
:bufdo %s/pattern/replace/ge

Another alternative is to set the 'hidden' option so buffers do not need to be saved, then use :wa to save all changes (only changed buffers are written):

:set hidden
:bufdo %s/pattern/replace/ge

All windowsEdit

If you are not dealing with a lot of files, it can be useful to display each wanted file in its own window, then operate on each window. For example, after opening multiple files with a shell command like gvim *.c, you could choose which files you wanted to operate on like this:

:sball Split screen to show all buffers (one window per buffer).
Move to a window you do not want to change.
<C-w>c Close the window (press Ctrl-W then c).
<C-w>T<C-PageUp> Or, move the window to a new tab page, then switch back to the original tab.
Repeat until only buffers you want to change are displayed in the current tab page.
:windo %s/pattern/replace/ge Search and replace in all visible windows.
:wa Save all changes.

All files in a treeEdit

Suppose all *.cpp and *.h files in the current directory need to be changed (not subdirectories). One approach is to use the argument list (arglist):

:arg *.cpp All *.cpp files in current directory.
:argadd *.h And all *.h files.
:arg Optional: Display the current arglist.
:argdo %s/pattern/replace/ge | update Search and replace in all files in arglist.

A similar procedure can perform the same operation on all wanted files in the current directory, and in all subdirectories (or in any specified tree of directories):

:arg **/*.cpp All *.cpp files in and below current directory.
:argadd **/*.h And all *.h files.
... As above, use :arg to list files, or :argdo to change.

In the above, a forward slash was used in **/*.cpp. That works on all systems (Unix and Windows). If wanted, a backslash can be used on Windows systems.

Replacing current wordEdit

A common requirement is to replace the word under the cursor in a number of files. Rather than automating the process, it is best to use Vim's procedures. For example:

:arg *.cpp All *.cpp files in directory.
:argadd *.h And all *.h files.
Move cursor to word that is to be replaced.
* Search for that exact word.
:argdo %s//replace/ge | update Search and replace in all files in arglist.

In the above substitute command:

  • The search pattern is empty, so the last search is used.
  • Type your replacement text instead of replace. If the text is similar to the current word press Ctrl-R then Ctrl-W to insert that word into the command line, then change it.

Alternatively, you might try the following user command or mapping.

" Search for current word and replace with given text for files in arglist.
function! Replace(bang, replace)
  let flag = 'ge'
  if !a:bang
    let flag .= 'c'
  let search = '\<' . escape(expand('<cword>'), '/\.*$^~[') . '\>'
  let replace = escape(a:replace, '/\&~')
  execute 'argdo %s/' . search . '/' . replace . '/' . flag
command! -nargs=1 -bang Replace :call Replace(<bang>0, <q-args>)
nnoremap <Leader>r :call Replace(0, input('Replace '.expand('<cword>').' with: '))<CR>


CentOS 6.4读写ntfs

我先在使用的是双系统Win7和CentOS6.4。在CentOS中无法识别win7中的硬盘。但是man mount的时候,在-t参数中有ntfs的选项。但是挂在的时候总是提示出错。

mount  -t ntfs /dev/sda1 /media

mount: unknown filesystem type ‘ntfs’





1. 启动vim的时候

2. 在vim已经启动的情况


1. 启动vim的时候


a. 多个文件垂直切分一个窗口

vim -o a.py b.py c.py


b. 多个文件水平切分一个窗口