Shell basic Commands

Source: Internet
Author: User

Command line and Shell: the command line refers to the interface that provides user input, which itself simply accepts input and then passes the command to the command interpreter, which is the shell.

Note: The command line and file for Linux are case-sensitive

Ii. Common Commands

1 $ cd/     # #进入根目录2 $ cd/home # #进入用户主目录3 $ ls       # #列出文件和目录
4 $ ls-f the ##-f option will be appended/after each directory, followed by * After the executable file, with the link file appended with @. This option is useful for some terminals where colors cannot be displayed
5 $ ls-a # #显示所有文件, including hidden files starting with., command options can be combined, using multiple options, such as: LS-AF
6 $ ls-l # #显示文件属性, LS followed by the path name, you can view the files in that subdirectory, for example: ls/etc/init.d/

There are a total of 8 different information columns, from left to right, in turn:

    • Permission flags for files
    • Number of links to the file
    • User name of the file owner
    • The user group group name where the user is located
    • File size
    • Date of last modification
    • Time of last modification
    • Filename
7 $ cat-n File name 1 file name 2  # #查看文本文件 to view multiple files simultaneously, the-N option to display line numbers
8 $ More file name # #按页显示文件, press SPACEBAR to turn down a page, press Eenter to scroll down one line, press the Q key to exit
9 $ head/tail-n 2 File name 1 file name 2 # #显示文件的开头或结尾,-n Specify the number of rows to display
$ less/boot/gurb/gurb.cfg # #查看文本文件, press the SPACEBAR to page down, press the B key to page UP, search for a string in the file can use "/" with what to find, press the Q key to exit. With parameter-m, you can display more text information
$ grep String file name 1 file name 2 # #查找文件内容, if the string contains spaces, you must enclose the space in a single quotation mark. For example: grep ' Red Hat ' stack.h
$ find/etc/-name init.d-type-d-print # #查找文件, type can be found according to file type, there are several types
Parameters Meaning Parameters Meaning
B Block device files F Normal file
C Character device files P Named pipes
D Catalog files L Symbolic Links

$ find/usr/bin-type f-atime +100-print # #查找最近100天内没有使用过的命令即查找最后一次使用在100天或100天以前的命令
$ find. -type f-mtine-1 # #查找在当前目录下最近一天内修改过的文件
$ locate *.doc
$ whereis-b Find # #whereis主要用于查找程序文件 and provides the file binary executable file, source code file, user manual of the storage path
$ who # #查找当前系统中登陆用户
$ Whoani # #查找用户自己身份
$ uname # #显示当前系统版本信息,-a option displays all useful information for the current system,-R displays kernel version information
$ man Find # #获取命令帮助信息

Three, wildcard characters

1. "*" to match strings of any length in the file name

2, "? "To match a single character

3, "[]" to match all occurrences of the character in square brackets

Shell basic Commands

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.