10 篇对初学者和专家都有用的 Linux 命令教程
Linux 命令

> 
> 在这有关 Linux 命令的十大文章中，了解如何使 Linux 发挥所需的作用。
> 
> 
> 


![](/data/attachment/album/202003/19/095932xc64xw7cwqlolale.jpg)


**很好地**使用 Linux 意味着了解有哪些命令以及它们可以为你执行的功能。


### 《在 Linux 命令行下使用“原力”》


<ruby> 原力 <rt>  force </rt></ruby>有光明的一面和黑暗的一面。正确理解这个对于真正掌握它至关重要。Alan Formy-Duval 在他的文章《[在 Linux 命令行下使用“原力”](/article-10881-1.html)》中，解释了一些流行的、有时是危险的命令的 `-f` 选项（也称为 `--force`）。


### 《Linux useradd 命令介绍》


共享帐户是一个坏主意。相反，请使用典型的 `useradd` 命令为不同的人（甚至是不同的角色）分配单独的帐户。作为其经典的 Linux 管理基础系列的一部分，Alan Formy-Duval 提供了《[Linux useradd 命令介绍](/article-11756-1.html)》，并且像往常一样，他用**朴实明白的语言**对其进行了解释，以便新老管理员都可以理解。


### 《用 Linux 命令显示硬件信息》


机器**里面**是什么？有时不使用螺丝刀检查硬件很有用。无论是你正在使用的计算机，还是在商店购买前进行测试的计算机、或者是正在尝试维修的计算机，在《[用 Linux 命令显示硬件信息](/article-11422-1.html)》中，Howard Fosdick 提供了或流行或晦涩难懂的命令，以帮助你深入了解计算机的硬件信息。


### 《如何在 Linux 上使用 gocryptfs 加密文件》


