(after waking up for a nap, the mind is particularly clear, so to organize a piece of Cao classmate's yesterday answers the ^_^, the process of collecting information, but also the process of learning)
Yesterday quickly off work, every time to catch the suburban bus Cao classmate will run off on time, but it is almost 7 o'clock, Cao classmate still indifferent in the seat, this is abnormal, after a small meeting, Cao classmate ran over.
Cao Classmate : I made a mistake ~ ~ ~ a Linux machine to hang up ~ ~ ~
me: 10.10.0.5? Alarm middle?
Cao classmate : Yes
me: What's the situation?
Cao classmate : After the mqadmin user changed to C shell, all the commands are invalid ...
Me:(feel very magical, but as long as not to lose files, just login not to go in, there is no tension, most of them are environmental variables problem it?
Login demo, mqadmin changed from B Shell to C shell, environment variable used. CSHRC.
In the phenomenon is: In addition to the CD command, the other commands all prompt command not found.
So it is not possible to delete the Mqadmin user's root directory. CSHRC
(Cao students want to delete. CSHRC then the other orders will take effect) the idea is right, but how to get in it, and delete it. CSHRC can be OK. That means things like environmental variables.
In order to be able to log in, first use the root user login, modify the/etc/passwd file, the CSH user to bash. OK, b Shell users can delete the. cshrc. There's something wrong with the wood.
But the problem is: Cao classmate still want to use C shell claiming to be familiar with C shell. (I'm not using shell B because I'm familiar with B shell because it's the default.) But give me b shell I use bash_profile, to C shell with CSHRC, I can not be so picky Cao classmate ^_^)
I know the user from B shell modified to C shell command does not take effect, it must be an environment variable problem, but how to explain this thing. That's going to be a collection of articles.
1 Why is the Linux B shell user having problems with the wood?
The first popular shell was presented by Steven Bourne, so he called it the Bourne shell, or simply called SH! And then another wide-spread shell, Bill Joy of Berkeley University, is designed to be attached to the shell in the BSD version of the Unix system, which has a bit of C-language, so it's named C Shell, CSH! Due to the great strength of the Sun Master in the academic world, and sun being one of the BSD branches, the C shell is also one of the most important and widely-spread shells.
Because the Linux preset is the Bash shell Oh, the default shell
Linux bash Shell,unix C Shell also has a variety of expanded Ksh tcsh ... (The syntax is not good, the same reason ...)
The root user is bash by default ...
2 command not found is almost always a matter of environment variables
After changing the C shell, why the LS command door does not take effect, why only CD a command is still valid?
Where are the LS commands?
/bin:bin is the shorthand for binary to place some of the system's essential executable files such as: Cat, CP, chmod DF, DMESG, gzip, kill,ls, mkdir, more, Mount, RM, Su, tar, etc.
/sbin: There are some essential programs for system management such as Cfdisk, DHCPCD, Dump, E2FSCK, Fdisk, Halt, Ifconfig, Ifup, Ifdown, Init, Insmod, Lilo, Lsmod, MKE2FS, Modprobe, Quotacheck, reboot, Rmmod, runlevel, shutdown, etc.
/usr/bin: Some of the essential executable files for application software tools are: C + +, g++, GCC, Chdrv, diff, Dig, Du, eject, elm, free, gnome*, gzip, htpasswd, KFM, Ktop, Last, Less, Locale, M4, make, man, Mcopy, NcFTP, newaliases, nslookup passwd, quota, smb*, wget, etc.
/usr/sbin: Some essential programs for network management such as: DHCPD, HTTPD, IMAP, IN.*D, inetd, LPD, named, Netconfig, NMBD, samba, sendmail, squid, swap, TCPD , tcpdump, etc.
Since most of the commands are in the/bin/sbin//usr/bin/usr/sbin, they are added in the path, in case you change to CSHRC it does not allow the orders to come into force ^_^
OK, so the user changed from B Shell to C shell, only need to use the root user in/etc/passwd to change bash to CSH. Just add path to the. CSHRC and source. CSHRC in effect Oh ~ ~ ~
3 Why does the CD command not receive the influence pinch???
Online Explanation:Bash has its own internal commands, and CDs is one of them.
because the CD command in our system does not actually correspond to a binary, but we can still execute this command, which is because the CD is actually an internal command for BASH. Internal commands are integrated into the shell.
Supplemental knowledge: BASHRC Bash_profile profile under the B shell
(../.bash_profile makes the environment variable effective, as is the. BASHRC or. Bash_profile is just the difference between login. ）
/etc/profile: This file sets the environment information for each user of the system, and the file is executed the first time the user logs on. and collects the shell settings from the configuration file of the/ETC/PROFILE.D directory.
/ETC/BASHRC: executes this file for each user running the bash shell. When the bash shell is opened, the file is read.
~/.bash_profile: Each user can use the file to enter shell information dedicated to their own use, and when the user logs in, the file executes only once! By default, he sets some environment variables to execute the user's . BASHRC file.
~/.BASHRC: This file contains bash information dedicated to your bash shell, which is read when you log in and every time you open a new shell. (Each user has a. bashrc file in the user directory)
~/.bash_logout: Executes the file each time it exits the system (exiting the Bash shell).
In addition, variables set in/etc/profile (global) can be applied to any user, whereas variables set in ~/. BASHRC (local) can only inherit variables from/etc/profile, and they are "parent-child" relationships.
~/.bash_profile is interactive, login way into bash run, ~/.BASHRC is interactive non-login way into bash, usually the two settings are basically the same, So the former will usually call the latter.
When a new B shell user is created, the system generates three files by default. bashrc. Bash_profile. bash_logout
As described above, the relationship between the various documents, in short. BASHRC and. Bash_profile are two different ways to log in
If a call to/etc/basrc (Linux Red Hat has)
If a section of the home directory to determine whether there is BASHRC exist, read home directory BASHRC set.
Login and Non-login
- Login Shell: When you get bash, you need a full login process, called the login shell. For example, you need to enter the user's account and password by Tty1 ~ Tty6, and bash is called "Login Shell".
- Non-login Shell: The method of getting the Bash interface does not require a duplicate login, for example, (1) After you log in to Linux with X window and then activate the terminal with the graphical interface of X, the terminal interface does not need to enter the account and password again, that Bash's The environment is called the Non-login shell. (2) You are in the original bash environment again under the Bash command, the same does not enter the account password, the second bash (subroutine) is also the Non-login shell.
How does the. bashrc or. Bash_profile take effect?
Use. or source
Linux uses C shell, b shell environment variable problem