Basic linux learning (2)

Source: Internet
Author: User
(1) file operations 1. touch create new file and modify timestamp Touch + new file Touch-t201007111500f1 modify f1 timestamp Ll -- time-stylelong full display file time 2. cp option Source File target file option [-r] recursion...

 

(1) file operations

1. Touch creates a new file and modifies the timestamp.

Touch + new file

Touch-t 201007111500 f1 modified f1 timestamp

Ll -- time-style = long full file display time

2. cp option Source File target file

Option [-r] recursive [-f] force [-I] Interactive [-d] copy link [-p] copy permission [-a] = [-dpr]

Ln-s/etc/password ln1 create link ln1 -- "/etc/password (soft link)

Cp-d ln1/boot/qq simply copies the link and does not copy the source file.

Cp ln1/boot/qq copies the source file

Alias viewing aliases unalias canceling aliases can customize aliases

3. you can change the name of an mv cut.

4. View cat tail more less vi [m] head

Head-1 ~ N File display the first few lines (10 by default)

Tail-1 ~ N the last few lines of the file (10 by default)

Head | wc-l wc count l rows

5. delete rm [parameter]-f force-I interaction-r recursion-rf delete non-empty directory

(2) directory operations

1. create mkdir-p (create multi-level sub-directories)-m (permission)

2. delete rmdir (only empty directories can be deleted)

3. view the tree structure of the directory displayed by the tree file name

Ls-l (detailed)-h (easy to read)-a/-A (show all packages hidden)

-T (time sorting)-d (directory attribute)-R (recursion)-S (sorting)-r (reverse order)

(3) file attributes

-File d Directory c character device B block device s socke l link p Channel

(4) permissions

D (indicating directory) owner permission all group permissions other user permissions

2. indicates the number of links to a file when a file is counted, and the number of subdirectories when a directory is used.

Root owner root group

(5) editor

Ed vi (m) gedit (in GUI)

There are three modes for modifying files using vim:

1. command mode: 1) Move the cursor {(H, L, M), Direction Key, (h, j, k, l), G 1 ~ 10G}

2) copy the row yy nyy (n is a specific number)

3) paste p

4) cancel u

5) delete the dd ndd (n is a specific number)

6) save and exit ZZ.

7 )!! Date timestamp

2. insert mode (command mode --> Insert Mode a (original right side) I (current) o (current next line) A (last line) I (first line) O (the previous row of the current row ))

Insert mode -- command mode esc

3. bottom line mode (command line mode -- bottom line mode :)

1) display the row number set nu (set noun)

2) search/string (search down )? String (search up) n (same direction) N (opposite direction)

3) search for and replace row 1, row 2 s (search)/old/new/g (full line replacement)

Example: 1, $ s/o/g

4) save and exit (wq) w/save path as path q! Force exit without saving

Example: w>/root/test append rows 23 to 29 to test.

: R/path read from another file

(6) find Command

Format: find Path option parameter action

Option:-size by size-name-user owner-nouser no owner

-Perm Press permission-exec action-result found by xargs-print displayed on the terminal

-Ctime + n days before change-n days after change

-Atime + 1 day before-1 day

-Type search by type

-Newer is newer than a file.

-Maxdepth

Example: find/-name test-exec mv {}{}. old \;

Find the test file in the root directory and change it to test. old.

Find/-name "*. old" | xargs rm

Search for and delete files ending with. old in the root directory

Chmod modify permission chown modify owner charp Change Group

(7) switch the user's home directory at the same time

Su [space]-[space] user

(8) grep command

Which + command to view the location of the command

Grep standard grep egrep extended grep fgrep quick grep

Grep "based on content" "standard expression"

Grep-n "fds" * search all files containing "fds" in the current directory and add the row number

-C: Search for the number of "fds" contained in the current directory

-- Color = auto search for all files in the current directory containing "fds" and add the color

-Keyword is not included in the v fetch.

-I case-insensitive

(9) regular expression

Grep '\ <'match the beginning of a word'/> 'tail matching' ^ 'matches the beginning of a line' $ 'matches the end of a line

Ll | grep 'f [1-9] 'search f1 ~ Files between f9 are likewise [a-z] [A-Z]

'..' Any character '. *' any character is matched n times

Patt \ {n \} character patt is matched at least n times

\ {M, n} matches at least m times and at most n times

Extended grep [[: upper:] A-Z [[: lower:] a-z [[: digit:] 0 ~ 9

(10) cal and date

Cal calendar date

Date Month Day hour minute year (sequence) change Date

Display format: Date "+ % Y % m % d % H % M % S" year/month/day/hour/minute/second y is the default year

This article is from the "note_book" blog

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.