Showing posts with label Ubuntu. Show all posts
Showing posts with label Ubuntu. Show all posts

Tuesday, April 13, 2021

How to get started with the Linux terminal

The terminal may seem scary for new Linux users. However, it's one of the tools that has the biggest potential on your Linux journey. Learn why
The Linux terminal on Ubuntu

On a previous post we discussed the benefits of using the Linux terminal. Today, let's review how to get started with Bash, the most common shell in GNU/Linux operating systems.

The history of Bash

But before we get hands-on, let's learn more a little about Bash. Bash is a Unix shell and command language written by Brian Fox for the GNU Project as a free software replacement for the Bourne shell (which is located in your system under /usr/bin/sh and is still widely used, especially in containers).

First released in 1989, it has been used as the default login shell for most Linux distributions including the most popular distributions such as UbuntuFedora, Arch, Debian and even on the Raspberry Pi.

But bash is way beyond a simple place to enter commands. It's a powerful command processor where commands can be entered. Bash can also read and execute commands from a file, called a shell script. Like other shells, it supports filename globbing (wildcard matching), piping, command substitution, variables, and control structures for condition-testing and loops.

To finish our introduction, the name Bash is an acronym for Bourne Again Shell, a pun on the name of the Bourne shell that it replaces (and extends).

Why learn Bash

Due to its popularity, power and ubiquity, we strongly recommend that you learn it if you want to be comfortable in Linux and computers in general. Many skills you'll learn in your bash/OSS-journey will definitely carry over to Macs, Windows and well into your professional life.

Bash on Windows

Today, Bash can also be found on Windows via the Windows Subsystem for Linux (WSL for short). We will review how to get started on WSL real soon. Keep tuned!

Starting the Terminal

To start the terminal on Ubuntu (or any GNOME-based distro), simply type terminal on the Activities tab. KDE and Xfce users should also have equivalent terminal apps in their systems.

On Ubuntu, type terminal to open your first terminal

Clicking on the terminal icon should open a new terminal for you:

Your bash terminal on Linux

You can confirm that it's running bash by running the following command:

echo $SHELL
/bin/bash

Entering Commands

Entering commands in your terminal is straightforward, just type them. For example, here are some basic ones:

  • pwd - lists the current directory
  • ls - lists the files in the current directory
  • cd - change the current folder
  • cat - prints the contents of a file
  • cp - copies a file
  • mv - moves a file
  • rm - removes a file
  • mkdir - creates a new directory
Some simple commands on the terminal
The above list may seem a lot for a new user. Don't stress, with time you'll learn these tools and soon they'll be part of your muscle memory

Manual Page

Linux also has an interesting utility called man that is used for reading the manuals (documentation) of the programs, tools and libraries available on your system. To view Bash's manual, type:

man bash

To go the extra mile, we also recommend checking this related manual page:

man bash-builtins

Follow up video

To finish, we would like to point you to an online resource that will teach you Bash better than we could. Feel free to watch it at your own pace to get familiar with it. For the record, we have absolutely no affiliation we the video below, we just want you to learn Bash and Linux 😊

Conclusion

On this article we learned a little more about the Linux terminal and Bash. Bash is a fantastic tool that any Linux user should learn. We hope it helps!

See Also

Tuesday, April 6, 2021

Why use the Linux terminal

The command-line (aka terminal) is a scary thing for new Linux users. But understanding it can be a huge step in your Linux journey and a significant step in your career
Photo by Tianyi Ma on Unsplash

If you're new to Linux, the command-line interface (also known as CLI or terminal) may look scary. But it shouldn't. The CLI is a powerful and resourceful tool that every aspiring Linux user should learn and be comfortable with. On this article, let's review many reasons why you should learn and use the command line, commonly (and often incorrectly) referred to as terminal, shell, bash and CLI. 

Ubiquitous

The command-line interface (CLI) is available in every operating system, not only in Linux. Very frequently, developers and system administrators spend most of the time in them. If you want to work with Linux and technology in general, better start learning it.

Terminals are available in every operating system including Linux, Windows and Macs

Powerful

