Basic Terminal Commands for Backend Engineers.

I want to discuss some of the basic commands you need to know as a backend engineer.

Hello “👋”

Welcome to another week, another opportunity to become a Great Backend Engineer.

Today’s issue is brought to you by MasteringBackend, a great resource for backend engineers. We offer next-level backend engineering training and exclusive resources.

Before we get down to the business of today. Basic Terminal Commands for Backend Engineers.

I have a special announcement: You will love this one.

Masteringbackend is launching the beta version of its platform. We have been building intensively for the past five months, and today, we are finally pushing the beta version to you.

This platform will help you grow your backend engineering career and turn you into a great backend engineer.

It will house the following:

  1. Personal Backend Portfolio to showcase your skills

  2. Learn to build from Thousands of Real-world Projects

  3. Track your learnings and set schedules

  4. Follow expert-vetted roadmaps to learn backend engineering.

  5. Map courses to Backend Projects to help you master your skills

  6. Online coding challenges by experts to improve your skills

  7. Pick projects from different business domains to practice.

Here are some of the features on the way:

  1. Roadmaps => MB Roadmap enables a structured-based learning approach for Backend engineers.

  2. Project Land => MB Projects enables backend engineers to use a learn-by-building model. Build real-world backend projects without coding the frontend.

  3. Backend Portfolio => Create and manage your backend portfolio with many real-world backend projects.

  4. BackLand => Learn backend engineering by solving challenges in a gamifying way.

Sound interesting?

The beta version is out for testing, reviews, and feedback.

Sign up here and reply to this email if you find anything worth reporting or if there is more feedback to help us improve.

Now, back to the business of today.

I discussed Setting up NGINX as a Web Server in the previous edition. I used many commands to set it up, and today, I want to discuss some of the basic commands you need to know as a backend engineer.

Terminal Usage

As a backend engineer, working with the terminal is a common practice and a skill you should learn. Some commands and utilities can help you perform your tasks more efficiently.

Becoming efficient in using Commands requires practice and patience because it takes time to grab them.

I started using commands on August 28, 2017, without prior knowledge, and since then, it has been a journey of constant practice, failing, and Googling.

Above all, I have discovered basic commands that are crucial for a backend engineer to learn, and that’s exactly what I will cover in this edition.

I grouped them into the following categories:

  1. Basic Commands

  2. Files and Directory Commands

  3. Permission Commands

  4. Downloading Commands

Basic Command for Backend Engineers

Basic Commands

Learning the basic commands will go a long way if you want to use the Linux operating system. I will review some basic Linux commands for backend engineers to help you get started.

Before starting the lesson, you must install Linux and your terminal.

Sudo Command

This command is short for “superuser do”. sudo is one of the most used commands that lets you perform tasks requiring administrative or root privileges and permissions.

When using sudo for the first time, your system will prompt you to re-authenticate with a password, allowing you to use the command for a specific timeframe.

Here is the syntax for the sudo command:

sudo (command)

You can also add options, such as:

  • -k or —reset-timestamp: This option invalidates the timestamp file.

  • -g or —group=group: This option runs commands as a specified group name or ID.

  • -h or host=host: This option runs commands on the host.

Here’s an example of deleting a folder on my computer:

sudo rm -rf MB_projects

CD Command

The cd command is one of the most used commands in Linux. the cd command is used to navigate through the Linux files and directories.

Depending on your current working directory, it requires either the full path or the directory name.

Assuming you’re in /home/username/Downloads and want to go to Videos. You can use the following command:

cd Videos

Here are some shortcuts to help you navigate faster:

  • cd ...: It helps you move one directory up.

  • cd ~[username]: It helps you go to another user’s home directory.

  • cd -: It helps you move to your previous directory.

LS Command

The ls command lists files and directories within a system or a directory. If you run this command without a flag, parameter, or option, it will show the current working directory’s content.

Here are two ways you can use the ls command to display all files and folders inside the Videos folder.

// Navigate
cd /home/username/Downloads/Videos

// Type the command
ls

OR

// Type the command followed by the path
ls /home/username/Downloads/Videos

Here are some options you can use with the ls command:

  • ls -a: It shows all files, including all the hidden files

  • ls -R: It shows all the files, including files in sub-directories

  • ls -lh: It shows the file sizes in easily readable formats such as MB, GB, etc.

CAT Command

The cat command lists, combines, and writes file content to the standard output. Type the cat command followed by the file name and its extension to run the command. For example:

cat filename.txt

Here are other ways you can use the cat command:

  • Typing cat > filename.txt creates a new file.

  • Typing cat filename1.txt filename2.txt > filename3.txt merges both files to filename3.txt.

  • Typing cat filename.txt displays the content in reverse order.

Files and Directory Commands

Here, I will discuss commands such as:

  • mkdir

  • cp

  • rmdir

  • mv

  • rm

  • nano, vi, jed

  • touch

  • grep

MKDIR Command

The mkdir command is used to create one or multiple directories at once and set permissions for each of them.

Note that you must have permission to create a new folder in the directory, or you may receive a permission denied error.

Here is a basic syntax:

mkdir [option] directory_name

Here are some examples of creating a directory called videos:

mkdir videos

To create a new directory called PDFs inside Documents directory.

mkdir Documents/PDFs

The mkdir command accepts some options such as:

  • -p or —parents which creates a directory between two existing folders. For instance, mkdir -p Documents/PDFs/Books will make a new PDFs directory.

  • The -m option sets the file permissions. For instance, running the command mkdir -m777 Documents/Books will allow all users to read, write, and execute the command fully.

  • The -v option prints a message for each created directory.

CP Command

The cp command is used to copy files or directories and their content from one location to another.

