The Command Line
Welcome back again, gentle readers! Tonight we will continue with a lighter topic: the command line. Truthfully we could fill a book (and others have!) of everything the command line is capable of. The purpose of this entry is not to make you a command line expert, but to get you comfortable with some of the functions of the command line. Most of these commands should work regardless of the linux distribution you’re running. Where there are differences I will try to point them out. As an aside: I know that everyone has a preference in terminals, whether it’s tilex, yakuake, or the standard terminal that comes bundled with your distro. No judgements, but I do encourage you to explore different options to figure out what works best for you!
To start lets install a program:
For Ubuntu based distributions:
sudo apt-get install -y cowsay fortune
For RHEL/Fedora-based distributions:
sudo dnf install cowsay fortune
or for CentOS:
sudo yum install cowsay fortune
This command installs two programs. Cowsay and Fortune. I will go into more details regarding these programs later, however if you want to remove them at any point just replace “install” with “remove” in the commands above.
So, what can we do with the command line? Short answer: just about everything! Being comfortable in the command line requires a certain amount of imagination, and a little bit of intuition. One of the most useful features of the command line, for me anyhow, is tabbing. Try this command out:
ip
instead of pressing ‘Enter’ press ‘Tab’ twice.
you should see a list of possible commands populate. This is useful if you’re familiar with a program (such as ip) but don’t recall a specific command.
The next feature of the command line you should know is the double &. This strings two commands together, which is useful in distributions like Ubuntu where you have to run two separate commands to update and upgrade.
sudo apt-get update && sudo apt-get dist-upgrade
does the same thing as:
sudo apt-get update
sudo apt-get dist-upgrade
In other distributions you’ll find it useful when conducting routine installations, for instance installing nginx:
sudo dnf install nginx && sudo nano /etc/nginx/nginx.conf
This string of commands will install Nginx (a webserver) and then open the configuration file in nano for editing. Nano can be swapped out with your preferred text editor (vim, gedit, kate, etc...)
The last useful feature we will cover is the pipe ‘|’ otherwise known as “shift + \”. The pipe takes information and allows it to be filtered or otherwise manipulated. For instance run the following command:
fortune | cowsay
And now we come full circle. This pipes the output of the program “Fortune” into the program “Cowsay” which outputs the text as a speech bubble coming from a cow. I sometimes use ‘cowsay’ to parse logs...because even bad news sounds better when coming from a cow!
Other uses for the pipe include parsing output using grep. Try this out:
cd /
sudo find | grep cowsay
Your output should show any files or folders that contain the word ‘cowsay’.
Now, if you were to say:
sudo find | grep fortune | cowsay
The output would be a search of all files that contain the word ‘fortune’ output in the speech bubble of a cow! The formatting isn’t the best, but it’s a fun way to parse information, and you get to use a double pipe! I know...I’m a nerd.
Next time we will explore something a little more exciting now that we’ve gotten the basics out of the way. Until then, continue exploring!
~TechnoExplorer

















