Advanced Linux Commands For The Power User

Filed Under: UNIX/Linux
Linux Commands For The Power User

If you’re a beginner, you may want to take a look at the top 50+ Linux commands. Today let’s take look at the advanced Linux commands for power users. Linux, in general is a CLI driven tool and as a power user, you might be inclined to use the terminal for all things possible.

Advanced Linux Commands for Power Users

In this module, we’ll go over some advanced functionalities for the power user who loves the command line. Without any further ado, let’s get right into it.

1. Checking Battery Status From The Terminal

One of the aspects of being a power user is to do even the simplest GUI-based tasks from the terminal. Sometimes, it is good practice to do even the simplest things from the terminal.

Checking your battery might be something menial but you might need it while writing scripts or while configuring your system (for example to write polybar or i3-status scripts)

To view your current battery stats, type in the acpi command:

$ acpi -V
Battery 0: Full, 100%
Battery 0: design capacity 2800 mAh, last full capacity 1939 mAh = 69%
Adapter 0: on-line
Thermal 0: ok, 27.8 degrees C
Thermal 0: trip point 0 switches to mode critical at temperature 100.0 degrees C
Thermal 0: trip point 1 switches to mode active at temperature 71.0 degrees C
Thermal 0: trip point 2 switches to mode active at temperature 55.0 degrees C
Thermal 0: trip point 3 switches to mode active at temperature 50.0 degrees C
Thermal 0: trip point 4 switches to mode active at temperature 45.0 degrees C
Thermal 1: ok, 25.0 degrees C
Thermal 1: trip point 0 switches to mode critical at temperature 107.0 degrees C
Thermal 2: ok, 29.8 degrees C
Thermal 2: trip point 0 switches to mode critical at temperature 100.0 degrees C
Thermal 2: trip point 1 switches to mode passive at temperature 95.0 degrees C
Cooling 0: Fan 0 of 1
Cooling 1: Processor 0 of 3
Cooling 2: Processor 0 of 3
Cooling 3: intel_powerclamp no state information available
Cooling 4: Fan 0 of 1
Cooling 5: Fan 0 of 1
Cooling 6: x86_pkg_temp no state information available
Cooling 7: Fan 0 of 1
Cooling 8: Processor 0 of 3
Cooling 9: Processor 0 of 3
Cooling 10: Fan 0 of 1

This should give you comprehensive details about your battery stats, which you can later use in scripts!

2. Replace Ping And Traceroute With MTR

When it comes to network diagnostics, we all are familiar with the commands like ping and traceroute. However, many users might find mtr to be a much more utilitarian tool.

It investigates the network connection between the host mtr runs on and the target by sending packets with purposely low TTLs, so at to examine each node in the route.

It continues to send packets with low TTL, noting the response time of the intervening routers. This allows mtr to print the response percentage and response times of the internet route to target.

MTR
MTR

3. Recursively List Files And Folders Tree

Another simple utility which can be greatly helpful is the tree command which is a recursive directory listing program that produces a depth indented listing of files.

It helps you view all the files and sub-folders in a directory in a clean way. This is useful especially during project management when you have a large number of files and doing ls every time proves to be too cumbersome.

$ tree
.
├── Program-1
│   ├── program-1
│   ├── program-1.rs
│   └── README.md
├── Program-2
│   ├── program-2
│   │   ├── Cargo.lock
│   │   ├── Cargo.toml
│   │   └── src
│   │       └── main.rs
│   └── README.md
├── Program-3
│   ├── program-3
│   │   ├── Cargo.toml
│   │   └── src
│   │       └── main.rs
│   └── README.md
├── Program-4
│   ├── program-4
│   │   ├── Cargo.toml
│   │   └── src
│   │       └── main.rs
│   └── README.md
└── README.md

4. Taking Screenshots From The Terminal

Adding to the list of CLI tools to replace their GUI alternatives, we have scrot, a CLI based screen capture utility which you can use to capture screenshots.

A very handy function of scrot is that it can be included in scripts and config files. For example, you can add the following line to your i3 config to capture a screenshot and store it in a folder ~/Pictures/Screenshots when the PrtScr button is pressed:

bindsym --release Print exec scrot 'Screenshot_%Y%m%d_%H%M%S.png' -e 'mkdir -p ~/Pictures/Screenshots && mv $f ~/Pictures/Screenshots && xclip -selection clipboard -t image/png -i ~/Pictures/Screenshots/`ls -1 -t ~/Pictures/Screenshots | head -1`'
Taking Screenshots With Scrot
Taking Screenshots With Scrot

