scope is ultimately valid. So if there are ambiguous configurations in both the global configuration and the personal configuration, then the individual configuration is effective.
How does the login shell read the configuration file?/etc/profile--/etc/profile.d/*.sh--and ~/.bash_profile--~/.BASHRC--/ETC/BASHRCHow do I configure a file for a non-logon shell?~/.BASHRC--/ETC/BASRC-/etc/profile.d/*.sh
variables: scope current shell process and its child processes local variable: scope current shell process Local variables: scoped only to a snippet of code in the current shell process (usually a function context) Position variable: $ $, $ Special variables: $? How variables are defined:Bash built-in variables: can be called directly, built in a number of envir
Bash FeaturesUser working environment: root # Normal User $Shell Child shell can open multiple bash and exit with exit
Command history, Historical histsize command history size, default 1000 bar-C Empty Command history-d specifies the line number to delete command keep path home directory. Bash.history-w saved to h
When you enter an instruction to the computer, Bash sends the instruction to the core kernel, and the core calls the relevant program to start the hardware.If you let the user operate the operating system directly, it may cause a crash of the system, so the operating system through the application to let the user operating system shell program Shell,
, #ls? y*[] matches any single character within the specified range, such as [a-za-z][0-9] [0-9a-za-z][[: Space:]] all whitespace characters[[:p UNCT:]] all punctuation[[: Lower:]] all lowercase characters[[: Upper:]] all uppercase characters[[: Alpha:]] all uppercase and lowercase letters[[:d Igit:]] All numbers[[: Alnum:]] numbers and uppercase and lowercase[^] matches any character outside the specified rangeCases:1. A file that starts with a letter and ends with a letter and contains a space
We know when we use the mouse to click, or enter a command, the system will play to help us complete a task, then when we click on a link, the system is how to know to complete the corresponding operation? This is done through the shell.So what is a shell?The shell is an interface between the user and the operating system through which the shell accepts commands
(System variables):Local variables:Varname=value : scoped to entire bash process; Local variables:Localvarname=valuw : The scope is the current code snippet; environment variable: scope is current shell process and its child processesSetexport Varname=value :"Export"The script starts a child shell process when it executes ;scripts that are started on the co
also used "." When invoking the system function library under/etc/init.d/. Point number and source, let's look at the system function library/etc/init.d/functionsYou can also call the library with source, and the action prints out very flashy results, such asThe action in/etc/init.d/functions is a function defined in theWe can also define the functions ourselves in the functions, and then we can invoke the custom function. Such asYou can also send a reference, such asFour Basic specifications a
Login:Interactive login:Enter the account password directly via the terminal;Users switching with "Su-username" or "Su-l UserName"Loading process/etc/profile---/etc/profile.d/*.sh------~/.BASHRC----and/ETC/BASHRC//late loading will overwrite the same variables that were loaded firstNon-interactive logon:Su UserNameThe terminal opened under the graphical interfaceExecute scriptLoading process~/.BASHRC--/ETC/BASHRC-/etc/profile.d/*.shEdit the new configuration defined by the profile to take effec
: Three, position parameter variableUsed to pass parameters or data to a script, variable names cannot be customized, and variables are fixed
Positional parameter variables
Role
$n
$ A represents the command itself$1-$9 represents 1th to 9th input parameters${10}
$*
$* all the parameters as a whole
[Email protected]
[email protected] treat each parameter differently
$#
The number of all
1, command line completion, PATH completiontab, press two tab to give all the commands of the systemCommand completion: Finds the path defined in the PATH environment variable based on the string we give, and more than one press two times tab to give the list, otherwise direct completionPath completion, completion based on the file name under the starting path we gave2. Command aliasesAlias can view aliases defined in the systemAlias aliases = commandRemove aliases using Unalias aliasesAliases d
variable stores data, it is written by default, and any variable can be directly referenced without being declared; - : 24bits120:8bitsTo define a local variable:Name=valueView: SetDefine Environment variables:Export Name=valueDeclare-x Name=valueView: env, printenv, exportUndo Variable:unset nameReference variable:${name}, $nameBash the reference symbol in:"': strong references, variable substitution does not occur"" : Weak references``: Command ReferenceShell Login Type:Interactive login:Log
machine, you will need to install VMware Tools to have vmware worksation download, wait for the download to complete, choose to cancel its installation option, and mount the file directly on the LI Nux system on the optical drive. Execute the DF command to view the Mount relationship, and its ISO file is mounted directly on the/DEV/SRO.#cd/media/vmware\ tools/into the folder location where you need to install the program.#cp the compressed file in the directory to the specified location for dec
Bash's configuration fileBash configuration file :Persist User ConfigurationProfile class: Provides configuration for interactively logged-on users/etc/profile Global/etc/profile.d/*.sh Global~/.bash_profile personal Configuration, valid only for the current userFunction:Setting environment variablesUsed to implement a run command or scriptHow to read the configuration file:/etc/profile-->/etc/profile.d/*.sh-->~/.BASH_PROFILE-->~/.BASHRC-->/ETC/BASHRCBASHRC class: Non-interactive user login prov
It is useful to learn good shell programming, and you can use shell scripts to do interesting work with a light weight.This address: http://www.cnblogs.com/yhLinux/p/4047516.htmlBash Instances , Daniel Robbins ([email protected]), President and CEO, Gentoo Technologies, Inc.The first part: http://www.ibm.com/developerworks/linux/library/l-bash/index.htmlPart II:
command:$WC-L You can also use here Document in a script, for example:
#!/bin/bash
Cat
A simple lookup program
For good (and bad) restaurants
In Cape town.
Eof
Operation Result:This was a simple lookup programfor good (and bad) Restaurantsin Cape town.The following script saves the document to the Test.txt file through the VI editor:
#!/bin/sh
FileName=test.txt
VI $filename
I
If the expression contains special characters, the Shell will replace it. For example, using a variable in double quotes is a substitution, and an escape character is also a substitution.As an example:
#!/bin/bash
A=ten
echo- e "Value of A is $a \ n"
Operation Result:Value of A is 10Here-e indicates the substitution of the escape character. If you do not use the-e option, it i
3.2.0, using the root super user. View User Login file/etc/passwd
View/etc/passwd:
root:x:0:0:root:/root:/bin/bash
daemon:x:1:1:daemon:/usr/sbin:/bin/sh
bin:x:2:2:bin :/bin:/bin/sh
sys:x:3:3:sys:/dev:/bin/sh
sync:x:4:65534:sync:/bin:/bin/sync
games:x:5:60:games:/ Usr/games:/bin/sh
man:x:6:12:man:/var/cache/man:/bin/sh
Can see: Root:x:0:0:root:/root:/bin/bash So, what I'm doing is
Shell interpreter (learning note 4) and shell interpreterI. Shell interpreter
Shell interpreter, a bridge between the user and the operating system kernel
Shell is between the operating system kernel and the user. It is responsi
the written command.
Second, my first shell program
#! /bin/bash
# filename:FileType.sh
read-p "Please input the filename:" filename
fpath= $filename
if [D $ Fpath];
Then
echo "$fpath is a direstory.";
elif [-e $fpath];
Then
echo "$fpath is a file.";
else
echo "$fpath is not a file or direstory.";
Fi
This is my first sh
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.