CLI-based apps are much more powerful than their GUI-based equivalents. That happens because usually GUIs are wrappers around libraries developed by developers. Very frequently, these libraries contain way more functionality than what's available in the graphical interface because, as you might expect, since software development takes time and costs money to produce, developers only add to GUI apps the most popular features. 

For example, these are some of the options that the GNU find tool provides us:

Does your GUI-based find tool has all those options?

Quicker

Common and repetitive tasks are also faster in the terminal with the advantage that you will be able to repeat and even schedule these tasks so they run automatically, releasing you to do actual work, leaving the repetitive tasks to computer.

For example, consider this standard development workflow:

  1. download code from GitHub
  2. make changes
  3. commit code locally
  4. push changes back to GitHub

If you were doing the above using a GUI-based git client (for example, Tortoise Git), the workflow would be similar to the below, taking you approximately 20 minutes to complete:

  1. Open Tortoise Git's web page
  2. Click Download
  3. Next -> Next -> Next -> Finish
  4. Right-click a folder in Nautilus (or Windows Explorer, or Finder) -> Select clone -> Paster the Url -> Click OK
  5. Wait for the download to Complete -> Click OK
  6. Back to Nautilus -> Find File -> Open it
  7. Make your changes (by probably using GEdit, KEdit or Visual Studio Code) -> Save
  8. Back to Nautilus
  9. Right Click -> Commit
  10. Right Click -> Push
  11. Take a deep breath

In the terminal (for example, in Ubuntu), the workflow would be equivalent to the below and could be completed in less than 2 minutes:

sudo apt update && sudo apt install git -y   # install git
git clone <url>     # clone the GitHub repo locally
vim/nano file -> save  # edit the file using a text-based editor
git commit -m <msg> # commits the file locally
git push  # push the changes back to our GitHub repo

Scriptable

Terminal/CLI-based tasks can be scripted (automated) and easily repeated meaning that you will be able to optimize a big part of your workflow. Another benefit is that these scripts can be easily shared, exactly as business and professional developers do!

So let's continue the above example. Our developer realized she is wasting too much time in the GUI and would like to speed up her workflow even more. She learned some bash scripting and wrote the function below:

gcp ()
{
    msg="More updates";
    if [ -n "$1" ]; then
        msg=$1;
    fi;
    git add ./ && git commit -m "$msg" && git push

She's happy because now she can run from the terminal, the below command as soon as she finishes her changes:

gcp <commit-msg>

What previously took 5 minutes is now is done in 2 seconds (1.8 seconds to write the commit message and 0.2 to push the code upstream). A huge advantage in her workflow. Imagine how much more productive she would be during the course of her career!

It's important to always think how can you optimize your workflow. These small optimizations add up to your productivity significantly over time.

Lightweight

Not only the CLI is faster and more lightweight than equivalent GUI-based applications but it's quicker to run the same commands. For example, consider a Git client like Tortoise Git. It was supposed to be lightweight (what most GUI apps aren't) but it takes 3s to completely load and uses 10Mb of memory:

Our GUI-based git client TortoiseGit

Meanwhile, its CLI equivalent, git status runs in 0.3s and consumes less than 1Mb. In other words, 20 times more efficient memory-wise and 10 times faster. 

A simple CLI command is 20x more efficient and 10x faster then its GUI equivalent

Disk Space Efficient

Another advantage of terminal apps over their GUI-equivalents is reduced disk space. For example, contrast these two popular apps. Can you spot the differences?

Application    Installation Size       Total Size       Memory Usage   
Visual Studio Code        80Mb 300Mb 500Mb (on sunny days)
Nano 0.2 Mb 0.8 Mb 3 Mb
400x more efficient 375x more efficient 160x more efficient

Extensible

Another important aspect is that the CLI is extensible. From it, skilled users could easily either extend its basic functionality using its built-in features like pipes and redirections combining inputs and outputs from different tools.

For example, sysadmins could list the first two users in the system who use Bash as a shell, ordered alphabetically with:

cat /etc/passwd | grep bash | cut -d : -f 1 | sort | head -2

