How can beginners learn to code in Linux

Share your love

When starting my software development career, I anticipated using a Linux operating system to learn to code and do incredible things.

However, I thought I would probably face some problems down the line when using Linux and simultaneously learning to program in Python.

But, that wasn’t the case.

Beginners can learn to code on Linux easily by ensuring that they have installed essential programming tools such as Visual Studio Code or Sublime Text.

Besides, they should familiarize themselves with the Linux shell and command-line statements.

What should I learn first in Linux?

Before you start programming on a Linux machine, you must install the operating system first.

The operating system plays a role in managing your computer’s memory, processes, software, and hardware.

You can do a fresh install of the Linux operating system on a machine, install it alongside Windows 10, or use a virtual machine.

If you are going all-in with using Linux, doing a fresh install should be the easiest option.

I would recommend that you install Ubuntu or Kali Linux.

I am not much of a fan of Ubuntu. I mean, it is pretty much graphical.

If you are really interested in learning how to use Linux, installing Kali Linux should be the best choice.

It has a customizable window manager, GNOME.

GNOME offers you the capability to install new extensions, themes, and sounds; the challenge comes in learning how to do that.

Most of the time, you will be using bash commands and scripts to customize your Kali Linux.

Not only will you make your Linux machine cool, but it also offers you the opportunity to learn the basic bash commands such as cp, mkdir, mv, etc. The Linux Command Line Textbook is a perfect book to start with when you want to learn these bash commands.

For a course, check out this course by Colt Steele:

The Linux Command Line Bootcamp: Beginner To Power User

Looking to master the Linux command line interface?

This course is a great opportunity for anyone looking to improve their command line skills in Linux. It covers a vast range of topics, from basic navigation and file manipulation to more advanced topics like file permissions, shell customization, and Bash scripting.

The course is led by an experienced instructor who has taught thousands of students, including me, and has received high ratings and reviews.

The course covers dozens of powerful commands, including find, locate, grep, and more. It teaches you how to string together multiple commands to build complex data pipelines, and how to master command-line navigation and the Linux folder structure.

You’ll also learn how to create, delete, move, copy, and rename files and folders, and how to decipher and manipulate Unix file permissions.

The Linux Command Line Bootcamp is a comprehensive course that will turn you into a command line power user. Whether you’re a Python programmer, web developer, data scientist, machine learning engineer, or just a plain old computer user, the skills you learn in this course will make you feel powerful and give you full control of your machine.

Be sure to check it out.

As a general rule, you should be able to understand the basic bash commands that include:

1. ls

The ls command is used for listing files in the current directory.

However, it does not display all the files because the hidden files are exempted.

ls is one of the most commonly used Linux commands.

And which ls switch is used to display all the files, including the hidden ones?

The -a is used to display all the files in the current directory.

Another switch you can use is the -l.

The -l switch displays additional information about the files and folders in the current directory.

The switch will provide additional file/folder permissions, creator, date created, date modified, and size information.

using ls command on Linux

2. pwd

How do you know the directory that you are currently in?

Well, you use the pwd command.

The pwd command displays the name of the current directory as a standard text output.

Each directory name follows a slash /, where your current directory is displayed at the end.

3. cd / chdir

cd / chdir means change directory.

Use these commands whenever you want to change into another directory that is the parent or the child of the current directory.

The parent directory is the folder preceding, while a child directory is a folder displayed when you run the ls command.

Add two dots after the cd command whenever you want to change into a parent directory.

cd ..

On the other hand, changing into a child directory requires you to specify the name of the directory after the cd command as follows:

cd folder1

You are free to use cd or chdir interchangeably.

The following commands work the same way.

chdir folder1

cd folder1

4. echo

Use the echo command to display text output on your terminal.

The command produces a line of string data passed as an argument.

For example, opening your terminal and typing the following produces a new line of text.

echo "Hello World"
Using echo command on Linux

5. mkdir

mkdir is a short form for make directory.

The command creates new directories in the current directory or any other directory specified as an argument.

An example is

mkdir folder24

The above command creates a folder named folder24 in the current directory.

As you may have noticed, you can specify a directory whose parent folder is the root directory.

A root directory on Linux is the topmost directory level in the system.

It is represented by a slash /.

You can start with the root directory, then into a child directory such as the user directory, and finally create a folder in the child directory as follows:

mkdir /home/hoofhoof/newfolder

6. rmdir / rm -d

rmdir does the opposite. It is used to remove directories.

The switch -d means the command rm is used to remove a directory.

However, the rm -d and rmdir do not remove a folder containing contents.

You must use another switch on the rm command to recursively delete a folder.

– r switch provides a recursive option of removing the directory and all its contents.

rm -r folderName

The above command removes the folder and all the files and other folders that are stored in it.

7. rm

The rm command can be used to delete a folder and remove files and symbolic links.

8. touch

We have only been removing files, although we may not have created one.

The touch command is used to create new empty files.

Besides, the command changes the access date or timestamps that a file was updated.

To add text to an empty file, you can open it with your preferred text editor such as Sublime Text, Vim, or Visual Studio Code, or you can use the echo or nano to enter new textual data into the files.

echo "Hello World" > file1.txt

9. Other basic bash commands that you need to know are:

  • mv – used for moving files and directories. Also, it can be used to rename files if you specify the destination folder as the source folder.
  • cp – the command copies files and folders.
  • chmod – command used to change the access mode of a file. By specifying a file or folder permissions, you can assign particular users the ability to read, execute, and modify such objects. For example, chmod 777 makes a file accessible to every user.
  • man – the most important command that you should be familiar with. The command displays the user manual of any command that can run in a terminal. For example, to get detailed information about the cp command, how it is used, or its switches, type man cp

After you are familiar with these commands, you can easily use the Linux operating system.

In addition to the graphical GNOME option, you can create, view, edit, delete, and change files and folder access permissions.

CRUD (CREATE READ UPDATE DELETE) are the essential operations used in programming.

However, the sky is the limit, you can learn more about the ins and outs of Linux. Be sure to check this book or this course that has all the information you need to know about how Linux works. It has helped me a lot.

When you can perform these operations, learning to code on Linux becomes straightforward.

You can create and run script files in any programming language.

After you are familiar with the Linux filesystem and navigation, you can start learning a new programming language of your choice.

Python is the most common beginner-friendly programming language that you can start with.

However, the easiness of learning a new language should not be the best criterion for choosing a programming language.

Learning a programming language depends on the nature of the problem you are trying to solve. To get a better understanding of how to learn programming in an effective approach, check out this resource I have prepared.

Python best suits machine learning, data science, and web development. Check out this book if you want to learn Python in the most straightforward way.

JavaScript is mainly used in web development. Eloquent JavaScript should be the book to learn to understand all the basic to advanced concepts used in JavaScript.

Java for app and web development. Start with this book: Head First Java: A Brain-Friendly Guide.

C++ is used in system/software development. Check out this book: C++ Crash Course: A Fast-Paced Introduction Illustrated Edition

R is suited for data science. If you want to learn Data Science, then R for Data Science: Import, Tidy, Transform, Visualize, and Model Data should be the book to get your hands on.

The criteria for choice really depend on many things.

If you are not sure, just go with Python.

You can do web development, make graphical applications, machine learning, and data science.

How to write Python programs in Linux

Python is a beginner-friendly programming language that you can get started with.

It is easy to understand and use because it has a syntax similar to English.

It prioritizes readability making it a perfect choice for first-time programmers.

You can write Python programs in Linux using basic editors such as nano or vim.

You can also write your programs with more graphical editors and IDEs such as Visual Studio Code, Pycharm, Spyder, or Sublime Text.

Here are the easy steps to install Pycharm, Spyder, and Visual Studio Code on your system.

They are great tools when you are learning to code in Python.

You are free to choose any of them.

How to install Visual Studio Code on Linux?

Visual Studio Code is a free source code editor that can be used to edit any file written in Python or any other programming language.

Install Visual Studio Code on Linux by opening the terminal and executing the following commands:

sudo apt update

sudo apt install software-properties-common apt-transport-https

wget -qO- | gpg --dearmor >

sudo install -o root -g root -m 644 /etc/apt/trusted.gpg.d/

sudo sh -c 'echo "deb [arch=amd64 signed-by=/etc/apt/trusted.gpg.d/] stable main" > /etc/apt/sources.list.d/vscode.list'
sudo apt update
sudo apt install code

Take a look at this book (Visual Studio Code: End-to-End Editing and Debugging Tools for Web Developers) to learn how to edit and debug your code using Visual Studio Code. You will learn how to leverage Pycharm to develop effective Python applications and be effective in writing clean and maintainable code.

Check out this article to learn how to open directories, VS Code, and files on Linux using the Terminal.

How to install Pycharm on Linux?

Pycharm is a great IDE that is used to write Python programs.

It comes with code linting functionality that automatically checks the code for errors as you write.

Execute the following commands to install the Pycharm community edition on your system.

sudo apt update

sudo apt install snapd

sudo systemctl enable snapd --now

sudo ln -s /var/lib/snapd/snap /snap

sudo snap install pycharm-community --classic --edge 

After installing Pycharm, get your hands dirty with Effective PyCharm: Learn the PyCharm IDE with a Hands-on Approach book by Matt Harrison and Michael Kennedy.

How to install Spyder on Linux?

Spyder is another IDE used to create and edit Python programs.

The IDE provides detailed editing and analysis capabilities when writing code and handling data.

Open the terminal and execute the following commands to install Spyder.

sudo apt update
sudo apt install spyder
Using spyder on Linux to write Python code

After you have all the tools ready, confirm that you have a working latest Python Version on your Linux system.

How to run Python programs in Linux

Before running your Python scripts, you must confirm that you have installed Python in your system.

However, finding a Linux operating system that does not use Python is infrequent.

Probably, you should update Python to the latest version. To do that, run the following commands in your terminal:

sudo apt update

sudo apt install python3 python3-pip

python3 --version

You will see the current version that Python has been updated to.

After, you can run your Python programs in the following steps.

Step 1: Create a new .py file or use an existing .py file script

Step 2: Navigate into the directory where you have written your Python script or program

Step 3: Type python3 name_of_the_file

Step 4: Press Enter

Your program will execute immediately.

You are now ready to learn more advanced concepts on how to use Kali Linux and program in Python.


Choosing the right development environment is critical when starting a program.

As a beginner, you can learn to code on Linux by first understanding the basic bash commands.

Secondly, you will need graphical text editors to create, inspect, and debug your source code.

Share your love
Nganga Stephen
Nganga Stephen

Nganga Stephen here, creator of— A website dedicated to providing helpful information and how-to's of web development and hosting. Inspired by a fascination to write the most efficient code to make a computer laugh, & humans, Steve has a passion for organizing characters to create code and informative content.
What makes me happy?
Well, nothing like the feeling of finally figuring out that one pesky bug that's been driving me crazy.

Leave a Reply

Your email address will not be published. Required fields are marked *