export Command in Linux

Learn via video courses
Topics Covered

Build an AI-First Career, Master the Complete Skillset

Choose from our industry-leading programs designed for career success

NSDC Certified

Modern Software and AI Engineering Program

Master full-stack development with AI integration

12 MonthsDuration
AI-LedCurriculum
Career SupportSupport
GoogleAmazonPaytm+1000 more
Go to Program
NSDC Certified

Modern Data Science and ML with specialisation in AI

Advanced data science techniques with AI specialization

12 MonthsDuration
AI-LedCurriculum
Career SupportSupport
GoogleAmazonPaytm+1000 more
Go to Program
NSDC Certified

Advanced AIML with Specialisation in Agentic AI

Deep dive into AIML with focus on Agentic systems

12 MonthsDuration
AI-LedCurriculum
Career SupportSupport
GoogleAmazonPaytm+1000 more
Go to Program
NSDC Certified

DevOps, Cloud & AI Platform Engineering

Build and manage AI-powered cloud infrastructure

12 MonthsDuration
AI-LedCurriculum
Career SupportSupport
GoogleAmazonPaytm+1000 more
Go to Program
NSDC Certified

AI Engineering Advanced Certification by IIT-Roorkee

Premier AI engineering certification from IIT-Roorkee

3 MonthsDuration
AI-LedCurriculum
Career SupportSupport
Program highlights
Go to Program
NSDC Certified

AI Forward Deployed Engineer Program

Full-stack engineering, production AI and client-facing consulting

12 MonthsDuration
AI-LedCurriculum
Career SupportSupport
GoogleAmazonPaytm+1000 more
Go to Program

Overview

The export command in Linux is a built-in shell command used to export environment variables from the shell to child processes. It's an essential tool for configuring and managing the environment of your Linux system.

Syntax of export Command in Linux

The basic syntax of the export command in Linux is as follows:

Where:

  • -nf: These are options that can be used with the export command. '-n' removes names from the export list, and '-f' exports function names.
  • name=value: This is the name of the variable and the value you want to assign to it.
Sharpen Your Fundamentals with Free Learning

Options in export Command in Linux

  1. -p: This option displays a list of all names that are exported in the current shell.

    For example -

    Output:

    This command is useful to check the current exported environment variables and functions.

  2. -n: This option removes the export property from each NAME.

    For example -

    Output:

    This command removes VARIABLE from the list of exported variables.

  3. -f: The -f option means the NAMES refer to functions.

    For example -

    Output:

    This command exports a function called 'function_name'.

How Scaler Transformed Careers in Different Fields

₹23L
AVG CTC
SCALER PLACEMENT PROOF

Scaler learners achieved 2.5x salary growth with average post-Scaler CTC reaching ₹23L.

11,000+placements
650+companies
Verified data
Hiring Partners:
GoogleGoogleAmazonAmazonMicrosoftMicrosoftFlipkartFlipkartAdobeAdobe1200+ more

Example Usages

  • Setting a new environment variable:

    Output:

    Explanation: This command creates an environment variable called VARNAME and assigns the value "VALUE" to it.

  • Exporting a function:

    Output:

    Explanation: This command exports a shell function called 'function_name' so it can be used in child processes.

Tips

  • The export command in Linux affects only the current shell and its child processes, not the parent shell or sibling processes.

  • The -p option is useful to check your current environment.

Turn Learning into Career Growth

1200+Hiring Partners
89%Placement Rate
11,000+Placements
147%Avg Salary Increment
2.5XCareer Growth
₹23 LPAAvg Post-Scaler Salary
1200+Hiring Partners
89%Placement Rate
11,000+Placements
147%Avg Salary Increment
2.5XCareer Growth
₹23 LPAAvg Post-Scaler Salary

Advanced Use Cases of export Command in Linux

  • Exporting multiple variables at once:

    Output:

    Explanation: This command sets and exports multiple environment variables at once.

  • Unsetting an exported function:

    Output:

    Explanation: This command removes the exported function 'function_name' from the list of exports, making it unavailable in child processes.

  • Exporting variables from a file:

    Output:

    Explanation: This command reads and executes commands from file_name in the current shell environment, effectively exporting variables defined in the file.

Conclusion

  • The export command in Linux is used to export environment variables from the shell to child processes.

  • The -p, -n, and -f options modify the behavior of the export command.

  • The export command only affects the current shell and its child processes.