From 4e0d1ae27ab6a25bd6204566a923892ed1cda684 Mon Sep 17 00:00:00 2001 From: Kalyanasundaram Somasundaram Date: Tue, 17 Nov 2020 16:30:02 +0550 Subject: [PATCH] Deployed d08cd14 with MkDocs version: 1.1.2 --- linux_basics/command_line_basics/index.html | 62 +++++----- linux_basics/intro/index.html | 2 +- .../linux_server_administration/index.html | 114 +++++++++--------- sitemap.xml.gz | Bin 214 -> 214 bytes 4 files changed, 89 insertions(+), 89 deletions(-) diff --git a/linux_basics/command_line_basics/index.html b/linux_basics/command_line_basics/index.html index 2953cfe..c79e165 100644 --- a/linux_basics/command_line_basics/index.html +++ b/linux_basics/command_line_basics/index.html @@ -1223,14 +1223,14 @@ documentation, most commands will have a command-line argument -h or most popular documentation system in Linux is called man pages - short for manual pages.

Using --help to show the documentation for ls command.

-

+

File System Organization

The linux file system has a hierarchical (or tree-like) structure with its highest level directory called root ( denoted by / ). Directories present inside the root directory stores file related to the system. These directories in turn can either store system files or application files or user related files.

-

+

bin | The executable program of most commonly used commands reside in bin directory
sbin | This directory contains programs used for system administration. home | This directory contains user related files and directories. @@ -1262,25 +1262,25 @@ online bash shell.

At any given moment of time, we will be standing in a certain directory. To get the name of the directory in which we are standing, we can use the pwd command in linux.

-

+

We will now use the cd command to move to a different directory and then print the working directory.

-

+

cd (change directory)

The cd command can be used to change the working directory. Using the command, you can move from one directory to another.

In the below example, we are initially in the root directory. we have then used the cd command to change the directory.

-

+

ls (list files and directories)**

The ls command is used to list the contents of a directory. It will list down all the files and folders present in the given directory.

If we just type ls in the shell, it will list all the files and directories present in the current directory.

-

+

We can also provide the directory name as argument to ls command. It will then list all the files and directories inside the given directory.

-

+

Commands for Manipulating Files

There are four basic commands which are used frequently to manipulate files:

@@ -1311,14 +1311,14 @@ the simplest use case of creating a new file.

General syntax of using touch command

touch <file_name>
 
-

+

mkdir (create new directories)

The mkdir command is used to create directories.You can use ls command to verify that the new directory is created.

General syntax of using mkdir command

mkdir <directory_name>
 
-

+

rm (delete files and directories)

The rm command can be used to delete files and directories. It is very important to note that this command permanently deletes the files and @@ -1331,7 +1331,7 @@ run this command with care.

Let's try to understand the rm command with an example. We will try to delete the file and directory we created using touch and mkdir command respectively.

-

+

cp (copy files and directories)

The cp command is used to copy files and directories from one location to another. Do note that the cp command doesn't do any change to the @@ -1344,14 +1344,14 @@ their copy both co-exist after running cp command successfully.

command to create a new directory named "test_directory". We will now try to copy the "_test_runner.py" file to the directory we created just now.

-

+

Do note that nothing happened to the original "_test_runner.py" file. It's still there in the current directory. A new copy of it got created inside the "test_directory".

-

+

We can also use the cp command to copy the whole directory from one location to another. Let's try to understand this with an example.

-

+

We again used the mkdir command to create a new directory called "another_directory". We then used the cp command along with an additional argument '-r' to copy the "test_directory".

@@ -1368,7 +1368,7 @@ move the files or directories, the original copy is lost.

already exists in "test_directory". The mv command will just replace it. Do note that the original file doesn't exist in the current directory after mv command ran successfully.

-

+

We can also use the mv command to move a directory from one location to another. In this case, we do not need to use the '-r' flag that we did while using the cp command. Do note that the original directory will not @@ -1377,7 +1377,7 @@ exist if we use mv command.

directories. Let's see how we can use this command for renaming.

We have first changed our location to "test_directory". We then use the mv command to rename the ""_test_runner.py" file to "test.py".

-

+

Commands for Viewing Files

There are three basic commands which are used frequently to view the files:

@@ -1397,7 +1397,7 @@ these commands. You should also practice the given examples on the online bash shell.

