In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)05/31 Report--
Today, I will talk to you about the principle analysis of .bashrc and why to edit .bashrc. Many people may not understand it very well. In order to make you understand better, the editor has summarized the following content for you. I hope you can get something according to this article.
There are many hidden files in your home directory. If you are running macOS or a mainstream Linux distribution, you will see a file called .bashrc near the top of the list of hidden files. So what is .bashrc and what is the use of editing .bashrc?
Finder-find-bashrc
If you are running an operating system based on Unix or Unix-like operating system, bash is most likely installed as the default terminal. Although there are many different shell,bash, it is the most common and perhaps the most mainstream. If you don't understand what that means, bash is something that explains your input into the terminal program and runs commands based on your input. It supports the use of scripts to customize functionality to some extent, and .bashrc will be used at this time.
To load your configuration, bash loads the contents of the .bashrc file every time it starts. This shell script is available in each user's home directory. It is used to store and load your terminal configuration and environment variables.
Terminal configurations can contain many different things. The most common,. Bashrc file contains the alias that the user wants to use. Aliases allow users to point to commands by shorter or alternative names, which is a time-saving tool for people who often work under the terminal.
Terminal-edit-bashrc-1
You can edit .bashrc in any terminal text editor. We will use nano in the next example.
To use nano to edit .bashrc, invoke the following command from the terminal:
Nano / .bashrc
If you have never edited .bashrc before, you may find it empty. It doesn't matter! If not, feel free to add your configuration on any line.
Any changes you make to bashrc will take effect the next time you start the terminal. If you want to take effect immediately, run the following command:
Source / .bashrc
You can add to any .bashrc location and feel free to use commands (through #) to organize your code.
Editing .bashrc needs to follow the bash script format. If you don't know how to write scripts in bash, there is a lot of online information available. This is a fairly comprehensive introduction guide that contains some aspects of bashrc that we have not been able to mention here.
Related: how to run bash scripts with root privileges when Linux starts
There are some useful tips to make your terminal experience more efficient and user-friendly.
Why should I edit bashrc? Bash prompt
The bash prompt allows you to customize your terminal and let it display prompts when you run the command. Custom bash prompts can really improve your productivity on the terminal.
Take a look at these useful and interesting bash prompts, which you can add to your .bashrc.
Alias
Terminal-edit-bashrc-3
Aliases allow you to use abbreviated code to execute a command in a certain format you want. Let's use the ls command as an example. The ls command displays the contents of your directory by default. This is useful, but it is often more useful to show more information about the directory, or to show the hidden content under the directory. Therefore, a common alias is ll, which is used to run ls-lha or other similar commands. In this way, you can display most of the information about the file, find out the hidden file, and display the file size in units that can be read by humans, instead of using blocks as units.
You need to write aliases in the following format:
Alias ll = "ls-lha"
Enter the alias you want to set on the left, and the command to be executed in the quotation marks on the right. You can use this method to create a short version of a command, prevent common spelling mistakes, or have a command always run with the parameters you want. You can also use your favorite abbreviations to avoid annoying or easy-to-forget grammar. This is a common use of aliases that you can add to your .bashrc.
Function
Terminal-edit-bashrc-2
In addition to shortening the command name, you can also use the bash function to combine multiple commands into a single operation. These commands can be complex, but most of them follow this syntax:
Function_name () {command_1 command_2}
The following command combines the mkdir and cd commands. Type md folder_name to create a directory called "folder_name" in your working directory and navigate to it immediately.
Md () {mkdir-p $1 cd $1}
As you can see, the $1 in the function represents * parameters, which is the text you enter immediately after the function name.
After reading the above, do you have any further understanding of the principle analysis of .bashrc and why to edit .bashrc? If you want to know more knowledge or related content, please follow the industry information channel, thank you for your support.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.