Command interpreter shell is most closely related with the user application, the user primarily through the shell using the system. After each log, they launched a user interaction with the shell, the shell will give a prompt waiting for user input, (sh for the "$", csh as "%", if it is to use root user, the login prompt symbol will be "#"), and then interpret the implementation of the user's input.
FreeBSD's base system can be used in shell two: sh and csh. The two basic shell is not the same style, different users often come under the preferences to choose between the two. Of course, the current shell process better choice available to users, these follow-up of the shell are under sh or csh style further developed, so it can be said in the shell, there are also two styles, require the user according to their own use used to choose.
For the administrator to be, to use a different shell as the user set up the basic environment, we must understand these two styles of shell set up. System log, sh will be the first implementation of the / etc / profile file for each user to set the basic environment, csh will use the / etc / csh.cshrc, csh.login and csh.logout csh as a system resource file. Implementation of the system-level log file, each user's shell on the user's home directory to find the resources the user personal files: sh to use. Profile files, csh use. Login and. Cshrc file. These resource files are using the appropriate shell language, / etc / profile and personal directory. Profile use sh-style control language, / etc / cshrc and personal directory. Login,. Cshrc use csh-style control language. System administrators can change these resource files to provide users with the most convenient use of the environment. Of course, the system administrator does not need to edit your home directory directly under the resource files that should be managed by the user, but the system administrator account can be generated when the user create the default resource file in order to reduce the user to set the resource file trouble. adduser command default to use / usr / share / skel files in a variety of resource files to provide users with the default settings, apart from this directory into the shell's resource file, you can also add other applications of the resource file . Because these resource files are hidden files to point at the beginning, in order to express clearly, in the skel directory, using a conversion method, such as the use dot.profile as. Profile template.
# Ls / usr / share / skel
dot.cshrc dot.mail_aliases dot.rhosts
dot.login dot.mailrc dot.shrc
dot.login_conf dot.profile
In / usr / share / skel for the user to set the default configuration file, the user-generated, the user will not affect the. Therefore, modifications to the system log files more effective and direct. For sh-style user can change the / etc / profile file, and csh should be changed / etc / csh.cshrc file. Changes in these documents can use shell environment variables, so to change the shell's behavior, or perform a series of automatic operation, the completion of some users to log on automatically when the task.
Commonly used environment variables:
EDITOR editor used to set the user, many programs view this variable to start a specific editor, the situation can change according to the system
HOME User's home directory name, this variable set by the login procedure, generally do not need to change
DISPLAYX use this environment variable to identify the specific display location, the format for the "Computer name: X server serial number. Display serial number", such as: xt1: 0.0, it does not need to define in the resource file
LANG system uses the language for localization of the system, the default is "C", specific settings can view / usr / share / locale directory, where the definition of the different languages, you can set it to zh_CN.EUC to make some software to use Chinese characters.
MAIL location of the user mail file, do not need to change
PATH uses a series of colon-separated path, the system uses to find specific executable program, so this variable is very important, can change the value of the specific situation. For security reasons, not to the current directory search path as the implementation of the program, especially for root. This startup programs in the current directory, need to add the path, for example, to start the current directory a.out program, enter ". / A.out".
MANPATH using a series of colon-separated path, the system uses to find the specific command-line manual, set the same methods and PATH.
PS1sh style shell using the variable value as the prompt, the default value is "$" (root for the "#"). More modern sh prompt to enhance the flexibility, you can prompt to add the current directory, user name, machine name, order number and so on.
PS2sh shell style variables to use this as a follow-up prompt, prompt the command has not been fully entered, the default is ">"
TERM Terminal type, the need for full-screen operation procedure is very important. Sometimes adjust the settings according to the situation.
TZ time zone settings, the specific time zone information in / usr / share / zoneinfo directory, need to set the standard for the local time zone value
The user's shell can be set for specific applications, to achieve the limit users on a special purpose. For example, just to give the user an e-mail, but do not want to give him the right to use the terminal, you can change the user's shell to / bin / true or other immediate exit procedures. For security purposes, users should be a non-existent shell holes binaries, it is best not to use an interpreted language script as login shell. Because the system is approved by shell procedures / etc / shells file listed in the program, the special user's shell is set to specific applications, but these applications not included in the shells file, then the user will be some applications to differentiate between ordinary users to refuse to provide services. Ftp server programs such as ftpd, by checking the user's shell is not the standard shell, to distinguish the user is normal user or users for a particular purpose.
Note that the user can not easily change the root shell, because it may cause root can not login properly, and so is unable to perform system maintenance. Even the root of the shell to change to other newer, stronger and features a standard shell, such as bash or tcsh, it should not be. Although the shell is very mature shell, still should not use them as a root of the shell. Main reason is that these shell generally has not been installed to the root partition, then when the system into single-user state, problems can arise. Another shell may be as a result of these upgrades and other reasons, and occasionally the formation of faults, causing root can not login properly. In addition, these non-standard shell does not come from the installation disk in the system, and therefore the existence of shell sources of security and trust issues, we must ensure that these shell is not changed by the attacker's version. If you want to use them to provide a convenience feature shell can be used in the system log after the full path to execute them.
* Configure user shell
In fact sh and csh, not the best choice for general users, as the two shell in the ease of use is not good enough to do, such as command line editing is not strong, can not use the hot key repeat orders. Relatively new shell, such as bash and tcsh have these user-friendly features, but these shell procedures must be installed after the ordinary user's shell to change the settings to use the shell program. Change the user's shell can use pw, vipw or chsh.
The two were in accordance with sh and csh shell style, so you can choose style preferences csh tcsh, and sh-style choices like bash. In addition to the two shell, there is ksh, zsh and other shell available. If the two shell no preference, you can choose bash, it is a GNU software, powerful than the standard multi-sh.
Use two more enhanced shell, users can use the shell command-line editing. According to different habits, you can choose vi or emacs-style editing style means the default is emacs mode, this way, use the arrow keys to go back over the order execution, and modify the letter of the command to use vi style editing keys , such as using h, j, k, l four keys to move the cursor, vi-style benefit is not used outside of basic keyboard controls, which can be applied to any terminal equipment, and edit basic keyboard without having to leave when the hand , after proficiency in the most efficient. emacs style is more suitable than the vi style shift from the personal computer habits of Unix users. bash, ksh, zsh use the following command in emacs and vi style switch style:
bash $ set-o emacs
bash $ set-o vi
tcsh use different commands:
% Bind emacs
% Bind vi
Frequently used commands can also set an alias to simplify user input, such as:
bash $ alias ec = "echo This is a alias"
bash $ ec
This is a alias
shell for another user's ability to operate auto-complete command or file name of the function, as FreeBSD, the file name may be long, will they all input much trouble. In fact you can enter part of the name, then press the Tab key (vi style in the press under the Esc key twice in a row), shell will automatically fill the remainder of the full file name. If you have already entered this part of the name can not determine the specific order or document, then the shell will be able to identify only part of make up, and then notify the user to enter the ring with clear and specific documents.
In fact even in the basic under sh or csh, you can also use the "*" and other special characters, use the pattern matching approach to simplify the input.
bash $ cd / usr / local
bash $ pwd
/ Usr / local
Most Unix programs are available in the pattern matching processing capacity, while the shell's pattern matching functions most commonly used. shell can use these special mode to configure multiple files, to simplify operations purposes. If you are familiar with Unix, must have the pattern matching.
When trying to bash when typing Chinese characters, in addition to the terminal property must be set to accept 8-bit characters other than (Executive stty pass8 command), also need to set the bash of the input and output conversion, you can logon script. Profile file includes the following settings:
bind''set convert-meta off''
bind''set meta-flag on''
bind''set output-meta on''
Recommended links:
MMOG / LE assessment of the ROAD Troika
Evaluate Business Databases And Tools
Ansys Introduction slide
FreeBSD Serial (64): NetBIOS name resolution
Baidu stock Market "crazy" hidden undercurrent
Training of new employees approach HR
ASF Converter
MSN photo worm attacking Jiangmin Christmas warning Qi Rising
JSP Servlet Automatically Jump To The Wrong Instance Of The Page
apple 39 s own software programmed with a face
Report PERSONAL Interest
Art - Screen Savers Storage
3G2 To MPEG
Mold Industry Began To Show Radiation Effects
Easy To Use Astronomy
I am a third Category
DVR-MS to MP4