Meet 7 GNU tools that are the power of the command line

Indispensable tools for you to evolve in intimacy with terminal .


Meet 7 GNU tools that are the power of the command line


The GNU Project is a Free Software organization that created the term Open Source that today it is widely used by several companies.

The name GNU is an acronym for: GNU, is Not Unix . And that means:

The commands Unix© were so successful that many programmers and companies wanted to “copy them” . And most included the name Unix© in the name itself, examples: HP Unix, Berkeley Unix, … and so on.

But AT&T, the copyright holder of Unix© and its name, has prohibited the use of the Unix© name for projects similar to it.

So GNU came up with the idea of doing a satire using the name, but saying it wasn’t Unix©. 😛

Another thing is that the source code of Unix© programs was not available and even then, when used for study purposes, in this case for the University of California, Berkley, which later started BSD, had restrictive licenses.

So, the GNU created alternatives, that is, programs that did the same thing and with the source code available, in addition to having a license (created by them, the GPL) that even allowed redistribution.

The organization that distributes the software created by the GNU Project is the Free Software Foundation under the terms of the GNU General Public License (GNU GPL). Learn more .

One of the biggest differentiators of the GNU Software is the fact that it uses the POSIX standard which makes it portable to any operating system.

To advance in GNU commands is to advance in having terminal dexterity. So, let’s get to know 7 essential GNU tools for you !!!


1. GCC

GCC


GCC stands for GNU Compiler Collection, is a collection of compilers and optimizers for various programming languages, among them: C, C++, Java, Go, Fortran, Ada, D, Objective- C, Objective-C++ and more.

With nearly 20 million lines of code, GCC is one of the largest free programs in the world.

It has the widest range of architecture support, including:

AArch64, Alpha, ARM, AVR, Blackfin, eBPF, Epiphany (GCC 4.8), H8/300, HC12, IA-32 (x86), IA-64 (Intel Itanium), MIPS, Motorola 68000, MSP430, Nvidia GPU, Nvidia PTX, PA-RISC, PDP-11, PowerPC, R8C / M16C / M32C, RISC-V, SPARC, SuperH, System/390 / zSeries, VAX, x86-64, 68HC11, A29K, C6x, CR16, D30V, DSP16xx, ETRAX CRIS, FR-30, FR-V, IBM ROMP, Intel i960, IP2000, M32R, MCORE, MIL-STD-1750A, MMIX, MN10200, MN10300, Motorola 88000, NS32K, RL78, Stormy16, V850, Xtensa, Cortus APS3 , ARC, AVR32, C166 and C167, D10V, EISC, eSi-RISC, Hexagon[73], LatticeMico32, LatticeMico8, MeP, MicroBlaze, Motorola 6809, MRISC32, MSP430, NEC SX architecture[74], Nios II and Nios, OpenRISC , PDP-10, PIC24/dsPIC, PIC32, Propeller, Saturn (HP48XGCC), System/370, TIGCC (m68k variant), TMS9900, TriCore, Z8000 and among others.

The GCC has a list of over 500 contributors, all names can be accessed here .

Several companies use the GCC in many of the free software projects, among them the most famous ones such as: NASA, Google, IBM and more.

GCC’s biggest competitor is Clang/LLVM which is also a great compiler and despite being written from scratch, according to its own creator, Chris Lattner , said in some interviews that his biggest reference was the GCC, so Clang has all the parameters used by the GCC, also for compatibility reasons.

To install GCC you can use your system’s package manager or download GCC here.

Usage examples

Compiling programs written in C language :

gcc main.c
./a.out # Run the binary

Compiling programs in C++:

g++ main.cpp
./a.out # Run the binary

Compiling programs in Java:

gcj -C Hello.java # Compile to Hello.class
gij Hello # Run Hello.class

gcc is one of the most parameter-rich programs out there. To know all the parameters, use the manual:

man gcc

For more information visit the Official GCC Page .


2. GNU Sed

GNU Sed is a command-line text stream editor that parses and transforms text using a simple and compact programming language.

There are a few versions of Sed, and GNU Sed is one of them. When using GNU Sed and Sed from macOS, for example, you may come across a lot of differences between both and to note that the usability of GNU Sed is superior and has more parameters.

Basic usage example

Replacing and modifying all occurrences of the word That with the word This in a text file: example.txt

sed -i 's/That/This/' example.txt

For more information visit the Official GNU Sed Page .


3. GNU Awk

GNU Awk is one of the domain-specific language variants: AWK . As with GNU Sed, its main differential is the fact that it has the POSIX standard as we mentioned in the introduction.

It is also widely used for text editing and data filtering via the command line. The most basic example of usage would be:

Lists only the first column of a text file generated by the command ls -l > file.txt.

awk '{print $1}' file.txt

For more information visit the GNU Awk Official Page .


4. GNU Make

GNU Make


GNU Make is a build automation tool that automatically creates executable programs and libraries from source code by reading files called Makefiles that specify how to derive the target program.

Although integrated development environments and language-specific compiler features can also be used to manage a build process, GNU Make remains widely used.

There are some versions of the make command which is the command used by GNU Make, however, on many systems make is just an alias for GNU Make where the original command is gmake, this symlink can be discovered by combining two other GNU tools which is GNU Coreutils with the following command: ls -l $ (which make) .

When you have a correctly created Makefile, to compile it just run the command:

make

This command can be customized with parameters according to the Makefile .

We have an article for GNU Make and Makefile beginners that can be accessed at the link: How to Create a Makefile .

For more information visit the GNU Make Official Page .


5. GNU findutils

GNU findutils


The GNU findutils is a package that has the commands: find, locate, updatedb and xargs.

Among them, the most widely used in everyday life is, of course, the find. The GNU find command is more user-friendly than the Unix© command. For example:

To find all .txt files in your home directory with GNU findutils just run the command:

find ${HOME} -name *.txt

In Unix© find you need to explicitly enclose the search target in quotes, whereas in GNU find with or without quotes works the same way. And among many other differences.

We have an article with 20 examples of using the find command that can be accessed at the link: 20 examples of the find command .

For more information go to GNU findutils Official Page .


6. GNU grep

GNU grep is a command-line utility for searching plain-text datasets for patterns that match a regular expression .

There are variations of the grep command like: egrep and fgrep . Many usability of these commands are specific to GNU grep .

GNU grep becomes really powerful for use in conjunction with RegEx .

A basic usage example is, for example, listing the system groups that your user belongs to with the following command:

grep "$USER" /etc/group | egrep -o '^[a-z]+'

For more information visit the Official GNU grep Page .


7. GNU Bash

GNU Bash is an improvement over Unix© Sh. GNU Bash made it much simpler and easier to automate commands in Shell due to also its stability in relation to its options .

It is the most adopted in the world and has many modern features that set it apart. It was created by programmer Brian J. Fox

It has several commands such as: if, [[ ]], for, while,… that can be used directly in Shell and also combined as a scripting language in a file of any extension, however the most commonly used extensions to identify it are .sh and .bash .

I’ve created several things in my life with GNU Bash and it’s impossible to list them all. The last one I did and ironically the most successful was an app that adds videos as wallpaper.

You can see the video of this app working below:

The video is in Brazilian Portuguese, but it is possible to understand everything, as the commands are universal. To try to improve even more, you can activate automatic translation for your language, which although not 100% effective, it improves a lot.

A lot of people have submitted issues on GitHub and I’m just annotating the issues to fix them with the refactoring of this code that will be done with C++ .

I noticed that one of the biggest complaints is not being able to render the background videos as Full HD, so for that I’ll have to use more advanced libraries.

For more information go to Official GNU Bash Page , this is one of the best software documentation I’ve ever read.


Conclusion

There are, in fact, several other solutions from the GNU Project, such as GNU Glibc which is the interface that the Linux kernel runs on and allows miscellaneous: programs, graphical interfaces, window managers and desktop environments to work with great performance, and most of them don’t work without GNU Glibc.

For more information access:

https://gnu.org .


Useful links

The thumbnail used as the headline for this article was created and used by Red Hat at this link . The other images, with the exception of the GCC logo, were found on Google Images after searching for terms related to those used in this article.


gnu gcc bash


Share


YouTube channel

Subscribe


Marcos Oliveira

Marcos Oliveira

Software developer
https://github.com/terroo

Related articles