99% all the Linux commands the Ops people need

Source: Internet
Author: User
Tags parent directory


1 Landing and switching machine


Shutdown

Halt

Poweroff

Init 0

Restart

Reboot

Init 6

Shutdown

Shutdown-r restart

Shutodwn-h shut down the machine

Shutdown-c canceling a scheduled shutdown

Shutdown +0 shut down now.

+1 shut down after one minute.

-X × minutes after shutdown

20:00 Today 20:00 shutdown

WHOAMI Displays the current login user name

Who am I displays the current logon user name Terminal name logon time

WHO displays all currently logged-in User name Terminal name logon hours

W Displays all currently logged-in User name Terminal name logon time the source of the login is currently doing what


2. Switch user to current working directory


su– User name Switch user, and switch to user home directory

SU User name non-login switch user

CD relative or absolute path into the directory

-P If the destination directory is a soft-link directory, go directly to its source directory

.. Go to the top level directory

CD into home directory

CD ~ or direct CD into home directory

cd– into the last working directory

PWD Gets the current directory path


3. Basic common commands


Date Gets the system time

Date-s "2018-1-20 13:50:11" set the system time

Hwclock or clock gets atomic time

-S writes hard time to soft time.

-W writes soft time to hard time.

Cal Get Calendar

History gets the historical record of the command

Hostname Get Host Name

Interrupt command

CTRL + C Force interrupt

Ctrl+d Normal Interrupt


4. Help command document Query


Type used to determine the types of commands

Enable management displays internal commands

Enable command to disable internal commands

Enable-n command activates an internal command that has been disabled

Help internal command

External command Help

To view the help information for a specified command

Whereis command view the path to the commands (External command) and the path to the Help document

Which command to view the commands path

Man retrieve command Help document

5. File Query


LS lists the contents of the directory

LS lists the contents of the directory

-A lists all files (including hidden files)

-a lists all files that contain hidden files but do not contain. and. )

-L long list (that is, display attribute information)

-R recursion

-ld viewing the properties of a specified directory

-1 Vertical display

Stat file name

View the detailed properties of a file, including three timestamps.

File file path to determine the type of files

-B displays only the identification results and does not display the file name

-F file path identifies the files in the file according to their contents

Cat file name view file contents

Vim file name view and edit file


6. Create a new file, move, copy, delete files


Touch NewFile Create an empty file

Three timestamps of touch oldfile update files

Touch-a oldfile update files for atime and CTime

Touch-m oldfile update files for Mtime and CTime

Touch-t 201802122021.59 Fstab

Touch-c NewFile If the file exists, update the timestamp if there is no

Mkdir

-P creates a multi-level directory at once, regardless of whether the parent directory exists.

-V displays information when created

-M mode to specify permissions directly when created

RmDir Deleting an empty mesh

CP SRC DST is copied file path new file or overwritten file path

-I overlay prompt

-R recursive, can copy directory

–preserv=mode permissions are not changed

–preserv=owner permissions and ownership relationship unchanged

–preserv=timestamp time does not change

–preserv=all Above all changes

-P equals –preserv=mode,owner,timestamp when copy is preserved, time is constant

-D Copy Soft links

-V shows the replication process

-A above all

-F when DST already exists, but the current user does not have the W permission, can not be directly overwritten, if the current user has WX permission to the directory to create and delete files, then, with-F, the file will be deleted first, and then create a new file, and then fill the content with the SRC consistent.

MV SRC DST

If DST does not exist, it is renamed.

-I if DST already exists, ask whether to overwrite

-F cancels out the role of-I, directly overwrites, does not inquire

RM Delete

RM file Name

-I asks whether to delete

-F cancel out the role of-I, directly delete, do not ask

-R recursion, delete directory

LS |xargs RM-RF When the number of deleted files is too large, exceeding the number of supported parameters can be removed with the pipe and xargs.

–no-preserve-root


7. Text Processing commands


Tr

[Set1] [Set2 converts set1 to set2,set1 more bits than Set2, the number of digits is converted to the last of the Set2, such as TR ABCD EF, which is a-turn-to-E,BCD, and turns to F

-d [Set1] Delete Set1 characters

-c [Set1] [Set2 other characters except Set1 are converted Set2 (newline character will also be transferred)

-CD [Set1] removes characters other than Set1

-S [Set1] converts a continuous repetition of a character to a

Cut-d delimiter (can only be a single character)-F take which column file name

The-output-delimiter= delimiter represents the delimiter for the output. Default to original file delimiter

-fn,m or-fn-m

-cn,m or-CN,M-CN

Sort

-T delimiter

-K Sort by the first column of the delimiter

-N Sort by number

-R Reverse Order

-U Remove Duplicates

-F ignores case

Uniq to Heavy

Uniq remove consecutive rows of duplicates, leaving only one row

-U removes consecutive rows of duplicates, without preserving

-D displays only duplicate rows, removing non-repeating rows

-C Displays the number of repetitions before the results are displayed


8. Regular expression grep and sed


Grep

–color=auto keyword highlighting

-V Reverse Selection

-N Display Line number

-C Displays the number of matching rows

-I ignores case

-Q Silence

-a n Displays the keyword and its next n rows

-B n Displays the keyword and its top n rows

-c n Displays the keyword and its top and bottom n rows

-E: Implementing a logical or relationship between multiple options

-W: Matches entire word

-E or egrep using the extended regular

-F or Fgrep do not use regular

Sed

-I change the original file

-i.bak back up the original file to. bak before you change it

-N Do not print

-E Multi-mode

-f Sed.txt Specifying scripts files

-R Specify extended regular

P Printing

D Delete

A increases after the specified line

I increase before the specified line

C replaces the specified line

W writes the lines of the pattern space to the specified file

R reads the contents of the file into the mode space

=: Prints line numbers for lines in pattern space

!: matching row in pattern space reverse processing

Marco Linux OPS trainee Daishitong

This article is from the "Marco Linux Training" blog, so be sure to keep this source http://mageedu.blog.51cto.com/4265610/1964655

All Linux commands required by the 99% Ops people

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.