search
HomeSystem TutorialLINUXInteresting treasure! 6 Unique and Amazing Linux Utilities for You

In this article, we'll dig deeper into the hidden corners of /usr/bin and uncover some more interesting treasures. We'll explore some unique and interesting programs that may seem outdated at first glance, but are actually still very useful today.

Let's get back on the road of adventure and continue to discover more wonderful things that Linux has to offer us.

1、fold

First of all, we have a very useful little tool that can help you wrap input lines to a specific length. You can define the length by specifying the number of bytes or spaces. Using the fold tool, you can quickly process files with different lengths.

For example, assume we have a line of input that is six characters long. We want to limit each line to only five characters and wrap the remainder. Using fold, we can achieve this using the following command:

┌──(linuxmi㉿linuxmi)-[~/www.linuxmi.com]
└─$ echo "12345678" | fold -w 7

The corresponding output should be:

1234567
8
有趣的宝藏!6 个你独特而惊人的 Linux 实用工具

Now we can quickly fit some text into our length limit. This is useful for breaking up long text streams or for enforcing line length limits on code or other configuration files.

For more details on using fold, check out the wiki page.

2、column

This is another very useful formatting tool. The column tool can help you create columns in text output or even generate entire tables, all from the command line.

Although the same functionality can be achieved using tools such as awk, the column tool is designed for this specific purpose, so it is very simple to use, and its syntax is easy to remember.

If we want to build a simple table based on a few lines of input, we can execute the following command:

┌──(linuxmi㉿linuxmi)-[~/www.linuxmi.com]
└─$ echo -e "one two three\n1 2 3\n93139 777777 999999" | column -t

The output of the command should look like this:

one    two     three
1      2       3
93139  777777  999999
有趣的宝藏!6 个你独特而惊人的 Linux 实用工具

As you can see, the output is automatically formatted into neatly aligned columns. This forms a small table in the output, which automatically resizes based on the length of each line of input.

This tool will be a big help if you are working with a slightly longer unstructured data set on the command line and want to quickly create some tabular forms.

column's man page provides more usage details and unique ways of handling different inputs.

3、sg

You may have heard of the newgrp command. This command executes commands as a different group, but there is a simpler utility that achieves the same functionality. The sg utility allows you to directly execute commands with the permissions of another group you specify. You don't need to use pipes or change existing shell groups, just specify a group and a command.

To execute the ls command with the permissions of the sudo group, you can enter the following command:

┌──(linuxmi㉿linuxmi)-[~/www.linuxmi.com]
└─$ sg sudo ls
有趣的宝藏!6 个你独特而惊人的 Linux 实用工具

This will switch the ls command to run with the permissions of the sudo group. Once the command has finished executing, you will be returned to the normal group permissions you had before execution.

The

sg command is very helpful for testing new group permissions or quickly switching context to run a program from another group.

4、xxd

The xxd utility is one of many ways to perform a hex dump on Linux. There are many utilities with similar functionality, but the xxd program is slightly different. It has the added advantage that you can use this utility to do hex dumps and restores. There are many configurable flags and you can also perform patching operations on binaries.

Suppose we want to take a hex dump of the following file named linuxmi:

linuxmi

我们只需提供输入,xxd 将自动将文件编码到 stdout(对于较短的输入文件,这是一个很方便的默认功能):

┌──(linuxmi㉿linuxmi)-[~/www.linuxmi.com]
└─$ xxd linuxmi
00000000: 6c69 6e75 786d 690a
有趣的宝藏!6 个你独特而惊人的 Linux 实用工具

您还可以通过传递一个额外的文件名参数来直接将输出发送到转储文件:

xxd linuxmi 93139
有趣的宝藏!6 个你独特而惊人的 Linux 实用工具

这将将十六进制转储发送到名为 93139 的文件中。

xxd 的 man 页面可以在此处找到。

5、pwdx

这个方便的小实用程序来自于我们都熟悉和喜爱的古老 ps 实用程序家族。pwdx 实用程序可以让您获取运行中进程的当前工作目录。您只需要将进程的 PID 传递给它,它就会告诉您该进程的工作目录在哪里。

假设我们想找出 cron 进程在我们的机器上的工作目录。首先,我们只需要使用 ps 搜索并找到它的 PID,像这样:

┌──(linuxmi㉿linuxmi)-[~/www.linuxmi.com]
└─$ ps aux | grep cron
有趣的宝藏!6 个你独特而惊人的 Linux 实用工具

在这里,我们可以看到cron的PID是612。现在,我们只需要将该进程的PID传递给pwdx来确定其工作目录,像这样:

┌──(linuxmi㉿linuxmi)-[~/www.linuxmi.com]
└─$ sudo pwdx 691

如下图:

有趣的宝藏!6 个你独特而惊人的 Linux 实用工具

