Linux Basic Three

Source: Internet
Author: User
Tags bz2

Cat: View All (cons: Inconvenient to view when there is more content)

Format: Cat [options] File name

Common Command Options

-N: Add a line number before each line

[Email protected] Desktop]# cat-n/etc/passwd

1 Root:x:0:0:root:/root:/bin/bash

2 Bin:x:1:1:bin:/bin:/sbin[em]e188[/em]login

3 Daemon:x:2:2:daemon:/sbin:/sbin[em]e188[/em]login

4 Adm:x:3:4:adm:/var/adm:/sbin[em]e188[/em]login

Less: Split-screen reading (view full content)

Format: less [option] file name

Basic operations

Press PgUp to page forward, PgDn page backward

By? Key forward, press/Backward lookup (N,n toggle)

[Email protected] ~]# LESS/ETC/PASSWD

——————————————————————————————————

Head: Intercept file header

Format: Head-n numeric file name

[[email protected] ~]# head-n 3/etc/passwd (first 3 lines shown)

Root:x:0:0:root:/root:/bin/bash

Bin:x:1:1:bin:/bin:/sbin[em]e188[/em]login

Daemon:x:2:2:daemon:/sbin:/sbin[em]e188[/em]login

————————————————————————————————————————

Tail: Intercepting file tails

Format: Tail-n numeric file name

[[email protected] ~]# tail-n 3/etc/passwd (shown after 3 lines)

Tcpdump:x:72:72::/:/sbin[em]e188[/em]login

Anonymous:x:1000:1000:anonymous:/home/anonymous:/bin/bash

Xxx:x:1001:1001::/home/xxx:/bin/bash

——————————————————————————————————————

Echo: redirect | (;: overwrite redirect, >>: Append redirect)

[Email protected] home]# echo xx >>/home/ls.help

————————————————————————————————————————

|: Pipeline operation (the result of the previous command is treated as a parameter of the following command)

[Email protected] ~]# HEAD-12/ETC/PASSWD | Tail-5

Halt:x:7:0:halt:/sbin:/sbin/halt

Mail:x:8:12:mail:/var/spool/mail:/sbin[em]e188[/em]login

Operator:x:11:0:operator:/root:/sbin[em]e188[/em]login

Games:x:12:100:games:/usr/games:/sbin[em]e188[/em]login

Ftp:x:14:50:ftp User:/var/ftp:/sbin[em]e188[/em]login

——————————————————————————————————————————————

WC: Text Statistics

Format: WC [option] File name

Common Command Options

-L: Calculates the total number of rows of text

-W: Calculates the number of words

-C: Calculate the number of bytes in a file

-M: Count the number of characters

(equivalent to-LWS when there is no option)

————————————————————————————————————————————————

grep retrieves the line of text conditionally

Purpose: Outputs the line containing the specified string

Format: grep [options] ' Find criteria ' target file

Common Command Options

-L: Ignore case when speeding

-V: Reverse lookup, output rows that do not match the find criteria

--color: Highlighting a Find string

Search criteria: Specify a string to find within double quotation marks

^xx: denotes starting with XX

xx$: means ending with XX

^$: Indicates a blank line

[Email protected] ~]# grep-v ' ^$ '/etc/default/useradd

# useradd defaults file

group=100

Home=/home

Inactive=-1

Expire=

Shell=/bin/bash

Skel=/etc/skel

Create_mail_spool=yes

[Email protected] ~]# grep-v ' a '/etc/passwd

Bin:x:1:1:bin:/bin:/sbin[em]e188[/em]login

Sync:x:5:0:sync:/sbin:/bin/sync

(In most Linux configuration files, the part that starts with # represents the comment text)

————————————————————————————————————————————————-

Compression and archiving

Zip compression: A cross-platform compressed file format,

Format: Zip Compressed package Name compressed file

Combine option-R to package a directory

Unzip decompression operation

Format: Unzip [-D destination folder]. zip Archive Package

Tar Production archive

Format: tar [options] archive file, original file or directory

Tar Release archive

Format: tar [options] Archive file [-C target directory]

Common options for the tar command

-C: Create an archive file in. tar format

-X: Unpack the. Tar archive file

-C: Unpacking is the target folder for the specified release

-F: Indicates the use of an archive file

-Z,-J,-J: Call GZIP,BZIP2,XZ compression/decompression, respectively

-V: Output details

-T: List view files in package

(The leading character of the option '-' can be omitted when extracting the archive, the option-z,-j,-j can be omitted, the tar command can automatically identify the package format)

[Email protected] ~]# TAR-ZCF hydra.tar.gz/bin//etc/passwd

Tar: Remove the Beginning "/" from the member name

[[email protected] ~]# ls

anaconda-ks.cfg hydra.tar.gz public Picture Download desktop

home.xx initial-setup-ks.cfg Template Document Music

[Email protected] ~]# TAR-JCF xxx.tar.bz2/bin//etc/passwd

Tar: Remove the Beginning "/" from the member name

[Email protected] ~]# TAR-JCF x.tar.xz/boot/

Tar: Remove the Beginning "/" from the member name

[[email protected] ~]# ls

Anaconda-ks.cfg hydra.tar.gz x.tar.xz public Picture Download desktop

home.xx initial-setup-ks.cfg xxx.tar.bz2 Template Document Music

[Email protected] ~]# TAR-CJF usrsbin.tar.bz2/usr/sbin/

Tar: Remove the Beginning "/" from the member name

Tar: Remove the Beginning "/" from the hard connection target

[Email protected] ~]# TAR-TF usrsbin.tar.bz2

usr/sbin/

Usr/sbin/xfs_copy

Usr/sbin/rtmon

Usr/sbin/build-locale-archive

[Email protected] ~]# TAR-XF usrsbin.tar.bz2-c/root/usrsbin/

————————————————————————————————————————————————

Program and File Lookup

Which: Finding programs

Find: Find the most common search criteria {based on the exact criteria, find by type, find by name, find by size, search by file modification time, process find to file}

Format: Find [Look in] [find criteria]

Common search criteria

-type: Find by File type

-name: Find by file name

-size: Find by File size

-mtime: Search by content modification time (+1,1 days ago, -1,1 days)

F: Normal file

D: Catalogue

L: Connection File

B: Block device files

C: Character device file

[[email protected] boot]# find/root/-type l-exec ls-l {} \; (Displays the link file under the root directory. and show detailed properties)

lrwxrwxrwx. 1 root root 67 May 16:48/root/.mozilla/extensions/{ec8030f7-c20a-464f-9b0e-13a3a9e97384}/[email protected]/usr /lib64/firefox/langpacks/[email protected]

lrwxrwxrwx. 1 root root 6 April 20:18/root/usrsbin/usr/sbin/ctstat-Lnstat

lrwxrwxrwx. 1 root root 5 April 20:17/root/usrsbin/usr/sbin/btrfsck, Btrfs

Locate: File location

Search by keyword

Linux Basic Three

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.