"foreground tasks" is only one: whether to inherit standard input. Therefore, the user can also enter additional commands while performing background tasks.Three, Sighup signalbecomes a "background task", does a process become a daemon? Or, after the user exits the session, will "background tasks" continue to execute?The Linux system is designed like this.
User ready to exit session
The system sends a signal to the session SIGHUP
Session sends the SIGHUP signal to all c
property. A good practice is to make all historical environment variables read-only, such as:Export histcontrol= export histfile= $HOME/.bash_history export histfilesize=2000 export histignore= Export histsize=1000 export histtimeformat= "%a%b%Y%T%z" typeset-r histcontrol typeset-r histfileHisttimeformat is an extension of the bash shell that will provide timestamps in the history file.For bash shell, you need to change some of the standard options for history:Shopt-s cmdhist #设置cmdhist
1 Call TrackingTrace system call Strace ls–l Trace Library Call Ltrace2 lsof (list open file)See what files The program commands open lsof–p PID; Lsof–c CMD View files opened by a user lsof–u root See which program a file is accessed by lsof filename3 proc File systemVirtual file system, you can use cat,more,less to view For example: Cat/proc/cpuinfo; Cat/proc/meminfo4 Network debuggingPing tcpdump tcpdump–i ETH0–S0–SVX host 192.168.1.12 and Port 1234–w test.pcap Ethtool Traceroute NETSTAT–ANP |
session, the system sends a SIGHUP signal to the sessionSession sends the SIGHUP signal to all child processesAutomatically exits after the child process receives the SIGHUP signalFront desk work will definitely receive sighup signal.Whether the background work will receive the sighup signal, determined by the Huponexit parameter ($shopt | grep hupon), this parameter determines whether the SIGHUP signal will be sent to background work when the sessio
One of my colleagues once asked me this question: how do I delete all files in the directory except some files under Linux? At the time, I told him that he could solve it by pattern matching. But in fact, besides, there are other methods, which are called "All roads lead to Rome". Let's take a look at them.
If you want to delete all files except *.iso and *.zip in the ~/downloads directory, you can do this in bash:
Method 1: Pattern matching method
Copy Code code as follows:
In PERL development, system commands can usually be executed using the systems function or the ' operator ', but pay attention to alias, BG, bind, break, Builtin, CD, command, Compgen, complete, continue, Declare, dirs, Disown, Echo, enable, Eval, exec, exit, export, FC, FG, Getopts, hash, help, history, jobs, kill, le T, local, logout, popd, printf, pushd, pwd, read, ReadOnly, return, set, shift, shopt, source, suspend, test, times, tra P, type, type
* *TodoEcho $iDone}cd/root/jay/echo "------------------------"echo "Disable Globstar option:"# Globstar is disabled by defaultShopt-u GlobstarShowecho "------------------------"echo "Enable Globstar option:"Shopt-s GlobstarShow Executing the shell script of the test Globstar above, looking at its output, it is easy to understand Globstar, as follows: [Root@smilejay jay]#./test_globstar.sh------------------------Disable Globstar option:Dir1Dir2File1Fi
for the telnet command:
$ telnet [tab][tab]
localhost dev-db fileserver
To allow programmable command completion to function at your terminal, you only need to perform the following/etc/bash_completion: #./etc/bash_completion
You can also cancel/ETC/BASH.BASHRC (from the Ubuntu Linux 13.04 system) as follows, so that you do not need to execute the above command:
### Enable bash completion in interactive shells
if! shopt-oq P
Tags: setup ATI string pass LOB schema installation machine x86_642017-12-25 # Configure host name full display vim/etc/BASHRC # Turn on checkwinsize shopt-s Checkwinsize ["$PS 1"="\\s-\\v\\\$"] ps1="[\[email protected]\h \w]\\$"# Configure host name to be permanently active vim/etc/sysconfig/Network NETWORKING=Yes HOSTNAME=mysql-5.7-Master # Configure host name to take effect temporarilyhostnamemysql-5.7-Master # Configure hosts to parse vim/etc/hos
, getopts, hash, help, history, jobs, kill, let,local, logout, mapfile, popd, printf, pushd, pwd, read, readonly, return, set, shift, shopt, source, suspend, test,times, trap, true, type, typeset, ulimit, umask, unalias, unset, waitAll of the above built-in commands must know the meaning, 90% can be easily used to qualify.External command:such as LS,IP,SS, etc.
To see whether a command belongs to an external command or to a built-in com
27535 27467 0 00:00:00 pts/0 grep ping
Obviously, it is a sub-process of shell. The command is executed by a sub-shell in the background. The current shell (27467) gets control immediately and waits for user input, so my grep can be used. The background commands are executed in parallel with the current shell. They do not have mutual dependencies or waiting relationships, so they are asynchronous and parallel. Now the problem arises. If ssh exits and bash ends, what will happen to this process
The following two tips to enhance Bash functions: one is to improve Bash command history management, and the other is to enable Bash to have a more intelligent automatic completion feature. The implementation process is not complex. You only need to modify the default configuration of Bash. Improve Bash command History Management: The default configuration of Bash has a problem. If you open two (or more) consoles at the same time, the commands executed on these two consoles are not shared to his
, shell automatically fixes all input errors when identifying the file or path name.
Shopt-s cdspell
8. Open the application in the background
When inspecting command lines, you may need to perform another task, such as responding to an email. Of course, you can open the GUI application from the terminal by executing other commands. You only need to call their names. In this example, open Gimp:
$ Gimp
But this effectively ends your terminal session,
; * * The essential difference between "background task" and "foreground task" is only one: whether to inherit standard input. Background tasks no longer inherit the current session's standard input (stdin), you cannot enter instructions to the background task, but the background task inherits all the output from standard output (STDOUT) and standard error (STDERR) Background tasks will still be displayed synchronously on the command line * * The Hang-up signal (SIGHUP) is sent to the terminal c
. Example: j ?? K | [a-c] OK | jak. If the extglob option is enabled, advanced matching is supported. Shopt-s extglob? (Matching string) matches 0 or 1 matching string in parentheses. * (Matching string) matches 0 or more matching strings in brackets. + (Matching string) matches the matching string in one bracket. @ (Matching string) matches one of the matching strings in brackets .! (Matching string) matches a matching string that is not in parenthes
mode is generally used on the production machine, and the Server established according to the production mode needs to enter the management user name and password at startup. If you want to start the instance directly without being disturbed by the user name and password, follow these steps.
Create the file boot. properties in the root directory of the domain to be started. The content is the user name and password for controlling the domain. Directly write the file in plain text as follows:
mainConfiguration files (. bash_profile,. bash_login,. profile) then the above wowouldHappen. On the other hand, these files must read. bashrc in their body so thatThe options mentioned to. bashrc are actually applied in the first login shellAs well.
# Cat>/home/bob/. bashrc > Shopt-s histappend> Readonly PROMPT_COMMAND = "history-"> EOF
The option histappend orders bash to append the last $ HISTSIZE lines to$ HISTFILE file (normally ~ /. Bash_histor
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.