简体   繁体   中英

How can I automatically load alias on startup?

我想添加alias ll = "ls -l" ,我想知道每次登录linux时如何加载它。

You can add it to your ~/.bashrc file in your home directory.

For more information on .bashrc and the likes, see this question .

You can add your aliases to ~/.bashrc as explained by cschol but, if you prefer a tidier solution, then you can include all of your additions in one or more files.

Many distributions already do it by default. Just add the following code to your .bashrc file:

# Alias definitions.
# You may want to put all your additions into a separate file like
# ~/.bash_aliases, instead of adding them here directly.
# See /usr/share/doc/bash-doc/examples in the bash-doc package.

if [ -f ~/.bash_aliases ]; then
    . ~/.bash_aliases
fi

And then just add your aliases to ~/.bash_aliases

除了将其添加到〜/ .bashrc(仅影响当前用户)之外,还可以将其添加到/ etc / profile,这将在登录时影响所有用户。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM