Monday, April 22, 2024

Learn Basic Linux Commands, Your First Steps in Terminal

Let’s assume you’re a Windows user who has decided to get acquainted with the Linux operating system, constantly hearing about Linux distributions while never having used them yourself. You’re tired of not knowing, wanting to learn new things and progress regardless of your age or the job you’re in. You have an older computer where you could install the Linux operating system, or you have a fast and powerful computer with plenty of hard disk space to install a virtual machine and one of the Linux distributions on it.

The first step is to do some research, question yourself about what kind of Linux distribution you would like to use. There are many Linux distributions for different purposes, some may be more appealing to you while others are not, tastes differ; maybe you would want to limit yourself to your own criteria or simply see what’s on offer and what other Linux users are using. Therefore, before you make your decision, we recommend that you look at the list of the Top 50 Linux distributions; take a look here; before you make a decision.

And then, once you’ve made the right decision, read some text about your distribution or watched a video on the YouTube channel on how to install it, and if you’ve gathered enough courage and installed the Linux distribution you like and have chosen yourself, then you’re ready to sail into the world of Linux and become one of the significant users of the Linux operating system and its huge community on the Internet. We won’t hold it against you as a beginner if someone else helped you install your Linux distribution or if you simply got it pre-installed with your new laptop.

Linux Terminal Commands

Linux Terminal Commands

When you start your already installed Linux distribution and enter the correct password, the graphical desktop of your Linux distribution will appear. Of course, this is provided that you are not using a Linux distribution that does not use any graphical environment. Such a Linux distribution is definitely not for beginners. But since you probably have one of the most common graphical environments like Xfce, KDE, GNOME, and others, customized with themes, colors, and the appearance of your Linux distribution, it is obvious that after starting and logging into your Linux distribution, you will see the desktop of your Linux distribution. Take a good look at the desktop of your Linux distribution and look for a button on the navigation menu, which has an icon with a black window drawn on it, similar to the Command Prompt in the Windows operating system.

This button is usually visible on the navigation bar because it is frequently used. If this is not the case with your Linux distribution, look for Terminal or Console in the menu or search bar. Then start the mentioned application and expand its window so that you can comfortably type Linux Terminal commands. This application is generally called Terminal although a terminal itself is a smaller computer, i.e., an embedded system. A terminal emulator is software that runs on general-purpose machines that implements the behavior of a real terminal. You won’t be wrong if you call the Terminal emulator Terminal, because most Linux users have such a habit and because it is a shorthand that covers all types of Terminal emulators.

The most commonly used Terminal emulator in more popular Linux distributions is Bash Shell, but you also have Zsh, Ksh, Fish, etc. Zsh, for example, offers numerous advantages and improvements over Bash Shell, due to better autocompletion, support for multilingual characters, more advanced configurations and personalizations, integration with plugins, and more options for managing command history. In recent years, it has been increasingly used although Bash Shell is spread across many more Linux distributions.

From Windows Explorer to Terminal: Navigating Linux Like a Pro

We live in a time when even Windows users will almost never open Command Prompt to copy a file on their computer. Believe it or not, there are also Linux distribution users who use the Terminal emulator only when they have to. However, there are some things that you just can’t do as simply in File Explorer. For example, how would you create a hundred directories that differ only by a sequence of numbers, dates, or alphabetical order in their names? In File Explorer, you would create each directory one by one, while in the Terminal emulator, it is just one precise line of text composed of several precise commands, and you press Enter.

Another advantage of the Terminal emulator is that you can connect commands in it, perform multiple actions at once, and immediately send the results of any commands to a file, for example, instead of just viewing their display on the screen. In the Terminal emulator, you can create your own commands, shortcuts, automate some tasks, and do some things that would definitely be complex to do for days. Secondly, access to some remote computers, servers, or databases often does not have a graphical environment, so even on the Windows operating system, you must use Command Prompt.

But the biggest reason for using the Terminal emulator is precisely the ability to use your own imagination, creativity, and intelligence. It is essentially an incredible feeling of power and intelligence; the smartest and best game of all time. It also has a huge tradition. For the pleasure of fast typing, find a good, glowing keyboard that has thin keys and a quick response like those you see on laptops. On them, you will type much faster and more pleasantly even in a darkened room late at night, until it becomes so intuitive and natural to you.

Typing Keyboard

Choosing a keyboard is a key factor when you're typing a lot for productivity

The first thing we do is type the following command.

$ sudo apt update

Enter your password then type the following command.

sudo apt upgrade

When prompted whether to continue with the procedure, press the y key on your keyboard and watch the screen as various processes are executed. Do not touch anything until all processes are completed and you see the prompt. You will execute these commands every time you start your computer or once a day. This is important to keep your system up-to-date with the latest security patches and software improvements whenever you use your Linux distribution.

The command sudo, which stands for “Super User Do,” allows you to execute a command with superuser privileges or administrative rights. It enables you to perform commands that require special privileges. The apt or apt-get command represents the apt package manager. It is a package manager used in many Linux operating systems, including Ubuntu and Debian distributions and their derivatives. It simplifies installation, removal, and updating of software. If, for example, you are using Arch or Manjaro distribution, these Linux distributions do not use the apt package manager; instead, they use the pacman package manager, so you would need to use pacman commands instead of apt commands.

Next, the update command is used to update the local package index. When executed, apt update retrieves the latest information about available packages from the software repositories you’ve added to your system, updates that information, and puts it into the local database. Note that this does not update the actual software; it only updates the information about which packages are available for installation.

Finally, the upgrade command is used to update installed packages to their latest available versions. When you run apt upgrade, the system checks existing installed packages, and if newer versions are available, it downloads and installs those updates. This ensures that you always have the latest versions of all installed software in your Linux distribution. Feel free to enter the following Linux Terminal command.

The clear command will clear your Terminal emulator, or it won’t; instead, it will just move everything you’ve typed so that you have a clean space for typing new commands. In that case, you can see everything you’ve typed by moving the vertical bar on the right side of the Terminal emulator. This clearing depends on which Terminal emulator you use, but it can also depend on the command. Type the following Linux Terminal command. 

ls

The ls command without options will list all the directories and files in the directory you are in. However, this does not apply to hidden directories and files. If you want to see them, type:

$ ls -a

If you want to see a detailed view of your directories and files showing additional information such as owner, group, size, date of last modification, and permissions, then type:

ls -l or shortly: $ ll

If you type the following command:

ls --help

It will display help information about the ls command, including its options and usage.

Linux Terminal Command ls

The ls command with its options lists the folders and files of your working directory

Then you’ll receive concise information about the ls command, how it can list the current directory in various ways. You can also use the --help option for other Linux Terminal commands. If you want more details about a specific command, simply prefix it with man. Type the following Linux Terminal command: 

$ man man

This command, which stands for “manual”, provides a brief guide or documentation for the command you want to learn in detail. Now, let’s proceed with the following Linux Terminal command:

cd Documents

The cd command, short for “change directory”, is used to navigate through directories. The previous command will take you to the Documents directory. If you want to move back one directory level, type the following command: 

cd ..

Note that the .. dots must be separated by a space, unlike in the Command Prompt in the Windows operating system. To return to your home directory regardless of your current location, type:

cd ili cd ~ ili $ cd –

If you want to display the directory you’re currently in, use the following command:

pwd

The main advantage of the Linux approach is the clear separation of privileges between root users and regular users, contributing to greater security and system stability. In contrast, the Windows operating system follows a different user management approach. Although there’s a concept of administrative and standard users, there’s usually no clear division as in the Linux operating system. In Windows, users are often elevated with administrative privileges, granting them access to most system functions.

However, this can increase the risk of unauthorized access and system damage, as users with administrative privileges can execute critical system commands without restrictions. Let’s see how you can switch from a regular user status to root or superuser status in the Linux operating system. Of course, you need the appropriate rights and the superuser password.

sudo su

cd /

# ls

exit

pwd

Linux Terminal Command sudo su

Change to the roor directory with super user rights

Pay attention to the prompt that changes appearance when you switch from one mode to another. You only switch to superuser mode when you need to do something with system tasks. Everything else is done as a regular user. When an installation requires root privileges, i.e., superuser privileges, then you type sudo before the commands. For which, of course, you must have the password and permission to use. With superuser privileges, you can add other users yourself and determine what rights they have. Look at the following commands:

sudo adduser novikorisnik

$ sudo deluser novikorisnik

When creating a new user, you will simply be asked for a password and additional information about the user. When deleting a user, be aware that you may also need to manually delete their home directory with its folders and files. As for creating, copying, and deleting folders and files, it’s best to do a small exercise. Type the following Linux Terminal commands:

mkdir test

tree

cd test

echo “Hello World” > test.txt

cat test.txt

cp test.txt test1.txt

ls

mv test.txt test2.txt

ls

rm test2.txt

ls

exit

Through this short exercise, you saw that the mkdir command is used to create directories, then the tree command graphically lists all directories and files in the working directory where you are located. With the cd test command, we move into the test directory, then we create a text file and write “Hello World” in it, without any text editor, using only the Terminal emulator.

Linux Terminal Commands Test

Basic Linux Terminal commands for working with files and directories

By using the cat command, you display the text that is written in the test.txt file on the screen. The cp command is used to copy test.txt to a new file named test1.txt. If you want to rename a file, use the mv command. To delete a file, use the rm command. Finally, if you want to close the Terminal emulator window without using the mouse, simply type the exit command. These are the most basic Linux Terminal commands, and this text serves as an introduction to some of them. For each command, it’s essential to study it thoroughly and explore the available options. The man command is particularly helpful for this purpose. Additionally, you can download a Linux Cheat Sheet with a list of commands; take a look here.









 

 

No comments:

Post a Comment