IBM WebSphere Application Server Performance Cookbook - POSIX
100 zombies slot xargs
If the user who is logged on the system is rooted, the shell invitation logo is##for users other than ROOT to display $.
To recognize the current shell, remember to use one of the following shells:
Echo $ 0 Bash $ $ $ shell/bin/bin $ P S-P $ PID TTY TIME CMD 6549 PTS/4 00:00:00 Bash
Cross-Shell Topics
POSIX-compatible shell scripting
Variable Expansion
Development of variables supports the correct operation:
- Returns the meaning of the variable or the default meaning.
- If the variable is not zero, the meaning is returned, and the default meaning is returned if it is zero.
- Returns the length of the variable.
- Returns the meaning of the variable that the suffix is deleted: $.
- Returns the meaning of the variable that removed the prefix: $
Create a file in one command
None of variable extensions (enclosed in HEREDOC text with single quotes or double quotes):
cat & amp; diag. sh & amp; gt; "$" 2 & amp; gt; & amp; amp; 1 Uname & amp; gt; & amp; p; amp; gt ; & amp; amp; 1 Echo "[[$ (data)]] & amp; amp; gt; & amp; gt;" $ "2 & amp; gt; & amp; F
cat & amp; diag. sh & amp; gt; "$" 2 & amp; gt; & amp; amp; 1 Uname & amp; gt; & amp; p; amp; gt ; & amp; amp; 1 Echo "[[$ (data)]] & amp; amp; gt; & amp; gt;" $ "2 & amp; gt; & amp; F
To apply the variable deployment, delete a single quote or double quot that surrounds the heredoc text.
If you need a rapper command, for example, sudo:
Sudo S H-C "CAT & amp; gt; Diag. sh" & amp; amp; gt; "$" 2 & amp; gt; gt; gt; gt; gt; & amp; amp; amp; 1 Uname & amp; amp; ; gt "$" 2 & amp; amp; gt; & amp; amp; 1 Echo "[$ (data)] Command Completed" & amp; amp; gt; & amp; amp; gt; "$" 2 & amp; gt ; & amp Amp; amp; 1 EOF
test
Test commands are often used in the Boule style, and their abbreviation is []:
-
Check that the line is empty (you can us e-z, but this is easier to read):
if [$ = "]; Echo Then" There is no first argument "EXIT 1 Fi
IF [$! = "]; Echo" No first argument "EXIT 1 Fi
if [$ = "string"]; Echo "The first argument is a string" EXIT 1 Fi
IF [-f "$"]; Echo THEN "File is present and is considered a simple file" EXIT 1 Fi
If [-f "$"]; Echo THEN "File does not exist" EXIT 1 Fi
if [-d "$"]; Echo Then "Directory exists" EXIT 1 Fi
Globs
When expanding a list of files and folders using gloves (*) in the terminal, files (also called dot files or hidden files) starting with dot (.) Are not included in the list. To enable these, first execute the command to disable this operation:
Shop t-s dotglob
Select glob_dots
set
Setopt is the current context setting option command. At the same time, you can specify only once or specify the number of flags.
- se t-e ends the script when the command receives an error.
- SE T-X outputs to the standard error output before executing each command.
Usually, se t-e is at the top of the script and expands when an error occurs:
/bin/shse t-e
case
Case "$" in ta0*) echo "First branch" ;; ITC*) Echo "second branch" ;;;*) echo "Default branch" ;; ESAC
POSIX-compliant one-liners
- Generate a random priority in A-Z, A-Z or 0-9 (replac e-w 22 with a count):
CAT /DEV /Random | lc_all = c tr u-Dc ' a-z a-z0-9' | Fol d-W 22 | Hea d-N 1
I = 1; max = 11; While ["$ i" -ne $ max]; echo $ i; i = $ (($ i + 1)); Done
Script template
#!/bin/sh # Explanation of how to use this script ()< printf "Usage: %s [-v] [-d DELAY] COMMAND [ARGUMENTS. ]\n" "$(basename "$")" cat DELAY="30" VERBOSE=0 OPTIND=1 while getopts "d:hv?" opt; do case "$opt" in d) DELAY="$" ;; h|\?) usage ;; v) VERBOSE=1 ;; esac done shift $((OPTIND-1)) if [ "$" = "--" ]; then shift fi if [ "$" -eq 0 ]; then echo "ERROR: Missing COMMAND" usage fi printInfo() < echo "[$(date '+%Y-%m-%d %H:%M:%S.%N %Z')] $(basename "$"): $" >Print Bourbose ()< echo "[$(date '+%Y-%m-%d %H:%M:%S.%N %Z')] $(basename "$"): $" >& amp; amp; gt; /stderR & amp; amp; gt; printinfo "$" [Start with a delay of $ ”[$” -EQ “1”] & amp; amp; amp; Printinfo "Completed"
bash
Change the command line to include more information:
PS1 = "[Printinfo]".
Search for command status with Ctrl+R support, enter with ESC support, check, and execute with Enter:
Less /etc /Hosts $ OtherCommand1 $ OtherCommand2 $ #Enter the Ctrl + R and Less now (reverse IoereSis): Less /etc /Hosts
Remember and execute the last team with Support.
$/Opt/IHS/BIN/Apachertl Restart $ Sudo !!!!
Remember the team in front of the search line and execute with support.
$/opt/IHS/bin/Apachertl Restart $ !!!?
Remember and execute the last team, but otherwise change all instances of the first formula:
$. GS/STOP/START/
Or support all arguments of the previous team. *
Search for the status of the specified team and the secondary start based on the position in the situation:
SH Server 1 543/Opt/IBM/WebSphere/ProfileS/Node01/Bin/StartServer! 543
Display the current username:
WHOAMI
Use the file name without an extension to screw all . tar. Gz files into the subcatalog:
for I in *. gz; do mkdir `basename $ i. tur. gz` & amp; amp; amp; amp; mv $ i` Basename $ i. Tar. gz` & amp; amp; amp; amp; amp; basename $ i. gz` & amp; amp; amp; tur xzvf $ I & amp; amp; amp; rm $ I & amp; amp; amp; e
Use the file name without an extension to screw all . tar files into the subcatalog:
for I in *. Tar; Do mkdir `BASENAME $ i. Tar` & amp; amp; amp; amp; mv $ I` BASENAME $ i. Tar` & amp; Name $ i. Tar` & Amp; amp; & amp; amp; turtf $ $ I & amp; amp; & amp; am $ I & amp; amp; amp; D; done
Use the file name without an extension to screw all files. zip into the subcatalog:
Before I in *. Zip; zip` & amp; amp; amp; mv $ i` Basename $ i. zip` & amp; amp; pushd $ i. zip` & amp; amp; amp; amp; unzip $ I & amp; amp; amp; amp; amp; rm $ I & amp; amp; amp; amp; amp; amp; popd; done
Gunzip all . gz files in the catalog:
search for. -Type f-name "*gz" -print | While Read Line; Do pass `DIRNAME $ LINE`; Gunzip` BASENAME $ LINE`; Popd; Done
Replace a part of the current catalog and shift to the catalog:
Remember the last text of the previous team with Alt+ support.
Command line navigation
Ctr l-Refers button. ⎇ AL T-Refers button.
- Start: A or ^XX
- Beginning of sentence: ⎇b
- End of text: ^e
- End of text: ⎇f
- First occurrence of X on right side: ^]X
- First occurrence of X on left side: ^⎇X
- Delete to beginning ^u
- Delete to end: ^k
- Delete text on left side: ^w
- Delete text on right side: ⎇d
- Insert what was actually deleted: ^y
Global aliases
To create a really huge alias, update scripts in both interactive shells (/etc/profile. d/*) and non-interactive shells (/etc/bashrc or /etc/bash. bashrc, depending on your distribution), for example. First, model a shell script containing the commands you want to run and put it in a fixed space like this: /etc/globalprofile. sh:
sh: #!/bin/sh alias x="exit" alias l="l s-ltrh" export PS1="[¬u@]¬w]¬u$ ”
Then, add output permissions:
# chmod +x /etc/globalprofile. sh.
Finally, add the appropriate lines to the location of your interactive and non-interactive shell scripts (e. g. /etc/bashrc):
source /etc/globalprofile. sh
Add the appropriate lines to the top of the file to initialize exit.
zsh
Completion
/zshrc :~autoloa d-U compinit; compiled
When you launch a new terminal tab and get the error message "zsh compinit: unsafe folders, run compaudit for list.", run compaudit and run it for each folder like this: If you get this error message, run compaudit and do the following for each folder:
sudo chow n-R $(whoami):staff $DIR sudo chmo d-R 755 $DIR
watchoutbound:
Script to watch netstat to create file triggers
- #SEARCH="10. 20. 30. 100:50000" SOCKETTHRESHOLD="150" SLEEPINTERVAL="30" while true; do currentcount="$(netsta t-an | awk " | gre p-c "$")" if [ $ -ge $ ]; echo then "$(date) Threshold exceeded with $ outgoing connections to $" & amp; amp; gt;& amp; amp; gt; /tmp/trigger. txt fi sleep $ done
This section has been moved to awk.
awk
Some operating systems have a dedicated command for truncation (such as "truncate" on Linux), but it is simpler and more platform independent to simply write /dev/null over the file to truncate:
Truncating Logs
cat /dev/null & amp; amp; gt; file. log
This doesn't work with sudo because the redirection command is actually done outside of sudo. In this case you can use tee:
cat /dev/null | sudo tee file.
Use p s-elf | grep lifted to record the completed process.
Defunct Processes
An i n-work process is the process of ending the process and waiting for the parent process to read the individual's final code. Most of the completed process resources are released, but the PID, output, and record code remain in the process of the process, and the systematic and enormous number of completed processes can limit scalability. All processes are completed, but in principle, this happens only for a short time. In principle, the no n-changing process means that the parent process is actually dependent. In the case of WAS, this is a normal node agent process. To dispatch a process that does not work, destroy the parent process. Before that, collect the diagnostic data of the parent process. For example, execute an Impact to find out if you are still alive, request a jet dump, and finally demand a dump-core. The killing of the parent process is basically a course of the completed process, which is an INIT (1) course that reads the output code and then enables the end of the completed process.
Int Main (int Argc, Char ** ARGV) containing #include
Example C Program that Crashes
$ GC C-G Test. C $ ./a. Out
To go around all tuned closed keys
SSH
Ss h-O pubkeyauthentication = No user@host
SSH connection to the server is possible, but other ports that you want to access are often blocked by firewalls. By creating SSH-TUNNEL, you can receive your car traffic on a specific port, redirect through SSH connection, and send it to another motivated server port. For example, let's say something is liston a port 8879 in the host X. You can make a tunnel in the following way:
SSH Port Forwarding
ss h-L 9999: hostx: 8879 sshuser@hostx
Here, you need to prepare a listening port in LOCALHOS T-PORT 9999. To access Hoostox port 8879, you can access this port through a client program.
It is also possible to arrange these program support using tunnel options, such as Putty
Kill is used to send signals to the process. ARTEL of the next tea m-Format:
kill
Kill -$k.
Is a number or signal name.
For example, when sending 123 characters equivalent to Ctrl+C:
Kil l-int 123
LES S-Command for fighting to see files and inputs:
less
Less Input
Transferred at the beginning of the input: g
- Move to the end of the entry: g
- Move to number N line: NG
- Move to the next input :: n
- Find something:/Search
- Find the future: n
- When you walk around at the end of the input and display "Calculation of line number", click Ctrl+C.
- Start a magazine stitch: Shift+F
- After loading the file, enable any command line option: -OPTION & gt; Enter. Co:
- Show line numbers: -N
- Show file progress: -m
- If byte X is shown, less doesn't know how many bytes there are in total, so it can't determine the percentage. Go to lid, then to beginning: G & gt; G
- tail can skip the first N lines with th e-n (N+1) command. For example, to skip the first input line, use:
tail
tai l-n +2 entries
Sort by a specific column with k support:
sort
sor t-k 3 input
sor t-k 3-n input
paste and bc can be used to sum a range of quantities from the input:
bc
cat input | past e-sd+ | bc
sed and bc can be used to perform simple mathematical operations on the input:
sed
cat input | sed's/$/*1024/' | bc
Display lines 4 through 10: se d-n '4, 10p'
- Delete the first 5 lines: sed '1.
- Delete blank lines: sed '/^$/d'
- perl is a widely used scripting language. Perl scripts usually contain the extension . pl and are preceded by a line like this:
Perl
#usr/bin/env perl
Useful command line functions
perldoc perlrun: A manual page for running the perl interpreter.
- -e: Display perl code on command line instead of perl file.
- -p: Execute the specified perl command for each line of normal input.
- -n: Same a s-p, except that n: lines are not printed yet.
- For example, to convert a POSIX date epoch to a human readable time, use:
$date +%s | per l-ne 's/(Λ+)/local time($1)/e;'.
The variable $_ will contain all lines from the file.
Support for BEGIN and END commands allows code to be executed at the beginning and end.
and END<>Block support allows code to be executed at the beginning and end:<>date +%s | per l-ne 'BEGIN
s/(date+)/local time($1)/e; END< print "Starting\n"; >Some useful things to remember in perl:< print "Finished\n"; >'
$x =\
- /$REGEX/: Returns true if $REGEX matches $x~$x =\
- /$REGEX/: Returns true if $REGEX matches $x~Commonly used systematic expression labels:
Match zero or more times: *
- Search one or more times: +
- Any character: .
- Space characters (space, tab, newline): \s
- The opposite of a space character: \S
- Text characters (a-z, A-Z, 0-9 or underscore): \w
- Non-word symbols: \W
- Digital characters (0-9): \d
- Non-digit characters: \D
- wget can be used for HTTP requests:
wget
wget http://ibm. com/ go to: "index. html".
If multiple URLs are passed to wget, which is highly likely, wget will try to use a TCP socket again. Using Perl to automate the generation of one same URL, a large number 1 on the command line. In this case, 64 requests are made to the socket in one go:
wge t-O/dev/null `per l-e 'print "http://ibm. com/ 「 x 64;」`.
To see the response headers and (short) headers, it is useful to use oneliner:
$ Wge t-qs http://ibm. com/-O-
If you want more control over what goes into the HTTP/HTTPS-Request, you can use printf and netcat or OpenSL S_Client:
netcat (nc) / openssl s_client
printf "get / http / 1. 1" ¦nhost: copy.
Show the external TLS certificate (replace both dots in localhost):
openssl
echo | OpenSSL S_Clien t-ShowCert s-ServerName LocalHos t-Connect LocalHost: 8880 2 & amp; amp; gt;/dev/null | OpenSSL X50 9-Formal pe m-nou t-text
usr/bin/fin d-team recursively finds files by filename or metadata. See the example at the bottom for Linux.
find
Performs a recursive search by filename or metadata name. xml $ find /opt/ibm/webspher e-Size +100m (Note: suffix M is not allowed) $ find. -Name server. xml | gre p-v i-templates |
Mark a file for saving or forwarding:
gpg
File Encryption
GPG ---S2K-mode 3 --2k-count 65536--force-mdc--cipher-algo AES256--S2K-Digest-Algo SHA51 2-o $ . pgp--symmetric $ .
Decrypt an encrypted PGP file:
File Decryption
Gp g-output $ -decrypt $ . pgp
Change the temporary label (=access/modification time) of a file to the current date and time:
touch
Touch input
Touch: "Touch [non-existent filename]" creates a new empty file (without catalog). You can also create multiple new files with the command Touch [newFile1 newfile2 newfile3].
The special character in Terminal is $.
Filenames and special characters
If you want to use them, you must precede them with a [backslash]. You cannot create file names containing the symbols / [straight slash] or zeros.<> & |;"'\
"CD+[first few characters of the filename]+tab" will allow you to change the catalog to files beginning with the characters you specify with autoselect:
Auto completion
"CD+inp+tab"
"LS+Tab+Tab" will open a list of lists that can be used with this command.
Go to beginning of line: Ctrl+A
Keyboard shortcuts:
- Go to end of line: Ctrl+E
- Move back one word: alt+b
- Delete symbol at cursor: Ctrl+D
- Cut text from cursor to end of line (beginning of line): Ctrl+K (u) to go back and use. "Kill" and "pull out" text.
- Convert current word to lower (upper) register [at beginning of word]: alt+l (u)
- Display contents of files filename1 and filename2 in reverse order:
tac
tac [FileEname1] [FileName2].
Append line to line.
nl
To list all built-i n-in commands available in a shell for a given scale, use:
Types of commands
compge n-b
To consider the similarity of the team, you can apply "Team Name] or File [Absolute Pass to Team].
Enter a CD or enter ifconfig and file/sbin/ifconfig.
You can also apply the WHO command to display the absolute path to the location/ command of the executable (integrated shell-not functioning):
Which IFCONFIG
To find out if the team name is already used or may be used as a pseudonym, you can apply "Type [Pseudo Candidate]":
Type myalias
Use 1stCommand to combine the 1st team and the 2nd team. Combine; 2ndCommand ;. If you do not use "exit", the correct command is executed.
Combining commands
- Date; Cal
Date & amp; amp; amp; & amp; amp; Cal
At least represent a sign or correspond: *
Wildcards
- One letter or match one character:?
- Again to the spectrum of the symbol: [Symbol range]
- It does not match the spectrum of the sign: [!
- Any amount from the number spectrum: [Digital-Digital]*.
- Note:[!]
- Uppercase: [[:upper:]]
- Lowercase: [[:lower:]]
- Digit: [[:digit:]]
- Alphabetical: [[:alpha:]]
- Alphanumeric: [[:alnum:]]
- Create 10 users with a random password:
htpasswd
- I = 1; max = 11; output = users. Htpassw d-9 "| Fol d-W 22 | Heade r-n 1)"; htpasswd $ (IF! [F "$"]; THEN PRINT "%s" "-c"; Fi) -B "$" "USER $" "$"; Echo "user $ = $"; i = $ (($ i + 1)); done
Makefil e-Automatting tasks using make.
Makefiles
Makefile is a set of appearance rules:
Makefile Basics
Target: $ TAB $ command $ Tab $ command [.].]
Each $ command starts with a dedicated shell.
A. Out: Test. C gcc test. C
Make launches the rules only when the final conversion time of the $ target is older than the final conversion time of the $ condition. Tasks without requirements are always evaluated as execution:
Clean: RM A. OUT
Comments start with#.
The first $ target is considered a default target at startup. If it is inconvenient, specify the target with make $ turtle. For example, Make A. OT.
To secure the POSIX standard ratio, the first line shall be correct without explanation:
POSIX:
(Macro) Create files with all opportunities to apply macros. The default meaning can be specified by the command to support:
CFLAGS = -G
Macros may be redeemed with support for macros = values in the challenge shell or command line; for example, CFLAGS = "-g --o". $ Parameters can be applied as a variable environment.
POSIX: CC = GCC CFLAGS = - W-G -FN O-Pointer Prefix =/usr/local All: a. Ot Install: A. Ot Mkdi r-p $ (DestDDIR) $ (Prefix)/Bin C P-F A. Out $ (DestDDIR) $ (Prefix)/bin a. out: test. c $ (CC) $ (ldflags) $< macro expands to the prerequisite.
Makefile Example
Special tasks. PHONY specifies the list of targets to be executed when the prompt comes out. Even if there is a file name corresponding to the target. for example< clean: rm -f a.out
PHONY
If one folder has a large number of programs, it is most convenient to put all the programs into one makefile ./makefile. Since the tasks that are reproduced by default to Makefile are 1, it is common to create this fake task under the name 'All' and broadcast all individual programs as SEND. for example
ALL: OC C-O PROG1 OUTILS. O PROG2 O CC2 Prog2 Outils. Outils. Span> Special Task. Phone is specified a list of targets to be executed when the prompt comes out. Even if there is a file name corresponding to the target. for example
If one folder has a large number of programs, it is most convenient to put all the programs into one makefile ./makefile. Since the tasks that are reproduced by default to Makefile are 1, it is common to create this fake task under the name 'All' and broadcast all individual programs as SEND. for example