Common linux commands (for personal use)

Source: Internet
Author: User

After using some commands in linux, I don't remember. Here I will take a note of my linux commands. I hope this article will be helpful to you.

View Disks
Df-h
View the file folder size in the current directory.
Du-sh *

View system cpu
Top and press "1" to view the number of cpu Cores
Free-m to check the memory size.

View the handle occupied by the 2743 thread
/Usr/sbin/lsof-p 2743
/Usr/sbin/lsof-p 2743 | grep del | wc-l: the number of del characters contained in the process-related modules.
Wc is statistics
-L: How many lines?-c: How many characters are contained?

Check the number of handles occupied by threads in the system. And corresponding thread number
/Usr/sbin/lsof-n | awk '{print $2}' | sort | uniq-c | sort-nr | more
View the details of a thread number.
Ps-aef | grep 24204

File Storage path occupied by NO release handle
Log on to cd/proc with the root permission
Ls displays the directories named by all process numbers.
Find the corresponding process to enter
Cd fd
Ls
A flickering file marked as deleted.

Cause of not releasing the handle: The first thread opens the file. Another thread deletes the file. The problem occurs. Kill the entire process to release all handles.

Grep ERROR stdout. log | more-c view ERROR log
Grep ERROR stdout. log. *-c

Obtain the port occupied by a thread
Netstat-anp | grep 13755

Check whether a port is occupied
Netstat-a | grep 14444

The isysearch user can log on to the root user. (Added functions)
Sudo su-root

Log on to mysql
Mysql-u username-p

Vi does not support Chinese characters.
Solution: In the esc status: set encoding = UTF-8
But it can only be used in the current window.
If the user is always valid, the user's home directory must be used again.
Vim. vimrc
Type set encoding = UTF-8.

View host uname-
Reboot

Stress tool thread ps-ef | grep JM


View the number of files in a folder, including files in subfolders.
Ls-lR | grep "^-" | wc-l
View the number of folders in a folder, including those in subfolders.
Ls-lR | grep "^ d" | wc-l

The-I option of grep indicates case-insensitive

Vi to the last line]
Vi jump to the first line [[
Vi jump to the beginning of the line $
Vi jump to the end of the row ^

Df-m is displayed as M
Df-h is displayed as G

Folder Link
Ln-s/home/support/nosql_data # nosql_data points to another directory
Delete
Rm nosql_data

Display the row number when viewing the file
Nl a.txt

Modify the folder owner
Chown-R username/dir: Call dir to the username user.


View disk io
Vmstat 1 100

Ll-t sort by the latest time

Send the variables in ssh to the script for Division calculation. Decimal places are allowed.
A = 2
B = 4
Echo $ a, $ B | awk-F "," '{print $1/$2 }'

Pass the script result to the variable in ssh (included with the 'sign)
L10 = 'grep "$ TODAY" $ FILE_PATH_STROE_GET | wc-l'

Show all restrictions on the host
Ulimit-

 

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.