在 Linux 中玩乐：Cmatrix 之旅
Cmatrix 趣味
![](/data/attachment/album/202311/28/072046sff97h9bfqvfq8va.png)



> 
> 玩得开心，安德森先生！
> 
> 
> 


Cmatrix 是一款充满乐趣的 Linux 和 Unix 系统命令行程序。它可以模仿经典电影《<ruby> 黑客帝国 <rt>  Matrix </rt></ruby>》系列中的场景，用绿色的字符流营造出雨一般的下落效果。


![Cmatrix 命令](/data/attachment/album/202311/28/072131a1ov77n4bvooh9vi.gif)


除了充满视觉冲击力的绿色字符流之外，你还可以发挥想象，利用这款有趣的命令做更多事情。



> 
> ? 需要注意的是，Cmatrix 是一个 CPU 密集型的命令，所以请慎重使用它。
> 
> 
> 


### 如何在 Ubuntu 及其他 Linux 系统中安装 Cmatrix


Cmatrix 已经被收录在几乎所有主要的 Linux 发行版的官方库中。如果你是 Ubuntu 用户，可以通过如下命令来安装 Cmatrix：



```
sudo apt install cmatrix

```

对于 Fedora 用户，应该使用以下命令进行安装：



```
sudo dnf install cmatrix

```

而对于 Arch Linux 用户，则可以使用 pacman 命令进行安装：



```
sudo pacman -S cmatrix

```

### Cmatrix 的基础应用


cmatrix 命令自身提供了丰富的选项，你可以自由改变默认的绿色字符流的外观呈现。


#### 加粗的字符


你可以选择使用 `-b` 选项，偶尔展示加粗的字符，



```
cmatrix -b

```

![加粗的 Cmatrix 字符](/data/attachment/album/202311/28/072131mqsgr96qnf9s6a6r.png)


或者，你也可以调整设置，让所有的字符都以加粗方式显示，



```
cmatrix -B

```

![全部显示为加粗的字符](/data/attachment/album/202311/28/072132gx204rn2554ssr0n.png)


#### 异步滚动


默认情况下，Cmatrix 会创建一个字符同步下落的显示。但如果你想看到一个更为动态、视觉上更吸引人的显示效果，就可以在代码中操控字符的下落速度。


你可以这样设置 Cmatrix，让其进行异步滚动：



```
cmatrix -a

```

#### 自定义字符下落速度


你想让字符下落的速度更快，或者更慢吗？只需在 Cmatrix 中做出微小改动，就可以实现。


如想让字符以更快的速度下落，你可以这样设定：



```
cmatrix -u 2

```

![字符快速下落](/data/attachment/album/202311/28/072133l5554m58oxjlxirp.gif)


在这里，默认的屏幕更新延迟是 4，如果你把这个值降低，那么字符下落的速度就会增加，反之则会减慢。所以，如果你想让 Cmatrix 以更慢的速度运行，你可以这样设置：



```
cmatrix -u 9

```

![字符慢速下落](/data/attachment/album/202311/28/072134w2eqad028dnqj0ad.gif)


#### 自定义颜色


你可能想问，绿色能改吗？当然，你想变成紫色也行。


运行 Cmatrix 的时候，你可以自由调整它的颜色。只需要使用 `-C` 选项，然后在后面添加你想要的颜色，如下所示：



```
cmatrix -C magenta

```

![颜色变为洋红色](/data/attachment/album/202311/28/072134jo8dyezovqavdqqw.png)


你可以任选绿色（`green`）、红色（`red`）、蓝色（`blue`）、白色（`white`）、黄色（`yellow`）、青色（`cyan`）、洋红色（`magenta`）以及黑色（`black`）这些颜色。


#### 其他可选设置




| 选项 | 对应功能 |
| --- | --- |
| `cmatrix -o` | 旧式滚动模式 |
| `cmatrix -m` | Lambda 模式：把所有的字符变为 lambda 符号 |
| `cmatrix -s` | 屏保模式：按键有就自动退出 |
| `cmatrix -h` | 调出帮助手册 |


### 运行 Cmatrix 时的快捷键选项


就算在启动 Cmatrix 的时候你没有添加任何选项，你仍可以在实际运行中随时改变设置。下面就是一些可供你随时选择的选项。


#### 随时改变颜色


当然，你无需重新启动程序，就可以随时改变显示的颜色。但需要记住，不同的键位对应着不同的颜色。在 Cmatrix 未关闭的情况下，如果你按下了存储在键位上的指令，显示的颜色将会直接变更。




| 颜色 | 相应键位 |
| --- | --- |
| 红色 | `!` |
| 绿色 | `@` |
| 黄色 | `#` |
| 蓝色 | `$` |
| 洋红色 | `%` |
| 青色 | `^` |
| 白色 | `&` |
| 黑色 | `)` |


#### 自由调整更新速度


在 Cmatrix 运行的过程中，你可以按 `0` 到 `9` 的任何一位数字键来随意改变当前的更新速度。


此外，Cmatrix 也有许多其他的选项可供你选择，你可以在命令的 man 页面里面找到它们。



```
man cmatrix

```

### 彩虹魔法：Cmatrix 配合 lolcat



> 
> ? 请注意，Cmatrix 本身就是 CPU 密集型的命令，所以在使用其他命令操控它的时候需特别小心。
> 
> 
> 


你可以将 Cmatrix 和 lolcat 结合在一起使用，以此营造出一种更加有趣的视觉效果。如果你是 Ubuntu 的用户，可以通过如下的命令来安装 lolcat：



```
sudo apt install lolcat

```

安装完毕后，只需简单地通过管道将 Cmatrix 连接到 lolcat，你便可以看到赏心悦目的彩虹效果了。



```
cmatrix | lolcat

```

![Cmatrix 配合 Lolcat 效果](/data/attachment/album/202311/28/072135ehzesslvwhdzdhwe.png)


当然，你也可以尝试用 lolcat 来管理所有的 Cmatrix 的功能。


或者，你可以调出一个倾斜的彩虹条纹效果，为自己的视觉体验增添一些新花样。



```
cmatrix | lolcat -p 100

```

此外，只要轻轻一点，你就可以直接反转现有的背景和前景颜色，使你的终端完全沉浸在五彩斑斓之中。



```
cmatrix | lolcat -i

```

![Cmatrix 与反转颜色的 Lolcat](/data/attachment/album/202311/28/072135hem7zmh9aojwqjvh.png)


### 终端界面的无尽可能


