Linux and its Basic Terminal Commands

Linux and its Basic Terminal Commands

( based on my experience )

Welcome To My Blog Everyone !!

What is Linux?

Linux® is an open-source operating system (OS). An operating system is a software that directly manages a system’s hardware and resources, like CPU, memory, and storage. The OS sits between applications and hardware and makes the connections between all of your software and the physical resources that do the work.

What's a command line?

The command line is your direct access to a computer. It's where you ask the software to perform hardware actions that point-and-click graphical user interfaces (GUIs) simply can't ask.

Command lines are available on many operating systems—proprietary or open source. But it’s usually associated with Linux, because both command lines and open-source software, together, give users unrestricted access to their computers.

Installation of Linux Terminal ( Windows )

Step 1: Before Installing anything, we first go to the Control Panel -> Programs and Features and then click on Turn Windows features on or off.

Step 2: After selecting Turn Windows features on or off tick Windows Subsystem for Linux as it is unticked by default.

Step 3: After this go to the Microsoft Store and search for Linux and click on UBUNTU.

Step 4: Now just click on Install.

Step 5: After the Installation is complete, launch UBUNTU and enter a Username and Password of your choice.

Step 6: And Voila! Your Linux Terminal ( UBUNTU )

Installation of zsh shell on UBUNTU

Step 1: Open your Linux Terminal and update your Linux package index.

Step 2: Install the zsh shell with a simple apt install command.

Step 3: After the installation is complete, we now install Oh-my-ZSH which is a zsh modifier and really helpful.

  • Copy and Paste the below code on your terminal.

    sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
    

image

After installing Oh-my-ZSH on your terminal you are good to go. Happy Coding !!!

Basic Terminal Commands

1. pwd 🌎

You can use the pwd command to find out your current location in the filesystem/name of the folder currently open in your terminal window.

The output of pwd will look something like this:

After executing the pwd command, the terminal tells us that we're in the folder called ahivang inside the folder home at root.

2. ls 📝

The ls command is used to list all the folders/files under the location specified, or if not specified, under the current location.

Here, we're listing all the directories/files inside ~

Also, we can add options/flags to our ls command, such as:

  • ls -l

  • ls -a

ls -l

-l is the lowercase letter L, and it stands for long. It lists all contents in a long list format.

Here, terminal will output more information about the listed files when we use the -l option.

This is out the scope of this article, but the long format shows information, such as, permissions, file owner, file size, date, etc.

ls -a

The option a stands for 'all'. The ls -a command lists all of the files inside the current folder/directory, including hidden files.

The photo below shows all of the files inside the ~ folder/directory:

As you saw in the photo above, there's a full-stop (period) at the beginning of certain files. Filenames with a full stop at the beginning are hidden files.

3. mkdir 📁

The mkdir command stands for 'make directory'. This creates a new folder in your current location (current directory).

Use the mkdir command with the name of the new file you want to create:

4. cd 📂 ➡️ 📂

The cd command stands for 'change directory'. This allows you to change your current location (current directory) to another directory.

You use the cd command alongside the other file/directory name you want to change to.

Here, we changed from the ~ directory to the shivangblog directory:

5. touch 📄

The touch command creates a new empty file.

You type touch with the new name of the new file.

Check the terminal below:

6. rm, rmdir 💣

The rm command stands for 'remove'. rm removes a FILE from the system completely.

For example, check out the photo below:

In the photo above, we're listing the contents inside the shivang directory and we see that there's the blog.txt file. Then, we remove the blog.txt file with the rm command.

When we check the contents of shivang once again, we see that the blog.txt file is gone.

rmdir

The rmdir command stands for 'remove directory', and you guessed it, It removes an empty directory. It's very similar to the rm command. You type the name of the directory/folder you want to remove after the rmdir command and press enter.

7. cp ©

The cp command stands for 'copy', and it copies a file from one location to another.

You type cp with the name of the file you want to copy, then the name of the new file.

If you want to copy a directory/folder, use the -R option/flag as well.

8. mv

The mv command stands for 'move'. The mv command moves a file to another directory/folder, or (if the directory name doesn't exist), it renames the file.

Check this photo below: we moved the blog.txt file inside the folder shivangblog.

In the photo above, we first listed all the content inside the ~ using the ls command.

Then, we moved the blog.txt file inside the shivangblog folder. We do this by using the mv command followed by the name of the txt file we wanted to move, in this case, the blog.txt file, followed by the new location, in this case, shivangblog.

When we check the contents of shivangblog, we can see that we successfully moved the blog.txt file inside.

9. man 👨

The man command stands for 'manual'. It displays all the information about commands that we can run on the terminal. Also, it shows all the options/flags you can use.

Below, I typed man ls, and the terminal shows me the manual of the ls command.

10. sudo 👮

Finally, the sudo command allows you to run programs with admin privileges. You'll be required to enter your personal password to execute these commands.

AND WE'RE DONE !!!

Hope, y'all got to learn and understand these 10 basic Terminal Commands of Linux..

Find Me On Twitter