We will create a new file called "numbers.txt" and insert numbers from 1 to 100 in this file. Each number will be in a separate line.

-

+

Do not worry about the above command now. It's an advanced command which is used to generate numbers. We have then used a redirection operator to push these numbers to the file. We will be discussing I/O redirection in the @@ -1406,7 +1406,7 @@ later sections.

The most simplest use of cat command is to print the contents of the file on your output screen. This command is very useful and can be used for many other purposes. We will study about other use cases later.

-

+

You can try to run the above command and you will see numbers being printed from 1 to 100 on your screen. You will need to scroll up to view all the numbers.

@@ -1416,20 +1416,20 @@ can include additional arguments to display as many lines as we want from the top.

In this example, we are only able to see the first 10 lines from the file when we use the head command.

-

+

By default, head command will only display the first 10 lines. If we want to specify the number of lines we want to see from start, use the '-n' argument to provide the input.

-

+

tail

The tail command displays the last 10 lines of the file by default. We can include additional arguments to display as many lines as we want from the end of the file.

-

+

By default, the tail command will only display the last 10 lines. If we want to specify the number of lines we want to see from the end, use '-n' argument to provide the input.

-

+

In this example, we are only able to see the last 5 lines from the file when we use the tail command with explicit -n option.

Echo Command in Linux

@@ -1437,7 +1437,7 @@ when we use the tail command with explicit -n option.

shell. This command is equivalent to what we have in other programming languages.

The echo command prints the given input string on the screen.

-

+

Text Processing Commands

In the previous section, we learned how to view the content of a file. In many cases, we will be interested in performing the below operations:

@@ -1470,7 +1470,7 @@ these commands. You should also practice the given examples on the online bash shell.

We will create a new file called "numbers.txt" and insert numbers from 1 to 10 in this file. Each number will be in a separate line.

-

+

grep

The grep command in its simplest form can be used to search particular words in a text file. It will display all the lines in a file that @@ -1481,7 +1481,7 @@ an input to the grep command.

In this example, we are trying to search for a string "1" in this file. The grep command outputs the lines where it found this string.

-

+

sed

The sed command in its simplest form can be used to replace a text in a file.

@@ -1490,7 +1490,7 @@ file.

Let's try to replace each occurrence of "1" in the file with "3" using sed command.

-

+

The content of the file will not change in the above example. To do so, we have to use an extra argument '-i' so that the changes are reflected back in the file.

@@ -1498,10 +1498,10 @@ changes are reflected back in the file.

The sort command can be used to sort the input provided to it as an argument. By default, it will sort in increasing order.

Let's first see the content of the file before trying to sort it.

-

+

Now, we will try to sort the file using the sort command. The sort command sorts the content in lexicographical order.

-

+

The content of the file will not change in the above example.

I/O Redirection

@@ -1518,19 +1518,19 @@ output of the command to files or even to the input of other commands. I/O redirection is a very powerful feature.

In the below example, we have used the '>' operator to redirect the output of ls command to output.txt file.

-

+

In the below example, we have redirected the output from echo command to a file.

-

+

We can also redirect the output of a command as an input to another command. This is possible with the help of pipes.

In the below example, we have passed the output of cat command as an input to grep command using pipe(|) operator.

-

+

In the below example, we have passed the output of sort command as an input to uniq command using pipe(|) operator. The uniq command only prints the unique numbers from the input.

-

+

I/O redirection - https://tldp.org/LDP/abs/html/io-redirection.html

Applications in SRE Role

diff --git a/linux_basics/intro/index.html b/linux_basics/intro/index.html index 86c6ece..3a31c20 100644 --- a/linux_basics/intro/index.html +++ b/linux_basics/intro/index.html @@ -1127,7 +1127,7 @@ system by a package manager.

Linux Architecture

-

+

-

+

@@ -1481,10 +1481,10 @@ commands on your own.

id command can be used to find the uid and gid associated with an user. It also lists down the groups to which the user belongs to.

The uid and gid associated with the root user is 0. -

+

A good way to find out the current user in linux is to use the whoami command.

-

+

"root" user or superuser is the most privileged user with unrestricted access to all the resources on the system. It has UID 0

Important files associated with users/groups

@@ -1506,9 +1506,9 @@ command.

-

-

-

+

+

+

If you want to understand each filed discussed in the above outputs, you can go through below links: