Difference between revisions of "Linux Usage Tips"
Line 1: | Line 1: | ||
==== Linux shells==== | ==== Linux shells==== | ||
− | * <tt>/bin/sh</tt> is the default login shell. | + | :* <tt>/bin/sh</tt> is the default login shell. |
− | ** Edit <tt>$HOME/.profile</tt> to change interactive variables. | + | :** Edit <tt>$HOME/.profile</tt> to change interactive variables. |
− | ** The <tt>$HOME/.bashrc</tt> file ''will not'' be run for non-interactive shells. | + | :** The <tt>$HOME/.bashrc</tt> file ''will not'' be run for non-interactive shells. |
− | * <tt>/bin/bash</tt> | + | :* <tt>/bin/bash</tt> |
− | ** Edit <tt>$HOME/.profile</tt> to change interactive variables. | + | :** Edit <tt>$HOME/.profile</tt> to change interactive variables. |
− | ** The <tt>$HOME/.bashrc</tt> file ''will'' be run for non-interactive shells. | + | :** The <tt>$HOME/.bashrc</tt> file ''will'' be run for non-interactive shells. |
− | * <tt>/bin/csh</tt> and <tt>/bin/tcsh</tt> | + | :* <tt>/bin/csh</tt> and <tt>/bin/tcsh</tt> |
− | ** Edit <tt>$HOME/.login</tt> to change interactive variables. | + | :** Edit <tt>$HOME/.login</tt> to change interactive variables. |
− | ** The <tt>$HOME/.cshrc</tt> file ''will'' be run for non-interactive shells. | + | :** The <tt>$HOME/.cshrc</tt> file ''will'' be run for non-interactive shells. |
The change shell command, <tt>chsh</tt>, will not permanently change your shell. You must send a request instead. {{ContactCAC}} | The change shell command, <tt>chsh</tt>, will not permanently change your shell. You must send a request instead. {{ContactCAC}} | ||
Line 21: | Line 21: | ||
References | References | ||
− | * "man bash" from the command line. | + | :* "man bash" from the command line. |
− | * [http://tldp.org/LDP/abs/html/ Advanced Bash Scripting Guide], one of the Linux Documentation Project [http://www.tldp.org/guides.html guides] | + | :* [http://tldp.org/LDP/abs/html/ Advanced Bash Scripting Guide], one of the Linux Documentation Project [http://www.tldp.org/guides.html guides] |
− | * [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 code on Linux==== | ====Compiling and linking code on Linux==== |
Revision as of 10:34, 21 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.
- /bin/sh is the default login shell.
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 code on Linux
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.