Basics Linux Commands

Basics Linux Commands

ยท

2 min read

Introduction:

Linux, with its powerful command-line interface, provides users with a robust and efficient way to interact with the operating system. For those new to Linux, understanding the basics of command-line navigation is essential. In this blog post, we will explore three fundamental Linux commands that every beginner should know.

  1. Check Your Present Working Directory:

The pwd command is used to check the Present Working Directory (PWD). This command helps users identify their current location in the directory structure. To use it, simply type pwd and press Enter. The terminal will display the absolute path of the current directory.

Example:

$ pwd
/home/user/MyFolder
  1. List All Files or Directories, Including Hidden Files:

The ls command is used to list files and directories in a specified location. To list all files and directories, including hidden ones, you can use the -a (or --all) option with the ls command. Hidden files and directories in Linux start with a dot (.), and they are not displayed by default.

Example:

$ ls -a
.  ..  file1  file2  .hidden_directory  another_file

In this example, the -a option reveals all files, including hidden ones, in the current directory.

  1. Create a Nested Directory A/B/C/D/E:

To create a nested directory structure, you can use the mkdir command. The -p option allows you to create parent directories if they do not exist. In this case, we want to create a nested directory A/B/C/D/E. The following command accomplishes this:

Example:

$ mkdir -p A/B/C/D/E

The -p option ensures that the entire path is created, even if some of the directories in the hierarchy do not exist. After executing this command, you will have a nested directory structure with directories A, B, C, D, and E.

Now, let's put it all together in a scenario:

$ pwd
/home/user/MyFolder

$ ls -a
.  ..  file1  file2  .hidden_directory  another_file

$ mkdir -p A/B/C/D/E

After running these commands, you'll have navigated to a directory, listed its contents (including hidden files), and created a nested directory structure. This example should help you understand how these basic Linux commands work in a real-world scenario. As you explore more, you'll find these commands indispensable for navigating and managing your files and directories in a Linux environment.

I'm confident that this article will prove to be valuable, helping you discover new insights and learn something enriching .

thank you : )

ย