Some common commands for Linux

Source: Internet
Author: User
Tags set time

I am Linux small white, because the project in contact with Linux soon, the collection of some common Linux commands, hope to be useful to the later.

--List the top 100 files in the/var/data directory by a-Z alphabetical order
Ls/var/data |sort|head-100

--List the top 100 files in the/var/data directory sorted by a-Z letter
Ls/var/data |sort-r|head-100

--See if the program Testwatcher is running
PS Aux|grep Testwatcher

--Check if the program Testwatcher is running and exclude itself from this query process
PS Aux|grep Testwatcher | Grep-v grep

--Delete a file or folder (no hint)
Rm-rf/data/testfolder

--View file properties
Stat/data/testfolder.zip

--Compression
Zip-r/data/testfolder1117.zip/data/testfolder
--Overlay Decompression
Unzip-o/data/testfolder.zip

--View Time
Date
--Set the date and time
Date-s "2015-10-10 12:12:12"
--Set time zone
Timedatectl Set-timezone Asia/shanghai

--Reclaim memory
Echo 3 >/proc/sys/vm/drop_caches

--Copy file (clip)
cp/data/new2.csv/data2/xdata/

--RPM Package Installation Command
rpm-ivh/opt/aaaa.rpm

--query which packages have been installed
Rpm-qa

--Shut down immediately
Shutdown-h now

--Unzip the tar.gz format file
Tar-xzvf/opt/1.tar.gz

--Restart
Reboot

--View process status
Ps-x
--View the specifics of a PID (example 4900)
Lsof-p 4900
Cat/proc/4900/status

--Push files (clips) to another machine or to the machine
Scp-r/opt/* 192.168.100.20:/opt/

View Memory
Free-m
Free-h

To view mounted hard disk conditions
Df-ht

--to the directory to execute, can only count the next level of files and folders
LS |wc-l

--Statistics file number and size, max-depth represents the maximum number of layers
Du-sm/opt/data
Du-h--max-depth=1/opt/data

--View CPU, memory and other usage
Top

--Start looking for all text files with a. log extension from the/data directory and find the line that contains "ERROR"
Find/data-type f-name "*.log" | Xargs grep "ERROR"
--Example: start looking for all text files with an. In extension from the current directory and find the line that contains "Thermcontact"
Find. -name "*.in" | Xargs grep "Thermcontact"

Some common commands for Linux

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.