search
HomeOperation and MaintenanceMac OSHow to add environment variables to mac computer

How to add environment variables to mac computer

Dec 22, 2020 am 10:18 AM
macenvironment variablescomputer

How to add environment variables to mac computer

Usually we probably use the Windows system the most, but there are also many students who like Mac computers. But for friends who are using Mac computers for the first time, configuring environment variables may become a problem. Let’s talk about how to configure environment variables under Mac.

(Learning video sharing: Programming video)

My mac configuration:

How to add environment variables to mac computer

1. Mac system The environment variables, the loading order is:

a. /etc/profile
b. /etc/paths
c. ~/.bash_profile
d. ~/.bash_login
e. ~/.profile
f. ~/.bashrc

2. Among them, a and b are at the system level, which will be loaded when the system starts, and the rest are connected by the user. c, d, e are read in order from front to back. If the c file exists, the following files will be ignored and not read, and so on. ~/.bashrc does not have the above rules, it is loaded when the bash shell is opened. It is recommended to add environment variables in c. The following is also demonstrated by adding environment variables in c. Open Terminal, enter vi ./.bash_profile, press Enter, open the ./.bash_profile file:

How to add environment variables to mac computer

How to add environment variables to mac computer

##Press Enter:

How to add environment variables to mac computer

3. The ./.bash_profile file has been opened, but it is still in view mode and cannot be edited. Enter "i" to enter insert mode

4. You can add environment variables at this time, for example: How to add environment variables to mac computer

export SCALA_HOME=/Users/fushuai/Documents/scala-2.12.4
export PATH=$PATH:$SCALA_HOME/bin

5. After editing is completed, click the "esc key to exit insert mode. ", then enter ":wq!", press Enter, and save successfully.

How to add environment variables to mac computer

#6. Enter “source ./.bash_profile” to make the environment variable take effect.

7. Enter "echo $PATH", check the environment variables, and find that the addition is successful.

How to add environment variables to mac computer

#8. Re-open the terminal and the environment variables will take effect.

Related recommendations:

macos system

The above is the detailed content of How to add environment variables to mac computer. For more information, please follow other related articles on the PHP Chinese website!

Statement
This article is reproduced at:csdn. If there is any infringement, please contact admin@php.cn delete
macOS: Identifying the Most Recent ReleasemacOS: Identifying the Most Recent ReleaseApr 17, 2025 am 12:02 AM

Use the command line tool "sw_vers-productVersion" to identify the latest system version on macOS. 1. Open the terminal and enter the command to get the version number. 2. This command can be used in the script for version comparison and operation. 3. If you need optimization, you can use the "defaultsread" command to read the system file to obtain version information.

macOS Development: Building Native Apps with Swift & XcodemacOS Development: Building Native Apps with Swift & XcodeApr 16, 2025 am 12:01 AM

To develop macOS applications, you need to use Swift and Xcode. 1. Install Xcode and create a new project. 2. Use InterfaceBuilder to design the interface. 3. Write logical code in Swift file. 4. Utilize advanced features such as protocols and generic optimization code. 5. Use debugging tools to resolve common errors. 6. Optimize performance through asynchronous processing.

macOS: The User Experience and DesignmacOS: The User Experience and DesignApr 14, 2025 am 12:02 AM

The design philosophy of macOS is simplicity, user-centered and highly personalized. 1) The simple user interface allows users to quickly find the functions they need; 2) The user-centric design improves the interactive experience; 3) Personalized settings allow the system to be tailored to users; 4) Excellent performance and stability ensure smooth operation of the system; 5) Hidden functions such as shortcut commands and air-to-air playback improve work efficiency.

Understanding the Current macOS: A Concise GuideUnderstanding the Current macOS: A Concise GuideApr 13, 2025 am 12:02 AM

macOSSonoma is the latest operating system version released by Apple in 2023. 1. It enhances the user experience through new features such as desktop widgets. 2. Rely on the SwiftUI framework to implement these functions. 3. The basic usage includes adding widgets. 4. Advanced usage such as using Automator to create workflows. 5. Common error handling includes checking system resources. 6. Performance optimization is recommended to clean the cache regularly.

How to open macos terminalHow to open macos terminalApr 12, 2025 pm 05:39 PM

Open a file in a macOS terminal: Open the terminal to navigate to the file directory: cd ~/Desktop Use open command: open test.txtOther options: Use the -a option to specify that a specific application uses the -R option to display files only in Finder

How to take screenshots of macosHow to take screenshots of macosApr 12, 2025 pm 05:36 PM

There are four screenshot methods on macOS: shortcut keys, touch bars, preview apps, and third-party apps. After the screenshot, the image will be automatically saved to PNG format on the desktop, and you can adjust the format, delay, save position, and floating thumbnail settings through System Preferences.

How to record macos screenHow to record macos screenApr 12, 2025 pm 05:33 PM

macOS has a built-in "Screen Recording" application that can be used to record screen videos. Steps: 1. Start the application; 2. Select the recording range (the entire screen or a specific application); 3. Enable/disable the microphone; 4. Click the "Record" button; 5. Click the "Stop" button to complete. Save the recording file in .mov format in the "Movies" folder.

How to open a terminal for macosHow to open a terminal for macosApr 12, 2025 pm 05:30 PM

The following five methods can be used to open a macOS terminal: Use Spotlight Search through application folders Use Launchpad to use shortcut keys Command Shift U through terminal menus

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
1 months agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
1 months agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
1 months agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Chat Commands and How to Use Them
1 months agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

EditPlus Chinese cracked version

EditPlus Chinese cracked version

Small size, syntax highlighting, does not support code prompt function

Safe Exam Browser

Safe Exam Browser

Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools