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
The Current macOS: Unveiling the Latest VersionThe Current macOS: Unveiling the Latest VersionMay 11, 2025 am 12:17 AM

The latest macOS version is macOSSonoma14. macOSSonoma14 brings enhanced desktop widgets and new video conferencing capabilities to improve user experience and productivity.

macOS: An Introduction to Apple's Operating SystemmacOS: An Introduction to Apple's Operating SystemMay 10, 2025 am 12:21 AM

macOS is an operating system designed for Mac computers by Apple, and is highly regarded for its seamless integration, stability and beautiful interface with other Apple devices. It is based on UNIX and provides powerful tools and applications to support creative workers and developers.

macOS: Features, Benefits, and AdvantagesmacOS: Features, Benefits, and AdvantagesMay 09, 2025 am 12:17 AM

The charm of macOS lies in its simplicity and strength, and its core advantages include stability, security and ecosystem. 1. The simple design is reflected in details such as the Dock and Notification Center. 2. Powerful features such as Spotlight Search and Continuity. 3. Unix-based stability and security. 4. Apple's software ecosystem is seamlessly connected and suitable for developers. 5. Multitasking and shortcut key systems improve work efficiency. 6. Performance optimization suggestions include cleaning caches, using virtual desktops and TimeMachine backups.

macOS and Linux: Understanding the Underlying TechnologiesmacOS and Linux: Understanding the Underlying TechnologiesMay 08, 2025 am 12:13 AM

The main difference between the underlying technologies of macOS and Linux is kernel design and file system. 1.macOS uses Mach microkernel and APFS file system to provide stability and efficient storage. 2. Linux adopts a modular kernel design, supports a variety of file systems such as ext4, XFS and Btrfs, to meet various needs.

The Latest macOS: Features, Improvements, and UpdatesThe Latest macOS: Features, Improvements, and UpdatesMay 07, 2025 am 12:15 AM

The latest macOS brings new control centers, performance optimization and enhanced security and privacy controls. 1. The control center integrates commonly used settings to improve operational efficiency. 2. System performance has been improved in startup speed and application response, but attention should be paid to old hardware compatibility. 3. Security and privacy controls are more meticulous, and users can accurately manage application permissions.

macOS: The Evolution of Apple's Operating SystemmacOS: The Evolution of Apple's Operating SystemMay 06, 2025 am 12:04 AM

macOS is an operating system designed by Apple for Mac computers, combining the power of UNIX and the ease of use of Macs. Its main function is to provide an efficient, secure and user-friendly computing environment.

macOS's Latest Version: Release Date and Key DetailsmacOS's Latest Version: Release Date and Key DetailsMay 05, 2025 am 12:05 AM

macOSSonoma14wasreleasedonOctober26,2023.Itintroducesdesktopwidgets,enhancesvideoconferencingwithPresenterOverlayandReactions,andaddsaGameModeforbettergamingperformance.Italsoimprovessystemresponsivenessandsecurity.

The Current macOS: An Overview of Apple's Latest OSThe Current macOS: An Overview of Apple's Latest OSMay 04, 2025 am 12:18 AM

macOSSonoma (14.0) brings new features such as desktop widgets, video conferencing enhancements and performance improvements. 1. The desktop widget allows users to quickly view information. 2. Video conferencing enhancement provides virtual background function. 3. System performance is improved, and application startup and response are faster.

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

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool

mPDF

mPDF

mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),