Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Introduction to Linux - A Hands on Guide
This guide was created as an overview of the Linux Operating System, geared toward new users as an exploration tour and getting started guide, with exercises at the end of each chapter.
For more advanced trainees it can be a desktop reference, and a collection of the base knowledge needed to proceed with system and network administration. This book contains many real life examples derived from the author's experience as a Linux system and network administrator, trainer and consultant. They hope these examples will help you to get a better understanding of the Linux system and that you feel encouraged to try out things on your own.
Click Here to receive this Complete Guide absolutely free.
This may be a terribly easy question but being a newbie to the whole Linux stuff... I dont have any other option than asking it openly and accepting frankly my ignorance..
So how to set environment variables in Linux.
I think I have to use set PATH variable..
But I am dont want to take risk..
Also unlike Windows there seems to be many paths...
Will export pathname=PATH1;PATH2; suffice?
Also how to view the current PATHs..
All info regarding environmental variable setiing and manipulating are welcome
i prefer storing my custom variables and aliases in a separate file rather than in ~/.bashrc (is bash your login shell?) like ~/.yourvar which is executed upon login. to get this done add this line to ~/.bashrc
Will export pathname=PATH1;PATH2; suffice?
export like this in your ~/.yourvar or ~/.bashrc ...as you like:
as many directories as you need.
thus you'll have N directories ADDED to your PATH variable. easy, isn't it.
Distribution: Debian Etch (w/ dual-boot XP for gaming)
Since you asked about environment variable manipulation in general, I found the set command very useful when I first came across it - it simply prints (to standard out) a list of all the currently active environment variables. Useful for double-checking you've sorted things properly - though I have a feeling it might only work for bash.
And to expand on zhelezov's method to set paths, you can execute that command from a shell, though it will remain active only in that shell and only until the shell is closed (e.g. if you started an xterm, set some variables, closed xterm and then opened xterm again, it'd be a new shell and your custom variables wouldn't be set). Also, the "$PATH:" at the front is not technically necessary (though a good idea) - what it does is substitute your current PATH variable at the start of the right hand side, so dir1,... dirN get added onto the end of your existing path. If you want to explicitly set path to "/home/foo" and nothing else, then
will do exactly that. Of course, in the vast majority of cases, you'll simply want to add another directory onto your existing path, so using the "$PATH:" format is preferable.
As above, there are many environment variables used for many reasons; to see them try the cmds
PATH is just one of many default variables and you can create your own.
Use the above techniques in login files to ensure new definitions are re-created when you login again.
Note that you need the export cmd to push the declarations down to sub-shells, otherwise they only affect current shell.
You cannot push them up the shell tree though ...
Just make a soft link.....For example, in your home directory, enter this:
ln -s /media/trans500/dl/music music
then, to go to that directory, just type "music"
To relate this to the original topic (the PATH env variable), the latter is intended to establish the search path for commands.
I apologize for editing my question - I wanted to put it in a different shape...
Ok, the ln is a way around. If I want to put a path to my music folder into let's say playlist conf file. I would than have to write ~/music.
But if I want to have clean path to /media/trans500/dl/music as just music, than ln desn't help. I was wondering if a global variable that refers to this path could be given by setenv and used in conf files or from wherever, like: MUSIC= /media/trans500/dl/music