# Linux Beginner Commands

Hi Everyone, welcome to **Day 02** of the **#90DaysofDevops** learning journey. In this session, we will cover Basic Linux commands.

Linux is a free and **open-source operating system** based on the Unix-like kernel. It is widely used in servers, supercomputers, and embedded systems, and is also popular among developers due to its flexibility and customizability.

A tool of the Linux operating system is the Linux command.

By running commands, you can complete all simple and complex activities. The Linux terminal is used to run the commands. Similar to the command prompt in Windows OS, the terminal is a command-line interface for interacting with the system. Linux commands are **case-sensitive.**

### 🚀 Basics Linux command🖥🖥

### 🔸 **pwd Command**

The pwd command is used to display the location of the current working directory.

syntax: `pwd`

```plaintext
pwd
```

### 🔸 **mkdir Command**

The mkdir command is used to create a new directory under any directory.

syntax: `mkdir <directory name>`

```plaintext
mkdir demo1
```

* `mkdir.NewFolder` --&gt; Make a hidden directory (also . before a file to make it hidden)
    
    ```plaintext
    mkdir .MyWorkData
    ```
    
* `mkdir P Q R S` --&gt; Make multiple directories at the same time.
    
* ```plaintext
            mkdir P Q R S
    ```
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1679653894406/7ff88d68-d314-44cb-b1ac-c703f4918216.png align="left")
    
    `mkdir ./demo1/demo2` --&gt; make a new folder in a specific location
    

```plaintext
mkdir ./demo1/demo2
```

* ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1679654202600/82b62908-0cd2-4245-9e32-c3ac81459802.png align="left")
    
    `mkdir -p A/B/C/D/E` --&gt; Make a nested directory
    
* ```plaintext
          mkdir -p A/B/C/D/E
    ```
    
* with the help of the `tree` command its easy to display all directories
    
* ```plaintext
          tree
    ```
    

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1679654628068/5254c562-4ec4-4ae7-ae5d-eb0beb5af31c.png align="right")

### 🔸 **cd Command**

The cd command is used to change the current directory.

syntax: `cd <directory name>`

```plaintext
cd demo1
```

To check the current location now use the `pwd` command.

### 🔸 **touch Command**

The touch command is used to create empty files. We can create multiple empty files by executing it once.

syntax: `touch <filename.ext> // single file creation`

`touch <file1.txt> <file2.txt> // multiple file creation`

```plaintext
touch file1.txt

touch file1.txt file2.txt
```

### 🔸 **cat Command**

The cat command is a multi-purpose utility in the Linux system. It can be used to create a file, display the content of the file, copy the content of one file to another file, and more.

**i. Display A File With cat Command**

To view file content. `cat <filename.ext>`

```plaintext
cat file1.txt
```

**ii. Create A File With cat Command**

we can create also a file with the help of the cat command.

syntax: `cat > <filename.ext`

`-----content of file ctrl+D`

```plaintext
 cat > <filename.ext>
-----
-----
content of file
----
<control+D>
```

You need to press \[CTRL\] + \[D\] i.e. hold the control key down.

**iii. Viewing A Large File With cat Command And Shell Pipes**

If the file is too large to fit on the computer screen, the text will scroll down at high speed. You will be not able to read. To solve this problem pass the cat command output to the more or less command as follows:

syntax: cat &lt;filename.ext&gt; | more

cat &lt;filename.ext&gt; | less

```bash
cat bigfile_data.txt|more

cat bigfile_data.txt|less
```

**iv. How To Combine Two Or More Files Using cat Command**

You can combine two files and creates a new file called all\_data.txt

syntax: `cat filename1.ext filename2.ext > new_filename.ext`

```plaintext
cat file1.txt file2.txt >all_data.txt

cat all_data.txt
```

**v. How To Append Data To A Text File**

To append (add data to existing) data to a file called all\_data.txt

```plaintext
cat >>all_data.txt
----
----
This is the final data report.
<control+D>
```

**vi. Count the number of All Output Lines in a specific file.**

```plaintext
cat -n filename1.txt
cat --number filename1.txt
```

### 🔸 **ls Command**

The ls command is used to display a list of the content of a directory.

syntax: `ls`

**i. Displaying the ls command help page**

To view more options and what you can do with ls simply run `ls --help`

```plaintext
ls --help
```

**ii. Accessing ls man pages**

Alternatively, you can view the manpages to find out more about its usage by running `man ls`

```plaintext
man ls
```

**iii. Listing file and directory permissions with the -l option**

using the -l flag, you can list the permissions of the files and directories as well as other attributes such as folder names, file and directory sizes, and modified date and time.

Syntax: `ls -l`

```plaintext
ls -l
```

**iv. Viewing Hidden files**

You can view hidden files by appending the -a flag. Hidden files are usually system files that begin with a full stop or a period.

syntax: `ls -a`

```plaintext
ls -a
```

**v. Listing files in reverse order**

To list files in reverse order, append the -r flag as shown

Syntax: `ls -r`

```plaintext
ls -r
```

### 🔸 **cp Command**

The cp command is used to copy a file or directory.

syntax: `cp <existing file name> <new file name>`

```plaintext
cp file1.txt file_copydemo1.txt
```

### 🔸 **mv Command**

The mv command is used to move a file or a directory from one location to another location.

syntax: `mv <file name> <directory path>`

### 🔸 **rmdir Command**

The rmdir command is used to delete a directory.

syntax: rmdir &lt;directory name&gt;

```bash
rmdir demo2
```

### 🔸 clear command

The clear command is used to clear the terminal screen.

```plaintext
clear
```

### 🔸 **help command**

The help command is used to display information about commands//c

**Syntax:** `help [-d | -m | -s] [Command_name]`

**Option**: **\-d**

**Description**: Display a short description for each topic.

```plaintext
help -d pwd
```

**Option**: **\-m**

**Description**: Display usage in pseudo-manpage format.

```plaintext
help -m pwd
```

**Option**: **\-s**

**Description**: Display a short usage synopsis for each topic matching.

```plaintext
help -s pwd
```

Example:

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1679655237373/ae2d969c-0f8b-4687-97d6-22034a3d926b.png align="center")

### 🔸 List all the files or directories including hidden files.

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1679654845364/1a96a241-3f84-40ad-b516-8b7af648d18c.png align="center")

### 🔸 **exit command**

The exit command is used to exit the shell.

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1679655636267/449180aa-e9f3-40c6-9ca8-56b745219571.png align="center")

### **🎉 Task Done👍 Day 02 of #90daysofdevops 💯**

In this article, we have covered the Day 02 task of how to check the present working directory and how to list all Hidden files or directories created nested directory A/B/C/D/E. As well as covered basic Linux commands used for DevOps

*If you enjoyed this article please like it and share it with your friends and colleagues!*

Thank you for reading🤓
