3.Linux Common basic commands

Source: Internet
Author: User
Tags parent directory cpu usage disk usage

1. Help Manual

Mans

--help

2. Date class

Data,cal

Commands for-------------file directory management classes

3. Display the current directory pwd

4.CD Switch Directory

Cd.. Return to Parent Directory

CD/Back To/

CD ~ Return home Directory

Cd/etc/sysconfig through absolute path access (Tab key)

CD./sysconf is returned by a relative path

5.ls

-A lists all files, including hidden files

-l lists the detailed list alias LL

6.grep

To display the contents of the command, according to the following content to show the line content, a bit of filtering feeling it

such as Ls-l | grep xxx

7.mkdir

-P can build a multi-level directory.

Example: mkdir directory Name

8.touch

Create a new file

Example: Touch aa.cnf

9.rmdir Delete an empty directory

Rm

To remove a file or directory

-RF Remove all directory contents recursively, without prompting

11.cp

CP [file to be copied] [where to]

-r recursively Copy entire folder

-V Displays a list of files during replication

12.mv

MV Oldfilename newfilename Rename

Mv/temp/movefile/targetfolder Moving files

-F Force overwrite file, non-empty directory can not overwrite, can only copy and then delete

13.cat

Cat file name View Lightweight text file

-a displays white and line breaks in the file

-N Display Line number

Cat file 1 File 2 connection displays multiple files

Cat file 1 File 2 > File 3 merge as new file

More.

View a longer file

Blank key: Next page

Enter: Next line

Q: Leave more now and no longer display the contents of the file

CTRL + F scroll down one screen

CTRL + B returns to the previous screen

= Output the line number of the current line

: F output File name and line number of the current line

15.less

Similar to more, features more than more

"PageDown": Flip one Page Down

"PageUp": Flip one page Up

/string: Search down the string

? String: Look up this string

N: Repeat the previous search

N: Reverse repeating the previous search

16.tail

Viewing from the tail, more suitable for viewing logs

-F Follow view

The functions shown in-N 200, n can be omitted

17.history

View history Commands

18.echo

Output environment variables

In shell scripts, when SUSTEM.OUT.PRINTLN is used

19. Soft Links

Also known as symbolic links, similar to Windows inside the shortcut, has its own data block, mainly the path of the link to other files

Command ln-s source file or directory name soft link name

Query: Through Ls-l can be viewed, List properties 1th is L, the tail will have a position pointing

------Search to find related commands

19.locate

Find files, query faster, more convenient to use

Need to execute updatedb before running to update file index

20.find

Find files, provide rich fuzzy search and conditional query

Find + search Path + parameters + search keywords

By file name: Find/home/seop-name ' *.txt ' Find the *.txt file under the appropriate directory by name

---------compression and decompression related commands

21.tar

Compressed file (TAR) uncompressed file (TAR)

TAR-ZCVF xxx.tar.gz n1.txt TAR-ZXVF xxx.tar.gz

-C Create a new archive-X to extract files from the archive

-V Show Details-V Show details

-f Specifies the compressed file name-F to specify the file name after compression

-Z Archive via gzip Filter-----Filter by gzip

22.zip

Zip mypackage.zip 1.txt 2.txt compression

Unzip Mypackage.zip Decompression

--------disk partition-related commands

23.lsblk

View all device Mounts

Command: LSBLK or lsblk-f

24.fdisk Partition command

Fdisk/dev/sdb

Start the/SDB partition

M Display command list

P Display Disk Sub = = Fdisk-l

N New Partition

D Delete Partition

W Write and exit

After starting the partition, enter n, add the partition, then select P, and the partition type is the home area.

Two times enter the default all remaining space. Last input w write to partition and exit without saving exit input Q

25.MKFS format Disk

Partition command: Mkfs-t EXT4/DEV/SDB1

Where EXT4 is the partition type

26.mount Mounting

Associate a partition with a directory

Mount Device name Mount directory

Mount/dev/sdb1/newdisk

Unmount device name or mount directory

UNMOUNT/DEV/SDB1 or Unmount/newdisk

Note: Mount on the command line and will fail after reboot

27. Permanent Mount

Implementing mounts by modifying Vim/etc/fstab

Execution mount-a Immediately after add is complete

28.DF du disk condition query

Df-h querying the overall disk usage of the system

DU-H/Catalogue

Querying disk usage for a specified directory

-s Specifies the directory occupancy size rollup

-H with unit of measure

-A With files

--max-depth=1 Sub-Directory depth

-C lists the details and increases the total value of the summary

Du-ach--max-depth = 1/opt

--------Network configuration-related commands

Ifconfig.

View network Configuration

How to modify IP

Graphical operations

Command-line mode Vi/etc/sysconfig/network-scripts/ifcfg-eth0

Refresh Network Settings

Service Network restart

---------Process-related

30.ps

PS is the process that shows the current state in running, and grep means searching in these, and PS aux is showing all processes and their status.

Ps-aux | grep xxx

Ps-ef means that all processes are displayed in a long format

Ps-ef | grep xxx

Note: If you want to see the CPU usage and memory usage of the process, you can use the Aux

If you want to see the process's parent process ID, you can use EF

PID: Each process has a PID as a unique identifier

Kill:kill PID kills the process by uniquely identifying the PID

Killall:kill name kills threads by process name

    

31.service

Registering a standardized process in the system

A convenient and unified management method

Service Name Start/stop/restart/reload/status

To view a service's method/etc/init.d/service name

Set up self-boot with the chkconfig command

View self-starting service chkconfig--list|grep xxx

Chconfig--level 5 Service name on

32.netstat

View the network situation of the system

-an the output in a certain order

-P shows which is in the calling

NETSTAT-ANP | grep 8080 viewing processes that occupy 8080 ports

33.lsof

lsof-i:8080 to see which program the port belongs to

Run level (RunLevel)

 

 

  

  

  

3.Linux Common basic commands

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.