Operating SystemsLinux

Important Basic Linux Commands for Beginners

Story Highlights
  • What is Linux?
  • Linux Shell or “Terminal”
  • Basic Linux Commands For beginners
  • Intermediate Commands
  • Tips and Tricks for Using Linux Command Line

Learn Basic Linux Commands, a free and open-source operating system that you can modify and resell. The Linux command prompt is a text-based computing interface.

It can be referred to as the husk, terminal, console, prompt, or a variety of other names, and it can appear to be difficult to use.

However, because of the ability to copy and paste commands from a webpage, as well as the power and flexibility the command line provides, it may be necessary to use it when trying to follow instructions online, including those on this website!

What is Linux?

The kernel of an operating system is Linux. You’ve probably heard about UNIX. Linux, after all, is a UNIX clone. Linus Torvalds, on the other hand, designed it entirely from scratch.

Linux is free and open-source, which means you can modify it and redistribute it under your own name! There are many Linux distributions, sometimes known as “Distros.”

  • Ubuntu Linux
  • Red Hat Enterprise Linux
  • Linux Mint
  • Debian
  • Fedora

Linux is primarily used in server environments. Around 90% of the internet is powered by Linux servers. Linux is fast, secure, and completely free! The primary disadvantage of adopting Windows servers is their high cost. This issue is addressed by Linux servers. The majority of viruses run on Windows, but not on Linux!

Linux Shell or “Terminal”

So, a shell is software that takes user commands and sends them to the operating system to process, then displays the results.

The essential component of Linux is its shell. Its distributions are GUI-based, although Linux is really a command-line operating system (command-line interface).

In Ubuntu, use Ctrl+Alt+T or Alt+F2, type gnome-terminal, and press enter to launch the terminal. Type the terminal into the Raspberry Pi. There is also a GUI option, but this is superior!

Basic Linux Commands for Beginners

pwd

You are in your user’s home directory when you first enter the terminal. The “pwd” command can be used to determine which directory you are in. It provides us with the absolute path, or the path that begins at the root. The root of the Linux file system is represented by the forward slash(/). The user directory is typically named “/home/username.”

ls

To see what files are in the directory you’re in, use the “ls” command. Using the command “ls -a,” you may see all the hidden files.

cd 

To get to a directory, use the “cd” command. The command “cd” requires a directory name or the path to a new directory as input. If you’re in the home folder and want to get to the media library, put “cd Downloads” into the search box.

When you write “cd Raspberry Pi” in this situation, the shell will interpret the new argument as a different one, resulting in an error stating that the directory does not exist.

You could use a reverse slash here. That is, in this case, you can use “cd Raspberry Pi” (Using Escape Sequence for”). You can type “cd..” to return from one folder to the previous one. The previous folder is represented by the two dots.

mkdir & rmdir

When you need to create a folder or directory, use the mkdir command. If you wish to create a directory called “DIY,” for example, type “mkdir DIY.” Remember that, as previously said, you can type “mkdir DIY Hacking” to create a directory named “DIY Hacking.” To delete a directory, type rmdir. rmdir, on the other hand, can only be used to delete an empty directory. Use rm to delete a directory containing files.

Basic Linux Commands 1

rm

To delete a file, use the rm command. To recursively delete all files within a directory, use “rm -r.”

touch

To make a blank file, just use the touch command. “Touch new.txt,” for example.

man & –help

Use the man command to learn more about a command and how to use it. It displays the command’s manual pages. For example, “man cd” displays the cd command’s instructional pages. Typing the command name and argument helps it reveal which options are available (for example, cd –help).

Read Also:

Disk Partition CMD- How to Manage Partitions

cp 

To duplicate files from the command line, just use the cp command.

mv

To move files from the command line, use the mv command. The mv command can also be used to rename a file. For example, “mv text new” can be used to rename the file “text” to “new.” It accepts the same two arguments as the cp command.

locate 

In Linux, the locate command, like the search function in Windows, is used to locate a file. Because it launches a number of factors that contribute to caching the location of files in your file system, the locate command is extremely quick. You must use the sudo updated command to update the local cache. Then, if you need to locate a file, you can simply use the command I demonstrated before. It’s that simple.

Intermediate Commands

cat

To see the contents of a file, use the cat command. It is commonly used to view applications quickly.

nano, vi, jed

The text editors Nano and vi are already installed in the Linux command line. The nano command is a decent text editor that can recognize most languages and color-code keywords. Vi is also less complicated than nano.

This editor allows you to create new files or edit existing ones. If you need to create a new file named “check.txt,” for example, you can use the command “nano check.txt.”

After you’ve finished modifying your files, use Ctrl+X, then Y to save them (or N for no). Because of its color, we find that using Nano for HTML writing isn’t as good, hence we prefer a jed text editor.

