Difference between revisions of "Linux Usage Tips"
(→FAQ: added content on revision control) |
|||
Line 12: | Line 12: | ||
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}} | ||
− | The default login shell on | + | The default login shell on linuxlogin is ''sh''. Be aware that in CentOS, /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). | 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). |
Revision as of 17:58, 18 September 2019
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 linuxlogin is sh. Be aware that in CentOS, /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.
How do I use revision control?
- Subversion, Git and CVS are examples of revision control (or version control or source control) software, which means they help you collaborate with others on revising your source code by saving versions of the code as you write it. Clients for all three are installed on the login nodes. See the man pages for svn, git and cvs for details. To see the installed versions, type the commands with --version.
CIT runs a free TeamForge server for Subversion users. You can login with Cornell Single Sign-on. There is also a GitHub server that is intended for users in Engineering, CIS, and Cornell Tech.