1.別名使用alias
[root@CJtest ~]$alias cdnet=‘cd /etc/sysconfig/network-scripts/‘
[root@CJtest ~]$cdnet
[root@CJtest network-scripts]
[root@CJtest ~]$nano .bashrc
[root@CJtest ~]$exit
logout
[chaijing@CJtest ~]$su -
Password:
[root@CJtest ~]$cat .bashrc
# .bashrc
# User specific aliases and functions
alias rm='rm -i'
alias cp='cp -i'
alias mv='mv -i'
alias cdnet='cd /etc/sysconfig/network-scripts/'
# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
[root@CJtest ~]$cdnet
[root@CJtest network-scripts]$
~/.bashrc 對當(dāng)前用戶有效
/etc/bashrc 對所有用戶有效
2.unalias取消別名
[root@CJtest ~]$unalias cdnet
[root@CJtest ~]$cdnet
bash: cdnet: command not found...
[root@CJtest ~]$
unalias [-a] Name -a是取消所有別名
3.時間缕坎、地區(qū)設(shè)置
[root@CJtest ~]$clock -s
[root@CJtest ~]$clock
2020-04-20 22:57:46.334174-04:00
[root@CJtest ~]$date
Mon Apr 20 22:57:50 EDT 2020
[root@CJtest ~]$clock -w
[root@CJtest ~]$clock
2020-04-20 22:58:03.098092-04:00
[root@CJtest ~]$date
Mon Apr 20 22:58:08 EDT 2020
[root@CJtest ~]
[root@CJtest ~]$timedatectl list-timezones
Africa/Abidjan
Africa/Accra
Africa/Addis_Ababa
Africa/Algiers
Africa/Asmara
Africa/Bamako
Africa/Bangui
Africa/Banjul
Africa/Bissau
Africa/Blantyre
Africa/Brazzaville
Africa/Bujumbura
Africa/Cairo
Africa/Casablanca
……
[root@CJtest ~]$ll /etc/localtime
lrwxrwxrwx. 1 root root 38 Apr 20 07:11 /etc/localtime -> ../usr/share/zoneinfo/America/New_York
[root@CJtest ~]$timedatectl set-timezone Asia/Shanghai
[root@CJtest ~]$ll /etc/localtime
lrwxrwxrwx. 1 root root 35 Apr 21 11:00 /etc/localtime -> ../usr/share/zoneinfo/Asia/Shanghai
[root@CJtest ~]$date
Tue Apr 21 11:00:09 CST 2020
[root@CJtest ~]$
更改時間
# date 月日時分秒年
[root@CJtest ~]#date 042116252020
Tue Apr 21 16:25:00 CST 2020
[root@CJtest ~]#
4.日歷顯示
[root@CJtest ~]$cal 2 2020
? ? February 2020
Su Mo Tu We Th Fr Sa
? ? ? ? ? ? ? ? ? 1
2? 3? 4? 5? 6? 7? 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29? ?
[root@CJtest ~]$
*全年顯示# cal -y
5.簡單命令
\a 發(fā)出警告聲
\b 退格鍵
\c 最后不加上換行符號
\n 換行且光標(biāo)移至行首
\r 回車,即光標(biāo)移至行首芳誓,但不換行
\t 插入tab
\\ 插入\字符
\0nnn 插入nnn(八進(jìn)制)所代表的ASCII字符
\xHH 插入HH(十六進(jìn)制)所代表的ASCII數(shù)字
[root@CJtest ~]#echo -e "\0141"
a
[root@CJtest ~]#echo -e "\x61"
a
[root@CJtest ~]#echo -e "\x0a"
[root@CJtest ~]#echo -e "abc\x0a"
abc
[root@CJtest ~]#echo -e '\033[43;31;5mTEST\033[0m'
TEST
[root@CJtest ~]#
# iconv -l
# iconv -f gb2312 <filename> -o? <filename>
6.echo加花括號使用
[root@CJtest ~]#echo {1,2,3}
1 2 3
[root@CJtest ~]#echo file{1,2,3}
file1 file2 file3
[root@CJtest ~]#echo file{aa,2c,3x4}
fileaa file2c file3x4
[root@CJtest ~]#echo file{a,b,c}.{txt,log}
filea.txt filea.log fileb.txt fileb.log filec.txt filec.log
[root@CJtest ~]#echo file{1..10}
file1 file2 file3 file4 file5 file6 file7 file8 file9 file10
[root@CJtest ~]#echo file{Z..a}
fileZ file[ file file] file^ file_ file` filea
[root@CJtest ~]#echo {1..10}
1 2 3 4 5 6 7 8 9 10
[root@CJtest ~]#echo {1..10..2}
1 3 5 7 9
[root@CJtest ~]#echo {a..z}
a b c d e f g h i j k l m n o p q r s t u v w x y z
[root@CJtest ~]#echo {z..a}
z y x w v u t s r q p o n m l k j i h g f e d c b a
[root@CJtest ~]#echo {A..Z}
A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
[root@CJtest ~]#
7.history使用
[root@CJtest ~]#ls -la .bash_history
-rw-------. 1 root root 3474 Apr 21 17:11 .bash_history
[root@CJtest ~]#
[root@CJtest ~]#echo $HISTSIZE
1000
[root@CJtest ~]#more /etc/profile | grep HISTSIZE
HISTSIZE=1000
export PATH USER LOGNAME MAIL HOSTNAME HISTSIZE HISTCONTROL
[root@CJtest ~]#!!
more /etc/profile | grep HISTSIZE
HISTSIZE=1000
export PATH USER LOGNAME MAIL HOSTNAME HISTSIZE HISTCONTROL
[root@CJtest ~]#!-3
echo $HISTSIZE
1000
[root@CJtest ~]#!echo
echo $HISTSIZE
1000
[root@CJtest ~]#
!!上一條命令
!-3 history倒數(shù)第三條命令
!string history上一條包含字符串的命令
[root@CJtest ~]#echo a bsd v
a bsd v
[root@CJtest ~]#!$:p
v
[root@CJtest ~]#ls /etc/fstab /etc/motd
/etc/fstab? /etc/motd
[root@CJtest ~]#ll !$
ll /etc/motd
-rw-r--r--. 1 root root 16 Apr 20 16:52 /etc/motd
[root@CJtest ~]#!*:p
/etc/motd
[root@CJtest ~]#!-3:p
ls /etc/fstab /etc/motd
[root@CJtest ~]#echo abscd absojhg
abscd absojhg
[root@CJtest ~]#^ab
echo scd absojhg
scd absojhg
[root@CJtest ~]#echo /dev/sba /dev/sdb
/dev/sba /dev/sdb
[root@CJtest ~]#^sba^sdb
echo /dev/sdb /dev/sdb
/dev/sdb /dev/sdb
[root@CJtest ~]#