Linux Command Personal Summary

Source: Internet
Author: User

mkdir make directories Create an empty directory

Parameter-P recursive creation

Example: mkdir test.txt

CD switch directory CD ~ Home directory (current user) CD: Previous directory to CD-last in the directory

Example: CD/CD ~ CD.

LS Display directory or file

Parameter-a All files (hidden)-D directory-L detailed parameters

Example: Ls-a

VI = Notepad ESC switch to command mode I toggle input mode

command to enter: (Q exit Wq Save exit =x q! Force not to save exit wq! Force save exit)

Display lines: Set NU dd Delete when line yy copy when line P sticky line number +gg Navigate to the line shut+g locate file end GG to file header

VI test.txt

Cat View File contents TAC Reverse output

Parameter-n shows the number of rows

Example:

Cat >>test.txt<<eof multiple row append cat single line with Echo

Ddddddd

Ddddddd

Eof

Append to end > Replace All

CP Copy files or directories

Parameter-a=-dpr-d link-p Modify time and permissions-R recursion

Example: cp-dpr/oldboy/tmp

MV Move file or directory (renamed)

-T

Example: MV Test1.txt test2.txt Test3.txt Oldboy put three in Oldboy

Mv-t/oldboy2 test1.txt Test2.txt Test3.txt put three of them in Oldboy2

RM Delete a file or directory

Parameter-R Recursive Delete-F Force Delete

RM-RF Test.txt

Head shows the file header-N line number

Example: head-10 test.txt display first 10 rows

Tail show file trailing-n line number-F track tail latest changes

Example: tail-10 test.txt display tail 10 lines

Tail-f Test.txt

For-n in ' seq ';d o echo $n >>test.txt;sleep 1;done

grep filters out the content you need

Parameter-V exclusion-E multiple | split-I ignore case

Example: Grep-v test.txt

Sed to take the line

Parameter-n cancels the default output (filtered only)-p print-D Delete

Example: Sed-n 20,30p test.txt 20-30 Lines

Sed-n/^2/p Test.txt begins with 2

Awk's got a bad list.

Awk-f ":" ' {print $} '/etc/passwd to: Split the first $ all

awk ' {if (nr>19&&nr<31) print $} ' test.txt

Alias temporary alias (restart reset) 1: Protection against Misoperation 2: Responsible for command combination string simplification

Example: 1:alias cp= cp-i

2:alias 1= ' echo ' I am Oldboy "'

Permanent aliases: ~/.BASHRC (~ User home directory) or/ETC.BASHRC modified

Which view command path =where is

Find Files or directories

Parameter-type class (f file D directory)-name "ddd" by name-mtime by modified time

Example: Find/-type f-name test.txt

Tree view directory Structure tree/

Xargs is used to give the output of the find/ls to the back processing

SEQ Print sequence Seq5 =echo{1..5}

Parameter-s Specifies the separator

Example: seq-s = 5 seq 1 3 > Test.txt seq >>test.txt

Man query Command usage instructions

Example: Man CP

Touch Create file or modify file timestamp

Touch 1.txt

PWD Displays the current path

History View historical record (command)

Parameter-C clears the-D line number Delete

Example: History-c history-d 2

Diff Compare Text content difference-C context output format

Example: Diff-c 1.txt 2.txt

Useradd adding users

passwd Change Password

Parameter--stdin Modify-S query state-D Delete-L lock-u unlock-f force

Example: passwd--stdin 001

W shows the current logged on user, when to log in, what to do

SU Switch User

Example: su-001 Su-Switch to root

sudo gives normal users root privileges

Example: Normal user, using the front of the command plus SU

Yum Package management tool to resolve RPM package dependencies

Example: Yum-y instll MySQL

RPM Software Installation command General-IVH installation

parameter-I display document-V Display execution procedure-H list tags when installing

Chkconfig View the boot-up software you set up

Parameter--add Add service--del Delete--list list--level run level

Example--add httpd--list mysql--level mysqld on

Netstat Viewing network status

Parameters:-A All-L in Listen-n deny display alias, can digital display converted to a number,-TTCP-UUDP-P program name

Example: Netstat-lntup

Lsof list The process of the currently open file (find who is using the file) (Recover deleted files)

Parameter:-C program name-P pid-u uid or user name ^ take against meaning-I port

Example 1:LSOF/ETC/PASSWD lsof-c Tomcat Lsof-u^root lsof-i:80

Example 2: Check for a process that has not been opened after deleting the file by mistake

# lsof |grep/var/log/messages

SYSLOGD 1283 root 2w REG 3,3 5381017 177364/var/log/messages (Deleted)

# head-n 10/PROC/1283/FD/2 See if previous file contents

CAT/PROC/1283/FD/2 >/var/log/messages

Chattr changing file properties

Parameter + Append Property-Remove attribute = Update Property

A can only add data can not be deleted more for the log system, I can not change any properties and content, more advanced security

Example: Chattr +i/etc/resolv.conf

Lsattr Viewing file properties

Zip compressed file or directory

Parameter:-r recursive-d delete a file in a compressed file-m add to the compressed file----X compress when draining

Example: Zip-r 1.zip./* Compress all contents of the current directory zip 1.zip 1/* Compressed directory 1

Example: zip-d 1.zip 1/1.txt Delete compressed file 1.txt zip-m 1.zip 1/1.txt Add 1.txt

Example: Zip 1.zip 1/*-x 1/1.txt compression directory 1 when ignoring 1.txt

Unzip unzip the zip file

Parameter:-D extract to Where-n does not overwrite the original file-o overwrite the original file-V view content but do not understand the pressure

Example: Unzip-n (or-O) 1.zip-d/tmp unzip-v 1.zip

Tar package file or directory

Parameter:-F name-C package-X unzip-T view-r append Content-Z has gzip-c bz2-u Update-v process

Example: TAR-CF 1.tar. *.jpg to package all JPG files in the current directory

Example: TAR-TF 1.tar view tar-rf 1.tar *.gif append GIP file to 1.zip

Example: TAR-XF 1.tar extract to current directory tar-uf 1.tar 1.jpg update 1.jpg Content

Example: Tar-cvzf 1.tar.gz *jpg package All JPG files in the current directory with gzip compression

Example: TAR-CVJF 1.tar.bz2 *jpg packaging all JPG files in the current directory and compressing them bzip2

Example: Tar-cvzf 1.tar. Z *jpg package All JPG files in the current directory and compress them with compress

Date View or modification time

Parameter:-D Displays the-s setting

Example: date-d "1987-08-15 1000000 seconds" + "%y-%m-%d%h:%m:%s"

Example: Date-s "20160919 01:01:01"





Linux Command Personal Summary

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.