25 Common Linux Basic Commands __linux

Source: Internet
Author: User
Tags bz2 diff file copy lowercase nslookup secure copy

1. Xargs Usage Detailed

 

because many commands do not support | Piping to pass parameters, and there is a need in daily work, there is a xargs command, such as:

find/sbin-perm +700 |ls-l This command is wrong.

find/sbin-perm +700 |xargs ls-l This is the right thing to do.

 

 

2.tar Decompression Command Detailed

-C: Set up compressed Files

-X: Decompression
-T: viewing content
-R: Appending files to the end of a compressed archive
-U: Updating files in original compressed package

These five are independent commands, compression decompression to use one of them, can be used with other commands but only one. The following parameters are optional when compressing or decompressing files as needed.

-Z: With gzip properties
-j: With bz2 properties
-Z: With compress properties
-V: Show All procedures
-O: Unlocking files to standard output

the following parameter-F is required

- F: Use the file name, remember, this parameter is the last parameter, only after the file name

 

tar–zxvf file----compression

tar–cxvf filename file

3.zip

$ zip-r myfile.zip./*

compresses all files and folders in the current directory into Myfile.zip files, and-R represents all files under a recursive compression subdirectory.

4.unzip

$ unzip-o-d/home/sunny myfile.zip

Extract the Myfile.zip file to the/home/sunny/

- o: Overwrite files without prompting;

-d:-d/home/sunny to extract the file into the/home/sunny directory;

5.tcpdump

monitoring packets for a specified network interface

tcpdump-i eth1

If you do not specify a network adapter, the default tcpdump only monitors the first network interface, typically eth0, and the following examples do not specify a network interface.

 

monitoring packets for a specified host

Print all packets entering or leaving the sundown.

Tcpdumphost Sundown

You can also specify IP, such as intercepting all packets received and emitted by all 210.27.48.1 hosts

tcpdumphost 210.27.48.1

print a packet of Helios and hot or communication with Ace

tcpdumphost Helios and \ (hot or ace \)

interception of communication between host 210.27.48.1 and host 210.27.48.2 or 210.27.48.3

tcpdumphost 210.27.48.1 and \ (210.27.48.2 or 210.27.48.3 \)

6.SCP

1. Command format:

SCP [parameters] [Original path] [Target path]

2. Command function:

The SCP is a secure copy abbreviation, and the SCP is a secure remote file Copy command under the Linux system based on SSH login. The SCP commands for Linux can replicate files and directories between Linux servers.

Example 1: Copying files from a distance to a local directory

command:

SCP root@192.168.120.204:/opt/soft/nginx-0.5.38.tar.gz/opt/soft/

7.which

The which command works by searching for the location of a system command in the path specified by the path variable and returning the first search result. That is, by using the which command, you can see whether a system command exists, and which location is executing the command.

Use instance:

Example 1: Finding a file, displaying a command path

command:

which lsmod

which executable file name

8. Locate with the database to view the location of the file.

9.tar

 

Instance:
1 package Compression:
Tar cvf/dir/file.tar/dir/file #仅打包, not compressed
Tar zcvf/dir/file.tar.gz/dir/file #打包后, to gzip compressed
Tar jcvf/dir/file.tar.bz2/dir/file #打包后 to bzip2 compression
Tar zcvpf/dir/file.tar.gz/dir/file #打包后, gzip compressed, and reserve permission information
Tar-n ' 2007/01/15 ' zcvf/dir/file.tar.gz/dir/file #打包压缩比2007/01/15 new file
Tar--exclude/dir1/file1 zcvf file.tar.gz/dir1/*/dir2 #打包压缩dir1和dir2中所有文件, except/dir1/file file1
In fact, those suffixes above, such as the T parameter description:
-C: Create a packaging file;
-X: Unpack a packaged file;
-T: View the files inside the tar package;
-Z: After packaging with gzip compression, generate. tar.gz files;
-J: After packing with ZIP2 compression, generate. tar.bz2 file;
-V: Displays files during compression;
-F: Use the filename, please note that after the F to immediately receive the filename, do not add other parameters;
-P: Keep the original file properties;
-P: Use absolute path to compress; ar,tar.gz and so on, we can omit, as long as you know in what format compressed on the line, or you can not decompress

Extract:
Tar xvf Backup.tar
Tar zxvf/dir/file.tar.gz
Tar Zxvf/dir/file.tar.z
Tar jxvf/dir/file.tar.bz2
Tar jxvf/dir/file.tbz

10.find

example of find common usage in Linux

Find Path-option [-print] [-exec-ok command] {} \;

11.traceroute

traceroute instructions allow you to track network packet routing, the default packet size is 40Bytes, users can set up a separate

traceroute ip| Domain name

12.tree

View the file directory tree

Tree file

13.uname

uname–a: Display system name, node name, operating system release number, operating system version, running system machine ID number

Uname–r Displays the release version number of the operating system

14.date

Show System Time

15.DF

to view the specific usage of a disk

commonly used methods: df–k | Grep–v means%

details of df–th

- h Easy to read mode display

- T file system type

16.grep

- T file system type

-?

displays both the top and bottom of the matching row. Rows, such as: grep-2 pattern filename Displays the top and bottom 2 rows of matching rows at the same time.

-b,--byte-offset

Print the block number in which the line is printed before the matching line.

- C,--Count

prints only the number of rows that match and does not display the matching content.

