Linux Common commands

Source: Internet
Author: User
Tags bz2

1. Directory Processing commands

1,ls

① Command English original: list

② Command path:/bin/ls

③ Execute permissions: All Users

④ function Description: Display directory file

⑤ syntax: LS [options] [file or directory]

-A (all) displays all files, including (".") opening) hidden files

- L (long) details display

- D View Directory properties

- h humanized display

-I displays the inode number for each node

-rw-r--r--. 1rootroot 8470 Oct 04:56 Install.log

①-: File Type (-: binary file, D: directory, L: Soft link file)

②rw-r--r--: File permissions (r: Read, W: Write, x: Execute)

Each 3 is a group, the first group: Owner permissions, second group: All group permissions, Group Three: Other people permissions

③ 1: Number of hard links pointing to the file

④root: Owner

⑤root: Owning Group

⑥8470: File Size

⑦oct 15 04:56: Last Modified time

⑧install.log: File name

2,mkdir

① Command English original meaning: make directories

directory where the ② command is located:/bin/mkdir

③ Execute permissions: All Users

⑤ function Description: Create a new directory

④ syntax: mkdir [options] [directory name 1][directory name 2][directory name n]

- P: recursive creation

When no option is added, the directory is not recursively created by default, so the/tmp/test/testmkdir directory cannot be successfully created without/tmp/test the directory exists.

With the-p option, which means that the directory is created recursively, this command recursively creates the/tmp/test directory and/tmp/test/testmkdir directory if no/tmp/test directory exists

mkdir can create multiple directories at the same time, just separate multiple directory names with spaces in the parameters

3.CD

① Command English original meaning: Change directory

directory where the ② command is located: Shell built-in commands

③ Execute permissions: All Users

④ function Description: Switch directory

⑤ Syntax: CD [catalogue]

Cd.. : Represents the switch to the previous level of the current directory

4.pwd

① Command English original: Print working directory

directory where the ② command is located:/bin/pwd

③ Execute permissions: All Users

④ function Description: Show current directory

⑤ Syntax: pwd

5,rmdir

① Command English original meaning: remove empty directories

directory where the ② command is located:/bin/rmdir

③ Execute permissions: All Users

④ function Description: Delete empty directory

⑤ syntax: rmdir [Catalog]

6.CP

① Command English original meaning: copy

② Command path:/BIN/CP

③ Execute permissions: All Users

④ function Description: Copy files or directories

⑤ syntax: CP [option] original file or directory 1[original file or directory 2][original file or directory N] destination directory

- R: Copy Directory

- P: Preserve file attributes

cp: Copy files without the option.

cp-r: Copy Directory

cp-p : Copying files and preserving their file attributes

Copy multiple files at the same time (be sure to specify the destination directory at the end)

Cp/root/anaconda-ks.cfg/root/install.log.syslog/tmp

Copy and modify directory names using Cp-r:

Cp-r/tmp/test/test2/tmp/rename

Copy and modify the file name:

Cp/tmp/install.log/tmp

6,MV

① Command English Intent: move

② Command path:/BIN/MV

③ Execute permissions: All Users

④ function Description: Cut file, rename

⑤ Syntax: MV [original file or directory] [target directory]

* Renaming: Original and target files in the same directory

7,RM

① Command English Original: remove

② Command path:/BIN/RM

③ Execute permissions: All Users

④ syntax: rm-rf [file or directory]

- r Delete directory

- F Force Delete

⑤ function Description: Delete files or directories

2. File Processing command

1.Touch

① Command path:/bin/touch

② Execute permissions: All Users

③ syntax: touch [filename]

④ function Description: Create an empty file

Touch creates multiple files "separated by spaces":

Touch TestToch1 TESTTOUCH2

Touch create file name with spaces "double quotes":

Touch "Program Files"

2.Cat

① Command path:/bin/cat

② Execute permissions: All Users

③ syntax: cat [filename]

④ function Description: Display file contents

-N: Show line numbers

3.TAC

① Command path:/USR/BIN/TAC

② Execute permissions: All Users

③ syntax: TAC [filename]

④ function Description: Display file contents (reverse list)

4, more

① Command path:/bin/more

② Execute permissions: All Users

③ syntax: more [filename]

(space) or F: Page turn

(Enter): line break

Q or Q: Exit

④ Function Description: page displays the contents of the file (cannot page up)

