Basic Bash Shell command--1

Source: Internet
Author: User

1.man

Access the manual pages stored on your Linux system. You can use the Man command to view a command.

Eg:man ls man Mans

2.cd

Switch directories. The path to the directory has an absolute path and a relative path.

EG:CD. Switch to upper-level directory

CD example Switch to example directory (with relative file path)

3.ls

The most basic format is to display the files and directories in the current directory.

Common parameter options:

-F: Distinguishes between file types. /For directories, * for executable files, nothing for files.

-A: Shows hidden files.

-r: Displays the files in the directory contained in the directory. If there are many directories, the output content will be longer.

-L: Displays more information about each file in the directory. Includes file type, permissions, number of hard links, and so on.

-I: Displays the index value for each file.

Eg:ls-sail

In addition, LS also supports the definition of filters at the command line, that is, you can make simple text matching strings, support wildcards? (one character) and * (0 or more characters).

Eg:ls-l My displays information about this file.

Ls-l my? Displays information about files with a file name of three characters and the first two letters of my.

Ls-l my* Displays information about the first two characters of a file name for my files.

4.touch

Create a file.

5. CP

Copy the file.

EG:CP test1 test2 Test1 is the source object, Test2 is the target object.

CP can also create linked files.

Cp-l file1 file2 file2 is a hard link to file1, equivalent to ln file1 file2

Cp-s file1 file3 file3 for file1 soft links, equivalent to ln-s file1 file2

6.mv

Move a file or rename a file (a problem occurs when a file has a soft link, that is, the source file does not exist).

EG:MV file1 file2 The same directory, File1 is renamed to File2

MV File1 dir in different directories, File1 is moved to dir directory

7.rm

Permanently delete files (problems occur when there is a soft link in the file).

Eg:rm-i Test

8.mkdir

Create a directory.

Eg:mkdir TestDir

9.rmdir

Delete the empty directory.

Eg:rmdir TestDir

If the directory is not empty, you can use the RM command and the-r parameter to recursively delete the files in the directory, and then delete the empty directories.

Eg:rm-r TestDir

10.stat

View file statistics. More than LS command to see. Include file name, size, access time, modification time, and so on.

Eg:stat Test

11.file

View the file type. Includes text files, executable files, data files.

Eg:file Test

12.cat

View the contents of the file.

Eg:cat Test

Cat-n test adds line numbers to the text, including blank lines.

Cat-b test adds line numbers to non-blank lines.

Cat-s test compresses multiple blank rows into a single blank line.

13.more

Display the contents of the file, you can turn the page, each display a screen file.

14.less

Display the contents of the file, you can flip the page, do not load the entire file, each display a screen file. is the more upgraded version.

15.head

Displays the content at the beginning of the file, which defaults to 10 rows.

Eg:head-n 15 lines at the beginning of the file

16.tail

Displays the content at the end of the file, which defaults to 10 rows.

Eg:tail-n 15 lines at the end of the file

Tail-c 200-byte content at the end of a file

Basic Bash Shell command--1

Related Article

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.