Showing posts with label git. Show all posts
Showing posts with label git. Show all posts

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, October 5, 2020

Why Linux is perfect for web developers

Linux runs the cloud, the Internet and super-computers. Learn why web developers love Linux too!
Photo by Ilya Pavlov on Unsplash

Following up on our previous discussion on why use Linux, and learned why Linux is ideal for development. Today, let's focus on why Linux is a fantastic system for web developers.

If you recall our previous post, we started alluding to this StackOverflow pool, where Linux was cited as the most loved technology by developers at 83%. There are multiple reasons for that. Let's learn about them next.

Linux is free

Obviously, one of the main reasons to run Linux is because Linux is free. As poverty (unfortunately) grows around the world, it's important to minimize costs for users and companies. Since prices for Windows lincenses are really high and utilizing MacOS, almost impeditive for most of us, being free allows Linux to reach a much wider audience including independent developers, small organizations taught and used in schools, universities and research labs at a really low cost.

Robust package management

While it's true that MacOS users can use brew to enhance their terminal experience, and even Microsoft is building Windows a package manager (despite 20years late 😌) they are nothing more than a poor adaptation of Linux's built-in package mangers. It's on Linux where the real experience shines since the package manager integrates into the update system which integrates into the shell. 

Quicker access to modern tools

You'll get quicker access to the latest releases of your favorite programming language on Linux too. Linux users frequently get earlier access to Golang, Rust, NodeJS - just to name some - without resorting to building them from scratch.

Streamlined workflow

Beyond getting access to the latest tools, developing on Linux will be a much more pleasant experience to to the nature of the system: an awesome and powerful shell (Bash on most cases) accessible via a powerful window manager (GNOME or KDE) being backed by a super solid system with an extensible list of packages available to install at your fingertips.

Awesome command line tooling

Developers love the command line. Using the command line is key to automate your tasks and to opmitze tasks, resulting in huge productivity gains. Today, even tasks that are commonly UI-based such as browsing the web, managing files and even watching YouTube. Web developers can gain signifiant productivity if they embrace this workflow which's the recommended way to building new web apps quickly with ReactJS, VueJS, Angular. Popular tools and frameworks such as WordPress and even proprietary tools such as SendGrid or HubSpot have their own CLIs.

Plus, tools such as tmux or i3, allow you to multitask without sacrificing your productivity.

On the left man git, on the right: vim on top and htop on bottom

Streamlined cloud and container integration

As Red Hat usually says, containers are Linux. Creating your web app today requires probably a lot of dependencies, some of which (a database server, for example) may not be trivial to install - or may use a lot of your resources. Containers are today the way to streamline that process as you can build complex applications with tools such as DockerDocker Compose and Minikube.

Dotfiles

Once you get comfortable with the shell, you'll probably want to customize it to your needs. Developers realize that they really make them productive. Since it's common days to work on multiple machines, an elegant solution to that problem is to host your dotfiles in a private or public repository like GitHub so you can quickly restore your favorite settings in any of your development machines.

Integrated Git

Git is an essential requirement today. On Linux git is an integral part of the workflow (of course, it was invented by Linux Torvalds, Linux creator to facilitate the complex integration workflow of the Linux kernel). Using git in Linux makes everything simpler as it integrates into your command line and shell.

A powerful shell

Bash (and siblings such as ZSH and Fish) is a really powerful tool in Linux. Developers who know it can leverage it to enhance their workflows. For example, you could map the following three commands:
  • git add .
  • git commit -m <your-message>
  • git push
As one operation, the following gcp command:
gcp(){
        msg="More updates"
        if [ -n "$1" ]
        then
                msg=$1
        fi
        git add . && git commit -m "$msg" && git push;
}
So that using it, would be:
gcp "Some commit message"

Oh, and simply typing gcp would do all the above using "More updates" as the git commit message. Use but don't abuse 😊.

Linux is reliable

Writing software requires a a reliable system. As you probably know, Windows (and even Macs) are not as reliable as their companies tell advertise. Your Linux system will rarely crash. You'll also realize that Linux tools will be more stable than their Windows or Mac equivalents.
Remember this?

Excellent Documentation

Developers have to frequently access the documentation. Linux comes the man tool allowing you access to the documentation you need available regardless of your exposure to to the internet. Just run man <cmd> to view documentation for the software you need:

Good for old hardware

Linux is also excellent for old hardware. For example, you can run lighter tools that utilize less resources. Most distributions (such as Fedora LXDE shown below) release alternative lightweight versions optimized for lower-end hardware.

Updated Software