sudo

The text editors Nano and vi are already installed in the Linux command line. The nano command is a decent text editor that can recognize most languages and color-code keywords.

Vi is also less complicated than nano. This editor allows you to create new files or edit existing ones. If you need to create a new file named “check.txt,” for example, you can use the command “nano check.txt.” After you’ve finished modifying your files, use Ctrl+X, then Y to save them (or N for no). Because of its color, we find that using Nano for HTML writing isn’t as good, hence we prefer jed text editor.

Basic Linux commands 2

df 

To check the remaining hard drive space in every one of your system’s partitions, use the df command. You could see every booted partition and its used or available space in percent and KBs by typing df on the command line.

The program “df -m” can be used to display it in megabytes. The “-h” flag in df produces output in the most understandable format.

du

Du can be used to determine a file’s disk use on your system. In Linux, enter the command df followed by the name of the folder or file to find out how much space it takes up on the drive.

For example, on Linux, you may run the command “du Documents” to find out how much disk space the documents folder takes up. To see the file sizes of all the files in a folder, use the command “ls -lah.”

uname

Uname is a command that displays information about the system that your Linux distribution is operating on. The command “uname -a” prints the majority of the system’s information. This displays the kernel’s release date, version, processor type, and other information.

apt-get

In the Linux command line, use apt to work with packages. Install packages via apt-get. Because this requires root access, use the sudo command.

For example, we may use the command “sudo apt-get install jed” to install the text editor jed . Any package can be installed in the same way. Each time you try to install a new package, you should update your repository.

Type “sudo apt-get update” to accomplish this. “sudo apt-get dist-upgrade” can also be used to upgrade the distribution. To find a package, run the command “apt-cache search.” You can look for one by typing “apt-cache search jed” (this does not require root).

chmod

In Linux, use chmod to declare a file accessible and to change its permissions. Assume you have a numbers.py python code on your computer. Every time you need to use it, you’ll need to run “python numbers.py.”

Instead, after you make it executable, all you have to do is type “numbers.py” in the terminal to start the file. In this scenario, the command “chmod +x numbers.py” can be used to make a file executable.

You can give it read, write, and execute permissions for the owner and only read and execute permissions for the group and others by using “chmod 755 numbers.py.”

hostname

It essentially shows your hostname and IP address. The output is obtained by just typing “hostname.” The command “hostname -I” returns your network’s IP address.

ping

Ping can be used to test your server connection. Simply put, when you input “ping google.com,” it checks to see if it can connect to the server and returns.

It calculates the round-trip time and provides you with the details. This command is used to check your internet connection for simple users like us.

You may confirm that your internet connection is active if it pings the Google server (in this case).

Tips and Tricks for Using Linux Command Line

  • If the terminal becomes too cluttered with commands, use the clear command to clean it.
  • TAB can be used to replenish terminal supplies. For example, type “cd Doc” and then TAB, and the terminal will fill in the rest and change it to “cd Documents.”
  • Ctrl+C can be used to safely terminate any command in the terminal.
  • If it doesn’t stop after that, press Ctrl+D to force it to stop.
  • The exit command can be used to exit the terminal.
  • The commands sudo halt and sudo reboot can be used to turn off or restart the computer.

Conclusion

Linux is so common that it may be found in cell phones, automobiles, refrigerators, even Roku boxes. It is responsible for the majority of the Internet and multiple supercomputers.

In fact, Linux is used by stock exchanges in a number of nations throughout the world.

Because Linux is one of the most stable, secure, and durable operating systems available, it has become the platform of choice for PCs, servers, and embedded systems all around the world.

People May Ask

Q- Is learning Linux commands simple?

A- Learning Linux is not tough. The more technology experience you have, the easier it will be to learn the fundamentals of Linux. In a few days, you may learn how to use the fundamental Linux commands if you have the time. It will take a few weeks for you to grow comfortable with these commands.

Q- How long will it take you to master Linux?

A- Basic Linux may be learned in a month if you commit 3–4 hours per day to it. 2–5 years for kernel complexities and kernel programming.

Q- Should I learn Linux first and then Python?

A- Before you start programming, make sure you know your way around your operating system. As a result, learning Linux before learning Python is recommended. It’s also a good idea to get to know your favorite IDE (Integrated Development Environment) before diving into the Python language.

Q- Is Python a Linux program?

A- Python is preinstalled on most Linux distributions and can be downloaded as a package on the rest.

Q- Is Python available in Kali Linux?

A- Kali Linux has completely adopted Python 3. This means that any Kali tool that used Python 2 has been removed or changed to Python 3. Only scripts containing the shebang /usr/bin/python3 are included in any Python 3 utility.

Related Articles

0 0 votes
Article Rating
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments
Back to top button
0
Would love your thoughts, please comment.x
()
x