5. Less

① Command path:/usr/bin/less

② Execute permissions: All Users

③ syntax: less [filename]

④ Function Description: page displays the contents of the file (can page up)

(space) or F: Page Down

(Enter): Wrap Down

(PageUp): Page Up

(↑): Line up

/: Find (/+ Find content + "enter")

N: Look down

Q or Q: Exit

6.Head

① Command path:/usr/bin/head

② Execute permissions: All Users

③ syntax: head [filename]

④ function Description: Displays the first few lines of the file

-n Specifies the number of rows (10 rows are displayed by default if the-n parameter is not executed)

7,tail

① Command path:/usr/bin/tail

② Execute permissions: All Users

③ syntax: tail [file name]

④ function Description: Displays the following lines of the file

-N: Specify the number of rows (10 rows By default if the-n parameter is not executed)

-F: Dynamic display of File end content

8,Ln

① Command English original meaning: link

② Command path:/BIN/LN

③ Execute permissions: All Users

④ Syntax: ln [original file] [target file]

-S: Create soft links (do not add parameters to create hard links)

⑤ function Description: Generate link file

3. Rights Management Commands

1,chmod

① Command English Original: Change the permissions mode of a file

② Command path:/bin/chmod

③ Execute permissions: All Users

④ syntax: chmod [{ugoa}{+-=}{rwx}] [file or directory]

[Digital Permissions] [File or directory]

-R Recursive modification

⑤ function Description: Change file or directory permissions

* Only the file or directory "owner" or "root user" can modify the permissions of the current file or directory

*u: Owner, G: Owning group, O: Others, A: everyone

* Digital rights: R (Read): 4,w (Write): 2,x (Execute): 1

Example: chmod 755/tmp/test (File permissions modified to: Rwxr-xr-x)

* Delete this file only if you have write access to the directory where the file is located

2, chown

① Command English Original: Change file ownership

② Command path:/bin/chown

③ Execute permissions: All Users

④ syntax: chown [user] [file or directory]

⑤ function Description: Change the owner of a file or directory

⑥ Example: Chown yonghu/tmp/test (Change the owner of the file/tmp/test to Yonghu)

* Only the root user can change the file owner

* The specified user must be a user present in the system

3,chgrp

① Command English Original: Change file group ownership

② Command path:/BIN/CHGRP

③ Execute permissions: All Users

④ syntax: chgrp [user Group] [file or directory]

⑤ function Description: Change the owning group of a file or directory

⑥ Example: Chgrp yonghuzu/tmp/test (change file/tmp/test belongs to group Yonghuzu)

4,umask

① Command English original: the User file-creation mask

② command path: Shell built-in command

③ Execute permissions: All Users

④ syntax: umask [-S]

-S Displays the new file default permissions in rwx form

⑤ function Description: Display, set default permissions for files

* Use Touch to create a new file with no executable permission (equivalent to the default permission to remove all enforceable permissions)

* Default permissions: U=rwx,g=rx,o=rx, new file permissions: rw-r--r--

* When setting default permissions, set the value to 777 minus the default permission value for the desired setting

* Default permissions you want to set: U=rwx,g=rx,o=r (754) "777-754=023"

* Execution command: umask 023

"No Modification recommended"

4. File Search command

1.Find

① file path:/bin/find

② Execute permissions: All Users

③ syntax: Find [Search Range] [match condition]

④ function Description: File search

⑤ Common options:

-name: Search by file name (-iname not case-sensitive) "Wildcard characters supported"

"*": matches any character

Example: Find/etc-name *init*

”?“ : Matches a single character

Example: Find/etc-name init???

-size: Search by File size (unit: Data block "1 database =0.5k")

+n: Greater Than

-N: Less than

N: Equals

Example: Find/-size +204800 (find files larger than 100M)

-user: Search by Owner

-group: Search by owning group

-type: Search by file type

F: File

D: Catalogue

L: Soft Connection file

-inum: Search by I node

-exec/-ok command {} \; : Performing actions on search results

Search by Time attribute:

-amin Access Events (Access)

-cmin file attributes (change)

-mmin file contents (odify)

+n:n minutes or more

Within-n:n minutes

Example: Find/etc-cmin-5 (Find files and directories with properties modified within 5 minutes in/etc)

Connection properties:

-A: two conditions simultaneously satisfy

