找回密码
 注册
广告投放 虚位以待【阿里云】2核2G云新老同享 99元/年,续费同价做网站就用糖果主机-sugarhosts.comJtti.com-新加坡服务器,美国服务器,香港服务器
查看: 543|回复: 0

优化Hostmonster运行环境

[复制链接]
发表于 2010 年 10 月 2 日 08:31:57 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?注册

×
『特别提示:以下内容由金光新闻采集从互联网自动获取』
Bash 配置文件
当我们要求登录Shell的时候,系统将会验证权限,设置运行环境并启动用户交互界面,在unix系统下,系统启动时一般会加载位于主目录或 /ect 目录下的bash文件。假设bash文件存在,就会接着依次查找 ~/.bash_profile, ~/.bash_login and ~/.profile, 并加载文件里的配置,假设这些文件都不存在,就使用 /etc/bashrc
修改命令行参数
export LD_LIBRARY_PATH=$HOME/lib/
export PATH="$HOME/binPATH"
source ~/.bash_profile
修改命令行提示符
只需要修改 ~/.bash_profile 文件中的PS1 变量.想要修改立即生效, 运行命令
. ~/.bash_profile
下面是命令行提示符中可用的参数意义
\a     an ASCII bell character (07)
\d     the date in "Weekday Month Date" format (e.g., "Tue May 26")
\D{format}  the format is passed to strftime(3) and the result is inserted into the prompt string; an empty format results in a locale-specific time representation.
\e     an ASCII escape character (033)
\h     the hostname up to the first `.'
\H     the hostname
\j     the number of jobs currently managed by the shell
\l     the basename of the shell's terminal device name
\n     newline
\r     carriage return
\s     the name of the shell, the basename of $0 (the portion following the final slash)
\t     the current time in 24-hour HH:MM:SS format
\T     the current time in 12-hour HH:MM:SS format
\@     the current time in 12-hour am/pm format
\A     the current time in 24-hour HH:MM format
\u     the username of the current user
\v     the version of bash (e.g., 2.00)
\V     the release of bash, version + patchelvel (e.g., 2.00.0)
\w     the current working directory
\W     the basename of the current working directory
\!     the history number of this command
\#     the command number of this command
\$     if the effective UID is 0, a #, otherwise a $
\nnn   the character corresponding to the octal number nnn
\\     a backslash
\[     begin a sequence of non-printing characters, which could be used to embed a terminal control sequence into the prompt
\]     end a sequence of non-printing characters
    The command number and the history number are usually different: the history number of a command is its position in the history list, which may include commands restored from the history file, while the command number is the position in the sequence of commands executed during the current shell session. After the string is decoded, it is expanded via parameter expansion, command substitution, arithmetic expansion, and quote removal.
一些有用的命令行提示符配置
export PS1='\[\033[1;33m\]\u\[\033[1;37m\]@\[\033[1;32m\]\h\[\033[1;37m\]:\[\033[1;31m\]\w \[\033[1;36m\]\$ \[\033[0m\]'
user@host:~/bin/tools $
export PS1="\e[1;31m[\h]$NC \W > \[\033]0;\${TERM} [\u@\h] \w\]"
[lifesaver] tools >
export PS1="\n\e[1;37m[\e[0;32m\u\e[0;35m@\e[0;32m\h\e[1;37m]\e[1;37m[\e[0;31m\w\e[1;37m]\n$ \e[0m"
[user@host][~/bin/tools]
$
export PS1="\n[$?]\e[1;37m[\e[0;32m\u\e[0;35m@\e[0;32m\h\e[1;37m]\e[1;37m[\e[0;31m\w\e[1;37m]($SHLVL:\!)\n\[\033[0m\]\$ "
[0][user@host][~/bin/tools](1:2130)
export PS1='[\u@\h:\w]\$ '
设置登录欢迎信息
在你的 ~/.bash_profile 添加一些可以执行的命令,在你登录的时候就会直接显示了
# 显示文本
echo 'hello'
# 显示日历
cal $(date +"%m") $(date +"%Y")
# 显示机器状态
echo -e "Machine stats"; uptime
procinfo|head -n 13|tail -n 11
为目录列表添加颜色
使目录,普通文件,压缩文件,链接文件显示不同的颜色
命令行:
vim ~/.bash_profile
复制下面的代码到 ~/.bash_profile:
# enable color support of ls and also add handy aliases
if [ "$TERM" != "dumb" ]; then
    eval "`dircolors -b`"
    alias ls='ls --color=auto'
    #alias rm 'mv \!* ~/TRASH'
    #alias dir='ls --color=auto --format=vertical'
    #alias vdir='ls --color=auto --format=long'
fi
编辑你自己的运行环境配置
命令行
vi ~/.bashrc
添加如下代码
export PATH=~/binPATH
假设你使用 .bash_profile
命令行:
vi ~/.bash_profile
添加如下代码
. .bashrc
使用以下命令是修改立即生效.
. .bashrc
使用自己的运行目录
假设你使用上面介绍的命令,在你的根目录下将会生成许多文件夹,假设你不喜欢这种凌乱的样子,你可以创建一个目录用来存放执行目录和运行时库:
mkdir packages
设置PATH 和 LD_LIBRARY_PATH
export LD_LIBRARY_PATH=$HOME/packages/lib/
export PATH="$HOME/packages/binPATH"
完整的例子请查看Unix account setup.
禁止新邮件提醒
添加以下代码到 .bash_profile.
unset MAILCHECK
来源:http://xuming.net/2008/06/hostmonster-environment.html

Jgwy.Com - Free Web Hosting Guide & Directory In China since 2001! Jgwy.Net-Jglt.Net
您需要登录后才可以回帖 登录 | 注册

本版积分规则

Archiver|手机版|小黑屋|金光论坛

GMT+8, 2025 年 2 月 3 日 18:54 , Processed in 0.025896 second(s), 22 queries .

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表