创建.bashrc文件

创建.bashrc

1
touch /home/roy/.bashrc


P.S.: “roy”为用户名,请替换为您的用户名。

进入编辑模式

1
2
cd /home/roy/
sudo nano /home/roy/.bashrc

~./.bashrc

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
30
31
32
33
34
35
36
37
38
39
40
41
# 添加用户本地 bin 目录到 PATH
# Global Environment Variable
export PATH="$HOME/.local/bin:$PATH"

# Hexo
alias hexocgd="hexo clean && hexo generate && hexo deploy"
alias hexo4000="hexo clean && hexo generate && hexo server"

# Quickly Command
alias rmd="rm -rf"
#alias e="vim ~/.bashrc"
alias e="nano ~/.bashrc"
alias s="source ~/.bashrc"
alias c="clear"
alias la="ls -la"
alias ll="ls -lah --color=auto"
alias grep="grep --color=auto"
alias catbashrc="cat ~/.bashrc"
alias ipcheck="ip route get 8.8.8.8"
alias testgoogle="curl -Iv https://www.google.com --connect-timeout 10"
alias testyoutube="curl -Iv https://www.youtube.com --connect-timeout 10"
alias restartdhcpcd="sudo systemctl restart dhcpcd"
alias dockerrestart="sudo systemctl daemon-reload && sudo systemctl restart docker && sudo systemctl status docker"
alias wificheck="sudo nmcli dev wifi list"
alias editdhcpcdconfig="sudo nano /etc/dhcpcd.conf"
alias rpishutdown="sudo shutdown -h now"
alias rpireboot="sudo reboot"

# Docker command
alias dps='docker ps -a --format "table {{.Names}}\t{{.ID}}\t{{.Status}}\t{{.Image}}"'

# Quickly come to file address
alias ..="cd .."
alias ...="cd ../.."
alias ~="cd /home/roy"

# Functions
# Create a directory and immediately enter it
mkcd() {
mkdir -p "$1" && cd "$1"
}

使其生效

1
source /home/roy/.bashrc

查看文件是否创建

1
ls -la /home/roy/.bashrc

拥有文件所有权限

1
sudo chmod -R 777 /home/roy/.bashrc