Closed Captioning Closed captioning available on our YouTube channel

How to use the env command: 2-Minute Linux Tips

Network World | Sep 6, 2019

Learn how to use the env command. The most useful thing it does is to provide information on your shell environment when you’re working on the Linux command line.

Copyright © 2019 IDG Communications, Inc.

Similar
Hi, this is Sandra Henry-Stocker, author of the “Unix as a Second Language” blog on NetworkWorld.
In this Linux tip, we’re going to look at the env command. The most useful thing it does is to provide information on your shell environment when you’re working on the Linux command line. Type env and you should see a long list of settings such as these:
In the output above, we see the shell we’re using, our present working directory, our username, the type of session we’re using and our home directory. With a full listing, we’d also see our search path, a listing of screen colors, etc.
You can display a particular setting with the env command, but it’s easier to use echo:
The env command also plays another role. You can use it to run a command in an altered environment. For example, to run a command with limited search path, you could do something like this:
If you use the env command with the -C option, you will run the command as if you were currently in that directory. Here’s a simple example:
The env command is primarily used to display environment variables, but it has some interesting options for running commands in an altered environment.
That’s your Linux tip for the env command.
If you have questions or would like to suggest a topic, please add a comment below.
And don’t forget to subscribe to the IDG Tech(talk) channel on YouTube.
If you liked this video, please hit the like and share buttons. For more Linux tips, be sure to follow us on Facebook, YouTube and NetworkWorld.com.
Popular
Featured videos from IDG.tv