The basics of how to use Linux (如何使用Linux,基础笔记六)

Untile now, we have seen some basic Linux commands, and each of them has own options and arguments. In this blog, we will thoroughly understand those commands by some other commands, and even we could create own commands.

Cite from Linux command line

  1. what are commands exactly?

1.1. An executable program
1.2. An command built into the shell itself
1.3. A shell funtion
1.4. An alias

  1. Identifying commands : “type”

It is often useful to know exactly which of the four kinds of commands is being used .

在这里插入图片描述
e.g.
在这里插入图片描述

  1. Display the location of an executable program : “which”

Sometimes there is more than one version of an executable program installed on a system. To determine the exact location of a given executable , the which command is used.

e.g.
在这里插入图片描述

  1. Getting a command’s documentation : “help”, “–hep”, “man”

4.1. bash has a built-in help facility available for each of the shell builtins. To use it, type “help” followed by the name of shell builtin.

e.g.
在这里插入图片描述

4.2. Many executable programs support a “–help” option that displays a description of the command’s supported syntax and options.

在这里插入图片描述

4.3. Most executable programs intended for command line use provide a formal piece of documentation called a manual or man page. A special paging program call "man " is used to view them.
在这里插入图片描述

e.g.
在这里插入图片描述在这里插入图片描述

tips: The “manual” that man displays is broken into sections and not only covers user commands but also system administration commands, programming interfaces, file formats and more.

The table below describes the layout of the manual:
在这里插入图片描述
e.g.
在这里插入图片描述
在这里插入图片描述在这里插入图片描述

  1. Display appropriate commands : “apropos”

It is also possible to search the list of man pages for possible matches based on a search term. It’s very crude but sometimes helpful.

e.g.
在这里插入图片描述

  1. Display a very brief description of a command : “whatis”

The “whatis” program displays the name and a one line description of a man page matching a specified keyword.

e.g.在这里插入图片描述

  1. Display a program’s info entry : “info”

The GNU project provides an alternative to man pages for their programs, called “info”.
Info pages are displayed with a reader programs named, appropriately enough, info. Info pages are hyperlinked much like web pages.

  1. Create your own commands with alias : “alias”

we can use the “alias” to give a name to a string of commands, then the alias makes the same function.

8.1. It’s possible to put more than one command on a line by each command with a semicolon character.

e.g.
在这里插入图片描述
The commands will be executed as follow steps:
a. go to /usr
b. ls all items
c. go back last working directory

8.2. “alias”
usage:
在这里插入图片描述
e.g.
在这里插入图片描述
在这里插入图片描述

8.3. “unalias”

To reomve an alias, the unalias command is used.

在这里插入图片描述

Tips:
There is one tiny problem wiht defining aliases on the command line. They vanish when you shell session ends. In later blog, well will see how to add our own aliases to the files that establish the environment each time we log on.

发布了20 篇原创文章 · 获赞 3 · 访问量 261

猜你喜欢

转载自blog.csdn.net/qq_34515959/article/details/97906058