由于cron是系统进程,您需要使用sudo才能获取有关它的信息。命令完成后,我们得到了cron的当前工作目录,即 /var/spool/cron。
这可以是一个非常有价值的故障排除工具,特别是当您追踪目录范围问题时。通过使用 pwdx 进行快速检查,您可以准确地确定一个进程认为它应该从哪个位置运行。

在这里查看 pwdx 的 man 页面。

6、write

这个强大的小程序可能不会像您一开始想的那样执行某个特定任务。它在 Linux 中已经存在了几十年,甚至可以追溯到 1975 年 Unix 的第 6版。

write 实用程序实际上允许您向同一系统上的其他用户发送消息。您可以针对任何其他登录的用户发送消息。提供用户名,您将进入一个交互式shell,以向他们写任何您想要的文本。您键入的所有内容(包括换行符)都将出现在目标用户的控制台上。

这里是一个快速示例:

write 

这将使您进入一个交互式控制台,以向相应的用户发送消息。请记住,这是一种相当侵入性的与其他用户通信的方式。这将使他们的终端显示您输入的文本,而无需任何警告或提示。对他们来说,这将出现在他们的终端上,就像自动出现的信息一样。由于这是单向通信,他们也无法回复。

尽管现在有更好的方法来处理用户之间的消息传递,但这是计算历史的一部分。我相信今天仍然可以有一些创造性的用途。

The above is the detailed content of Interesting treasure! 6 Unique and Amazing Linux Utilities for You. For more information, please follow other related articles on the PHP Chinese website!

Statement
This article is reproduced at:良许Linux教程网. If there is any infringement, please contact admin@php.cn delete
Does the internet run on Linux?Does the internet run on Linux?Apr 14, 2025 am 12:03 AM

The Internet does not rely on a single operating system, but Linux plays an important role in it. Linux is widely used in servers and network devices and is popular for its stability, security and scalability.

What are Linux operations?What are Linux operations?Apr 13, 2025 am 12:20 AM

The core of the Linux operating system is its command line interface, which can perform various operations through the command line. 1. File and directory operations use ls, cd, mkdir, rm and other commands to manage files and directories. 2. User and permission management ensures system security and resource allocation through useradd, passwd, chmod and other commands. 3. Process management uses ps, kill and other commands to monitor and control system processes. 4. Network operations include ping, ifconfig, ssh and other commands to configure and manage network connections. 5. System monitoring and maintenance use commands such as top, df, du to understand the system's operating status and resource usage.

Boost Productivity with Custom Command Shortcuts Using Linux AliasesBoost Productivity with Custom Command Shortcuts Using Linux AliasesApr 12, 2025 am 11:43 AM

Introduction Linux is a powerful operating system favored by developers, system administrators, and power users due to its flexibility and efficiency. However, frequently using long and complex commands can be tedious and er

What is Linux actually good for?What is Linux actually good for?Apr 12, 2025 am 12:20 AM

Linux is suitable for servers, development environments, and embedded systems. 1. As a server operating system, Linux is stable and efficient, and is often used to deploy high-concurrency applications. 2. As a development environment, Linux provides efficient command line tools and package management systems to improve development efficiency. 3. In embedded systems, Linux is lightweight and customizable, suitable for environments with limited resources.

Essential Tools and Frameworks for Mastering Ethical Hacking on LinuxEssential Tools and Frameworks for Mastering Ethical Hacking on LinuxApr 11, 2025 am 09:11 AM

Introduction: Securing the Digital Frontier with Linux-Based Ethical Hacking In our increasingly interconnected world, cybersecurity is paramount. Ethical hacking and penetration testing are vital for proactively identifying and mitigating vulnerabi

How to learn Linux basics?How to learn Linux basics?Apr 10, 2025 am 09:32 AM

The methods for basic Linux learning from scratch include: 1. Understand the file system and command line interface, 2. Master basic commands such as ls, cd, mkdir, 3. Learn file operations, such as creating and editing files, 4. Explore advanced usage such as pipelines and grep commands, 5. Master debugging skills and performance optimization, 6. Continuously improve skills through practice and exploration.

What is the most use of Linux?What is the most use of Linux?Apr 09, 2025 am 12:02 AM

Linux is widely used in servers, embedded systems and desktop environments. 1) In the server field, Linux has become an ideal choice for hosting websites, databases and applications due to its stability and security. 2) In embedded systems, Linux is popular for its high customization and efficiency. 3) In the desktop environment, Linux provides a variety of desktop environments to meet the needs of different users.

What are the disadvantages of Linux?What are the disadvantages of Linux?Apr 08, 2025 am 12:01 AM

The disadvantages of Linux include user experience, software compatibility, hardware support, and learning curve. 1. The user experience is not as friendly as Windows or macOS, and it relies on the command line interface. 2. The software compatibility is not as good as other systems and lacks native versions of many commercial software. 3. Hardware support is not as comprehensive as Windows, and drivers may be compiled manually. 4. The learning curve is steep, and mastering command line operations requires time and patience.

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: How To Unlock Everything In MyRise
1 months agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool