Home > Backend Development > PHP Tutorial > Some experience and skills accumulated in five years of using Linux_PHP tutorial

Some experience and skills accumulated in five years of using Linux_PHP tutorial

WBOY
Release: 2016-07-21 15:05:04
Original
817 people have browsed it

1. $ related parameters in bash

Copy code The code is as follows:

$0 - represents the current File name
$* - Separate all parameters with spaces to form a string
$@ - Separate all parameters with spaces to form a string combination. The difference with $* is that when quoted by "", "$*" is a string, while "$@" contains multiple strings
$# - the number of parameters passed to the process
$? - The execution result of the previous command, if there is no error, is 0
$$ - The PID of this command

2. bash technique, combine the contents of a variable into another variable Variable name
EXAMPLE:
Copy code The code is as follows:

A_B_C_D ="something"
t1="B"
t2="_D"
eval echo $A_${t1}_C${t2};

3 . Under Ubuntu (12.04, 12.10), ThinkPad 🎜>
echo -n 225 > /sys/devices/platform/i8042/serio1/serio2/sensitivity
echo -n 115 > /sys/devices/platform/i8042/serio1/serio2/speed
4. Back up the master boot sector (bootsector)
If the boot file is damaged, you can restore it by restoring the master boot sector:

Backup


Copy code
The code is as follows:

dd if=/dev/hda of=bootsector.img bs=512 count = 1 >dd if=bootsector.img of=/dev/hda
The above two steps only restore the main boot sector. It is very likely that you need to restore all the contents of /boot to start normally, so You can also back up the files under /boot. 5. Bash command line input skills:
Use Ctrl+R to search for previously used commands
Use Ctrl+W to delete the current single item
Use Ctrl+U to delete Current line
6. xargs is very powerful, you can use -l{} to specify the location of parameters:
EXAMPLE
Copy code The code is as follows:
cat hosts | >
set -e, when an error occurs, the script will exit
set -u, when bash finds that there are no initialized variables, it will exit
For more reference: "Writing Robust Bash Scripts" 》

8. tar packages the files listed in the specified list:


Copy the code
The code is as follows:

cat yourlist.lst
/etc/fstab /home/admin/bin/somefile.sh /home/mysql/somefile ... tar cvzf xxx. tar.gz -T yourlist.lst


9. Specify a DNS server to query domain name records


Copy code

The code is as follows:

dig @8.8.8.8 www.google.com
10. The parameters that need most attention in the sort command are -k and - s:

Copy code

The code is as follows:


-s, --stable
stabilize sort by disabling last-resort comparison
stable indicates that the final order depends on the original order.

EXAMPLE
Copy code The code is as follows:

$ cat a.txt
a
A
b
$ sort -f a.txt
a
A B $ sort -f -s a.txt a
A

b


In the example, -f means case-insensitive, -s means the order depends on the order of the original file


Copy code The code is as follows:

-k, --key=POS1[,POS2]
start a key at POS1 (origin 1), end it at POS2 (default end of line).

So to sort only by the second column, you should write:
Copy the code The code is as follows:

sort -k1,1

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/327730.htmlTechArticle1. The $ related parameter copy code in bash is as follows: $0 - represents the current file name $* - with spaces Separate all parameters to form a string $@ - Separate all parameters to form a string...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template