我知道 Cmatrix 不可能是 [最实用的 Linux 命令](https://itsfoss.com/essential-ubuntu-commands/)，但无可否认，它令人喜爱且同样能够带给你乐趣。难道你不想尝试更多和你的 Linux 系统之间的 [有趣交互](https://itsfoss.com/funny-linux-commands/) 吗？


就像 [Cowsay](/article-15952-1.html) 这样的命令，虽然简单，却欢乐无穷：



> 
> **[哞~ 我的 Linux 终端里有头牛](/article-15952-1.html)**
> 
> 
> 


这里还有更多玩法等待你去探索：



> 
> **[在终端中享受乐趣的 13 种 Linux 命令](https://itsfoss.com/funny-linux-commands/)**
> 
> 
> 


现在，玩得开心，安德森先生！


*（题图：MJ/9f9f8665-e5d0-47b5-9df0-b39abd9dca3d）*




---


via: <https://itsfoss.com/using-cmatrix/>


作者：[Sreenath](https://itsfoss.com/author/sreenath/) 选题：[lujun9972](https://github.com/lujun9972) 译者：[ChatGPT](https://linux.cn/lctt/ChatGPT) 校对：[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)

Cmatrix is an entertaining command-line program for Linux and Unix systems. It gives a 'Matrix'-style display, where a rain of green characters streams down the screen, just like in the iconic Matrix film series.

![Running Cmatrix command without any options.](https://itsfoss.com/content/images/2023/10/Cmatrix.gif)

But other than this green streams of characters, you can do several other things with this interesting command.

## Install Cmatrix in Ubuntu and Other Linux systems

Cmatrix is available in the official repositories of almost all major Linux distributions. In Ubuntu, you can install Cmatrix using the command:

`sudo apt install cmatrix`


Fedora users should use:

`sudo dnf install cmatrix`


Arch Linux user can use pacman:

`sudo pacman -S cmatrix`


## Basic cmatrix options

The cmatrix command alone provides several options, to change the appearance of the default output, that is the green character streams.

### Bold characters

You can either toggle the bold characters on using `-b`

option, where you will find occasional bold characters,

`cmatrix -b`


![Cmatrix will show occasional bold letters if used with the small letter b option.](https://itsfoss.com/content/images/2023/10/cmatrix-occasional-bold-characters.png)

or, turn all the characters to bold using:

`cmatrix -B`


![Cmatrix will show occasional bold letters if used with the capital letter B option.](https://itsfoss.com/content/images/2023/10/cmatrix-all-bold-characters.png)

### Asynchronous scroll

The usual Cmatrix will create a display, where characters are falling down in a synchronous manner. In this mode, you can see a dynamic and visually engaging display, where the speed of the characters is varied.

To use Cmatrix in asynchronous scroll:

`cmatrix -a`


### Change the speed of characters

Do you want to display the characters falling very fast, or very slow? You can do this in Cmatrix.

To make characters fall down fast, use:

`cmatrix -u 2`


![Cmatrix with low value of update delay, so that the characters are moving fast.](https://itsfoss.com/content/images/2023/10/Cmatrix-fast.gif)

Here, the default value of screen update delay is 4 and if you reduce it, the speed will be increased and vice versa. So, to run a slower cmatrix, use:

`cmatrix -u 9`


![Cmatrix characters moving slowly because the value for screen update delay was set high.](https://itsfoss.com/content/images/2023/10/cmatrix-slow.gif)

### Use different Colors

Go green! Or perhaps go purple?

You can run Cmatrix with a different color. For this, you can use the `-C`

option.

`cmatrix -C magenta`


![Running Cmatrix with a different color using the color option. Here, the magenta color is used.](https://itsfoss.com/content/images/2023/10/cmatrix-magenta-color.png)

The supported colors are **green, red, blue, white, yellow, cyan, magenta and black**.

### Other Options

Option | Function |
---|---|

cmatrix -o | Old Style Scrolling |

cmatrix -m | Lambda Mode: Every character becomes a lambda |

cmatrix -s | Screensaver Mode: Exits on first keystroke |

cmatrix -h | Help |


## Cmatrix keystrokes during execution

Even if you don’t provide any option in Cmatrix, you can provide some input later on during execution. Those are listed below.

### Change Color

Yes, you can change the color of characters while running. But you need to remember some keys and their corresponding color. What to do is, while running Cmatrix, press these keys and the color will change.

Color | Keystroke |
---|---|

Red | ! |

Green | @ |

Yellow | # |

Blue | $ |

Magenta | % |

Cyan | ^ |

White | & |

Black | ) |


### Adjust update speed

While running, you can use the number keys from 0 through 9 to change the update speed.

There are other options also, which you can find from the man page of the command.

`man cmatrix`


## Bonus: Cmatrix with lolcat

You can use Cmatrix, in combination with the lolcat command, to make it look more interesting. In Ubuntu, you can install lolcat using:

`sudo apt install lolcat`


Now, just pipe Cmatrix to lolcat so that you will get a rainbow effect.

`cmatrix | lolcat`


![Piping the Cmatrix command to lolcat, to display rainbow color effect.](https://itsfoss.com/content/images/2023/10/Cmatrix-with-lolcat.png)

Also, try all the above functions of Cmatrix, while piping into lolcat.

Or, you can use an inclined stripe for a rainbow effect, giving another type of experience.

`cmatrix | lolcat -p 100`


Additionally, you can just invert the background and foreground colors so that your terminal will be filled with colors.

`cmatrix | lolcat -i`


![Inverting the background and foreground color in lolcat. The output of Cmatrix is piped to this inverted color option.](https://itsfoss.com/content/images/2023/10/cmatrix-with-inverse-colors.png)

## More fun with terminal

I know this is not the [most useful Linux command](https://itsfoss.com/essential-ubuntu-commands/) but it's fun nonetheless and you can have some [fun with your Linux system](https://itsfoss.com/funny-linux-commands/) sometime, right?

[Cowsay](https://itsfoss.com/cowsay/) is another such command:

[Using Cowsay Linux Command Like a ProThe cowsay is a fun little Linux command line utility that can be enjoyed in so many ways. Here are several examples.](https://itsfoss.com/cowsay/)![](https://itsfoss.com/content/images/2023/06/cowsay-linux-1.png)


![](https://itsfoss.com/content/images/2023/06/cowsay-linux-1.png)

And even more here:

[13 Amusing Funny Linux CommandsSo, you think Linux terminal is all work and no fun? These funny Linux commands will prove you wrong.](https://itsfoss.com/funny-linux-commands/)![](https://itsfoss.com/content/images/wordpress/2020/04/fun-linux-commands.png)


![](https://itsfoss.com/content/images/wordpress/2020/04/fun-linux-commands.png)

I let you enjoy it now, Mr. Anderson.