Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the skills of using Linux

2025-04-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article mainly introduces the skills of using Linux, the article is very detailed, has a certain reference value, interested friends must read it!

1. $related parameters in bash

The copy code is as follows:

$0-indicates the current file name

$*-separate all parameters with spaces to form a string

$@-separates all parameters with spaces to form a string combination. Unlike $*, when referenced by "*", "$*" is a string, while "$@" contains multiple strings.

$#-number of parameters passed to the process

$?-the execution result of the previous command, 0 if there are no errors

$- PID of this order

2. Bash technique, which combines the contents of a variable into the variable name of another variable.

EXAMPLE:

The copy code is as follows:

Average Bond Clearing D = "something"

T1 = "B"

T2 = "_ D"

Eval echo\ $Aids ${T1} _ C$ {T2}

3. Under Ubuntu (12.04,12.10), ThinkPad X220 pointer is set to set sensitivity and speed, respectively.

The copy code is as follows:

Echo-n 225 > / sys/devices/platform/i8042/serio1/serio2/sensitivity

Echo-n 115 > / sys/devices/platform/i8042/serio1/serio2/speed

4. Back up the primary boot sector (bootsector)

If the startup file goes bad, you can fix it by restoring the main boot sector:

Backup

The copy code is as follows:

Dd if=/dev/hda of=bootsector.img bs=512 count=1

Restore

The copy code is as follows:

Dd if=bootsector.img of=/dev/hda

The above two steps only restore the main boot sector, and you probably 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

Delete the current single time using Ctrl+W

Delete the current line using Ctrl+U

6. Xargs is so powerful that you can specify the location of the parameters with-l {}:

EXAMPLE

The copy code is as follows:

Cat hosts | xargs-I {} ssh root@ {} hostname

7. Write secure bash scripts:

Set-e, when an error occurs, the script exits

Set-u, exits when bash discovers that there are no initialized variables

For more information: "write a robust Bash script"

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

The copy 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

The copy code is as follows:

Dig @ 8.8.8.8 www.google.com

10. The most important parameters for the sort command are-k and-s:

The copy 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

The copy 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, and-s indicates that the order depends on the order of the original files.

The copy code is as follows:

-k,-- key=POS1 [, POS2]

Start a key at POS1 (origin 1), end it at POS2 (default end of line).

So sorting only by the second column should write:

The code is as follows:

Sort-K1Pol 1

The above is all the contents of this article entitled "what are the skills of using Linux?" Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report