Difference between revisions of "Linux Usage Tips"
(Created page with "==== Linux shells==== * <tt>/bin/sh</tt> is the default login shell. ** Edit <tt>$HOME/.profile</tt> to change interactive variables. ** The <tt>$HOME/.bashrc</tt> file ''will...") |
|||
Line 25: | Line 25: | ||
* [http://mywiki.wooledge.org/BashFAQ Bash FAQ] | * [http://mywiki.wooledge.org/BashFAQ Bash FAQ] | ||
*[http://mywiki.wooledge.org/BashPitfalls Bash Pitfalls] | *[http://mywiki.wooledge.org/BashPitfalls Bash Pitfalls] | ||
+ | |||
+ | ====Compiling and Linking Codes==== | ||
+ | {{:Compiling Code Linux}} | ||
====FAQ==== | ====FAQ==== |
Revision as of 09:20, 17 September 2015
Linux shells
- /bin/sh is the default login shell.
- Edit $HOME/.profile to change interactive variables.
- The $HOME/.bashrc file will not be run for non-interactive shells.
- /bin/bash
- Edit $HOME/.profile to change interactive variables.
- The $HOME/.bashrc file will be run for non-interactive shells.
- /bin/csh and /bin/tcsh
- Edit $HOME/.login to change interactive variables.
- The $HOME/.cshrc file will be run for non-interactive shells.
The change shell command, chsh, will not permanently change your shell. You must send a request instead. Contact Support
The default login shell on v4 interactive and batch nodes is sh. Be aware that in Red Hat Enterprise Linux, /bin/sh is a soft-link to /bin/bash, so you are really using a variant of bash. Accordingly, you will find that "man sh" brings up the man page (the help document) for bash. In a way, then, you can think of your login shell as being bash, too.
There are slight differences between sh and bash, however. The "Invocation" section of the man page states: "If bash is invoked with the name sh, it tries to mimic the startup behavior of historical versions of sh as closely as possible." Therefore, you will find that ~/.profile is run at login, because this behavior is common to both sh and bash; but any interactive sh shells you start thereafter will not run ~/.bashrc as you might expect from bash. The way to get sh to do this is to "export ENV=~/.bashrc" beforehand (perhaps as part of your .profile).
Let's say you simply prefer to have bash as your default shell and be done with it. There are two ways to accomplish this. First, you can "export SHELL=/bin/bash" in your .profile; then all subsequent interactive shells will truly be bash. Second, you can enter "chsh -s /bin/bash", which forces all login and interactive shells to be bash (because you have changed your default shell). The problem with the second method is it may well wreck your batch environment, too, because the scheduler sets it up under the assumption that the login shell is sh.
The relationship between the csh and tcsh shells is similar to the one between sh and bash. For instance, your csh shells are automatically endowed with the tcsh-style ability to retrieve history through the up- and down-arrow keys. The best way to make tcsh into your everyday working shell is to run it on top of sh after you log in (again, you can do this as part of your .profile).
References
- "man bash" from the command line.
- Advanced Bash Scripting Guide, one of the Linux Documentation Project guides
- Bash FAQ
- Bash Pitfalls
Compiling and Linking Codes
FAQ
- ldd - see the man page.
If your program cannot find all the .so files it needs, you may need to add paths to the LD_LIBRARY_PATH shell variable.
How do I display an image file (such as jpeg or gif)?
- display mypic.jpg - uses one of the many ImageMagick tools - see "man ImageMagick" for help on this and various file format converters.
- firefox mypic.jpg - any decent Web browser can handle it.
Note, the image will show up only if you have X11 forwarding enabled.