关于 Ubnutu Linux 终端的必知必会的 19 件超简单的事情
终端
终端常常让新用户感到害怕。然而，一旦你了解了它，你就会逐渐开始喜欢上它。好吧，这事往往发生在大多数 Linux 用户身上。


即使你使用 Ubuntu 作为桌面系统，你可能有时也要进入终端。新用户往往对很多事情毫无头绪，在这种情况下，一些基本的 Linux 命令的知识总是有帮助的，但这篇文章不是关于这个。


这篇文章的重点是解释关于使用终端的一些小的、基本的、经常被忽视的东西。这应该可以帮助 Ubuntu 桌面的新用户了解终端，并以更高的效率使用它。


![](/data/attachment/album/202112/09/075520x7a4zkaplokrowd8.png)


你看到的“<ruby> 终端 <rt>  terminal </rt></ruby>”只是 [各种终端应用程序](https://itsfoss.com/linux-terminal-emulators/) 中的一个。毕竟终端只是一个 GUI 工具，它可以让你进入一个可以运行命令的 Shell 。


不同的终端应用程序（正确地应该被称为“<ruby> 终端仿真器</ruby>”）看起来有些稍微不同的功能和特点（如不同的键盘快捷键、颜色组合、字体等）。


本文特别关注 Ubuntu 的默认终端，它是 “GNOME 终端”的一个实现。


### 1、用键盘快捷方式打开终端


你可以 [在 Ubuntu 中打开终端](https://itsfoss.com/open-terminal-ubuntu/)，在系统菜单中寻找到它。然而，我最喜欢的方式是使用 [Ubuntu 中的键盘快捷键](https://itsfoss.com/ubuntu-shortcuts/)：`Ctrl+Alt+T` 。


### 2、终端、Shell、提示符和命令行


在你看其他内容之前，你应该知道这些不同术语之间的区别，这些术语经常被（不正确地）互换使用。


![终端、提示符和命令](/data/attachment/album/202112/09/075520qwzi6dkubru56sw6.png)


“终端”是图形化的应用程序，默认情况下运行 Shell。


Shell 很难与终端分开进行可视化。终端运行着一个 Shell，在 Ubuntu 中通常默认为 Bash shell。和终端一样，也有各种 Shell。Bash 是其中最受欢迎的，也是大多数 Linux 发行版上的默认 Shell。


你输入的命令是由 Shell 解释的。通常人们认为他们在终端看到的屏幕就是 Shell。这适合理解这个概念。


“提示符”是你在输入命令的空格前看到的东西。对于提示符没有固定的标准。在一些旧的终端中，只是在你可以输入命令的地方有一个闪烁的光标而已。在 Ubuntu 终端中，提示符给了你一些信息，你会在本文后面的章节中看到这些信息的细节。


“命令行”不是 Linux 特有的东西。很多操作系统都有一个命令行界面。许多编程语言也都有命令行界面。它是一个术语，用来指你可以运行和执行命令的界面。


Luke Smith 的 [这个视频](https://www.youtube.com/embed/hMSByvFHOro) 用例子详细解释了它。言归正传，我在这里就不多说了。


### 3、了解提示符


你现在已经知道了。你在输入命令的空格前看到的东西叫做“提示符”。它是可配置的，在不同的发行版、终端应用程序和 Shell 中提示符看起来是不同的。


Ubuntu 终端对提示符进行了配置，让你看到一些东西。你可以一目了然地得到以下信息：


* 用户名
* 主机名（计算机的名称）
* 当前工作目录


还有一些你可能想知道的惯例。


提示符中的冒号（`:`）是一个分隔符，常用来区分主机名和当前位置。


波浪号（`~`）表示当前用户的主目录。


对于普通用户，提示符以美元（`$`）符号结束。对于 root 用户来说，它以英镑或哈希（`#`）符号结束。因此有一个笑话说，英镑比美元强。


![](/data/attachment/album/202112/09/075521trvbni5lnfo4lzvb.png)


你是否注意到，当我切换到 root 用户时，命令提示符看起来不一样，没有任何颜色？这又一次提醒了我，提示符不是一个标准，是要明确配置的。对于普通用户来说，Ubuntu 对提示符的配置与 root 用户不同。


像这样的简单信息间接地帮助了我们。在一个多用户环境中，你可以很容易地弄清楚你现在使用的是哪个用户，以及它是否是 root 用户。其显示的路径位置也是有帮助的。


![](/data/attachment/album/202112/09/075521uxx7m654smyx1yu5.png)


### 4、目录和文件


在 Linux 中你听到最多的两个术语是目录和文件。


你可能知道什么是文件，但你可能会对“<ruby> 目录 <rt>  directory </rt></ruby>”这个术语感到困惑。目录就是“<ruby> 文件夹 <rt>  folder </rt></ruby>”。它把文件和文件夹放在里面。


你可以进入目录，但你不能进入文件。当然，你可以读取文件。


![](/data/attachment/album/202112/09/075521zsxzs8idnvkrvxxr.png)


你可以用“文件夹”这个词来表示目录，应该没有问题。然而，最好使用“目录”，因为你会在各种教程、文件等中看到引用这个词。你甚至会发现像 `rmdir`、`mkdir` 这样的命令，暗示它们是处理目录的。


补充说明：在 Linux 中，所有东西都是文件。甚至目录也是一种特殊的文件，里面有文件和目录的地址。我已经在我的关于 [硬链接的文章](https://linuxhandbook.com/hard-link/) 中解释了这一点。如果你想了解更多关于这个主题的信息，可以参考一下。


### 5、路径：绝对路径和相对路径


[Linux 中的目录结构](https://linuxhandbook.com/linux-directory-structure/) 类似于一棵树的根。所有的东西都从根部开始，并从那里向外扩散。


如果你要访问一个文件或目录，你需要通过提供它的“路径”来说明如何到达它的位置。这个路径是由目录名和分隔符（`/`）组成的。如果一个路径以 `/`（即根）开头，它就是一个绝对路径，否则就是一个相对路径。


![路径](/data/attachment/album/202112/09/075521qbhfjjlsjuljlsbs.png)


绝对路径从根开始，可以很容易地从系统的任何地方引用。相对路径则取决于你在目录结构中的当前位置。


![绝对路径与相对路径](/data/attachment/album/202112/09/075522dld5ibd4hd7ddi7v.png)


如果你在 `/home/abhishek` 这个位置，有一个名为 `scripts` 的目录，里面有一个文件 `my_script.sh`，你想知道这个文件的路径，它的绝对路径将是：



```
/home/abhishek/scripts/my_script.sh

```

它的相对路径将是：



```
scripts/my_script.sh

```

如果你改变所在位置，文件的绝对路径保持不变。但是，相对路径会改变，因为它是相对于你当前的路径而言的。


![相对路径随位置变化但绝对路径保持不变的真实例子](/data/attachment/album/202112/09/075522arweykynkkxy2epx.png)


### 6、 . 和 ..


在使用 Linux 终端时，你可能经常会遇到 `.`和 `..` 符号。


单点（`.`）表示当前目录。


双点（`..`）表示父目录（比当前位置高一个目录）。


你经常在相对路径中使用双点（`..`），或者用于改变目录。单点（`.`）也用于相对路径中，但更重要的是，你可以在指定当前位置的命令中使用它。


![ . 和 .. 的使用](/data/attachment/album/202112/09/075522rf69ykrt1otoiri7.png)


### 7、理解命令的结构


一个典型的 Linux 命令由一个命令名和选项及参数组成。



```
命令名 [选项] 参数

```

“选项”，顾名思义，是可选的。当使用时，它们可能会根据其属性来改变输出。


例如，`cat` 命令是用来查看文件的。你可以添加选项 `-n`，它也会显示行数。


选项不是标准化的。通常情况下，它们是由单字母和单破折号（`-`）组成的。它们也可能是两个破折号（`--`）和一个单词的形式。


同样的选项在不同的命令中可能有不同的含义。如果你在 `head` 命令中使用 `-n`，表明你想看行数，而不是行号。


![同样的选项 -n 在 cat 和 head 命令中有不同的用途](/data/attachment/album/202112/09/075522suyzuja4aydp5hzs.png)


在命令文档中，**如果你看到方括号（`[]`）之间有什么东西，它表示括号中的内容是可选的**。


同样地，“参数”也没有标准化。有些命令希望用文件名作为参数，有些则希望用目录名或正则表达式。


### 8、获得帮助


当你开始使用命令时，你可能会记住一些经常使用的命令的选项，但你根本不可能记住所有命令的所有选项。


为什么呢？因为一条命令可能有十多个或二十多个选项。


那么，当你无法记住所有的选项时，你该怎么办呢？你需要“帮助”。我所说的帮助，并不是指在 [Linux 论坛](https://itsfoss.community/) 上提问。我指的是使用命令的帮助选项。


每个标准的 Linux 命令都有一个快速帮助页面，可以用 `-h` 或 `—help` 来访问。



```
命令名 -h

```

它可以让你快速了解命令的语法、常用选项及其含义，在某些情况下还有命令的例子。


![cat 命令的帮助页](/data/attachment/album/202112/09/075523e6zih8m6u68f6eti.png)


如果你需要更多的帮助，你可以参考 [手册页](https://itsfoss.com/linux-man-page-guide/)，即命令的手册。



```
man 命令名

```

它涉及到所有的细节，阅读和理解起来可能会让人难以承受。另外，你也可以在网上搜索 “Linux 中 xyz 命令的例子”。


### 9、Linux 是区分大小写的


Linux 是区分大小写的。你在终端中输入的所有东西都是区分大小写的。如果你不考虑这一点，你会经常遇到 “[bash: command not found](https://itsfoss.com/bash-command-not-found/)” 或 “file not found” 的错误。


在主目录中，你的所有文件夹名称以大写字母开头的。如果你要切换到 `Documents` 目录，你必须把第一个字母保持为 `D`，而不是 `d`。


![Linux 是区分大小写的](/data/attachment/album/202112/09/075523kgmcdr6hzr5rhebr.png)


你可以有两个分别名为 `file.txt` 和 `File.txt` 的文件，因为对于 Linux 来说，`file` 和 `File` 是不一样的。


### 10、运行 Shell 脚本


你可以通过指定 Shell 来 [运行一个 Shell 脚本](https://itsfoss.com/run-shell-script-linux/)：



```
bash script.sh

```

或者你可以像这样执行 Shell 脚本。



```
./script.sh

```

第二种方法只有在文件有执行权限时才会起作用。更多关于 [Linux 文件权限参考这里](https://linuxhandbook.com/linux-file-permissions/)。


![运行bash脚本](/data/attachment/album/202112/09/075523jr8gtoawxgnrrome.png)


### 11、使用制表符补完而不是全部输入


Ubuntu 的终端已经预先配置了制表符补完功能。这意味着如果你开始在终端上输入，然后点击 `tab` ，它会尝试自动完成它，或者在有多个可能的匹配时提供选项。


它既适用于命令，也适用于参数和文件名。


![Tab 完成示例](/data/attachment/album/202112/09/075523amoaddkdskm6tiea.png)


这可以节省大量的时间，因为你不需要把所有的东西都写完整。


### 12、Ctrl+C 和 Ctrl+V 不是用来在终端复制粘贴的。


`Ctrl+C`、`Ctrl+V` 可能是复制粘贴的“通用”键盘快捷键，但它在 Linux 终端中不行。


Linux 继承了 UNIX 的很多东西，在 UNIX 中，`Ctrl+C` 被用来停止一个正在运行的进程。


由于 `Ctrl+C` 已经被用于停止一个命令或进程，所以它不能再用于复制粘贴。


### 13、你当然可以在终端复制粘贴


别担心。你仍然可以 [在终端中复制粘贴](https://itsfoss.com/copy-paste-linux-terminal/)。同样，复制-粘贴的键盘快捷键没有固定的规则，因为它取决于你使用的终端程序或你的配置。


在 Ubuntu 终端中，复制的默认键盘快捷键是 `Ctrl+Shift+C`，粘贴则是 `Ctrl+Shift+V`。


你可以使用 `Ctrl+C` 从终端外（如网页浏览器）复制文本和命令，并使用 `Ctrl+Shift+V` 将其粘贴。同样，你可以高亮显示文本，用 `Ctrl+Shift+C` 从终端复制文本，用 `Ctrl+V` 粘贴到编辑器或其他应用程序。


### 14、避免在终端中使用 Ctrl+S


另一个初学者常犯的错误是使用“通用”的 `Ctrl+S` 键盘快捷键来保存。如果你在终端中使用 `Ctrl+S`，你的终端会被“冻结”。


这来自于传统的计算机，在那里没有向上滚动的滚动条。因此，如果有大量的输出行，`Ctrl+S` 被用来停止屏幕，以便可以阅读屏幕上的文字。


你可以用 `Ctrl+Q` 来解除终端的冻结。但还是要避免在终端中使用 `Ctrl+S`。


### 15、注意命令例子中的 $ 和 <>


如果你参考一些在线教程或文档，你会看到一些命令例子中的文本在 `<>` 内。这表明你需要用一个合适的值来替换与 `<` 和 `>` 一起的内容。


例如，如果你看到一个这样的命令：



```
grep -i <搜索内容> <文件名>

```

你应该把 `<搜索内容>` 和 `<文件名>` 换成各自的实际值。（LCTT 译注：不要输入 `<` 和 `>`）


这表明该命令只是一个例子，你必须用实际值来完成它。


这里需要注意的另一件事是，有些教程显示的命令例子是以 `$` 开头的，比如这样：


![命令开头的美元符号](/data/attachment/album/202112/09/075524mbhgjg5cgtebe8bj.png)


这是表明它们是命令（而不是命令输出）的一种方式。但是，许多新的 Linux 用户把前面的 `$` 和实际的命令一起复制，当他们把它粘贴到终端时，显然会出现错误。


所以，当你复制一些命令时，如果开头有 `$`，就不要复制它。你也应该避免复制随机网站的随机命令，特别是当你不了解它的作用时。


既然你正在阅读关于复制命令的文章，当你看到多行的命令在一起时，你应该一次复制一行，然后逐一运行。


![避免将多个命令复制在一起](/data/attachment/album/202112/09/075524lsrqtheestfr0tke.png)


下一节将告诉你如何一次性运行多个命令。


### 16、你可以同时运行多个命令


你可以 [一次运行多个命令](https://itsfoss.com/run-multiple-commands-linux/) 而不需要用户干预。作为 Ubuntu 用户，你可能已经在这个命令的形式中看到了它：



```
sudo apt update && sudo apt upgrade

```

在终端中，有三种不同的方法来组合命令：




| `;` | `命令 1 ; 命令 2` | 先运行命令 1，再运行命令 2 |
| --- | --- | --- |
| `&&` | `命令 1 && 命令 2` | 只有命令 1 成功结束才运行命令 2 |
| `||` | `命令 1 || 命令 2` | 只有命令 1 失败时才运行命令 2 |


### 17、停止一个正在运行的 Linux 命令


如果一个 Linux 命令在前台运行，也就是说，它正在显示输出，或者说你不能输入任何其他命令，你可以用 `Ctrl+C` 键停止它。


我以前讨论过它。它来自于 UNIX 的传统计算时代。


所以，下次你看到像 `top` 或 `ping` 这样的命令在持续运行，而你想恢复终端控制，只需使用这两个键：`Ctrl+C`。


![在 Linux 中用 Ctrl+C 停止一个正在运行的程序](/data/attachment/album/202112/09/075524v9g3fvtfav1l8p5p.png)


### 18、清除终端


当我发现我的屏幕被不同类型的输出弄得太杂乱时，我会在开始其他工作之前清除终端屏幕。这只是一种习惯，但我发现它很有帮助。


要清除终端，请使用以下命令：



```
clear

```

你也可以使用 [终端快捷键](https://linuxhandbook.com/linux-shortcuts/) `Ctrl+L`。


### 19、退出终端


在少数情况下，我看到有人关闭终端程序来退出会话。你可以这样做，但退出终端的正确方法是使用退出命令：



```
exit

```

你也可以使用 Ubuntu 终端的键盘快捷键 `Ctrl+D`。


### 总结


即使你对终端完全陌生，你也可以在终端中做很多额外的事情。你可以：


* [运行有趣的 Linux 命令](https://itsfoss.com/funny-linux-commands/)
* [在终端中浏览互联网](https://itsfoss.com/terminal-web-browsers/)
* [在终端中玩游戏](https://itsfoss.com/best-command-line-games-linux/)


如果你想了解更多，[看看这些 Linux 命令技巧，可以像专家一样使用终端](https://itsfoss.com/linux-command-tricks/)。


说实话，要谈的东西太多了。很难确定哪些应该被认为是绝对的基础知识，哪些应该被排除在外。例如，我想避免包括关于路径的信息，因为它需要详细的解释，但在一个地方讲得太详细可能会让人不知所措。


我已经过了在终端中的小东西曾经让我困惑的阶段。如果你是 Linux 终端的新手，或者你还记得你最初使用 Linux 时的挣扎，请随时提出建议对列表进行补充。我可能会根据你的意见更新这个列表。


如果你学到了新的东西，请在评论中提及。我想看看这篇文章是否值得一读 ?




---


via: <https://itsfoss.com/basic-terminal-tips-ubuntu/>


作者：[Abhishek Prakash](https://itsfoss.com/author/abhishek/) 选题：[lujun9972](https://github.com/lujun9972) 译者：[wxy](https://github.com/wxy) 校对：[wxy](https://github.com/wxy)


本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译，[Linux中国](https://linux.cn/) 荣誉推出


OK
![Warp Terminal](/assets/images/warp-terminal.webp)


![Warp Terminal](/assets/images/warp-terminal.webp)

Terminal often intimidates new users. However, you gradually start liking it once you get to know it. Well, that happens with most Linux users.

Even if you are using Ubuntu as a desktop system, you may sometimes have to enter the terminal. New users are often clueless about many things. Some knowledge of basic Linux commands always helps in such cases but this article is not about that.

This article focuses on explaining small, basic, and often ignored things about using the terminal. This should help new Ubuntu desktop users know the terminal and use it more efficiently.

![ubuntu terminal basic tips](https://itsfoss.com/content/images/wordpress/2021/12/ubuntu-terminal-basic-tips.png)

The terminal you see is just one of the [various terminal applications](https://itsfoss.com/linux-terminal-emulators/) available. After all, the terminal is just a GUI tool that gives you access to a shell where you can run the commands.

Different terminal applications (properly called terminal emulators) look different and have slightly different functions and features (like different keyboard shortcuts, color combinations, fonts, etc).

This article specifically focuses on the default Ubuntu terminal, which implements the GNOME terminal.

## 1. Open the terminal with a keyboard shortcut

You can [open the terminal in Ubuntu](https://itsfoss.com/open-terminal-ubuntu/) by looking for it in the system menu. However, my favorite way is to use the Ctrl+Alt+T [keyboard shortcut in Ubuntu](https://itsfoss.com/ubuntu-shortcuts/).

`Ctrl+Alt+T`


## 2. Terminal vs shell vs prompt vs command line

Before you see anything else, you should know the difference between different terminologies that are often (incorrectly) used interchangeably.

![linux terminal introduction](https://itsfoss.com/content/images/wordpress/2021/12/linux-terminal-introduction.png)

The terminal is a graphical application that runs a shell by default.

Shell is difficult to visualize separately from the terminal. The terminal runs a shell, usually Bash shell by default in Ubuntu. Like terminals, there are various shells as well. Bash is the most popular of them all and the default shell on most Linux distributions.

The commands you type are interpreted by the shell. Often people think that screen they see in the terminal is the shell. That’s fine for understanding.

Prompt is what you see before the space where you type the commands. There is no set standard for the prompt. In some old terminals, you would just have a blinking cursor to the place where you can type the commands. In the Ubuntu terminal, prompt gives you some information which you’ll see in detail in the later sections of this article.

The Command line is not something specific to Linux. Every operating system has a command line interface. Many programming languages have command line interfaces. It’s a term for the interface where you can run and execute commands.

This video by Luke Smith explains it in detail with examples. I won’t go into details anymore to keep things on track.

## 3. Understanding the prompt

You know it by now. What you see before the space where you type the command is called the prompt. It is configurable and looks different in different distributions, terminal applications and shells.

Ubuntu terminal has configured the prompt to show you a few things. You can get the following information at a glance:

- User name
- Hostname (name of the computer)
- Current working directory

A few more things you may wonder about.

The colon (:) in the prompt is a separator to distinguish between the hostname and the current location.

Tilde (~) means the home directory of the present user.

For regular users, the prompt ends with dollar ($) symbol. For the root user, it ends with pound or hash (#) symbol. And hence the joke that pound is stronger than dollar.

![understanding prompt ubuntu terminal](https://itsfoss.com/content/images/wordpress/2021/12/understanding-prompt-ubuntu-terminal-800x346.png)

Did you notice that when I switched to the root user, the command prompt looked different without any colors? This is another reminder that prompt is not a standard and is configured explicitly. For regular users, Ubuntu has a different configuration of the prompt than the root.

Simple information like this helps indirectly. In a multi-user environment, you can easily figure out which user you are using and if it is a root user. The displayed location is also helpful.

![learning prompt ubuntu terminal](https://itsfoss.com/content/images/wordpress/2021/12/learning-prompt-ubuntu-terminal-800x346.png)

## 4. Directory and files

The two terms you hear the most in Linux are directory and files.

You probably know what a file is but you may get confused with the term ‘directory’. The directory is nothing but a folder. It keeps files and folders inside it.

You can go inside the directories but you cannot enter files. You can read files of course.

![directory files linux](https://itsfoss.com/content/images/wordpress/2021/12/directory-files-linux-800x346.png)

You can use the term ‘folder’ for the directory, which should be fine. However, it is better to use ‘directory’ because this is what you’ll see referenced in various tutorials, documents etc. You’ll even find commands like rmdir, mkdir hinting that they deal with directories.

Additional note: Everything is a file in Linux. Even directory is a special kind of file that has the memory address of files and directories inside it. I have explained it in my [article on hard links](https://linuxhandbook.com/hard-link/). You may refer to that if you want to know more on this topic.

## 5. Path: Absolute and relative

The [directory structure in Linux resembles](https://linuxhandbook.com/linux-directory-structure/) the root of a tree. Everything starts at root and spreads out from there.

If you have to access a file or directory, you need to tell how to reach its location by providing its ‘path’. This path is composed of directory names and separators (/). If a path starts with / (i.e., root), it is an absolute path otherwise it is a relative path.

![path linux](https://itsfoss.com/content/images/wordpress/2021/12/path-linux.webp)

The absolute path starts from the root and can be easily referenced from anywhere in the system. The relative path depends upon your current location in the directory structure.

![absolute vs relative path linux](https://itsfoss.com/content/images/wordpress/2021/12/absolute-vs-relative-path-linux.webp)

If you are in the location /home/abhishek which has a directory named scripts containing a file my_script.sh and you want the path for this file, its absolute path will be:

`/home/abhishek/scripts/my_script.sh`


Its relative path will be:

`scripts/my_script.sh`


If you change the location, the file's absolute path remains the same. However, the relative path changes because it is relative to your current path.

![absolute relative path real examples](https://itsfoss.com/content/images/wordpress/2021/12/absolute-relative-path-real-examples-800x346.png)

## 6. . and ..

You may often come across . and .. notations while using the Linux terminal.

Single dot (.) means the current directory.

Double dots (..) mean the parent directory (one directory above the current location).

You’ll often use the double dot (..) in the relative path or for changing the directory. Single dot (.) is also used in relative path; more importantly, you can use it in the commands to specify the current locations.

![use of single and double dot in linux](https://itsfoss.com/content/images/wordpress/2021/12/use-of-single-and-double-dot-in-Linux.png)

## 7. Understand the command structure

A typical Linux command consists of a command name followed by options and arguments.

`command [options] argument`


Option, as the name suggests, are optional. When used, they might change the output based on their properties.

For example, the cat command is used for viewing files. You can add option -n, which will also display line numbers.

Options are not standardized. Usually, they are used as a single letter with single dash (-). They may also have two dashes (--) and a word.

Same options may have different meanings in a different command. If you use -n with head command, you specify the number of lines you want to see, not the lines with numbers.

![command structure example](https://itsfoss.com/content/images/wordpress/2021/12/command-structure-example.png)

In command documentation, **if you see something between brackets ([]), it indicates that the contents of the bracket are optional.**

Similarly, arguments are also not standardized. Some commands expect filenames as arguments and some may expect a directory name or regular expression.

## 8. Getting help

As you start using commands, you may remember some of the options of frequently used commands but it is simply impossible for you to remember all the options of any command.

Why? Because a single command may have more than ten or twenty options.

So, what do you do when you cannot recall all the options? You take help. And with help, I do not mean asking a question in It’s FOSS [Linux forum](https://itsfoss.community/). I ask to use the help option of the command.

Every standard Linux command has a quick help page that can be accessed with -h or –help or both.

`command_name -h`


It gives you a quick glimpse of the command syntax, common options with their meaning, and command examples in some cases.

![cat command help page](https://itsfoss.com/content/images/wordpress/2021/12/cat-command-help-page.png)

If you need more help, you can refer to the [manpage](https://itsfoss.com/linux-man-page-guide/) i.e. manual of a command:

`man command_name`


It goes into all the details and could be overwhelming to read and understand. Alternatively, you can always search on the internet for ‘examples of xyz commands in Linux’.

## 9. Linux is case-sensitive

Linux is case-sensitive. Everything you type in the terminal is case-sensitive. If you do not take that into account, you’ll often run into [bash: command not found](https://itsfoss.com/bash-command-not-found/) or file not found errors.

In the home directory, you have all the folders' names starting with the upper case. If you have to switch to the Documents directory, keep the first letter as D and not d. Otherwise, the terminal will complain.

![linux is case sensitive](https://itsfoss.com/content/images/wordpress/2021/12/linux-is-case-sensitive.png)

You can have two separate files named file.txt and File.txt because file and File are not the same for Linux.

## 10. Running shell scripts

You can [run a shell script](https://itsfoss.com/run-shell-script-linux/) by specifying the shell:

`bash script.sh`


Or you can execute the shell script like this:

`./script.sh`


The second one will only work when the file has the execute permission. More on [Linux file permission here](https://linuxhandbook.com/linux-file-permissions/).

![run bash script](https://itsfoss.com/content/images/wordpress/2021/12/run-bash-script.png)

## 11. Use tab completion instead of typing it all

The Ubuntu terminal is pre-configured with tab completion. This means that if you start writing something in the terminal and then hit tab, it tries to automatically complete it or provide options if there is more than one possible match.

It works for both commands as well as arguments and filenames.

![tab completion ubuntu](https://itsfoss.com/content/images/wordpress/2021/12/tab-completion-ubuntu.png)

This saves a great time because you don’t have to write everything completely.

## 12. Ctrl+C and Ctrl+V is not for copy pasting in terminal

Ctrl+C, Ctrl+V might be the ‘universal’ keyboard shortcuts for copy paste but it doesn’t work in the Linux terminal.

Linux inherits a lot of stuff from UNIX and in UNIX, Ctrl+C was used for stopping a running process.

Since the Ctrl+C was already taken for stopping a command or process, it cannot be used for copy-paste any more.

## 13. You can surely copy paste in the terminal

Don’t worry. You can still [copy paste in the terminal](https://itsfoss.com/copy-paste-linux-terminal/). Again, there is no fixed rule for the copy-paste keyboard shortcuts because it depends on the terminal application you are using or the configuration you have in place.

In the Ubuntu terminal, the default keyboard shortcut for copying is Ctrl+Shift+C; for pasting, it is Ctrl+Shift+V.

You can use Ctrl+C to copy text and commands from outside the terminal (like a web browser) and paste it using Ctrl+Shift+V. Similarly, you can highlight the text and use Ctrl+Shift+C to copy the text from the terminal and paste it to an editor or other applications using Ctrl+V.

## 14. Avoid using Ctrl+S in the terminal

Another common mistake beginners do is to use the ‘universal’ Ctrl+S keyboard shortcut for save. If you use Ctrl+S in the terminal, your terminal ‘freezes’.

This comes from legacy computing where there was no scope for scrolling back up. Hence, if there were many output lines, Ctrl+S was used to stop the screen so that text on the screen could be read.

You can unfreeze your terminal with Ctrl+Q. But again, avoid using Ctrl+S in the terminal.

## 15. Pay attention to $ and <> in command examples

If you are referring to some online tutorial or documentation, you’ll see some command examples with text inside <>. This indicates that you need to replace the content along with < and > with a suitable value.

For example, if you see a command like this:

`grep -i <search_term> <file_name>`


You should replace the <search_term> and <file_name> with their respective actual values.

It is an indication that the command is just an example and you have to complete it with actual values.

Another thing to note here is that some tutorials show command examples that start with $ like this:

![dollar symbol at the beginning of command](https://itsfoss.com/content/images/wordpress/2021/12/dollar-symbol-at-the-beginning-of-command.png)

This is a way for them to indicate that it is command (not command output). But many new Linux users copy the preceding $ along with the actual command and when they paste it in the terminal, it throws an error, obviously.

So, when copying some commands, don’t copy the $ if it is at the beginning. You should also avoid copying random commands for random websites specially when you do not understand what it does.

Since you are reading about copying commands, when you see commands in multiple lines together, you should copy one line at a time and run them one by one:

![avoid copying multiple commands](https://itsfoss.com/content/images/wordpress/2021/12/avoid-copying-multiple-commands.png)

The following section tells you how to run multiple commands in one go.

## 16. You can run multiple commands at once

You can [run multiple commands at once](https://itsfoss.com/run-multiple-commands-linux/) without user intervention. You might have seen it already as an Ubuntu user in the form of this command:

`sudo apt update && sudo apt upgrade`


There are three different ways to combine commands in the terminal:

; | Command 1 ; Command 2 | Run command 1 first and then command 2 |

&& | Command 1 && Command 2 | Run command 2 only if command 1 ends sucessfully |

|| | Command 1 || Command 2 | Run command 2 only if command 1 fails |


## 17. Stop a running Linux command

If a Linux command is running in the foreground, i.e., it is showing output or you cannot enter any other command, you can stop it using the Ctrl+C keys.

I discussed it previously. It comes from the legacy computing days of UNIX.

So, the next time you see a command like top or ping running continuously and you want the terminal control back, just use these two keys:

`Ctrl+C`


![stop running program linux](https://itsfoss.com/content/images/wordpress/2021/12/stop-running-program-linux-800x385.png)

## 18. Clear the terminal

When I find that my screen is too cluttered with different kinds of output, I clear the terminal screen before starting some other work. It is just a habit but I find it helpful.

To clear the terminal, use the command:

`clear`


You may also use Ctrl+L [terminal shortcut](https://linuxhandbook.com/linux-shortcuts/).

## 19. Exiting the terminal

In a few cases, I have seen people closing the terminal application to exit the session. You could do that but the proper way to exit a terminal is to use the exit command:

`exit`


You may also use the keyboard shortcut Ctrl+D for Ubuntu terminal.

## Conclusion

There are so many additional stuff you can do in the terminal even if you are new to the entire terminal thing. You can:

And if you are looking for more, [take a look at](https://itsfoss.com/linux-command-tricks/)[ these Linux command tips and use the terminal like a pro](https://itsfoss.com/linux-command-tricks/).

[21 Super Handy Linux Command Tips and Tricks That Will Save you a lot of Time and Increase Your ProductivityBrief: Here are some tiny but useful Linux commands, terminal tricks and shortcuts that will save you a lot of time while working with Linux command line. Have you ever encountered a moment when you see your colleague using some simple Linux commands for tasks that took you several keystrokes?](https://itsfoss.com/linux-command-tricks/)![](https://itsfoss.com/content/images/wordpress/2021/07/linux-command-tips.png)


![](https://itsfoss.com/content/images/wordpress/2021/07/linux-command-tips.png)

Getting familiar with the basic commands is also highly recommended.

[31 Linux Commands Every Ubuntu User Should KnowWhat are the essential Ubuntu commands? I have been asked this question several times by regular readers, and I have tried to avoid answering it. Why? Don’t I know Ubuntu commands? Nope. That’s not the reason. It is because it is difficult to categorize them. What’s essential](https://itsfoss.com/essential-ubuntu-commands/)![](https://itsfoss.com/content/images/wordpress/2022/11/must-know-linux-commands-for-ubuntu-user.png)


![](https://itsfoss.com/content/images/wordpress/2022/11/must-know-linux-commands-for-ubuntu-user.png)

Honestly speaking, there is way too much to talk about. It is difficult to determine what should be considered absolute basics and what should be left out. For example, I wanted to avoid including the information about paths because it needs detailed explanation but going too much into detail on a single could be overwhelming.

I have passed the stage where small things used to baffle me in the terminal. If you are new to the Linux terminal or remember the struggle from your initial Linux days, feel free to suggest any additions to the list. I might update the list with your input.

And if you learned something new, please do mention it in the comments. I would like to see if this article was worth the effort :)