.bashrc file under Linux system users

Table of contents

introduce

Modify .bashrc for personalized settings

Example 1

Example 2


introduce

program files

This file mainly saves some personal settings of the individual, such as command aliases, paths, etc. That is to say, on the same server, only the personalized settings of a certain user are relevant.

~/bashrc: This file is executed for every user who runs a bash shell. This file is read when a bash shell is opened.

Modify .bashrc for personalized settings

After each modification .bashrc, use the following command to immediately load the modified settings to make them take effect.

source ~/.bashrc

Generally, when Linux .bash_profileis explicitly called in the file .bashrc。to start bash, it will first read  ~/.bash_profilethe file, so that  ~/.bashrcit will be executed, and your personalized settings will take effect. Using this feature, some personalized settings can be realized, such as: the Linux system automatically executes a certain script file after booting, etc., which is useful in automatic operation and maintenance.

Example 1

Modify  /home/mmoriarty/.bashrc the file:

sudo vim /home/mmoriarty/.bashrc #用不用vim无所谓,你也可以用nano或者kate
# 在最后添加两句后保存
echo '这句话开机就会启动'   #打印输出
/home/mmoriarty/test.py   #执行test.py这个Python脚本

When Linux is booted:

You can see that the file is loaded after Linux boots .bashrc.

Example 2

You can give the command an alias by modifying .bashrcthe file, so you don't have to type a long string every time. For example, you can use "syu" to update the system by adding the following command to the file.

alias syu="sudo pacman -Syu"

Guess you like

Origin blog.csdn.net/u012206617/article/details/130389469