-O: Two conditions to satisfy any one

Example: Find/etc-size +163840-a-size-204800 (find files larger than 80MB less than 100MB in/etc)

2,locate

① Command path:/usr/bin/locate

② Execute permissions: All Users

③ Syntax: Locate file name

④ function Description: Find files in the file repository

UpdateDB: Update file repository (files in/TMP are not included in the file repository)

3,which

① Command path:/usr/bin/which

② Execute permissions: All Users

③ syntax: which command

④ function Description: Search the directory of the command and alias information

4,Whereis

① Command path:/usr/bin/whereis

② Execute permissions: All Users

③ syntax: whereis [command name]

④ function Description: Search command directory and help document path

5.grep

① Command path:/bin/grep

② Execute permissions: All Users

③ syntax: grep [Specify string] [file]

④ function Description: Search the file for string matching lines and output

-I: Case insensitive

-V: Excludes specified strings

5. Help command

1, man

① Command English original meaning: manual

② Command path:/usr/bin/man

③ Execute permissions: All Users

④ syntax: Man [command or config file]

⑤ function Description: Get help information

You do not need to fill in the absolute path when viewing the configuration file, only the file name

2,Whatis

① Syntax: Whatis command

② function Description: View command Brief information

3,apropos

① syntax: Apropos configuration file name

② function Description: View cut SMS for profile

4,--help

① Syntax: Command--help

② function Description: Get help information for the command

5. Help

① command path: Shell built-in command

② Execute permissions: All Users

③ Syntax: Help command

④ function Description: Get help for Shell built-in commands

6. User Management commands

1,Useradd

① Command path:/use/bin/useradd

② Execute permissions: root

③ syntax: Useradd user name

④ function Description: Add new user

2,passwd

① Command path:/usr/bin/passwd

② Execute permissions: All Users

③ syntax: passwd user name

④ function Description: Set User password

Ordinary users can only modify their own password, the root user may modify all user's password

3. who

① Command path:/usr/bin/who

② Execute permissions: All Users

③ syntax: WHO

④ function Description: View logged in user information

4,W

① Command path:/usr/bin/w

② Execute permissions: All Users

③ Syntax: w

④ function Description: View logged in user details

7, Compression decompression command

1.gzip

① Command English original: GUN zip

② Command path:/bin/gzip

③ Execute permissions: All Users

④ syntax: gzip [file]

-D: Uncompressed (equivalent to gunzip)

⑤ function Description: Compress file

⑥ compressed file format:. gz

* Only files are compressed and source files are not preserved

2,gunzip

① Command English original: GUN unzip

② Command path:/bin/gunzip

③ Execute permissions: All Users

④ syntax: gunzip [Compressed file]

⑤ function Description: Unzip the. GZ zip file

3.Tar

① Command path:/bin/tar

② Execute permissions: All Users

③ Syntax:

Ⅰ: Packaging compression

Tar options [-ZCF] [file name after compression] [directory]

-C: Packaging

-V: Show more information

-F: Specify file name

-Z: Pack and Compress ". tar.gz"

-j: Pack and Compress ". Tar. BZ2 "

Ⅱ: Decompression

Tar options [-ZXVF] [Compressed Files]

-X: Unpacking

-V: Show more information

-F: Specifying Compressed Files

-Z: Unzip ". tar.gz"

-j: Unzip ". tar.bz2"

④ function Description: Package, compress, unzip directory

3.Zip

① Command path:/usr/bin/zip

② Execute permissions: All Users

③ syntax: Zip option [-r] [filename compressed] [file or directory]

-R: Compressed directory

④ function Description: Compress files or directories

⑤ compressed file format:. zip

4,unzip

① Command path:/usr/bin/unzip

② Execute permissions: All Users

③ syntax: Unzip [compressed file]

④ function Description: Unzip the. zip file

5,bzip2

① Command path:/USR/BIN/BZIP2

② Execute permissions: All Users

③ syntax: bzip2 option [-K] [file]

-K: Preserves source files after generating compressed files

④ function Description: Compress file

⑤ compressed file format:. bz2

6,bunzip2

① Command path:/USR/BIN/BUNZIP2

② Execute permissions: All Users

③ syntax: BUNZIP2 option [-K] [compressed file]

-K: Preserves source files after decompression

④ function Description: Unzip the. bz2 compressed file

Linux Common 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.