Configure Linux Environment Variables

LinuxBeginner
Practice Now

Introduction

In this challenge, you will learn how to set up and manage environment variables in a Linux system as a junior system administrator. The goal is to create a permanent environment variable named PROJECT_DIR that points to the /home/labex/project directory, and verify that the variable is correctly set and accessible in the current shell session.

Configure Linux Environment Variables

As a junior system administrator, you'll learn how to set up and manage environment variables in a Linux system to create a consistent development environment.

Tasks

  • Create a permanent environment variable named PROJECT_DIR that points to /home/labex/project
  • Verify the environment variable is correctly set and can be accessed in the current shell session

Requirements

  • Use the export command to set the environment variable
  • Add the environment variable to the ~/.zshrc configuration file
  • Ensure the variable can be accessed by running echo $PROJECT_DIR
  • Work within the /home/labex directory

Examples

Example of a correctly set environment variable:

echo $PROJECT_DIR
PROJECT_DIR=/home/labex/project

Hints

  • Remember to use export to create a permanent environment variable
  • Use source ~/.zshrc to reload the configuration file
  • Check the contents of the .zshrc file after modification

Summary

In summary, this challenge focuses on teaching junior system administrators how to set up and manage environment variables in a Linux system. The key tasks include creating a permanent environment variable named PROJECT_DIR that points to the /home/labex/project directory, and verifying that the variable is correctly set and accessible in the current shell session.

✨ Check Solution and Practice