📄 1166.html
字号:
<div align=center><font class=normalfont>搜索文章:
<input type=hidden value=result name=action2>
<input type=radio checked value=title name=type>标题
<input type=radio value=content name=type>内容
<input type=image src="images/button_go.gif" tppabs="http://www.linuxhero.com/docs/images/button_go.gif" border=0 name=image2>
</font></div>
</td>
</tr>
<tr>
<td noWrap>
<div align="center">
<input maxlength=100 size=30 name=keyword2>
</div>
</td>
</tr></tbody>
</table>
</form>
</TD>
<TD rowSpan=2><IMG src="images/header_r1_c7.gif" tppabs="http://www.linuxhero.com/docs/images/header_r1_c7.gif" width=26 border=0 name=header_r1_c7></TD>
<TD><IMG height=83 src="images/spacer.gif" tppabs="http://www.linuxhero.com/docs/images/spacer.gif" width=1 border=0></TD></TR>
<TR>
<TD background="images/bgline.gif" tppabs="http://www.linuxhero.com/docs/images/bgline.gif"><IMG height=22
src="images/header_r2_c1.gif" tppabs="http://www.linuxhero.com/docs/images/header_r2_c1.gif" width=296 border=0
name=header_r2_c1></TD>
<TD background="images/bgline.gif" tppabs="http://www.linuxhero.com/docs/images/bgline.gif" colSpan=5>
<DIV align=right><FONT class=normalfont>当前位置:
<A href="index.html" tppabs="http://www.linuxhero.com/docs/index.html">本站首页</A>
<font color="#FF6699">>></font>
<A href="type17.html" tppabs="http://www.linuxhero.com/docs/type17.html">速度优化</A> | <A href="copyright.html" tppabs="http://www.linuxhero.com/docs/copyright.html">版权说明</A></font></DIV>
</TD>
<TD><IMG height=22 src="images/spacer.gif" tppabs="http://www.linuxhero.com/docs/images/spacer.gif" width=1
border=0></TD></TR></TBODY></TABLE>
<TABLE cellSpacing=10 cellPadding=0 width="100%" bgColor=#ffffff
border=0>
<TR>
<TD>
<TABLE cellSpacing=0 cellPadding=3 width="100%" border=0>
<TR>
<TD vAlign=top align=middle width="60%">
<TABLE cellSpacing=0 cellPadding=0 width="100%"
background="images/back.gif" tppabs="http://www.linuxhero.com/docs/images/back.gif" border=0>
<TBODY>
<TR>
<TD vAlign=top width="80%">
<DIV align=center>
<FORM action="search.html" tppabs="http://www.linuxhero.com/docs/search.html" method=get>
</FORM>
<TABLE cellSpacing=0 cellPadding=0 width="95%"
border=0><TBODY>
<TR>
<TD background="images/bgi.gif" tppabs="http://www.linuxhero.com/docs/images/bgi.gif"
height=30></TD></TR></TBODY></TABLE>
<TABLE cellSpacing=0 cellPadding=3 width="95%"
align=center border=0>
<TBODY>
<TR>
<TD>
<TABLE cellSpacing=0 cellPadding=3 width="100%"
border=0>
<TBODY>
<TR>
<TD vAlign=top>
<p><FONT class=normalfont><B><font color=blue>Linux的配置与优化</font></B></FONT><BR><FONT class=smallfont color=#ff9900>2004-04-23 15:18 pm</FONT><BR><FONT class=normalfont>作者:张文胜<br>来自:Linux知识宝库<br>联系方式:无名<br><br>Linux作为一个免费的类似UNIX的操作系统,正日益受到人们的重视。本人作为一名Linux爱好者,出于学习,比较了各种不同的Linux发行套件,安装过各种Linux的发行套件,但是每一次安装完成,大量的配置与优化工作花费笔者许多时间,并且非常容易遗漏一些细节。本文以安装与使用RedHat 6.1为例,参考了/usr/doc/HOWTO/Config-HOWTO文档,结合自己的工作经验,谈一些自己的做法。以下的做法基本上适合各种liunx发行套件。<br>
<br>
一、关于硬盘分区<br>
关于安装Linux如何建立硬盘分区、交换分区等问题,已经超出本文范围,但是我的经验是安装Linux时一定要建立单独的分区,用于存储用户的私人数据,同时可以用于备份系统的配置文件(如像域名服务器,Samba的配置文件等),便于以后配置。<br>
<br>
二、编辑/etc/inittab文件<br>
大部分Linux的发行套件都建立六个虚拟控制台,实际上三个已经足够,并且可以节省可贵的内存空间。编辑/etc/inittab文件,在下面三行的前面加上#。 <br>
4:2345:respawn:/sbin/mingetty tty4<br>
5:2345:respawn:/sbin/mingetty tty5<br>
6:2345:respawn:/sbin/mingetty tty6<br>
然后执行init q,使系统重新读取/etc/inittab文件,关闭tty4、tty5、tty6虚拟控制台。如果不考虑系统的安全,你可以利用第四个虚拟控制台来查看各种系统信息,编辑/etc/syslog.conf文件,在最后一行加入:<br>
*.* /dev/tty4<br>
最后再执行killall -HUP syslog。<br>
<br>
三、建立或者编辑/etc/inputrc、/etc/profile、/etc/bashrc文件<br>
虽然最近几年个人计算机的潮流已经从命令行方式转向图形方式,采用鼠标操作,但是shell在Linux中依然有很强的生命力。shell有好几种,主要有bash、ksh、tcsh、zsh、ash, 用得最多的是bash。只要编辑/etc/inputrc文件,设置INPUTRC的环境变量,利用Tab键的命令补全功能,就可以实现类似于MSDOS的DOSKEY的功能。这样对文件与目录的各种操作,也一样方便与快捷。(附/etc/inputrc文件)<br>
__________________________________________________________________<br>
set bell-style none # don't beep<br>
set meta-flag on # allow 8-bit input <br>
set convert-meta off # don't strip 8-bit characters<br>
set output-meta on # display 8-bit characters correctly<br>
set horizontal-scroll-mode On # scroll long command lines<br>
set show-all-if-ambiguous On # after TAB is pressed <br>
<br>
"e[1~": beginning-of-line # home<br>
"e[2~": insert-last-argument # insert<br>
"e[3~": delete-char # delete<br>
"e[4~": end-of-line # end<br>
"e[5~": backward-kill-word # page up<br>
"e[6~": kill-word # page down<br>
<br>
# define F7 F8 like msdos doskey<br>
"e[18~": history-search-forward # F7<br>
"e[19~": history-search-backward # F8<br>
__________________________________________________________________<br>
<br>
编辑/etc/profile文件,在其尾部插入下面内容:<br>
_________________________________________________<br>
# add by zws<br>
# customize less<br>
#LESS='-M-Q-r'<br>
PS1="[u@h w]$ "<br>
INPUTRC=/etc/inputrc<br>
LESS='-M-r' # -r 为了ls | less 支持彩色。<br>
LESSEDIT="%E ?lt+%lt. %f"<br>
LESSOPEN="| lesspipe.sh %s"<br>
LESSCHARSET=latin1<br>
PAGER=less<br>
export LESS LESSEDIT LESSOPEN LESSCHARSET INPUTRC<br>
_________________________________________________<br>
<br>
建立/usr/bin/lesspipe.sh文件,内容如下:<br>
__________________________________________________________________________<br>
#!/bin/sh<br>
# This is a preprocessor for 'less'. It is used when this environment<br>
# variable is set: LESSOPEN="|lesspipe.sh %s"<br>
lesspipe() {<br>
case "$1" in<br>
*.tar.bz2) bzip2 -cd $1 $1 2>/dev/null | tar tvvf - ;;<br>
*.tar) tar tf $1 2>/dev/null ;; # View contents of .tar and .tgz files<br>
*.tgz|*.tar.gz|*.tar.Z|*.tar.z) tar ztf $1 2>/dev/null ;;<br>
*.Z|*.z|*.gz) gzip -dc $1 2>/dev/null ;; # View compressed files correctly<br>
*.zip) unzip -l $1 2>/dev/null ;; # View archives<br>
*.arj) unarj l $1 2>/dev/null ;;<br>
*.rpm) rpm -qpil $1 2>/dev/null ;;<br>
*.cpio) cpio --list -F $1 2>/dev/null ;;<br>
*.bz2) bzip2 -dc $1 2>/dev/null ;; # View compressed files correctly<br>
*.1|*.2|*.3|*.4|*.5|*.6|*.7|*.8|*.9|*.n|*.l|*.man) FILE=`file -L $1`<br>
FILE=`echo $FILE | cut -d ' ' -f 2`<br>
if [ "$FILE" = "troff" ]; then<br>
groff -s -p -t -e -Tascii -mandoc $1<br>
fi ;;<br>
*) file $1 | grep text > /dev/null ;<br>
if [ $? = 1 ] ; then # it's not some kind of text<br>
strings $1<br>
fi ;;<br>
esac<br>
}<br>
lesspipe $1<br>
_________________________________________________________________这样就可以使用less查看以上文件格式的信息与内容。<br>
注意要利用chmod 755 /usr/bin/lesspipe.sh命令将此文件设置为可执行!<br>
/etc/bashrc文件的例子:<br>
____________________________________________<br>
# /etc/bashrc<br>
<br>
# System wide functions and aliases<br>
# Environment stuff goes in /etc/profile<br>
<br>
# For some unknown reason bash refuses to inherit<br>
# PS1 in some circumstances that I can't figure out.<br>
# Putting PS1 here ensures that it gets loaded every time.<br>
# PS1="[u@h w]$ "<br>
<br>
eval `dircolors -b`<br>
alias ls='ls --color=yes -F -N' # ls 支持彩色<br>
alias l='ls --color=yes -l -F -N' # l <br>
alias cp='cp -i'<br>
alias mv='mv -i'<br>
alias rm='rm -i'<br>
alias df='df -h'<br>
alias ln='ln -i'<br>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -