10 Lesser Known Linux Commands – Part 2

Introduction

Write an introduction on 10 Lesser Known Linux Commands – Part 2

10 Lesser Known Linux Commands – Part 2

10 Lesser Known Linux Commands – Part 2

Following up on our previous discussion of lesser-known Linux commands, this article will explore more hidden commands, which are extremely useful for managing your Linux system from the command line.

12. Command – Hiding Commands from Linux History

Every command you type in the terminal gets recorded in the history and can be retried using the history command.

How about cheating history command? Yeah, you can do it, and it is very easy. Just put one or more white space before typing a command in the terminal and your command won’t be recorded.

Let’s give it a try. We will enter five common Linux commands (ls, pwd, uname, echo, and who) in the terminal with a leading space and check if these commands are logged in the history or not.

ls
pwd
uname
echo “hi”
who

Now run the ‘history‘ command to see whether these above executed commands are recorded or not.

history

You see our last executed commands are not logged. we can also cheat history by using an alternate command ‘cat | bash‘of course without quotes, in the same way as above.

Hide Commands in Linux History
Hide Commands in Linux History

13. stat Command – Show File Status Information

The stat command in Linux displays the status information of a file or filesystem. The `stat` command shows a lot of information about the file whose name is passed as an argument.

Status information includes file size, blocks, access permissions, and the date and time of the last access, modification, and change.

stat lists.txt
Show File Status Information
Show File Status Information

14. Using + . and + . to Recall Last Command Arguments

The above key combination is not actually a command but a tweak that puts the last command argument at the prompt, in the order of the last entered command to the previous entered command.

Just press and hold Alt or Esc and continue pressing…

If your last command was:

ls /home/user/documents

Pressing Alt + . or Esc + . in the terminal will insert /home/user/documents at the prompt.

15. Simulating Text with the pv Command

You might have seen text being simulated in movies, especially Hollywood movies, where it appears as if it is being typed in real-time. You can simulate any kind of text and output in this fashion using the pv command, as shown in the example above.

The pv command might not be installed on your system, and you may need to use your package manager to install the required packages.

sudo apt install pv         [On Debian, Ubuntu and Mint]
sudo yum install pv         [On RHEL/CentOS/Fedora and Rocky/AlmaLinux]
sudo emerge -a sys-apps/pv  [On Gentoo Linux]
sudo apk add pv             [On Alpine Linux]
sudo pacman -S pv           [On Arch Linux]
sudo zypper install pv      [On OpenSUSE]    
sudo pkg install pv         [On FreeBSD]

Now you can use pv in combination with echo to simulate the typing of a message. Here, -q suppresses the progress bar and -L 20 sets the typing speed to 20 bytes per second.

echo "Tecmint [dot] com is the world's best website for qualitative Linux article" | pv -qL 20
Simulating Text in Terminal
Simulating Text in Terminal

16. Formatting Mounted Filesystems with mount and column

The command mount | column -t displays a list of all mounted filesystems in a neatly formatted table.

mount | column -t

This will show the list of mounted filesystems in a clean, organized format with columns properly aligned, making it easier to read and interpret the output.

Show Mounted Filesystems in Table Format
Show Mounted Filesystems in Table Format

17. Clearing Your Terminal with Ctrl+L Command

Before we proceed, let me ask you how you clear your terminal. Do you type clear at the prompt? Well, the Ctrl+L keyboard shortcut performs the same action of clearing your terminal all at once.

Just press Ctrl+L and watch how it clears your terminal instantly.

18. Checking Unread Mail with curl Command

The curl command can be used to check your unread mail from the command line, which is especially useful for those working on headless servers.

Note that storing your password in the command line directly is not recommended. Instead, curl will prompt you for your password securely.

curl -u username:password https://mail.example.com/api/unread

In the above command, replace username, and password and adjust the URL to match your mail server’s API endpoint.

19. Using ‘screen’ to Manage Long-Running Processes

The screen command makes it possible to detach a long-running process from a session that can again be reattached, as and when required which provides flexibility in command execution.

To run a process (long) we generally execute it as:

long_running_command

Which lacks flexibility and needs the user to continue with the current session, however, if we execute the above command as.

screen long_running_command

It can be de-attached or re-attached in different sessions. When a command is executing press “Ctrl + A” and then “d” to de-attach.

To attach run.

screen -r 4980.pts-0.localhost

Note: Here, the later part of this command is screen id, which you can get using the ‘screen -ls‘ command.

20. Identify File Types Using file Command

The file command is used to determine the type of a file by examining its contents rather than its name or extension.

It analyzes the file’s content and provides a description of its type.

file lists.txt

lists.txt: ASCII text

21. Find User and Group ID’s

The id command displays information about the current user or a specified user, including their user ID (UID), group ID (GID), and group memberships.

id
Show User and Group IDs
Show User and Group IDs
Conclusion

That’s all for now. With the success of this article and the previous ones in the series, I hope you’ve enjoyed exploring these lesser known Linux commands. Stay tuned for more insightful content.

In the meantime, you might find these articles interesting:

Don’t forget to share your valuable feedback in the comments!


generate an article with html tags on 10 Lesser Known Linux Commands – Part 2

Jaspreet Singh Ghuman

Jaspreet Singh Ghuman

Jassweb.com/

Passionate Professional Blogger, Freelancer, WordPress Enthusiast, Digital Marketer, Web Developer, Server Operator, Networking Expert. Empowering online presence with diverse skills.

jassweb logo

Jassweb always keeps its services up-to-date with the latest trends in the market, providing its customers all over the world with high-end and easily extensible internet, intranet, and extranet products.

Contact
San Vito Al Tagliamento 33078
Pordenone Italy
Item added to cart.
0 items - 0.00
Open chat
Scan the code
Hello 👋
Can we help you?