What's interesting from the above command is how we combined 5 different tools to get the results we need. Once you master the Linux terminal, you'll too will be able to utilize these tools effectively to get work done significantly faster!

This is a more advanced topic. We'll see in future posts more details about it.

Customizable

As you might expect, the terminal is extremely customizable. Everything from the prompt to functions (as seen above) and even custom keybindings can be customized. For example, want to bind Ctrl+E to open the Nano text editor on the terminal? Simple. Add this to your .bashrc file:

bind '"\C-E":"nano\n"'

Extensive range of Apps

Contrary to what most newcomers thing, the terminal has apps too! You will find apps for pretty much any use case. For example:

Note: The above list is far from comprehensive. It's just to give you an idea of what you'd be able to find in there

For example, here's the Castero Podcast app running on a terminal:

Source; GitHub

Professional Development

Want to work with Linux? Another important aspect of using the terminal is that it will make you more ready for the job market. Since Linux servers usually don't have GUIs, you will end up having to use some of the above tools on your day-to-day work. So why not start now?

Learn more about Linux

Hopefully at this point you realize that you will learn way more about your Linux system and computers in general when you use the terminal. This is the secret sauce that the most productive developers want you to know!

It's also a huge win for testing new tools, maintaining your system, installing software, fixing issues and tweaking as you wish.

Getting Started

Ready to get started on your terminal/CLI journey? Watch the video below:

Note: We don't have any affiliation with the video above. We just want you to learn the terminal 😊

Conclusion

Every modern computer has a terminal. Learning it will save you time, allow you to automate common actions, make you learn more about your system, save time, grow professionally and be more comfortable with Linux. Well worth the effort, isn't it?

See Also

Monday, March 8, 2021

Installing Ubuntu Mate on a Virtual Machine

If you're looking for a lightweight and robust Linux distribution, check Ubuntu Mate. A lighter version of Ubuntu but not not less powerful
Ubuntu MATE's default desktop

Before switching to Linux permanently, it's recommended to test it first on a virtual machine so that you can feel the experience before making permanent changes on your system.

On this tutorial, we will continue revisiting the best lightweight distributions of 2021 and learn how to install Ubuntu MATE on VirtualBox in Windows 10.

This process should be pretty similar to accomplish in either VirtualBox or VMWare Workstation player.

About Ubuntu MATE

Ubuntu MATE is a lightweight and simplified Linux distribution based on Ubuntu. It's stable, easy-to-use and comes with the lightweight (and familiar) MATE desktop environment. It is ideal for those who want the most out of their computers and prefer a traditional. Another advantage is that it requires modest hardware requirements.

Another advantage of Ubuntu MATE is that it runs from modern workstations, to single board computers and IoT. Ubuntu MATE makes modern computers fast and old computers usable.

Downloading Ubuntu MATE

Head to Ubuntu Mate download page an grab the ISO by clicking on 64-bit PCs/Macs > 20.04.1 LTS Focal Fossa. For this tutorial we'll use Ubuntu MATE 20.04 LTS which's the a version supported until April 2023. The file should be around 2.5 Gb in size so go grab a coffee while it downloads.

An ISO is simply an image of the installer containing all the files needed to boot and install that distribution in your system.

Installing Mate

With the ISO downloaded, let's start the process. Open VirtualBox:

VirtualBox's main screen

Click New, enter the name of the VM, set Type = Linux and Version = Ubuntu (64-bit) and specify its save location:

Choose the memory size (4Gb or more is recommended):

Create a Virtual Hard Disk:

As Hard disk file type, Choose VDI (VirtualBox's default format):

Set it to Dynamically Allocated (slower) if you don't have much disk space or Fixed Size (faster) if you do:

Specify file location and size (recommended: 20GB), click Review > Create:

After clicking Create, you should see a summary of your new VM:

Booting the VM

Okay, so it's now time to boot (load) our VM so we can install it in the virtual hard drive. On the screen above click on Start to have your VM initialized. We'll first need to attach our ISO as if it were a virtual CD-ROM. Click Add and select your downloaded ISO from your Downloads folder and click Create to set it:

Installing Ubuntu

Once your VM boots, you will be asked to choose a language in the very first screen:

And will be prompted with this pleasant menu:

For our setup, choose the third (3) option: Install Ubuntu MATE. A few seconds later, you should see the loaded installer where you'll again be able to choose your language:

Select your keyboard:

Choose what/how to install and if you would like to download updates during installation:

On the Installation type screen, choose Erase disk and install Ubuntu MATE (don't worry, none of your files will be deleted):

Select your time zone:

And the installation begins. Give it 10 minutes or so and have fun with the information provided:

Installation Begins

You'll see nice progress, tips and tricks during the install

Once it ends, you'll be asked to reboot:

First Login

With the installation done, let's login the first time. Enter your password as specified during the installation on the login screen:

Default Desktop

After login, you should see Ubuntu MATE's beautiful desktop:

Ubuntu MATE's default desktop

Next Steps

There you are! Feel free to have fun with your new Ubuntu VM! We will cover some more interesting topics in the future but we recommend that you play with it in the meanwhile.

Conclusion

On this tutorial we learned how to install Ubuntu MATE in a VirtualBox virtual machine (VM). Installing Linux on a VM is the first step you need to explore Linux in its multiple variations. The next step is obviously, replacing your Windows or Mac. But take your time!

See Also

Monday, March 1, 2021

The best lightweight Linux distributions of 2021

Looking for a lightweight Linux distribution to install on that old PC? Check our top picks for 2021
Photo by Naman Porwal on Unsplash

On a previous post we discussed the best Linux distributions for new users in 2021. While those distributions are fantastic, they demand moderately powerful hardware and a decent amount of storage. Today, let's discuss the best lightweight Linux distributions in 2021.

What's a lightweight Linux distribution?

As you probably expect, a lightweight Linux distribution is a distribution that does not require super-recent hardware and, as much as possible is friendly on storage and energy consumption.

What should you expect from these distributions

All of the presented distributions were chosen not only because they're stable and secure but because they're easy-to-use, powerful (with no compromises) and require modest hardware requirements. As a bonus, running on single board computers and IoT would be a plus.

So let's get started and review what are the best most recommended lightweight Linux distributions in 2021.

Ubuntu MATE

Ubuntu MATE is a lightweight and simplified Linux distribution based on Ubuntu. It's stable, easy-to-use and comes with the lightweight (and familiar) MATE desktop environment. It is ideal for those who want the most out of their computers and prefer a traditional. Another advantage is that it requires modest hardware requirements, running on modern workstations, to single board computers and IoT. Ubuntu MATE makes modern computers fast and old computers awesome again 😊.

Ubuntu MATE's default desktop

elementary OS

We ❤ elementary OS and pretty much anyone in the community. elementary (lowercase e please) was select as one of our best distros in 2021 an still shows up in this list. It's installation is super quick and its Pantheon desktop environment certainly offers a very polished experience while still being lightweight! Being also based on Ubuntu makes it a solid choice for your old PC.

       
The beautiful elementary OS desktop

Solus

Solus is another of the fast and lightweight Linux distros that we love. Built by community by passionate developers, the Solus OS is a beautiful, lightweight, innovative and rolling-release operating system that everyone should try at least once. Sure, it's not backed up by the likes of Canonical, Ubuntu's parent company but is built on strong (and innovative) technologies. Definitely worth trying out.

Source: Solus Project 

Fedora XFCE

Fedora XFCE is another of our favorite lightweight distros of 2021. Built by the an awesome of independent and (RH)-dependent Fedora developers, Fedora XFCE is definitely a distro for those working (or willing to) in the Enterprise Linux space since it shares roots with RHEL (Red Hat Enterprise Linux) and many of its forks (including CentOS, Rocky Linux and AlmaLinux). And as happens with every Fedora spin, you'll get as vanilla as possible from XFCE's original experience

Source: Fedora Project

Manjaro XFCE

If  you're looking for a little more action than why not try Manjaro XFCE? Running the XFCE desktop environment, the same desktop environment as the Fedora spin listed in this article, Manjaro is based on the venerable Arch Linux but presents a less steep learning curve and counts with a thriving and ever-growing community. Manjaro XFCE presents a very polished and fast experience that would suit well to new and experienced Linux users on modern and old hardware.

Manjaro's beautiful XFCE desktop environment

Conclusion

On this article we presented the lightweight Linux distributions in 2021. Lightweight Linux distros usually run super-well on old PCs or Macs guaranteeing you some good years of use still. Another idea would be spinning them up in less resourceful virtual machines so you can practice your Linux skills. More on that later.

See Also

Thursday, February 11, 2021

Installing Ubuntu on a Virtual Machine

Ubuntu remains on of the best Linux distributions for new users. Learn on this tutorial how to install it on a Virtual Machine and test it to learn more about it
A brand new Ubuntu desktop

Before switching to Linux permanently, it's recommended to test it on a virtual machine so that you can feel the experience before making permanent changes on your system. On this tutorial, we will continue revisiting the best distributions for beginners in 2021 and install Ubuntu on VirtualBox in Windows 10.

Please note that this process should be pretty similar to accomplish in either VirtualBox or VMWare Workstation player.

Downloading Ubuntu

Head to Ubuntu Desktop download page an grab the ISO. For this tutorial we'll use Ubuntu 20.04 LTS. The file should be around 2.5 Gb in size so go grab a coffee while it downloads.

TIP: An ISO is simply an image of the installer containing all the files needed to boot and install that distribution in your system.

Installing Ubuntu

With the ISO downloaded, let's start the process. Open VirtualBox:

VirtualBox's main screen

Click New, enter the name of the VM and select its save location:

Choose the memory size (4Gb or more is recommended):

Create a Virtual Hard Disk:

Choose VDI (VirtualBox's default format):

Set it to Dynamically Allocated (slower) if you don't have much disk space or Fixed Size (faster) if you do:

Review and Create:

After clicking Create, you should see a summary of your new VM:

Booting the VM

Okay, so it's now time to boot (load) our VM so we can install it in the virtual hard drive. On the screen above click on Start to have your VM initialized. We'll first need to attach our ISO as if it were a virtual CD-ROM. Click Add and select your downloaded ISO from your Downloads folder and click Create to set it:

Confirm on the next screen and click Start:

Your VM should now be booting:

Installing Ubuntu

Once the initial boot ends, you should see the following Ubuntu installation screen providing you two options:

  • Install Ubuntu - install Ubuntu in your virtual hard drive
  • Try Ubuntu - to run Ubuntu in memory without installing it

Choose your language and click Install Ubuntu to proceed with the installation.

Choosing the Keyboard

On the next screen, choose your keyboard and click Continue:

Apps and Updates

Next, specify what kind of installation you want and how to update the system. For our VM, we're good with Normal installation:

Installation Type

Choose the default installation type. For VMs, Erase disk and install Ubuntu should be good enough. (don't worry, none of your files will be deleted):

Set Time Zone

Click Install Now > Confirm the changes and select your time zone:

Setting Host, User and Password information

On the next screen enter your name, username (how you will login as), password and host (how your machine is identified):

Finishing the Installation

Once the all the settings were satisfied, the actual installation begins. Give it 10 minutes or so:

First Login

With the installation done, let's login the first time. Enter your username/password as specified during the installation on the login screen:

Default Desktop

After login, you should see Ubuntu's beautiful desktop:

A brand new Ubuntu desktop

Next Steps

There you are! Feel free to have fun with your new Ubuntu VM! We will cover some more interesting topics in the future but we recommend that you play with it in the meanwhile.

Conclusion

On this tutorial we learned how to install Ubuntu in a VirtualBox virtual machine (VM). Installing Linux on a VM is the first step you need to explore Linux in its multiple variations. The next step is obviously, replacing your Windows or Mac. But take your time!

See Also

Featured Article

Free Software, Open-Source, Libre, FOSS and FLOSS: what are the differences?

Are these just different names for the same thing? Or there are differences? Photo by Romain Vignes on Unsplash We have been discussing...

Popular this Week