For instance:

cp filename.txt ~/Documents

You can copy multiple files to the same location as shown below:

cp file1.txt file2.txt ~/Documents

To copy the content of a file to another file in the same directory. Enter the following command:

cp file1.txt file2.txt

MV Command

The mv command moves files or directories from source to destination or renames files and directories.

mv file.txt ~/Documents

You can also rename files using the mv command as shown below:

mv old_file.txt new_file.txt

Lastly, you can also move a full directory, including all the files and sub-directory, to a new destination using the mv command with the -rf flag as shown below:

mv -rf ~/Documents/drectory1 ~/Documents/new_derectory

RMDIR Command

The rmdir command is used to permanently delete an empty directory. You should run this command using the sudo privileges.

For instance, if you want to remove an empty subdirectory named empty_folder, you can use the rmdir command as shown below:

rmdir empty_folder

RM Command

The rm command is used to delete files within a directory. However, before you execute this command, you must use the sudo command for permission. Also, note the files or directories deleted can’t be undone.

Here’s the general syntax:

rm filename.txt

To delete multiple files, enter the following command:

rm filename1.txt filename2.txt filename3.txt

Here are some acceptable options you can add:

  • Adding the -i option prompts system confirmation before deleting a file.

  • Adding the -f allows the system to remove without a confirmation.

  • Adding -r deletes files and directories recursively.

Touch Command

The touch command allows you to create an empty file or generate and modify a timestamp in the Linux command line.

To create a new file, use the following command:

touch ~/Documents/index.html

nano, vi, jed command

With these commands, such as nano, vi, and jed, you can edit and manage files in Linux via a text editor. nano and vi comes pre-installed with Linux while jed has to be installed.

The nano command can work with most languages. To use it, enter the following command:

nano [filename]

To use vi on a file, enter:

vi [filename.txt]

Grep Command

The greb command means global regular expression print. It allows you to search through all the texts in a specific file. Once it finds the match, it prints all lines that contain the specific pattern. This command helps filter through large log files.

For example, you want to search for the word red in the filename.txt file:

grep red filename.txt

The command’s output will display lines that contain red.

Permission Commands

Here, I will discuss commands such as:

  • chmod

  • chown

chmod Command

The chmod command is used to modify a file or directory's read, write, and execute permission. In Linux, each file is associated with three user classes – ownergroup member, and others.

For instance, here’s a general syntax:

chmod [option] [permission] [file_name]

While the owner of a file is the only one with full permissions for any file, you can give different permissions to different users or groups using the chmod command.

For example, to allow group members and others to read, write, and execute the file, change it to the -rwxrwxrwx permission type, whose numeric value is 777, using the command below:

chmod 777 filename.txt

This command supports many options, including:

  • Use c or â€“changes to display information when a change is made.

  • Use f or â€“silent to suppress the error messages.

  • Use v or â€“verbose to display a diagnostic for each processed file.

chown Command

The chown command means change ownership. It allows you to change the ownership of a file or symbolic link to a specified username or directory.

Here’s a general syntax:

chown [option] owner[:group] file(s)

For example, you want to make user2 the owner of filename2.txt:

chown user2 filename2.txt

Downloading Commands

Here, I will discuss commands such as:

  • wget

  • apt-get

wget command

The wget command allows you to download files from the internet. It works in the background without hindering other running processes.

The wget command retrieves files using HTTP, HTTPS, and FTP protocols and can perform recursive downloads.

Enter the following command to use:

wget [option] [url]

For example, you can download a file from the Mastering Backend. Assuming this is latest.zip file to download. Do this:

wget <https://masteringbackend.com/latest.zip>

apt-get command

The apt-get command is a tool for handling Advanced Package Tool (APT) libraries in Linux. It lets you retrieve information and bundles from authenticated sources to manage, update, remove, and install software and its dependencies.

It requires the use of sudo command when running the apt-get command. Here’s the main syntax:

apt-get [options] (command)

These are the most common commands you can add to apt-get:

  • Use update to synchronize the package files from their sources.

  • Use upgrade to install the latest version of all installed packages.

  • Use check to update the package cache and check broken dependencies.

I need you to practice all the above commands and reach out to more commands to solidify your knowledge of the terminal.

That was a quick lesson on Basic Terminal Commands for Backend Engineers. There are more commands to learn and master. So, get learning and improving.

That will be all for this one. See you on Saturday.

Don’t forget to Sign UP for the Beta version of Masteringbackend. It comes with unmatched benefits.

Weekly Backend Engineering Resources

  1. Backend Engineering Hub by Solomon Eseme

  2. Docker: The Definitive Guide by Solomon Eseme

  3. All Backend Books by Solomon Eseme

  4. Visit our Store by Solomon Eseme

  5. Join our Community by Solomon Eseme

Whenever you're ready

There are 4 ways I can help you become a great backend engineer:

1. The MB Platform: Join 1000+ backend engineers learning backend engineering on the MB platform. Build real-world backend projects, track your learnings and set schedules, learn from expert-vetted courses and roadmaps, and solve backend engineering tasks, exercises, and challenges.

2. ​The MB Academy:​ The “MB Academy” is a 6-month intensive Advanced Backend Engineering BootCamp to produce great backend engineers.

3. MB Video-Based Courses: Join 1000+ backend engineers learning from our meticulously crafted courses designed to empower you with the knowledge and skills you need to excel in the world of backend development.

4. MB Text-Based Courses: Access 1000+ resources, including PDF guides, comprehensive reference materials, and text-based courses that cater to learners at various stages of their backend engineering journey.

I moved my newsletter from Substack to Beehiiv, and it's been an amazing journey. Start yours here.

Reply

or to participate.