Another reason why developers love Linux is because (1) they're exposed to the cutting edge software and (2) they'll get frequent updates/upgrades. Regarding the latter, updates on Linux are not only reliable but are more frequent than anything you'd get on those systems. The system will be updated multiple times a week and a new version can be available every 6 months depending on the distribution with long-term releases available every 2 years.

Outstanding software availability

Not only installing software on Linux is simple  Every Linux distribution provides a tool to manage software with lots (literally, thousands) of apps. Visual Studio Code, Slack? You'll find on Linux. You'll also find enterprise software like Zoom and Microsoft Teams if you need to talk to your clients.
Source: Slack Downloads

Networking tools

Web development is all about networking. Linux comes with powerful networking tools, some of which you probably heard of. Samba, nmap, whois, nslookup, ping, curl, ssh, among others are natively available. There's just so much here and once you learn these tools you probably wouldn't be able to work without them.

Cloud-native tools

Linux comes with lots of tools to use in cloud development. The most commons are Docker (and its sibbling podman) and Kubernetes but it also has easily installable access to tooling for Azure, AWS, GCP and devops/automation tooling such as Ansible, Helm, Vagrant and more.

Support from a huge community

Linux users are spread around communities over the internet. Being on Reddit or on forums of your specific distribution, developers frequently share their thoughts with similarly minded folks around the web. This helps them share knowledge, news, learn new things and obviously, help others.

Linux is highly customizeable

Another reason web developers can benefit from using Linux is due to its extensive customization. With the right instructions they can customize their system as they wish resulting in a quicker setup or, in case containers aren't sufficient, modelling their systems as per the customer's requirements.

 Some of the things you can tweak in Linux are:

  • Desktop Managers: don't like GNOME or KDE? There's XFCE, LXQT, LXDE, etc for you.
  • Login Managers: how you login to your system.
  • Desktop themes: configure themes, colors, etc.
  • Fonts: customize your fonts, sizes, etc.
  • Shell: shell is the application that runs on your terminal and also can be changed or customized.
  • Systems and Services: your system will have an endless list of services to choose from.
  • Kernel: even the kernel, the main process of your system can be customized. 

Enterprise-Grade Security

Linux comes with built-in enterprise security tooling. Beyond that, curated repositories Linux users are used to having repositories curated by the community and available for them. That means less viruses, no adware, unsafe or untrusted software running on your machine.

Conclusion

On this post we understood a little more why developers use and love Linux. You too could benefit from using it today! We hope you learned something new today and are excited to try out Linux and use it as your main system as we do!

See Also

Monday, September 28, 2020

Why Developers love Linux

Linux runs the cloud, the Internet and super-computers. Learn why developers use and love Linux too.
Photo by Arget on Unsplash

Following up on our previous discussion on why use Linux, today we will discuss why Linux is the favorite operating system of developers, the folks who build the software you use. To get started, let's back up our assumption using StackOverflow's own insights, where it shows Linux is the most loved technology by developers:

Linux is free

Obviously, one of the main reasons to run Linux is because Linux is free. As poverty (unfortunately) grows around the world, it's important to minimize costs for users and companies. Since prices for Windows licenses are really high and utilizing MacOS, almost impeditive for half of the world, being free allows Linux to reach a wider audience including independent developers, small organizations, schools, universities and research labs.

Linux is (way) more secure

Linux is also (way) more secure than Macs and Windows. That's mainly due to its:
  • open-source code: due to its open nature, researches and hackers frequently inspect and crack the code. When issues are found, they're reported and fixed by community.
  • open collaboration model: open-source code also fosters open collaborations. Developers from all over the world will frequently push fixes to the software you use making it better and more secure.
  • enterprise-grade software: tools like SELinux that are run on mission critical environments run on your machine too.
  • different permission model: Linux users run on a low permission level making it very improbable that even if you're hit by a virus, you would infect the machine.
  • frequent updates: your system will always be updated getting the latest security, software and kernel fixes. These are usually the holes crackers explore to target you.
  • smaller exposure to viruses: yes, Linux has viruses but on an infinite smaller proportion than Windows users get. Linux also has anti-viruses if you need too.
  • curated repositories: the easiest way to install software on your Linux is by using its own repositories. These repositories are curated and are less prone to have viruses.

Awesome Command Line

Developers love the command line. Using the command line is key to automate your tasks and to opmitze tasks, resulting in huge productivity gains. Today, even tasks that are commonly UI-based such as browsing the web, managing files and even watching YouTube can be accomplished from the terminal. Plus, tools such as tmux or i3, allow you to multitask without sacrificing your productivity.
On the left man git, on the right: vim on top and htop on bottom

Linux is reliable

Writing software requires a a reliable system. As you probably know, Windows (and even Macs) are not as reliable as their companies tell advertise. Your Linux system will rarely crash. You'll also realize that Linux tools will be more stable than their Windows or Mac equivalents.
Add caption

Excellent Documentation

Developers have to frequently access the documentation. Linux comes the man tool allowing you access to the documentation you need available regardless of your exposure to to the internet. Just run man <cmd> to view documentation for the software you need:

Good for old hardware

Linux is also excellent for old hardware. For example, you can run lighter tools that utilize less resources. Most distributions (such as Fedora LXDE shown below) release alternative lightweight versions optimized for lower-end hardware.

Updated Software

Another reason why developers love Linux is because (1) they're exposed to the cutting edge software and (2) they'll get frequent updates/upgrades. Regarding the latter, updates on Linux are not only reliable but are more frequent than anything you'd get on those systems. The system will be updated multiple times a week and a new version can be available every 6 months depending on the distribution with long-term releases available every 2 years.

Streamlined cloud and container integration

As Red Hat usually says, containers are Linux. Creating your application today requires probably a lot of dependencies, some of which (a database server, for example) may not be trivial to install - or may use a lot of your resources. Containers are today the way to streamline that process as you can build complex applications with tools such as Docker, Docker Compose and Minikube.

Dotfiles

Once you get comfortable with the shell, you'll probably want to customize it to your needs. Developers realize that they really make them productive. Since it's common days to work on multiple machines, an elegant solution is to hosting your dotfiles in a private or public repository like GitHub so you can quickly restore your favorite settings in any of your development machines.

Integrated Git

Git is an essential requirement today. On Linux git is an integral part of the workflow (of course, it was invented by Linux Torvalds, Linux creator to facilitate the complex integration workflow of the Linux kernel). Using git in Linux makes everything simpler as it integrates into your command line and shell.

A powerful shell

Bash (and siblings such as ZSH and Fish) is a really powerful tool in Linux. Developers who know it can leverage it to enhance their workflows. For example, you could map the following three commands:

  • git add .
  • git commit -m <your-message>
  • git push
As one operation, the gcp command listed below:
gcp(){
        msg="More updates"
        if [ -n "$1" ]
        then
                msg=$1
        fi
        git add . && git commit -m "$msg" && git push;
}
So that using it, would be:
gcp "Some commit message"

Oh, and simply typing gcp would do all the above using "More updates" as the git commit message. Use but don't abuse 😊.

Outstanding software availability

Not only installing software on Linux is simple but Linux distributions come with thousands of applications to choose from. Need communication software? Linux has Slack, Skype, Zoom and even Microsoft Teams. Need a modern development environment? Try Visual Studio Code.
Source: Slack Downloads

Powerful build tooling

Its really simple to install the build tools you'll need in Linux. GCC, Make, glibc, Gdb, git and many other tools needed on their development workflows are available either out of the box or from their systems' package manager.

Powerful networking tooling

Linux is perfect for networking. And it offers lots, lots, and lots of tools in the space. Some of them you probably heard of are Samba, nmap, whois, nslookup, ping, curl, ssh, among others. There's just so much here and once you learn these tools you probably wouldn't be able to work without them.

Cloud-native tools

Linux comes with lots of tools to use in cloud development. The most commons are Docker (and its sibling podman) and Kubernetes but it also makes it very simple to install tooling for Azure, AWS, GCP and devops/automation tooling such as Ansible, Helm, Vagrant and others.

Support from a huge community

Linux users are spread around communities over the internet. Being on Reddit or on forums of your specific distribution, developers frequently share their thoughts with similarly minded folks around the web. This helps them share knowledge, news, learn new things and obviously, help others.Curated repositories Linux users are used to having repositories curated by the community and available for them. That means no viruses, adware, unsafe or untrusted software.

Linux is highly customizable

Another reason developers use Linux is due to its extensive customization. Here are some of the things that can be customized on Linux:

  • Desktop Managers: don't like GNOME or KDE? There's XFCE, LXQT, LXDE, etc for you.
  • Login Managers: how you login to your system.
  • Desktop themes: configure themes, colors, etc.
  • Fonts: customize your fonts, sizes, etc.
  • Shell: shell is the application that runs on your terminal and also can be changed or customized.
  • Systems and Services: your system will have an endless list of services to choose from.
  • Kernel: even the kernel, the main process of your system can be customized.

Powerful hardware integrations

Into IoT, Rasperry Pi, Arduino? Due to the open nature of these platforms and to the vast documentation available, developers have access to an outstanding amount of technical information on how everything works. And Linux is the best system to do so.

Conclusion

On this post we understood a little more why developers use and love Linux. You too could benefit from using it today! We hope you learned something new today and are excited to try out Linux and use it as your main system as we do!

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