从社会保险号到个人信件再到亲人，我们的文件中包含了许多私人数据。在《[如何在 Linux 上使用 gocryptfs 加密文件](https://opensource.com/article/19/8/how-encrypt-files-gocryptfs)》中，Brian Bex Exelbierd 解释了如何保持\**隐私*的私密性。此外，他展示了一种加密文件的方式，这种方式对你现有的工作流程几乎没有影响。这不是复杂的 PGP 风格的密钥管理和后台密钥代理的难题，这是快速、无缝和安全的文件加密。


### 《如何使用 rsync 的高级用法进行大型备份》


在新的一年中，许多人会下定决心要更加努力地进行备份。Alan Formy-Duval 早在几年前就已经做出了解决方案，因为在《[如何使用 rsync 的高级用法进行大型备份](/article-10865-1.html)》中，他表现出对文件同步命令的极其熟悉。你可能不会马上记住所有语法，但其思路是读取和处理选项、构造备份命令，然后使其自动化。这是使用 `rsync` 的明智方法，也是可靠地执行备份的**唯一**方法。


### 《在 Linux 命令行使用 more 查看文本文件》


在 Scott Nesbitt 的文章《[在 Linux 命令行使用 more 查看文本文件](/article-10531-1.html)》中，古老而良好的默认分页器 `more` 引起了人们的关注。许多人安装和使用 `less`，因为它比 `more` 更灵活。但是，随着越来越多的系统在新出现的容器中实现，有时甚至不存在像 `less` 或 `most` 之类的新颖的豪华工具。了解和使用`more` 很简单，这是常见的默认设置，并且是生产系统最后的调试工具。


### 《关于 sudo 你可能不知道的》


`sudo` 命令因其过失而闻名。人们知道 `sudo` 一词，我们大多数人认为我们知道它的作用。我们的观点是正确的，但是正如 Peter Czanik 在他的文章《[关于 sudo 你可能不知道的](/article-11595-1.html)》中所揭示的那样，该命令所包含的不仅仅是“<ruby> 西蒙说的 <rt>  Simon says </rt></ruby>”（LCTT 译注：国外的一个儿童游戏）。就像这个经典的童年游戏一样，`sudo` 命令功能强大，也容易犯愚蠢的错误 —— 有更多的可能产生可怕都后果，而这是你绝不想遇上的事情！


### 《怎样用 Bash 编程：语法和工具》


如果你是 Linux、BSD 或 Mac（以及近来的 Windows）用户，你也许使用过交互式 Bash shell。它是快速的、一次性命令的绝佳 shell，这就是为什么这么多 Linux 用户喜欢将其用作主要用户界面的原因。但是，Bash 不仅仅是个命令提示符。它也是一种编程语言，如果你已经在使用 Bash 命令，那么自动化的道路从未如此简单过。在 David Both 的出色作品《[怎样用 Bash 编程：语法和工具](/article-11552-1.html)》中对其进行全面了解。


### 《精通 Linux 的 ls 命令》


`ls` 命令是那些两个字母的命令之一。单字母命令是针对慢速终端的优化，因为慢速终端的输入的每个字母都会导致明显的延迟，而这对于懒惰的打字员来说也是不错的奖励。一如既往地，Seth Kenlon 清晰实用地解释了你可以怎样《[精通 Linux 的 ls 命令](/article-11159-1.html)》。最重要的是，在“一切都是文件”的系统中，列出文件至关重要。


### 《Linux cat 命令入门》


`cat` 命令（con*cat*enate 的缩写）看似简单。无论是使用它来快速查看文件的内容还是将内容通过管道传输到另一个命令，你都可能没有充分利用 `cat` 的功能。Alan Formy-Duval 的《[Linux cat 命令入门](https://opensource.com/article/19/2/getting-started-cat-command)》提供了一些新思路，可以使你没有打开文件的感觉就可以看到文件内容。另外，了解各种有关 `zcat` 的知识，这样你就可以无需解压缩就可以得到压缩文件的内容！这是一件小而简单的事情，但是**这**是使 Linux 很棒的原因。


### 继续旅程


不要让这些关于 Linux 命令的 10 篇最佳文章成为你的旅程终点。关于 Linux 及其多才多艺的提示符，还有更多值得去发现，因此，请继续关注以获取更多知识。而且，如果你想让我们介绍一个 Linux 命令，请在评论中告诉我们。




---


via: <https://opensource.com/article/19/12/linux-commands>


作者：[Moshe Zadka](https://opensource.com/users/moshez) 选题：[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
Using Linux *well* means understanding what commands are available and what they're capable of doing for you. We have covered a lot of them on Opensource.com during 2019, and here are 10 favorites from the bunch.

## Using the force at the Linux command line

The Force has a light side and a dark side. Properly understanding that is crucial to true mastery. In his article [ Using the force at the Linux command line](https://opensource.com/article/19/5/may-the-force-linux), Alan Formy-Duval explains the

**-f**option (also known as

**--force**) for several popular and sometimes dangerous commands.

## Intro to the Linux useradd command

Sharing accounts is a bad idea. Instead, give separate accounts to different people (and even different roles) with the quintessential **useradd** command. Part of his venerable series on basic Linux administration, Alan Formy-Duval provides an [ Intro to the Linux useradd command](https://opensource.com/article/19/10/linux-useradd-command), and, as usual, he explains it in

*plain English*so that both new and experienced admins can understand it.

## Linux commands to display your hardware information

What's *inside* the box? Sometimes it's useful to inspect your hardware without using a screwdriver. In [ Linux commands to display your hardware information](https://opensource.com/article/19/9/linux-commands-hardware-information), Howard Fosdick provides both popular and obscure commands to help you dig deep into the computer you're using, the computer you're testing at the store before buying, or the computer you're trying to repair.

## How to encrypt files with gocryptfs on Linux


Our files hold lots of private data, from social security numbers to personal letters to loved ones. In [ How to encrypt files with gocryptfs on Linux](https://opensource.com/article/19/8/how-encrypt-files-gocryptfs), Brian "Bex" Exelbierd explains how to keep

*private*what's meant to be private. As a bonus, he demonstrates encrypting files in a way that has little to no impact on your existing workflow. This isn't a complex PGP-style puzzle of key management and background key agents; this is quick, seamless, and secure file encryption.

## How to use advanced rsync for large Linux backups

In the New Year, many people will resolve to be more diligent about making backups. Alan Formy-Duval must have made that resolution years ago, because in [ How to use advanced rsync for large Linux backups](https://opensource.com/article/19/5/advanced-rsync), he displays remarkable familiarity with the file synchronization command. You might not remember all the syntax right away, but the idea is to read and process the options, construct your backup command, and then automate it. That's the smart way to use

**rsync**, and it's the

*only*way to do backups reliably.

## Using more to view text files at the Linux command line

In Scott Nesbitt's article [ Using more to view text files at the Linux command line](https://opensource.com/article/19/1/more-text-files-linux), the good old default pager

**more**finally gets the spotlight. Many people install and use

**less**, because it's more flexible than

**more**. However, with more and more systems being implemented in the sparsest of containers, the luxury of fancy new tools like

**less**or

**most**sometimes just doesn't exist. Knowing and using

**more**is simple, it's a common default, and it's the production system's debugging tool of last resort.

## What you probably didn't know about sudo

The **sudo** command is famous to a fault. People know the **sudo** term, and most of us believe we know what it does. And we're a little bit correct, but as Peter Czanik reveals in his article [ What you probably didn't know about sudo](https://opensource.com/article/19/10/know-about-sudo), there's a lot more to the command than just "Simon says." Like that classic childhood game, the

**sudo**command is powerful and also prone to silly mistakes—only with greater potential for horrible consequences. This is one game you do not want to lose!

## How to program with Bash: Syntax and tools

If you're a Linux, BSD, or Mac (and lately, Windows) user, you may have used the Bash shell interactively. It's a great shell for quick, one-off commands, which is why so many Linux users love to use it as their primary user interface. However, Bash is much more than just a command prompt. It's also a programming language, and if you're already using Bash commands, then the path to automation has never been more straightforward. Learn all about it in David Both's excellent [ How to program with Bash: Syntax and tools](https://opensource.com/article/19/10/programming-bash-syntax-tools).

## Master the Linux ls command

The **ls** command is one of those commands that merits a two-letter name; one-letter commands are an optimization for slow terminals where each letter causes a significant delay and also a nice bonus for lazy typists. Seth Kenlon explains how you can [ Master the Linux ls command](https://opensource.com/article/19/7/master-ls-command) and he does so with his usual clarity and pragmatism. Most significantly, in a system where "everything is a file," being able to list the files is crucial.

## Getting started with the Linux cat command

The **cat** command (short for con*cat*enate) is deceptively simple. Whether you use it to quickly see the contents of a file or to pipe the contents to another command, you may not be using **cat** to its full potential. Alan Formy-Duval's elucidating [ Getting started with the Linux cat command](https://opensource.com/article/19/2/getting-started-cat-command) offers new ideas to take advantage of a command that lets you open a file without feeling like you've opened it. As a bonus, learn all about

**zcat**so you can decompress files without all the trouble of decompression! It's a small and simple thing, but

*this*is what makes Linux great.

## Continue the journey

Don't let Opensource.com's 10 best articles about Linux commands of 2019 be the end of your journey. There's much more to discover about Linux and its versatile prompt, so stay tuned in 2020 for more insights. And, if there's a Linux command you want us to know about, please tell us about it in the comments, or share your knowledge with Opensource.com readers by [submitting an article](https://opensource.com/how-submit-article) about your favorite Linux command.

## 1 Comment