Common Linux Basic commands

Source: Internet
Author: User
Tags bz2 cpu usage disk usage inode usage iptables

1, LS display directory properties

-L: (can also be abbreviated to LL), list display permissions and other properties

-A: Show all files including hidden files, etc.

-D: Lists only the directory itself

2, CHGRP change the group of files belong to

EG:CHGRP Users install.log/

3, Chown Change the owner of the file

Eg:chown Emily Install.log; Chown Emily:users Install.log

-R: Continuous change of import (recursive), that is, all files under sub-login are changed/

4, chmod Modify permissions, r=4,w=2,e=1

Eg: Change the permissions of the. bashrc file back to the-rw-r--r--directive chmod 644. BASHRC or chmod

-R Modify permissions for a folder and its child files

5. CD Conversion Directory

CD represents back to the current user's home directory, equivalent to CD ~

.. Back to the top level directory

. Current directory

~ Home Directory

-Previous directory, previous directory

6. PWD Displays the current directory

-P: Indicates that a true path is displayed, for example Var/mail,mail is a link file, plus-p displays the actual path of mail Var/spool/mail

7, mkdir to create a new directory

-p recursive creation of subdirectories, such as Test/test1/test2; -m do not use default permissions, add permissions when creating directories

8. RmDir Delete an empty directory

-P: Delete Upper Directory

9. CP Replication

10. RM Delete file or directory

11, MV Mobile

12. Cat starts displaying the contents of the file from the first line

13, the TAC starts from the last line to show, you can see the TAC is cat's backwards write!

14, NL display time, by the output line number!

15, more one page of the display file content more file name

SPACEBAR (space): The representative down one page;

? Enter: Represents a downward turn "line";

? /string: Represents the keyword in this display, searching down the "string";

? : F: Displays the file name immediately and the number of rows currently displayed;

? Q: The delegate immediately leaves more and no longer displays the contents of the file.

? b or [ctrl]-b: The representative pages back, but doing so is only useful for files and useless for pipelines.

16, less and more similar, but better than more is that he can page forward, you can use PGUP/PGDN

17, head only a few lines

18, tail only look at the end of a few lines

Eg:tail/etc/man.config display 10 Rows by default

To display 20 rows Tail–n 20/etc/man.config

19, OD read the contents of the file in binary way

20. Touch modify file time or build new file

21. DF Lists the total disk usage of the file system

-H: Displays the size in the form of m/g

-I: Lists the available inode usage and the amount of remaining Df–ih

EG:DF–H/ETC the available disk capacity under/etc is displayed in an easy-to-read capacity format

Df–at lists the format and name of all special files in the system

22, PS View a process situation

Eg:ps–ef|grep Java

23, du list all the files in the current directory capacity

EG:DU–SM/* Check the capacity of each directory under the root directory

24. Gzip Compressed Files

25. Tar Packaging

Eg:tar–cv–f Etc.tar etc packing

Tar–xv–f Ect.tar Unpacking

tar–zpvc–f/root/etc.tar.gz Packaging and compressing

TAR–JPVC–F/ROOT/ETC/TAR.BZ2 Packaging and compressing

Tar–zxv–f/root/etc.tar.gz Unpacking and extracting

TAR–JXV–F/ROOT/ETC.TAR.BZ2 Unpacking and extracting

26, Zip compression

-R recursively compress all files under a subdirectory

Eg:zip Test.zip Test

27, unzip compression

Eg:unzip Test.zip

28, vi Editing files

: wq! Force write

: Set NU Displays line number

: 1, $s/word1/word2/g from the first line to the last line to find word1 and replace Word2

YY copy cursor row, p cursor line paste down, upper case p cursor line paste up

G jumps to the end of the beginning of the character, GG jumps to the first line of characters at the beginning

/word1 the string from the cursor down word1

NDD Delete cursor down n rows

29, RPM Installation

RPM–IVH Package Name

Install multiple software at once RPM–IVH a.i386.rpm b.i386.rpm *.rpm

Install RPM–IVH http://website/path/a.i386.rpm directly from a file on the network

View installation software Rpm–q name Eg:rpm–q zip

-nodeps Ignore dependent installations

Rpm-qa | grep JDK Check if JDK is installed

Rpm–e JDK Uninstall

30. Yum Installation

Yum Install name

-y system automatically gives a Yes response

Yum Remove software Yum remove name

Yum Cleanup cache Yum Clean all

Yum Info name Eg:yum Info Zip lists information about whether the software is installed, name, version, file capacity, etc. (Rpm–qi Zip)

Yum List | grep httpd to see if the httpd is installed

31. Top View memory usage (dynamic)

Q exit (Dynamic)

View Top–u user name by user

Top-h View Thread,-h means one thread at a line

PID: ID of the process
USER: Process Owner
PR: The priority level of the process, the smaller the higher the priority is executed
Ninice: Value
VIRT: Virtual memory consumed by the process
RES: The physical memory occupied by the process
SHR: Shared memory used by the process
S: The state of the process. s for hibernation, R for running, Z for Zombie, n for the process priority value is negative
%CPU: Process Consuming CPU utilization
%MEM: The percentage of physical memory and total memory used by the process
Time+: The total CPU time that is consumed after the process is started, which is the cumulative value of the CPU usage time.
Command: Process start name

32, PS viewing process (a point in time, static)

View a process situation ps–ef|grep Java

PS XH View all existing threads

PS-MP PID View the number of threads from a process

33. Free observation of memory usage

34, Netstat–anp|grep ' 80 ' view 80 port occupancy Netstat-nlpt|grep 80

NETSTAT–ANP | grep MySQL Viewer port

35. lsof–i:3306 View Port occupancy

36. System Service Related commands

Chkconfig--list View all system services
Chkconfig iptables off boot does not start the service
Chkconfig iptables on boot does not start the service
Service httpd stop to stop the system services
Service Iptables Start the services
Service Iptables Restart Restart the services

37, redirect > Check out the content copied to the file

For example, Rpm–qa > Test.txt writes the found content to the file Test.txt, this situation if the Test.txt content will be overwritten, if you do not want to overwrite the available two > such as Rpm–qa >> test.txt

Redirects can also be used to copy files, test.txt >> test01.txt text.txt content added behind Text01.txt original content

38, Date + '%y%m%d%h:%m:%s ' get system Current time

39, Su Switch identity

40. Sudo execution

41. Backstage Run Jmeter:nohup Jmeter-server &

Common Linux Basic commands

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.