Linux Common commands collation (partial)

Source: Internet
Author: User
Tags parent directory disk usage file permissions iptables

Linux common commands (partial)

Ready to install the VMware Virtual machine first, install the CentOS image file

1:linux directory structure (partial)

/bin Common system Command directory

/boot Command Directory

/etc configuration file directory

/Home Stores other user directories except the root user

/LIB Store jar Package Directory

/MNT Mount Directory-mount Other hardware

/root Root User's home directory

/tmp Store TEMP Data Directory

/USR General Software installation directory

2: Common directives (part)

View Folder ll

View All Folders Ll-a

View File Contents Cat work01.sh

Edit File VI work01.sh

Switch directories

CD/home Directory

CD ~ Current user's home directory

CD./Current Directory

Cd.. /Parent Directory

Show current working directory PWD

Create folder mkdir aa/bb-p (-P: Add when the AA folder does not exist and needs to create a deep directory)

Create a file Touch A.txt touch {c.txt,d.txt}

Create a with space touch "a Files" delete Rm-rf "a filed"

Recursive copy cp-r Aaa/bb/cc/manba

MV source file or directory destination directory

Rename. txt. txt.bak * Bulk modification of file suffix names

Display file contents Cat [-n] [filename]

-a displays all content, including hidden characters

-N Display Line number

Cat/etc/services

echo Console Prints Something

echo "Hello" > 1.txt write content to file (overwrite)

echo "Hello" >> 1.txt append content to File

Echo ' ll ' >> a.txt will command your content to redirect to the specified file

Tail real-time monitoring files from the tail view data exit Q

Tail-f 1.logs monitoring file when the file is deleted and then created with the same name as the file will monitor

Tail-f 1.logs monitoring files. Monitor interrupt after file is deleted

Create a connection

ln-s [Source file] [destination file] Create a soft link

ln [source file] [destination file] Create a hard link

Ln-s/etc/service./service.soft

Ln/etc/service/service.hard

Soft connection similar to Windows under the shortcut, dependent on the source file, the source file is deleted, the soft connection is invalid, the hard connection is equivalent to re-copy, the source file is deleted, hard connection is not affected

When the source file data changes, whether the soft or hard connection will read the latest content

Find File Contents

Find/etc-name "Init" to find file init in directory/etc

Match the characters in the Find lookup:

*: Match All

? : Matches a single character

Find/etc-name "Init???" In the directory/etc, look for files that begin with Init and have three bits behind them

For fuzzy matching conditions, it is recommended to enclose them in single or double quotation marks. If * is escaped, use single double quotes to enclose the query condition, or use the \*

grep searches the file for string-matched rows and outputs

Syntax: grep [-CINV] ' search string ' filename

-C: Output matches the number of rows (in the unit of behavior, not in occurrences)

-I: Case is ignored, so case is considered the same

-N: Display matching lines and line numbers

-V: Invert selection to display all lines that do not contain matching text

Package Compression:

TAR–ZCVF compression

TAR–ZXVF Decompression

tar [-ZCF] Compressed file name file or directory

TAR-CZVF ya1.tar.gz./2018-04-02

Package 2018-04-02 folder compression into ya1.tar.gz

TAR-XZVF ya1.tar.gz-c./hehehe

Unzip the compressed file into the hehehe directory

Reboot restart System

VI Text Editor

VI Hello.java-----> Command line----i a o---> Edit----> ESC----> Go to the command line

: wq! Force Save exit

: q! Forced exit

YY copy Current line 3yy copy three rows from current line

DD cut the current line 3DD cut 3 rows from the current line

P Paste

Shift+zz Save and exit

CTRL + Z hangs the program in the background----FG Sequence number

CTRL + C to end the current process: q!

Command mode

G jumps to the last line

GG First Line

/string N Find Next

:%s/oldstr/newstr/g Global Substitution

View the port situation on this computer

NETSTAT-LTNP | grep 8080 Viewing the 8080 port condition of this machine

-A all displays all connections and listening ports

-T (TCP) displays only TCP-related options

-U (UDP) displays only UDP-related options

-N Displays the address and port number in a digital manner

-L (Listening) indicates listening

-P indicates port

Modify Host Name

1: Temporarily modify hostname host name

2: Permanently modify Vi/etc/sysconfig/network

modifying domain names and IP mappings

Vi/etc/hosts

View Linux process boot status

PS-EF View all processes on this machine

Ps-ef | grep needs to query the process to search for the specified process

Kill-9 process Number (PID) force kill process

Common network commands

Service iptables Status View firewall state

Service iptables Stop/start Firewall Start-up or stop

Chkconfig iptabales off on firewall boot or off

Firewall does not start

Iptables-f

Service Iptables Save

Service Iptables Restart


Syntax: DF [-hkam] [Mount Point]

-H (human-readable) displays KB,MB,GB in an easy-to-read manner based on disk space and usage
-K displays information for each partition in kilobytes, by default

-m displays information in megabytes
-a show all partitions including partitions of size 0

View the status information for the Linux file system, showing the capacity, usage, unused amount, and mount point of each partition. See the rest of the space

Syntax: du [-ABHS] [file name directory]

-a displays the size of the child file

-H displays KB,MB,GB in an easy-to-read manner

-S summarize statistics total occupancy

Used to view the size of a file or directory (disk usage space)

free [-KMG]

View memory and swap space usage status

-K: Displayed in kilobytes, default is in KB

-M: Displayed in megabytes

-G: Displayed in GB

Cleanup Cache command:

Echo 1 >/proc/sys/vm/drop_caches

File permissions

Modify file Permissions

Chmond 777 File name

R: The eight-digit number that corresponds to the permission to read the folder is 4

W: the octal number corresponding to the Write permission is 2

X: the octal number corresponding to the permission performed is 1

The number that corresponds to the RWX permission is: 4+2+1=7s

Time to modify the system

Date

Ntpdate (if not installed from Yum)

Ntpdate 0.asia.pool.ntp.org Time Synchronization

Date + "%y-%m-%d%h:%m:%s"

Date-d "+1 Day" + "%y-%m-%d%h:%m:%s"

Date-d "-1 day" + "%y-%m-%d%h:%m:%s"

PS: The article part of the content reference online, just quite with do a collation, if there is the wrong place, welcome to point out, in addition, I hope to start Linux friends have a little help, thank you!

Linux Common commands collation (partial)

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.