- F File,--file=file

extracts the template from the file. The empty file contains 0 templates, so nothing matches.

-h,--no-filename

when searching for multiple files, the matching filename prefix is not displayed.

-i,--ignore-case

ignores case differences.

-q,--quiet

suppresses display and returns only the exit status. 0 indicates that a matching row was found.

-l,--files-with-matches

print a list of files that match the template.

-l,--files-without-match

print a list of files that do not match the template.

-n,--line-number

Print the line number before the matching line.

-s,--silent

does not display error messages about the absence or inability to read files.

-v,--revert-match

reverse retrieve, showing only rows that do not match.

-w,--word-regexp

if referenced by \< and \>, the expression is searched as a word.

-v,--version

displays software version information.

Example:

to use a good grep this tool, in fact, is to write a good regular expression, so here is not the grep all the features of the example to explain, only a few examples, explain a regular expression of the wording.

$grep ' KKK './*

searches the current directory for files containing "KKK" strings.

$ ls-l | grep ' ^a '

Filters the contents of the LS-L output through a pipe, showing only the rows that start with a.

$ grep ' test ' d*

Displays the rows that contain test in all files that start with D.

$ grep ' test ' AA bb cc

displays the row that matches test in the aa,bb,cc file.

$ grep ' [a-z]\{5\} ' AA

displays all the lines that contain at least 5 consecutive lowercase characters for each string.

$ grep ' w\ (es\) t.*\1 ' AA

16.wget–chttp:// ...

Power continued transmission

wget–i multiple files to continue downloading

17.route

View routing Table Route–n
[Root@linux ~]# Route del [-net|-host] [network domain or host] netmask [mask] [Gw|dev],

Example:

Route add-net 192.168.20.0netmask 255.255.255.0GW 192.168.10.1

Delete route: Route del-net192.168.20.0netmask255.255.255.0
Parameters to observe:
-N: Do not use the communication protocol or host name directly using IP or port number;
-ee: Use more detailed information to display
Increase (add) and delete (DEL) routing related parameters:
-net: Indicates that the route followed is a network domain;
-host: Represents a route followed by a connection to a single host;
Netmask: Related to the domain, you can set the netmask to determine the size of the network domain;
Gw:gateway, followed by the number of IP oh, and Dev is different;
Dev: If you just want to specify that a network card is connected, use this setting, followed by eth0, etc.

18.nslookup

role is to resolve the domain name view IP

linux under DNS test command

If there is no order to pass

yum-y Install bind-utils

to install include nslookup and dig commands

/etc/hosts: Record hostname corresponding IP address

/etc/resolv.conf: Set the IP address of the DNS server

/etc/host.conf: Specifies the order of domain name resolution (from local Hosts file resolution or DNS resolution)

parameter Description:

You can add the host name or IP to be queried directly after Nslookup, "server" is optional.

if no host name or IP is added after the nslookup, it will enter the Nslookup query function. In the Nslookup query function, you can enter additional parameters for special queries, such as:

Set Type=any: List all the information

set TYPE=MX: Lists MX-related information

19.dig

Dig [@server] [FQDN] [type]

parameter Description:

@server: If you do not want to use/etc/resolv.conf as your DNS host, you can fill in additional IP

Type: The default is to query A records, where you can write other records, such as Mx,ns.

This feature can also be used with [-t type] to handle

# Trace The parsing process of a domain name from the root server

Dig xmgd.com +trace

# View reverse resolution with dig

dig-x210.52.83.228 @server

# The most basic usage of dig

dig @serversina. com.cn.

20.21

ifup Ifdown turn on and off the NIC

ifup eth0

The ifup ifdown are usually stored under/etc/network/interfaces .

22.mount

Mount format mount/dev/cdrom/mnt

23.umount

umount/mnt

the place to view the automatic mount is/etc/fstab

24.passwd

passwd username

25.diff

usually the diff command uses contrasting data or svn,git.

Of course, there are more complex situations, such as "3c3,6", "6d8", which means that line 3rd in the old version of the file is modified to correspond to the 第3-6 line in the new file, which means that line 6th of the old version file is deleted, and the new file is line 8th.

you can specify the diff output format through parameters, and interested authors can try each:

§-e–ed Output to ed command format

§-n–rcs output to RCS command format

§-y output to two-column control mode

§-c Output as context mode diff Options

In addition to the above options, diff's useful options include:

§-r: When the diff parameter is a folder, diff traverses the entire folder to compare files of the same name under the new and old folders

§-w: Ignores all spaces and tabs, and treats all other white-space strings as consistent. For example, if (a = = b) is equal to if (a==b).

§-i: Ignores the case of letters. For example, lowercase A is considered to be the same as capital A.

 

format: Diffa.log c.log > B.patch

diff A.C B.c> B.patch

the contents of the output b.patch are as follows:

5c5

<    //Add code here

---

>     printf ("Hello World");

26.vmstat

The

Vmstat is similar to the top command, except that the data is viewed in a different way

Example:

vmstat 2 1

Vmstat 2

27.lsof

The

checks the process through the service port number, which is typically used to see whether the service starts and ends the process.

Example: lsof–i:8080

 

28.netstat

netstat and lsof are similar, and are primarily used to view the port number

netstat–antp:8980

strong> 

29.init

0: down--,

1: Single User form, Root only to maintain

2: Multiuser, cannot use net file system

3: Full multiple users

5

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.