# Linux Advance Commands

Welcome to the world of advanced Linux commands, where the terminal becomes your gateway to unparalleled control and efficiency. Beyond the familiar commands, lies a realm of powerful tools that can unravel the mysteries of file manipulation, system management and many more.

Let's not waste time and get started with the commands that we are about to discuss today.

The **cat** command in Linux is used to concatenate and display the contents of files. Its primary purpose is to read one or more files and print their contents to the terminal.

```plaintext
cat filename.txt
```

You can use a **cat** with various options and arguments to achieve different tasks. Some common use cases include:

Create a new file or append to an existing file:

```plaintext
cat text_to_append.txt >> existing_file.txt
```

To create a fruits.txt file and to view the content.

```plaintext
vim fruits.txt
```

Add content in fruits.txt (One in each line) - Apple, Mango, Banana, Cherry, Kiwi, Orange, Guava.

```plaintext
vim fruits.txt and hit i(insert) to append the above data :wq save and exit
```

Show only the top three fruits from the file.

```plaintext
head -3 fruits.txt
```

Show the bottom three fruits from the file.

```plaintext
tail -3 fruits.txt
```

* To create another file Colors.txt and to view the content and Add content in Colors.txt (One in each line) - Red, Pink, White, Black, Blue, Orange, Purple, and Grey.
    

```plaintext
vim colors.txt and hit i(insert) append data, :wq save and exit
```

The **diff** command in Linux is used to compare two text files and identify the differences between them.

```plaintext
diff colors.txt fruits.txt
```

**File Permissions**

File permissions in Linux are a fundamental aspect of the operating system's security model. They determine who can access, modify, or execute files and directories. Linux uses a permission system that assigns different levels of access to three main categories of users: the file owner, the group associated with the file, and others

There are three basic types of permissions for files and directories:

Read (r): Allows a user to view the content of a file or list the contents of a directory.

Write (w): Permits a user to modify the content of a file or add/remove files within a directory.

Execute (x): Grants a user the ability to execute a file as a program or enter a directory.

Linux file permissions are represented by numbers, it's called numeric mode. In numeric mode, a three-digit value represents specific file permissions (for example, 744.) The first digit is for owner permissions, the second digit is for group permissions, and the third is for other users. Each permission has a numeric value assigned to it:

**r for read permission with value 4**

**w for write permission with value 2**

**x for execution permission with value 1**

```plaintext
chmod 007 filename.txt
```

In the above example, **007** represents no read write and execute permission for the owner, same as with the groups (no read, write and execute permission) and here come the others part with all the permissions read -4 write -2 and the execute 1 sum up to 7.

Remember that improper use of file permissions can compromise the security of your system, so it's important to understand how they work and apply them carefully.

The **history** command in Linux is used to display the command history for the current user in a terminal session.

To remove a directory/folder the command is used **rm-r** here the r flag represents **recursively** which means directory inside the directory.

May your terminal forever echo with the symphony of advanced commands, creating harmonious solutions to even the most intricate of challenges.

As we conclude this journey through Linux Advanced commands, I hope you've gained valuable insights and a fresh perspective.