5. Process Monitoring With Pstree

Process management has always been a cumbersome task for Linux users. The tracking of processes and their child process can be quite the task for the user.

This is where pstree comes into play. pstree shows running processes as a tree which let’s you view the child threads of a process which can be found under the parent process.

For integration with xterminal, you can also use pstree.x11 command. This command is especially useful as it gives you a comprehensive output which let’s you visualize the process tree in the terminal itself.

systemd─┬─NetworkManager───2*[{NetworkManager}]
        ├─bluetoothd
        ├─brave─┬─brave───brave───12*[{brave}]
        │       ├─brave───brave─┬─brave───5*[{brave}]
        │       │               ├─6*[brave───10*[{brave}]]
        │       │               ├─brave───15*[{brave}]
        │       │               ├─brave───4*[{brave}]
        │       │               ├─brave───14*[{brave}]
        │       │               └─brave───13*[{brave}]
        │       ├─brave───7*[{brave}]
        │       ├─brave───4*[{brave}]
        │       ├─brave───6*[{brave}]
        │       ├─plasma-browser-───2*[{plasma-browser-}]
        │       └─25*[{brave}]
        ├─crond
        ├─dbus-daemon
        ├─kitty─┬─fish───pstree
        │       └─6*[{kitty}]
        ├─kwalletd5
        ├─nm-applet───7*[{nm-applet}]
        ├─polkitd───7*[{polkitd}]
        ├─polybar───10*[{polybar}]
        ├─rtkit-daemon───2*[{rtkit-daemon}]
        ├─sddm─┬─Xorg───5*[{Xorg}]
        │      ├─sddm-helper───i3───{i3}
        │      └─{sddm}
        ├─systemd─┬─(sd-pam)
        │         ├─at-spi-bus-laun─┬─dbus-daemon
        │         │                 └─3*[{at-spi-bus-laun}]
        │         ├─at-spi2-registr───2*[{at-spi2-registr}]
        │         ├─dbus-daemon
        │         ├─dunst───2*[{dunst}]
        │         ├─gvfsd───2*[{gvfsd}]
        │         ├─gvfsd-fuse───5*[{gvfsd-fuse}]
        │         ├─kdeconnectd───3*[{kdeconnectd}]
        │         └─pulseaudio─┬─gsettings-helpe───3*[{gsettings-helpe}]
        │                      └─2*[{pulseaudio}]
        ├─systemd-homed
        ├─systemd-journal
        ├─systemd-logind
        ├─systemd-udevd
        ├─systemd-userdbd───3*[systemd-userwor]
        ├─upowerd───2*[{upowerd}]
        ├─wpa_supplicant
        └─xss-lock───2*[{xss-lock}]

6. Make Your Shell Scripts Look More Professional With Whiptail

Whiptail is one of those programs which make your shell scripts look more professional and infact used very extensively. Whiptail lets you create a variety of questions or display messages using dialog boxes
from a shell script.

  • Menu boxes
  • Input boxes
  • Message boxes
  • Text boxes
  • Password input boxes
  • Yes or no choices
  • Checklists
  • Radiolist boxes
  • Gauge boxes
  • Password boxes
Whiptree Prompt
Whiptree Prompt

For example, you can create a YES/NO box to control the flow of execution of your program. You can create a dialog box and store the result in a variable : 0 signifies YES while 1 signifies NO

#!/bin/bash
whiptail --yesno "Question ?" 10 40
choice=$?
if [ $choice = 0 ]; then
  --do stuff--
else
  --do other stuff--
fi

7. Generate Color Palettes With Pywal

Tired of generating “just the right config” to match your desktop background everytime you rice your Desktop ? Pywal to the rescue ! Pywal is a tool that generates a color palette from the dominant colors in an image. It then applies the colors system-wide and on-the-fly in all of your favourite programs.

It is highly customizable and can be integrated with a lot of applications, including window managers, text editors, utility applications, application launchers, terminal emulators, etc.

You can fetch pywal from the Github Repository or install it directly with :

$ sudo pip3 install pywal
Pywal
Pywal

Conclusion

These are some intermediate to advanced level programs which you can use to be a better Linux user. These will help you be more proficeint and make your Linux Experience smoother !

Leave a Reply

Your email address will not be published. Required fields are marked *

close
Generic selectors
Exact matches only
Search in title
Search in content