Check to see if the remote port is open to bash:
Copy Code code as follows:
echo >/dev/tcp/8.8.8.8/53 && echo "Open"
To get a process into the background:
Copy Code code as follows:
To move a process to the foreground:
Copy Code code as follows:
Produces a random hexadecimal number where n is the number of characters:
Copy Code code as follows:
Execute a command in a file in the current shell:
Copy Code code as follows:
Source/home/user/file.name
Intercept the first 5 characters:
Copy Code code as follows:
SSH Debug Mode:
Copy Code code as follows:
SSH with PEM key:
Copy Code code as follows:
SSH user@ip_address-i Key.pem
Use wget to crawl the complete site directory structure and store it in the local directory:
Copy Code code as follows:
Wget-r--no-parent--reject "index.html*" http://hostname/-p/home/user/dirs
Create multiple directories at once:
Copy Code code as follows:
Mkdir-p/home/user/{test,test1,test2}
Lists the process trees that include child processes:
Copy Code code as follows:
To create a war file:
Copy Code code as follows:
To test hard drive write speed:
Copy Code code as follows:
DD If=/dev/zero of=/tmp/output.img bs=8k count=256k; Rm-rf/tmp/output.img
Test hard drive Read speed:
Copy Code code as follows:
Gets the MD5 hash of the text:
Copy Code code as follows:
Check XML format:
Copy Code code as follows:
To extract the tar.gz into a new directory:
Copy Code code as follows:
Tar zxvf package.tar.gz-c New_dir
To obtain HTTP header information using curl:
Copy Code code as follows:
Curl-i http://www.example.com
To modify a file or directory timestamp (YYMMDDHHMM):
Copy Code code as follows:
To perform FTP downloads with the wget command:
Copy Code code as follows:
Wget-m Ftp://username:password@hostname
Generate a random password (in the example 16 characters in length):
Copy Code code as follows:
Lang=c </dev/urandom tr-dc _a-z-a-z-0-9 | Head-c${1:-16};echo;
To quickly back up a file:
Copy Code code as follows:
To access the Windows shared directory:
Copy Code code as follows:
Smbclient-u "Domain\User"//dc.domain.com/share/test/dir
Execute the commands in the history (this is line 100th):
Copy Code code as follows:
Extract:
Copy Code code as follows:
Unzip package_name.zip-d Dir_name
Enter multiple lines of text (CTRL + D exit):
Copy Code code as follows:
To create an empty file or empty an existing file:
Copy Code code as follows:
Sync time with Ubuntu NTP server:
Copy Code code as follows:
Display all TCP4 listening ports with netstat:
Copy Code code as follows:
Netstat-lnt4 | awk ' {print $} ' | Cut-f2-d: | Grep-o ' [0-9]* '
Qcow2 Mirrored file Conversion:
Copy Code code 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, displaying its output (default is 2 seconds):
Copy Code code as follows:
All Users list:
Copy Code code as follows:
Mount root in Read/write mode:
Copy Code code as follows:
Mount a directory (this is the case where links are not available):
Copy Code code as follows:
Mount--bind/source/destination
To update DNS server dynamically:
Copy Code code as follows:
Nsupdate < <eof
Update add $HOST 86400 A $IP
Send
Eof
Recursively grep all directories:
Copy Code code as follows:
Grep-r "Some_text"/path/to/dir
List the top 10 largest files:
Copy Code code as follows:
Lsof/| awk ' {if ($ > 1048576) Print $7/1048576 MB ' $} ' | Sort-n-u | Tail
Show remaining memory (MB):
Copy Code code as follows:
free-m | grep Cache | awk '/[0-9]/{print $ MB '} '
Open vim and skip to end of file:
Copy Code code as follows:
Git clone Specifies branch (master):
Copy Code code as follows:
git clone git@github.com:name/app.git-b Master
Git switches to another branch (develop):
Copy Code code as follows:
Git Delete Branch (myfeature):
Copy Code code as follows:
Git Deletes a remote branch
Copy Code code as follows:
git push origin:branchname
Git pushes the new branch to the remote server:
Copy Code code as follows:
Git push-u origin mynewfeature
Print last Cat command in history:
Copy Code code as follows:
The last cat command in the Run history:
Copy Code code as follows:
Find all the empty directories under/home/user:
Copy Code code as follows:
Find/home/user-maxdepth 1-type D-empty
Get 第50-60 line contents in Test.txt file:
Copy Code code as follows:
< Test.txt sed-n ' 50,60p '
Run the last command (if the last command is Mkdir/root/test, the following will run: sudo mkdir/root/test):
Copy Code code as follows:
Create temporary RAM file System –ramdisk (create/tmpram directory first):
Copy Code code as follows:
Mount-t Tmpfs Tmpfs/tmpram-o size=512m
Grep whole words:
Copy Code code as follows:
Append text to a file when elevated permissions are required:
Copy Code code as follows:
echo "Some text" | sudo tee-a/path/file
List all kill signal parameters:
Copy Code code as follows:
To prevent the last session from being logged in bash history:
Copy Code code as follows:
Scan the network for open ports:
Copy Code code as follows:
Nmap-p 8081 172.20.0.0/16
Set up git email:
Copy Code code as follows:
git config--global user.email "me@example.com"
To-sync with master If you have unpublished commits:
Copy Code code as follows:
Git pull--rebase Origin master
Move files containing "TXT" in all file names into the/home/user directory:
Copy Code code as follows:
Find-iname "*txt*"-exec mv-v {}/home/user \;
To display files in line by row:
Copy Code code as follows:
The progress bar in the shell:
Copy Code code as follows:
Use Netcat to send data to Graphite server:
Copy Code code as follows:
echo "Hosts.samplehost ' date +%s '" | NC 192.168.200.2 3000
Convert tabs to spaces:
Copy Code code as follows:
Expand Test.txt > Test1.txt
Skip Bash History:
Copy Code code as follows:
Go to the previous working directory:
Copy Code code as follows:
Split a large volume of tar.gz files (each 100MB), and then merge back:
Copy Code code as follows:
Split–b 100m/path/to/large/archive/path/to/output/files
Cat files* > Archive
Use Curl to get HTTP status code:
Copy Code code as follows:
Curl-sl-w "%{http_code}\\n" Www.example.com-o/dev/null
Set root password to enhance MySQL security installation:
Copy Code code as follows:
/usr/bin/mysql_secure_installation
When the CTRL + C is bad:
Copy Code code as follows:
Get file Owner:
Copy Code code as follows:
Block Device list:
Copy Code code as follows:
Find a file with spaces at the end of the file name:
Copy Code code as follows:
Find. -type f-exec egrep-l "+$" {} \;
Find a file with a tab indent file name
Copy Code code as follows:
Find. -type f-exec egrep-l $ ' t ' {} \;
Print a horizontal line with "=":
Copy Code code as follows:
printf '%100s\n ' | TR ' =