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 tips for using Linux Shell?

2025-02-22 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

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

This article introduces the knowledge of "what are the tips for using Linux Shell". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

Check if the remote port is open to bash:

The code is as follows:

Echo > / dev/tcp/8.8.8.8/53 & & echo "open"

Let the process go to the background:

The code is as follows:

Ctrl + z

Move the process to the foreground:

The code is as follows:

Fg

Produces a random hexadecimal number, where n is the number of characters:

The code is as follows:

Openssl rand-hex n

Execute a command in a file in the current shell:

The code is as follows:

Source / home/user/file.name

Intercept the first five characters:

The code is as follows:

${variable:0:5}

SSH debug mode:

The code is as follows:

Ssh-vvv user@ip_address

SSH with pem key:

The code is as follows:

Ssh user@ip_address-I key.pem

Grab the complete website directory structure with wget and store it in the local directory:

The code is as follows:

Wget-r-no-parent-reject "index.html*" http://hostname/-P / home/user/dirs

Create more than one directory at a time:

The code is as follows:

Mkdir-p / home/user/ {test,test1,test2}

List the process trees that include child processes:

The code is as follows:

Ps axwef

Create a war file:

The code is as follows:

Jar-cvf name.war file

Test the hard drive write speed:

The code is as follows:

Dd if=/dev/zero of=/tmp/output.img bs=8k count=256k; rm-rf / tmp/output.img

Test the hard drive read speed:

The code is as follows:

Hdparm-Tt / dev/sda

Get the md5 hash of the text:

The code is as follows:

Echo-n "text" | md5sum

Check the xml format:

The code is as follows:

Xmllint-noout file.xml

Extract tar.gz to a new directory:

The code is as follows:

Tar zxvf package.tar.gz-C new_dir

Use curl to get HTTP header information:

The code is as follows:

Curl-I http://www.example.com

Modify the timestamp of a file or directory (YYMMDDhhmm):

The code is as follows:

Touch-t 0712250000 file

Use the wget command to perform the ftp download:

The code is as follows:

Wget-m ftp://username:password@hostname

Generate a random password (16 characters long in the example):

The code is as follows

LANG=c

< /dev/urandom tr -dc _A-Z-a-z-0-9 | head -c${1:-16};echo; 快速备份一个文件: 代码如下: cp some_file_name{,.bkp} 访问Windows共享目录: 代码如下: smbclient -U "DOMAIN\user" //dc.domain.com/share/test/dir 执行历史记录里的命令(这里是第100行): 代码如下: !100 解压: 代码如下: unzip package_name.zip -d dir_name 输入多行文字(CTRL + d 退出): 代码如下: cat >

Test.txt

Create an empty file or empty an existing file:

The code is as follows:

> test.txt

Synchronize time with Ubuntu NTP server:

The code is as follows:

Ntpdate ntp.ubuntu.com

Use netstat to display all tcp4 listening ports:

The code is as follows:

Netstat-lnt4 | awk'{print $4}'| cut-f2-d: | grep-o'[0-9] *'

Qcow2 image file conversion:

The code is as follows:

Qemu-img convert-f qcow2-O raw precise-server-cloudimg-amd64-disk1.img\

Precise-server-cloudimg-amd64-disk1.raw

Run the file repeatedly to show its output (the default is once every 2 seconds):

The code is as follows:

Watch ps-ef

List of all users:

The code is as follows:

Getent passwd

Mount root in read/write mode:

The code is as follows:

Mount-o remount,rw /

Mount a directory (this is the case where links cannot be used):

The code is as follows:

Mount-- bind / source / destination

Dynamically update DNS server:

The code is as follows:

Nsupdate

< test1.txt Skip bash history: 代码如下: < space >

Cmd

Go to the previous working directory:

The code is as follows:

Cd-

Split the large tar.gz file (each 100MB) and merge it back:

The code is as follows:

Split-b 100m / path/to/large/archive / path/to/output/files

Cat files* > archive

Use curl to get HTTP status code:

The code is as follows:

Curl-sL-w "% {http_code}\\ n" www.example.com-o / dev/null

Set the root password to strengthen the MySQL security installation:

The code is as follows:

/ usr/bin/mysql_secure_installation

When Ctrl + c doesn't work:

The code is as follows:

Ctrl +\

Get the file owner:

The code is as follows:

Stat-c% U file.txt

Block device list:

The code is as follows:

Lsblk-f

Find the file with a space at the end of the file name:

The code is as follows:

Find. -type f-exec egrep-l "+ $" {}\

Find files with tab indents in their names

The code is as follows:

Find. -type f-exec egrep-l $'\ t'{}\

Print a horizontal line with "=":

The code is as follows:

Printf'0s\ n' | tr''=

This is the end of the content of "what are the tips for using Linux Shell". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

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