[root@szm logrotate.d]# history 5
1338 cat ~/.bashrc
1339 history 5
1340 history
1341 q
1342 history 5
[root@szm logrotate.d]# !!
命令搜索模式Ctrl+r:(reverse-i-search)`':
上次使用参数:Alt+. 或者 Esc+. 或者 $!
命令编辑技巧:Ctrl+a,e,u,k,方向键(首,尾,删除首,删除尾,单词移动)
Terminal快捷键: Ctrl+Shift+t:新建标签 Ctrl+Shift+PaUP/PgDn:标签切换 Ctrl+Shift+c:复制 Ctrl+Shift+v:粘贴 Ctrl+Shift+w:关闭 Ctrl+Shift++:放大 Ctrl+-:缩小 标签切换:Alt+1234…… $():作用与``相同 {}:执行命令 |
[root@szm logrotate.d]# help alias
alias: alias [-p] [name[=value] ... ]
Define or display aliases.
Without arguments, `alias' prints the list of aliases in the reusable
form `alias NAME=VALUE' on standard output.
Otherwise, an alias is defined for each NAME whose VALUE is given.
A trailing space in VALUE causes the next word to be checked for
alias substitution when the alias is expanded.
Options:
-p Print all defined aliases in a reusable format
Exit Status:
alias returns true unless a NAME is supplied for which no alias has been
defined.
[root@szm logrotate.d]# alias -p
alias cp='cp -i'
alias l.='ls -d .* --color=auto'
alias ll='ls -l --color=auto'
alias ls='ls --color=auto'
alias mv='mv -i'
alias rm='rm -i'
alias which='alias | /usr/bin/which --tty-only --read-alias --show-dot --show-tilde'
[root@szm logrotate.d]# alias cls=clear
[root@szm logrotate.d]# help unalias
unalias: unalias [-a] name [name ...]
Remove each NAME from the list of defined aliases.
Options:
-a remove all alias definitions.
Return success unless a NAME is not an existing alias.
[root@szm logrotate.d]# unalias cls
[root@szm logrotate.d]# alias -p
alias cp='cp -i'
alias l.='ls -d .* --color=auto'
alias ll='ls -l --color=auto'
alias ls='ls --color=auto'
alias mv='mv -i'
alias rm='rm -i'
alias which='alias | /usr/bin/which --tty-only --read-alias --show-dot --show-tilde'
系统环境变量参数:
[root@szm logrotate.d]# env
PS参数查找:[root@szm logrotate.d]# man bash
PATH路径的添加
[root@szm logrotate.d]# PATH=$PATH:/path
[root@szm logrotate.d]# echo $PATH
/usr/lib/qt-3.3/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin:/path
全局配置文件:系统环境变量(PATH,MAIL,LOGINNAME,HOSTNAME,HISTORYSIZE,/etc/profile.d),login登录时候必须加载的一个配置文件;
[root@szm logrotate.d]# cat /etc/profile
# /etc/profile
# System wide environment and startup programs, for login setup
# Functions and aliases go in /etc/bashrc
# It's NOT a good idea to change this file unless you know what you
# are doing. It's much better to create a custom.sh shell script in
# /etc/profile.d/ to make custom changes to your environment, as this
# will prevent the need for merging in future updates.
pathmunge () {
case ":${PATH}:" in
*:"$1":*)
;;
*)
if [ "$2" = "after" ] ; then
PATH=$PATH:$1
else
PATH=$1:$PATH
fi
esac
}
if [ -x /usr/bin/id ]; then
if [ -z "$EUID" ]; then
# ksh workaround
EUID=`id -u`
UID=`id -ru`
fi
USER="`id -un`"
LOGNAME=$USER
MAIL="/var/spool/mail/$USER"
fi
# Path manipulation
if [ "$EUID" = "0" ]; then
pathmunge /sbin
pathmunge /usr/sbin
pathmunge /usr/local/sbin
else
pathmunge /usr/local/sbin after
pathmunge /usr/sbin after
pathmunge /sbin after
fi
HOSTNAME=`/bin/hostname 2>/dev/null`
HISTSIZE=1000
if [ "$HISTCONTROL" = "ignorespace" ] ; then
export HISTCONTROL=ignoreboth
else
export HISTCONTROL=ignoredups
fi
export PATH USER LOGNAME MAIL HOSTNAME HISTSIZE HISTCONTROL
# By default, we want umask to get set. This sets it for login shell
# Current threshold for system reserved uid/gids is 200
# You could check uidgid reservation validity in
# /usr/share/doc/setup-*/uidgid file
if [ $UID -gt 199 ] && [ "`id -gn`" = "`id -un`" ]; then
umask 002
else
umask 022
fi
for i in /etc/profile.d/*.sh ; do
if [ -r "$i" ]; then
if [ "${-#*i}" != "$-" ]; then
. "$i"
else
. "$i" >/dev/null 2>&1
fi
fi
done
unset i
unset -f pathmunge
[root@szm logrotate.d]# cat /etc/profile.d/
colorls.csh glib2.sh less.csh vim.csh
colorls.sh gnome-ssh-askpass.csh less.sh vim.sh
cvs.csh gnome-ssh-askpass.sh qt.csh which2.sh
cvs.sh lang.csh qt.sh
glib2.csh lang.sh udisks-bash-completion.sh
bash环境配置文件:这个文件是所有的Shell都要加载的配置文件,不论是login不是no-login
[root@szm logrotate.d]# cat /etc/bashrc
用户环境配置文件:
[root@szm logrotate.d]# cat ~/.bash_profile
# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
# User specific environment and startup programs
PATH=$PATH:$HOME/bin
export PATH
用户级别的Bash环境配置文件:
[root@szm logrotate.d]# cat ~/.bashrc
# .bashrc
# User specific aliases and functions
alias rm='rm -i'
alias cp='cp -i'
alias mv='mv -i'
# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi
[root@szm logrotate.d]# cat ~/.bash_logout
# ~/.bash_logout
应用配置生效:
[root@szm logrotate.d]# source /etc/bashrc
[root@szm logrotate.d]# . /etc/bashrc
转载于:https://blog.51cto.com/2816056/1153374