gnu

  • GNU – File

    Have you ever wanted to know the type of a file?. You can with the file command. For example, the command:

    file archive.pdf

    will return something like:

    archive.pdf: PDF document, version 1.5

    easy and very helpful. As always, check the man pages for more information.

  • Upower

    Have you ever wanted to know how good or bad is your battery health? You do not want to install complex programs to get that info. Think no more, because Upower comes to the rescue. This nice tool allows you to get information about your battery, showing you a very nice report about it. Just type:

    upower -e

    to list all avalaible devices. And type:

    upower -i "device"

    to get a report

    As always, for more information read the man pages.

  • GNU -less

    This is an impressive cli command. It does a simple task: show a file content progressively, that is to say, one page at a time. If the file is big this utility is faster than more because it does not have to load the entire file at once, just the first page. You can acces the rest of the document page by page with its own pager system, as if it was a text reader like vim or emacs. The basic sintax is :

    less "filename"

    You can do a ton of things with this utility. The man documentation shows hundreds of options and posibilities. For instance:

    less "filename" -p "text to start"

    command will allow you to open file «filename» and start showing the content when the text «text to start» is found.

    As always, check the man page for more information and options, but be aware that this utility is huge in terms of posibilities.

  • GNU- Uname

    This is a simple command. It give us the system information. It has a few options, as:

    uname -a -> shows all info

    uname - v -> shows kernel version

    uname - o -> shows operating system version

    There are many options, so as always, check the man pages for more info.

  • GNU – touch

    This simple command is able to do a few things. If you read the man description it will tell you this:

    touch - change file timestamps

    so basically this tool changes the timestamp of a file, but it can also do:

    A FILE argument that does not exist is created empty, unless -c or -h is supplied

    which is what people usually use this command for. So the next time you need to create an empty file, in a fast and simple way, just type:

    touch filename

    and a new empty file named filename will be created for you. As allways check the man page for more information

  • Ncdu

    Have you ever wondered what is taking so much space in your hard drives? You have thousands of files but you dont know what is what or where are the biggest files. Well, sometimes you need a way to know what is inside your hard drive. You can achieve this with a beautiful and useful utility: ncdu

    Simply type

    ncdu /

    and you will get something like this:

    88,6 MiB [##########] dockerd
    57,8 MiB [###### ] docker
    40,9 MiB [#### ] containerd
    30,7 MiB [### ] x86_64-linux-gnu-lto-dump-12
    23,7 MiB [## ] x86_64-linux-gnu-lto-dump-11
    23,3 MiB [## ] ctr
    19,6 MiB [## ] containerd-stress
    15,4 MiB [# ] snap
    15,1 MiB [# ] qemu-system-x86_64
    15,0 MiB [# ] qemu-system-i386
    9,8 MiB [# ] gdb
    9,6 MiB [# ] gimp-2.10
    8,0 MiB [ ] gtk4-encode-symbolic-svg
    7,7 MiB [ ] rustdoc
    7,7 MiB [ ] containerd-shim-runc-v2
    7,7 MiB [ ] containerd-shim-runc-v1
    7,3 MiB [ ] ctest
    6,5 MiB [ ] qemu-system-x86_64-microvm
    6,4 MiB [ ] cmake

    That way you have a good representation of every part of your file system. In some distros you need to install the utility as is not installed by default. As always check the man pages for more info.

  • The !! bash command

    There is a not very well known bash command that allows you to repeat the last input you typed in the shell. Behold the «!!» command. This simply allows us to retype the last input. For instance:

    If I type: (to list files in the local directory):

    ls -lh

    and after that I type:

    !!

    It will repeat the «ls -lh» command.

    This comes in handy when you want to script bash in a file. You can also add regex expressions. Imagine you forgot to include the hidden files in your listing, you can replace «lh» with «lha»

    !!:s/lh/lha

    As always, feel free to experiment. And do not forget to check the documentation.

  • GNU – Shred

    Have you ever wanted to delete «permanently» a file from your file system?. Well, you can do it with this command: shred . First, a litle about how a file system works. Simply put, the system keeps a table with references to each file. When you delete a file what really happens is that the operating system removes the reference to the file from the table of references, but the data is still there, so is possible to recover the data. If you really want to delete a file you can use shred. This utility overwrite with random data the file so its unrecoverable. Example: (the u option deletes the file after overwriting)

    shred -u filename

    As always, see the documentation for more options and use cases.

  • GNU – duf

    This can be seen as an improvement of the classical command df, that allows us to show the file system disk space usage. If you type df -h (the h option is for human readable) it will show you something like this:

    tmpfs 1,6G 2,8M 1,6G 1% /run
    /dev/nvme0n1p2 468G 222G 223G 50% /
    tmpfs 7,8G 0 7,8G 0% /dev/shm
    tmpfs 5,0M 4,0K 5,0M 1% /run/lock
    tmpfs 7,8G 0 7,8G 0% /run/qemu
    /dev/nvme0n1p1 511M 5,3M 506M 2% /boot/efi

    Nice, but a bit clunky. Instead if you use duf, you will see something like this:

    ╭──────────────────────────────────────────────────────────────────────────────────────────────────────╮
    │ 3 local devices                                                                                      │
    ├───────────────────┬────────┬────────┬────────┬───────────────────────────────┬──────┬────────────────┤
    │ MOUNTED ON        │   SIZE │   USED │  AVAIL │              USE%             │ TYPE │ FILESYSTEM     │
    ├───────────────────┼────────┼────────┼────────┼───────────────────────────────┼──────┼────────────────┤
    │ /                 │ 467.9G │ 221.9G │ 222.2G │ [#########...........]  47.4% │ ext4 │ /dev/nvme0n1p2 │
    │ /boot/efi         │ 511.0M │   5.2M │ 505.7M │ [....................]   1.0% │ vfat │ /dev/nvme0n1p1 │
    │ /media/user/disc  │ 457.1G │ 333.2G │ 100.6G │ [##############......]  72.9% │ ext4 │ /dev/sda2      │
    ╰───────────────────┴────────┴────────┴────────┴───────────────────────────────┴──────┴────────────────╯
    ╭────────────────────────────────────────────────────────────────────────────────────────────────╮
    │ 7 special devices                                                                              │
    ├────────────────┬──────┬────────┬───────┬───────────────────────────────┬──────────┬────────────┤
    │ MOUNTED ON     │ SIZE │   USED │ AVAIL │              USE%             │ TYPE     │ FILESYSTEM │
    ├────────────────┼──────┼────────┼───────┼───────────────────────────────┼──────────┼────────────┤
    │ /dev           │ 7.7G │     0B │  7.7G │                               │ devtmpfs │ udev       │
    │ /dev/shm       │ 7.7G │     0B │  7.7G │                               │ tmpfs    │ tmpfs      │
    │ /run           │ 1.5G │   2.8M │  1.5G │ [....................]   0.2% │ tmpfs    │ tmpfs      │
    │ /run/lock      │ 5.0M │   4.0K │  5.0M │ [....................]   0.1% │ tmpfs    │ tmpfs      │
    │ /run/qemu      │ 7.7G │     0B │  7.7G │                               │ tmpfs    │ tmpfs      │
    │ /run/snapd/ns  │ 1.5G │   2.8M │  1.5G │ [....................]   0.2% │ tmpfs    │ tmpfs      │
    │ /run/user/1000 │ 1.5G │ 140.0K │  1.5G │ [....................]   0.0% │ tmpfs    │ tmpfs      │
    ╰────────────────┴──────┴────────┴───────┴───────────────────────────────┴──────────┴────────────╯
    

    Which is a much better way to see the information. As always check the man page for more info about this command.

  • GNU – pwd

    Have you ever wondered how to get the path of the working directory?. To do that you can use the command: PWD . This simple order gives you precisely that, the working directory, for instance:

    pwd > returns /home/user/dir

    As always use the man command to get more info about the inner details of this easy but useful tool.