Have you ever used the "set" command in Linux?
Now for me, this outputs over 3,000 lines. Unless you're a very good speed reader, that's not much help.
But this shows how your user environment is set up. What your PATHs are, what your command line prompt looks like,
where your default directories are, all my environmental variables and functions are shown here.
So, I almost always use this with grep, and you kind of have to know what you're looking for.
To see my paths.
To see my prompts.
To see my rpm build environment ( this only works on rpm-based distros)
To see my autocomplete settings.
There is more, but hopefully you get the idea.
This is unique for each user. Bob probably won't have the same settings as Sue, and neither
will have the same settings as root.
These are called environmental variables. Most of these you can change. You can add custom paths, custom prompts,
and custom autocomplete arguments if you like. Some people like to add custom command aliases. (another article maybe )
Now, this is sort of related. When I use su to change to another user. I can do it with or without the dash option.
without...
with...
What's the difference? If I use the dash option, it will use that persons environmental variables, any custom paths or prompts they have created.
If I don't use the dash option, I won't get all their environmental variables.
It has happened (more than once). Someone told me that the foobar.sh command didn't work.
I try it, and it doesn't work.
Then I su to that user, and it still doesn't work, it says "command not found".
I realized it must be a path thing.
Then I su using the dash, and suddenly it works. Why? Because it was in a custom path.
When a command is in your path, you don't have to type the path.
For example most of us never type /usr/bin/ls
We just type ls. This works because /usr/bin is already in our path.
Code:
set
Now for me, this outputs over 3,000 lines. Unless you're a very good speed reader, that's not much help.
But this shows how your user environment is set up. What your PATHs are, what your command line prompt looks like,
where your default directories are, all my environmental variables and functions are shown here.
So, I almost always use this with grep, and you kind of have to know what you're looking for.
To see my paths.
Code:
set | grep -i path
To see my prompts.
Code:
set | grep -i prompt
To see my rpm build environment ( this only works on rpm-based distros)
Code:
set | grep -i rpm
To see my autocomplete settings.
Code:
set | grep -i complete
There is more, but hopefully you get the idea.
This is unique for each user. Bob probably won't have the same settings as Sue, and neither
will have the same settings as root.
These are called environmental variables. Most of these you can change. You can add custom paths, custom prompts,
and custom autocomplete arguments if you like. Some people like to add custom command aliases. (another article maybe )
Now, this is sort of related. When I use su to change to another user. I can do it with or without the dash option.
without...
Code:
su bob
with...
Code:
su - sue
What's the difference? If I use the dash option, it will use that persons environmental variables, any custom paths or prompts they have created.
If I don't use the dash option, I won't get all their environmental variables.
It has happened (more than once). Someone told me that the foobar.sh command didn't work.
I try it, and it doesn't work.
Then I su to that user, and it still doesn't work, it says "command not found".
I realized it must be a path thing.
Then I su using the dash, and suddenly it works. Why? Because it was in a custom path.
When a command is in your path, you don't have to type the path.
For example most of us never type /usr/bin/ls
We just type ls. This works because /usr/bin is already in our path.
Last edited: