Linux Shell Common Command Manual (Updating)

Source: Internet
Author: User
Tags md5 hash egrep

    • Check if the remote port is open for bash:

NC-nvv  $IP $PORTtelnet $IP $PORT

    • Front and back switch for current task:

Ctrl + ZFG

    • The first 5 characters of the Intercept variable:

${variable:0:5}

    • SSH Debug Mode:
ssh -vvv [email protected]_addressssh with PEM key:ssh [email protected]_address-i KEY.PEM

    • Monitoring log files
tail -F $FILE _name

Multiple Monitored scripts

Multi_tail:

#!/bin/SHfunctionClean () {#Echo[email protected]; # for file inch "[email protected]"; Do PS-ef|grep$file|grep-Vgrep|awk '{print $}'|Xargs Kill-9; DoneJobs-p|Xargs Kill-9}files=[Email protected]# when the exits, exit all ground process also. #trap"ps-ef|grep tail|grep-v Grep|awk ' {print"' $' "} ' |xargs kill-9"Exittrap"Clean $files"exit# Iterate through the each givenfilenames, for file inch "[email protected]" Do# Show Tails of eachinchbackground. Tail-F $file& Done# wait..untilCTRL +Cwait
    • Crawl the complete Site directory structure with wget and store it in a local directory:
wget " index.html* " http:///hostname/-p/home/user/dirs

Create multiple directories at once:

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

Lists the process trees that include child processes:

PS axwef

Create a war file, like the parameters of the tar ball decompression and compression:

File

Test hard disk write speed using the DD command:

DD if RM -rf/tmp/output.img

Get the MD5 hash of the text:

Echo " text " | Md5sum

Check the XML format:

file. xml

Extract the tar.gz into the new directory:

tar ZXVF package. tar. Gz-c New_dir

Get HTTP header information using curl:

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

To modify the timestamp (YYMMDDHHMM) of a file or directory:

Touch 0712250000 file

To perform an FTP download with the wget command:

wget FTP://Username:[email protected]

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

tr -dc _a-z-a-z-0-9head -c${1:-+}; Echo;

To quickly back up a file:

CP SOME_FILE_NAME{,.BKP}

To access the Windows shared directory:

" Domain\User " // Dc.domain.com/share/test/dir

The command in the execution history (here is line 100th), Ksh supports the operation of the turn command of Class VI, bash generally supports up and down:

!  -

Unzip and compress (Zip compressed original file is pressed in, different from tar):

Unzip Package_name. zip -D dir_name
Zip package_name.zip files

Enter multiline text (CTRL + D to exit, or specify an exit string):

Cat > TT
Cat > TT < EOF

Create an empty file or empty an existing file:

File

command to synchronize time:

Ntpdate Your_sync_server_name

Display all TCP4 listening ports with netstat:

The netstat command-n denotes a pure digital display,-T for the TCP protocol,-U for the UDP protocol, and-L for listening

awk ' {print $4} ' Cut grep ' [0-9]* '

Run the file repeatedly, showing its output (by default, 2 seconds):

PS -ef

List of all users, group user list:

cat /etc/passwdcat /etc/group

Mount a user in read/write mode:

Mount -o REMOUNT,RW/

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

Mount --bind/source/destination

Dynamically update DNS server:

86400 A $IP send EOF

Recursive grep all directories, and the Find command works with the same effect:

grep " Some_text " /path/to/dir

List the top 10 largest files:

awk ' {if ($7 > 1048576) print $7/1048576 "MB" $9} ' Sort Tail

Show remaining memory (MB):

If it is a UNIX environment, you can use the Vmstat or TOPAS command to view it

 Free grep awk ' /[0-9]/{Print $4 "MB"} '

Find all the empty empty directories under/home/user:

Find 1 -type d-empty

Get the contents of the 第50-60 line in the Test.txt file:

sed ' 50,60p '

Append text to a file in case you need to elevate permissions:

Echo " some text " sudo Tee -a/path/file

List all kill signal parameters:

Kill -L

Prohibit logging of the last session in bash history:

Kill -9 $$

Nmap scans the network for open ports:

8081 172.20. 0.0/ +

Move all files with "TXT" in the file name into the $home directory:

Find " *txt* " Xargs MV -V $HOME

Display the file in rows and lines:

Paste Test.txt Test1.txt

The progress bar in the shell:

PV Data.log

Use Netcat to send data to Graphite server:

Echo " hosts.samplehost ' Date +%s ' " 192.168. 200.2  the

Convert tabs to spaces:

Expand Test.txt > Test1.txt

Skip Bash History:

< space >cmd

Go to the previous working directory:

CD-

Split the large volume of tar.gz files (each 100MB), and then merge back:

Split Cat files* > Archive

Use curl to get the HTTP status code:

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

When CTRL + C is not good to make:

Ctrl + \

Get file Owner:

Stat file. txt

Block Device list:

Lsblk-f

Find files with spaces at the end of the file name:

Find Egrep "  +$ " {} \;

Find file with tab indent in file name

Find Egrep -L $'\ t' {} \;

Print the horizontal line with "=":

' %100s\n ' TR ' ' =

Linux Shell Common Command Manual (Updating)

Related Article

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.