'd' command. - Mandriva
This is a discussion on 'd' command. - Mandriva ; I'm sure many on this group already know this but
I just inadvertently typed 'd' into Bash and hit
enter. It does the same job as 'ls'. Only one keystroke
less I know but it made me wonder how many ...
-
'd' command.
I'm sure many on this group already know this but
I just inadvertently typed 'd' into Bash and hit
enter. It does the same job as 'ls'. Only one keystroke
less I know but it made me wonder how many other
shortcuts like this there are?
Andy J.
-
Re: 'd' command.
Quoth Andy J. :
> I'm sure many on this group already know this but
> I just inadvertently typed 'd' into Bash and hit
> enter. It does the same job as 'ls'. Only one keystroke
> less I know but it made me wonder how many other
> shortcuts like this there are?
>
Not "shortcuts" instead it's a bash alias. Type alias from command line to
get a list of what Mandriva has set up for you.
alias: usage: alias [-p] [name[=value] ... ]
You can make your own, I think they're supposed to go in your bashrc file.
--
The Man in the Yellow Hat
Linux with a monkey, since 1996.
-
Re: 'd' command.
On Sun, 06 May 2007 11:56:10 +0100, Andy J. wrote:
> I'm sure many on this group already know this but
> I just inadvertently typed 'd' into Bash and hit
> enter. It does the same job as 'ls'. Only one keystroke
> less I know but it made me wonder how many other
> shortcuts like this there are?
Depends on what is installed.
There are system wide and user defined aliases, functions and exported values.
For bash, global for everyone
/etc/profile - environment variables (PATH, USER, LOGNAME,...)
/etc/bashrc - contains function & aliases, not environment vars
You can place functions in the profile if you want to export the
function name. Example export -f function_name_here.
It is instructive to read the files in /etc/profile.d, if you have one.
I would place site/custom global environment variables in zz_local.sh
That way you can pop zz_local.sh in on new installs.
If you have an /etc/profile.d directory; do a
cd /etc/profile.d
touch zz_local.sh
chmod 755 zz_local.sh
Then add your changes, Example: export PATH=$PATH:new_path:another_path
The zz_local.sh name was picked to force it to be executed last.
/etc/profile runs the scripts in /etc/profile.d
do a ls -1 /etc/profile.d to see order of file execution.
User only
~userid_here/.bash_profile - for environment variables
~userid_here/.bashrc - for function & aliases, not env vars
ALWAYS do a su -l user_id to test your changes before logging out.
You can place functions in the .bash_profile if you want to export the
function name. Example export -f function_name_here.
Profiles usually run once, bashrc run everytime you spin up a non-login
interactive session.
Sessions inherit env vars from the parent process.
Setting BASH_ENV=~/.bashrc will cause it to execute during
non-interactive session.
Other places environment variables are set are
/etc/X11/xinit.d/
/usr/share/config/kdm/Xsession
/usr/share/config/kdm/kdmrc
/etc/X11/Xsession
You might find http://www.tldp.org/LDP/abs/html/index.html useful if
trying to understand scripts.
-
Re: 'd' command.
On 2007-05-06, Andy J. wrote:
> I'm sure many on this group already know this but
> I just inadvertently typed 'd' into Bash and hit
> enter. It does the same job as 'ls'. Only one keystroke
> less
That's because its set up as an alias. It's not a bash command,
and may differ between distros.
> I know but it made me wonder how many other
> shortcuts like this there are?
>
Type 'alias' at the command line for more...
Lordy
-
Re: 'd' command.
> Type 'alias' at the command line for more...
=========
Tnx ,very useful....good learning experience.
Frank
-
Be carefull with scripts in /etc/profile.d (was Re: 'd' command.
On Sun, 06 May 2007 08:23:47 -0400, Bit Twister wrote:
> It is instructive to read the files in /etc/profile.d, if you have one..
Be carefull.
The scripts in /etc/profile.d are no longer only executed at startup.
The scripts there must be able to be rerun, at any time, without
failing.
I downloaded and installed gutenprint-5.0.0~lsb3.1.i486.rpm
In order to get the rpm to install, I had to comment out the line
in /etc/profile.d/msec.sh that modifies the TMOUT bash variable,
to be readonly, and reboot, as there doesn't appear to be a way
to change a readonly variable, back to not-readonly, except by
rebooting.
An extract from the rpm ...
================================================== =
# Source /etc/profile and all scripts in /etc/profile.d, so that PATHs and
# other shell settings from other LSB packages get available
.. /etc/profile
for i in /etc/profile.d/*.sh; do if [ -x $i ]; then . $i; fi; done; unset i
# Create some directories if they are missing. Usually, they should exist
mkdir /opt 2>/dev/null || true
postinstall scriptlet (using /bin/sh):
# Source /etc/profile and all scripts in /etc/profile.d, so that PATHs and
# other shell settings from other LSB packages get available
.. /etc/profile
for i in /etc/profile.d/*.sh; do if [ -x $i ]; then . $i; fi; done; unset i
# LSB requires that a login shell executes all .sh scripts in the
# /etc/profile.d directory
================================================== =
So now, any script in /etc/profile.d, that fails when rerun, will cause
rpm to fail on installation attempts.
Regards, Dave Hodgins
--
Change nomail.afraid.org to ody.ca to reply by email.
(nomail.afraid.org has been set up specifically for
use in usenet. Feel free to use it yourself.)
-
Re: 'd' command.
On Sun, 06 May 2007 12:03:00 +0000, Big Yellow Hats wrote:
> Quoth Andy J. :
>
>> I'm sure many on this group already know this but
>> I just inadvertently typed 'd' into Bash and hit
>> enter. It does the same job as 'ls'. Only one keystroke
>> less I know but it made me wonder how many other
>> shortcuts like this there are?
>>
>
> Not "shortcuts" instead it's a bash alias. Type alias from command line to
> get a list of what Mandriva has set up for you.
>
> alias: usage: alias [-p] [name[=value] ... ]
>
> You can make your own, I think they're supposed to go in your bashrc file.
Better if one adds, to ~/.bashrc;
test -s ~/.alias && . ~/.alias
Then create a .alias file to place in ~/ with all your aliases. I mount a
separate partition at ~/Documents on eight different OSs so I have an
"alias" file in that, which I soft link to ~/.alias on each OS, so any new
alias I create shows up on all OSs, without retyping.
--
imotgm
"Lost? Lost? I've never been lost... Been a tad confused for a
month or two, but never lost."
-
Re: 'd' command.
Quoth imotgm :
>
> Better if one adds, to ~/.bashrc;
>
> test -s ~/.alias && . ~/.alias
>
> Then create a .alias file to place in ~/ with all your aliases. I mount a
> separate partition at ~/Documents on eight different OSs so I have an
> "alias" file in that, which I soft link to ~/.alias on each OS, so any
> new alias I create shows up on all OSs, without retyping.
>
good ideer!
--
The Man in the Yellow Hat
Linux with a monkey, since 1996.
-
Re: Be carefull with scripts in /etc/profile.d (was Re: 'd' command.
On 2007-05-06, David W. Hodgins wrote:
> On Sun, 06 May 2007 08:23:47 -0400, Bit Twister wrote:
>
>> It is instructive to read the files in /etc/profile.d, if you have one.
>
> Be carefull.
>
> The scripts in /etc/profile.d are no longer only executed at startup.
They were never only executed at startup (were they ever executed
at startup?)
They are normally executed on login. Except that I comment them
out whenever I install a new release; there is a lot of
unnecessary, and even inadvisable, material in them.
> The scripts there must be able to be rerun, at any time, without
> failing.
>
> I downloaded and installed gutenprint-5.0.0~lsb3.1.i486.rpm
>
> In order to get the rpm to install, I had to comment out the line
> in /etc/profile.d/msec.sh that modifies the TMOUT bash variable,
> to be readonly, and reboot, as there doesn't appear to be a way
> to change a readonly variable, back to not-readonly, except by
> rebooting.
Rebooting?? You're not serious!!
At most, you have log out.
--
Chris F.A. Johnson, author |
Shell Scripting Recipes: | My code in this post, if any,
A Problem-Solution Approach | is released under the
2005, Apress | GNU General Public Licence
-
Re: 'd' command.
Highland Ham wrote:
>> Type 'alias' at the command line for more...
> =========
> Tnx ,very useful....good learning experience.
>
> Frank
See, it's little tips like this that you only get to
learn on newsgroups. Well my Mandriva LE2005 has a
total of 18 'aliases' to play with. I'm not to sure
about using 'lsd' though, never can be to sure of a
bad trip......:-)
Cheers Guys,
Andy J.
-
Re: 'd' command.
On 2007-05-06, Bit Twister wrote:
> On Sun, 06 May 2007 11:56:10 +0100, Andy J. wrote:
>> I'm sure many on this group already know this but
>> I just inadvertently typed 'd' into Bash and hit
>> enter. It does the same job as 'ls'. Only one keystroke
>> less I know but it made me wonder how many other
>> shortcuts like this there are?
>
> Depends on what is installed.
>
> There are system wide and user defined aliases, functions and exported values.
>
> For bash, global for everyone
> /etc/profile - environment variables (PATH, USER, LOGNAME,...)
This is standard, and is sourced by all Bourne-type (login) shells.
> /etc/bashrc - contains function & aliases, not environment
> vars
This is non-standard. Unlike /etc/profile, it is not sourced by
bash; it has to be sourced from another file, such as /etc/profile.
> You can place functions in the profile if you want to export the
> function name. Example export -f function_name_here.
>
> It is instructive to read the files in /etc/profile.d, if you have one.
The first thing I do on installing a new distro is comment out the
lines in /etc/profile that source the files in /etc/profile.d;
there is nothing necessary in there, and some dangerous things
(especially in alias.sh).
Then, at the top of my .bashrc, I remove any other aliases that
might have snuck in from other scripts with: unalias -a
> I would place site/custom global environment variables in zz_local.sh
> That way you can pop zz_local.sh in on new installs.
>
> If you have an /etc/profile.d directory; do a
>
> cd /etc/profile.d
> touch zz_local.sh
> chmod 755 zz_local.sh
> Then add your changes, Example: export PATH=$PATH:new_path:another_path
>
> The zz_local.sh name was picked to force it to be executed last.
> /etc/profile runs the scripts in /etc/profile.d
> do a ls -1 /etc/profile.d to see order of file execution.
> User only
> ~userid_here/.bash_profile - for environment variables
> ~userid_here/.bashrc - for function & aliases, not env vars
>
> ALWAYS do a su -l user_id to test your changes before logging out.
>
> You can place functions in the .bash_profile if you want to export the
> function name. Example export -f function_name_here.
You can place functions in .bash_profile even if you don't want to
export the function name.
> Profiles usually run once, bashrc run everytime you spin up a non-login
> interactive session.
>
> Sessions inherit env vars from the parent process.
>
> Setting BASH_ENV=~/.bashrc will cause it to execute during
> non-interactive session.
You also need to export it.
> Other places environment variables are set are
> /etc/X11/xinit.d/
> /usr/share/config/kdm/Xsession
> /usr/share/config/kdm/kdmrc
> /etc/X11/Xsession
>
> You might find http://www.tldp.org/LDP/abs/html/index.html useful if
> trying to understand scripts.
--
Chris F.A. Johnson, author |
Shell Scripting Recipes: | My code in this post, if any,
A Problem-Solution Approach | is released under the
2005, Apress | GNU General Public Licence