mirror of
https://github.com/linkedin/school-of-sre
synced 2026-01-19 06:58:03 +00:00
broken image path in linux basics
This commit is contained in:
@@ -18,7 +18,7 @@ for manual pages.
|
|||||||
|
|
||||||
Using \--help to show the documentation for ls command.
|
Using \--help to show the documentation for ls command.
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
## File System Organization
|
## File System Organization
|
||||||
|
|
||||||
@@ -28,7 +28,7 @@ present inside the root directory stores file related to the system.
|
|||||||
These directories in turn can either store system files or application
|
These directories in turn can either store system files or application
|
||||||
files or user related files.
|
files or user related files.
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
bin | The executable program of most commonly used commands reside in bin directory
|
bin | The executable program of most commonly used commands reside in bin directory
|
||||||
sbin | This directory contains programs used for system administration.
|
sbin | This directory contains programs used for system administration.
|
||||||
@@ -62,12 +62,12 @@ 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
|
To get the name of the directory in which we are standing, we can use
|
||||||
the pwd command in linux.
|
the pwd command in linux.
|
||||||
|
|
||||||

|

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

|

|
||||||
|
|
||||||
### cd (change directory)
|
### cd (change directory)
|
||||||
|
|
||||||
@@ -77,7 +77,7 @@ command, you can move from one directory to another.
|
|||||||
In the below example, we are initially in the root directory. we have
|
In the below example, we are initially in the root directory. we have
|
||||||
then used the cd command to change the directory.
|
then used the cd command to change the directory.
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
### ls (list files and directories)**
|
### ls (list files and directories)**
|
||||||
|
|
||||||
@@ -87,12 +87,12 @@ 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
|
If we just type ls in the shell, it will list all the files and
|
||||||
directories present in the current directory.
|
directories present in the current directory.
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
We can also provide the directory name as argument to ls command. It
|
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.
|
will then list all the files and directories inside the given directory.
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
## Commands for Manipulating Files
|
## Commands for Manipulating Files
|
||||||
|
|
||||||
@@ -125,7 +125,7 @@ General syntax of using touch command
|
|||||||
touch <file_name>
|
touch <file_name>
|
||||||
```
|
```
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
### mkdir (create new directories)
|
### mkdir (create new directories)
|
||||||
|
|
||||||
@@ -138,7 +138,7 @@ General syntax of using mkdir command
|
|||||||
mkdir <directory_name>
|
mkdir <directory_name>
|
||||||
```
|
```
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
### rm (delete files and directories)
|
### rm (delete files and directories)
|
||||||
|
|
||||||
@@ -158,7 +158,7 @@ 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
|
delete the file and directory we created using touch and mkdir command
|
||||||
respectively.
|
respectively.
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
### cp (copy files and directories)
|
### cp (copy files and directories)
|
||||||
|
|
||||||
@@ -178,18 +178,18 @@ 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
|
try to copy the "\_test_runner.py" file to the directory we created just
|
||||||
now.
|
now.
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
Do note that nothing happened to the original "\_test_runner.py" file.
|
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
|
It's still there in the current directory. A new copy of it got created
|
||||||
inside the "test_directory".
|
inside the "test_directory".
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
We can also use the cp command to copy the whole directory from one
|
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.
|
location to another. Let's try to understand this with an example.
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
We again used the mkdir command to create a new directory called
|
We again used the mkdir command to create a new directory called
|
||||||
"another_directory". We then used the cp command along with an
|
"another_directory". We then used the cp command along with an
|
||||||
@@ -214,7 +214,7 @@ 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
|
**Do note that the original file doesn't exist in the current directory
|
||||||
after mv command ran successfully.**
|
after mv command ran successfully.**
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
We can also use the mv command to move a directory from one location to
|
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
|
another. In this case, we do not need to use the '-r' flag that we did
|
||||||
@@ -227,7 +227,7 @@ 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
|
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".
|
mv command to rename the ""\_test_runner.py" file to "test.py".
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
## Commands for Viewing Files
|
## Commands for Viewing Files
|
||||||
|
|
||||||
@@ -247,7 +247,7 @@ online bash shell.
|
|||||||
We will create a new file called "numbers.txt" and insert numbers from 1
|
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.
|
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
|
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
|
is used to generate numbers. We have then used a redirection operator to
|
||||||
@@ -261,7 +261,7 @@ 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
|
your output screen. This command is very useful and can be used for many
|
||||||
other purposes. We will study about other use cases later.
|
other purposes. We will study about other use cases later.
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
You can try to run the above command and you will see numbers being
|
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
|
printed from 1 to 100 on your screen. You will need to scroll up to view
|
||||||
@@ -276,13 +276,13 @@ from the top.
|
|||||||
In this example, we are only able to see the first 10 lines from the
|
In this example, we are only able to see the first 10 lines from the
|
||||||
file when we use the head command.
|
file when we use the head command.
|
||||||
|
|
||||||

|

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

|

|
||||||
|
|
||||||
### tail
|
### tail
|
||||||
|
|
||||||
@@ -290,13 +290,13 @@ 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
|
can include additional arguments to display as many lines as we want
|
||||||
from the end of the file.
|
from the end of the file.
|
||||||
|
|
||||||

|

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

|

|
||||||
|
|
||||||
In this example, we are only able to see the last 5 lines from the file
|
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.
|
when we use the tail command with explicit -n option.
|
||||||
@@ -310,7 +310,7 @@ programming languages.
|
|||||||
|
|
||||||
The echo command prints the given input string on the screen.
|
The echo command prints the given input string on the screen.
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
## Text Processing Commands
|
## Text Processing Commands
|
||||||
|
|
||||||
@@ -339,7 +339,7 @@ online bash shell.
|
|||||||
We will create a new file called "numbers.txt" and insert numbers from 1
|
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.
|
to 10 in this file. Each number will be in a separate line.
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
### grep
|
### grep
|
||||||
|
|
||||||
@@ -357,7 +357,7 @@ grep <word_to_search> <file_name>
|
|||||||
In this example, we are trying to search for a string "1" in this file.
|
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.
|
The grep command outputs the lines where it found this string.
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
### sed
|
### sed
|
||||||
|
|
||||||
@@ -373,7 +373,7 @@ sed 's/<text_to_replace>/<replacement_text>/' <file_name>
|
|||||||
Let's try to replace each occurrence of "1" in the file with "3" using
|
Let's try to replace each occurrence of "1" in the file with "3" using
|
||||||
sed command.
|
sed command.
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
The content of the file will not change in the above
|
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
|
example. To do so, we have to use an extra argument '-i' so that the
|
||||||
@@ -386,12 +386,12 @@ argument. By default, it will sort in increasing order.
|
|||||||
|
|
||||||
Let's first see the content of the file before trying to sort it.
|
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
|
Now, we will try to sort the file using the sort command. The sort
|
||||||
command sorts the content in lexicographical order.
|
command sorts the content in lexicographical order.
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
The content of the file will not change in the above
|
The content of the file will not change in the above
|
||||||
example.
|
example.
|
||||||
@@ -415,12 +415,12 @@ I/O redirection is a very powerful feature.
|
|||||||
In the below example, we have used the '>' operator to redirect the
|
In the below example, we have used the '>' operator to redirect the
|
||||||
output of ls command to output.txt file.
|
output of ls command to output.txt file.
|
||||||
|
|
||||||

|

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

|

|
||||||
|
|
||||||
We can also redirect the output of a command as an input to another
|
We can also redirect the output of a command as an input to another
|
||||||
command. This is possible with the help of pipes.
|
command. This is possible with the help of pipes.
|
||||||
@@ -428,13 +428,13 @@ command. This is possible with the help of pipes.
|
|||||||
In the below example, we have passed the output of cat command as an
|
In the below example, we have passed the output of cat command as an
|
||||||
input to grep command using pipe(\|) operator.
|
input to grep command using pipe(\|) operator.
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
In the below example, we have passed the output of sort command as an
|
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
|
input to uniq command using pipe(\|) operator. The uniq command only
|
||||||
prints the unique numbers from the input.
|
prints the unique numbers from the input.
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
I/O redirection -
|
I/O redirection -
|
||||||
[https://tldp.org/LDP/abs/html/io-redirection.html](https://tldp.org/LDP/abs/html/io-redirection.html)
|
[https://tldp.org/LDP/abs/html/io-redirection.html](https://tldp.org/LDP/abs/html/io-redirection.html)
|
||||||
|
|||||||
@@ -110,7 +110,7 @@ system by a package manager.
|
|||||||
|
|
||||||
## Linux Architecture
|
## Linux Architecture
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
- The Linux kernel is monolithic in nature.
|
- The Linux kernel is monolithic in nature.
|
||||||
|
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ commands on your own.
|
|||||||
|
|
||||||
- We will be running all the commands on Red Hat Enterprise Linux (RHEL) 8 system.
|
- We will be running all the commands on Red Hat Enterprise Linux (RHEL) 8 system.
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
- We will run most of the commands used in this module in the above docker container.
|
- We will run most of the commands used in this module in the above docker container.
|
||||||
|
|
||||||
@@ -41,12 +41,12 @@ 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.
|
It also lists down the groups to which the user belongs to.
|
||||||
|
|
||||||
The uid and gid associated with the root user is 0.
|
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
|
A good way to find out the current user in linux is to use the whoami
|
||||||
command.
|
command.
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
**"root" user or superuser is the most privileged user with**
|
**"root" user or superuser is the most privileged user with**
|
||||||
**unrestricted access to all the resources on the system. It has UID 0**
|
**unrestricted access to all the resources on the system. It has UID 0**
|
||||||
@@ -58,11 +58,11 @@ command.
|
|||||||
| /etc/shadow | Stores the password associated with the users |
|
| /etc/shadow | Stores the password associated with the users |
|
||||||
| /etc/group | Stores information about different groups on the system |
|
| /etc/group | Stores information about different groups on the system |
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||

|

|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
If you want to understand each filed discussed in the above outputs, you can go
|
If you want to understand each filed discussed in the above outputs, you can go
|
||||||
through below links:
|
through below links:
|
||||||
@@ -94,13 +94,13 @@ has been created by tailing the /etc/passwd file. The uid and gid are
|
|||||||
is /home/shivam and the login shell assigned is /bin/bash. Do note that
|
is /home/shivam and the login shell assigned is /bin/bash. Do note that
|
||||||
the user home directory and login shell can be modified later on.
|
the user home directory and login shell can be modified later on.
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
If we do not specify any value for attributes like home directory or
|
If we do not specify any value for attributes like home directory or
|
||||||
login shell, default values will be assigned to the user. We can also
|
login shell, default values will be assigned to the user. We can also
|
||||||
override these default values when creating a new user.
|
override these default values when creating a new user.
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
### passwd
|
### passwd
|
||||||
|
|
||||||
@@ -112,11 +112,11 @@ In the above examples, we have not assigned any password for users
|
|||||||
\"!!\" in an account entry in shadow means the account of an user has
|
\"!!\" in an account entry in shadow means the account of an user has
|
||||||
been created, but not yet given a password.
|
been created, but not yet given a password.
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
Let's now try to create a password for user "shivam".
|
Let's now try to create a password for user "shivam".
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
Do remember the password as we will be later using examples
|
Do remember the password as we will be later using examples
|
||||||
where it will be useful.
|
where it will be useful.
|
||||||
@@ -125,7 +125,7 @@ Also, let's change the password for the root user now. When we switch
|
|||||||
from a normal user to root user, it will request you for a password.
|
from a normal user to root user, it will request you for a password.
|
||||||
Also, when you login using root user, the password will be asked.
|
Also, when you login using root user, the password will be asked.
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
### usermod
|
### usermod
|
||||||
|
|
||||||
@@ -134,7 +134,7 @@ home directory or the shell.
|
|||||||
|
|
||||||
Let's try to modify the login shell of user "amit" to "/bin/bash".
|
Let's try to modify the login shell of user "amit" to "/bin/bash".
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
In a similar way, you can also modify many other attributes for a user.
|
In a similar way, you can also modify many other attributes for a user.
|
||||||
Try 'usermod -h' for a list of attributes you can modify.
|
Try 'usermod -h' for a list of attributes you can modify.
|
||||||
@@ -147,7 +147,7 @@ user, all the information related to that user will be removed.
|
|||||||
Let's try to delete the user "amit". After deleting the user, you will
|
Let's try to delete the user "amit". After deleting the user, you will
|
||||||
not find the entry for that user in "/etc/passwd" or "/etc/shadow" file.
|
not find the entry for that user in "/etc/passwd" or "/etc/shadow" file.
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
## Important commands for managing groups
|
## Important commands for managing groups
|
||||||
|
|
||||||
@@ -160,11 +160,11 @@ Commands for managing groups are quite similar to the commands used for managing
|
|||||||
| groupdel \<group_name\> | Deletes a group |
|
| groupdel \<group_name\> | Deletes a group |
|
||||||
| gpasswd \<group_name\> | Modifies password for group |
|
| gpasswd \<group_name\> | Modifies password for group |
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
We will now try to add user "shivam" to the group we have created above.
|
We will now try to add user "shivam" to the group we have created above.
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
## Becoming a Superuser in Linux
|
## Becoming a Superuser in Linux
|
||||||
|
|
||||||
@@ -175,11 +175,11 @@ described in the above section.**
|
|||||||
The su command can be used to switch users in linux. Let's now try to
|
The su command can be used to switch users in linux. Let's now try to
|
||||||
switch to user "shivam".
|
switch to user "shivam".
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
Let's now try to open the "/etc/shadow" file.
|
Let's now try to open the "/etc/shadow" file.
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
The operating system didn't allow the user "shivam" to read the content
|
The operating system didn't allow the user "shivam" to read the content
|
||||||
of the "/etc/shadow" file. This is an important file in linux which
|
of the "/etc/shadow" file. This is an important file in linux which
|
||||||
@@ -201,7 +201,7 @@ need to be a part of the sudo group.
|
|||||||
Let's first switch to the root user using su command. Do note that using
|
Let's first switch to the root user using su command. Do note that using
|
||||||
the below command will need you to enter the password for the root user.
|
the below command will need you to enter the password for the root user.
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
In case, you forgot to set a password for the root user, type "exit" and
|
In case, you forgot to set a password for the root user, type "exit" and
|
||||||
you will be back as the root user. Now, set up a password using the
|
you will be back as the root user. Now, set up a password using the
|
||||||
@@ -211,7 +211,7 @@ passwd command.
|
|||||||
sudo**. In redhat operating systems, this file is not present by
|
sudo**. In redhat operating systems, this file is not present by
|
||||||
default. We will need to install sudo.
|
default. We will need to install sudo.
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
We will discuss the yum command in detail in later sections.
|
We will discuss the yum command in detail in later sections.
|
||||||
|
|
||||||
@@ -220,23 +220,23 @@ information. This file stores the rules that users must follow when
|
|||||||
running the sudo command. For example, root is allowed to run any
|
running the sudo command. For example, root is allowed to run any
|
||||||
commands from anywhere.
|
commands from anywhere.
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
One easy way of providing root access to users is to add them to a group
|
One easy way of providing root access to users is to add them to a group
|
||||||
which has permissions to run all the commands. "wheel" is a group in
|
which has permissions to run all the commands. "wheel" is a group in
|
||||||
redhat linux with such privileges.
|
redhat linux with such privileges.
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
Let's add the user "shivam" to this group so that it also has sudo
|
Let's add the user "shivam" to this group so that it also has sudo
|
||||||
privileges.
|
privileges.
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
Let's now switch back to user "shivam" and try to access the
|
Let's now switch back to user "shivam" and try to access the
|
||||||
"/etc/shadow" file.
|
"/etc/shadow" file.
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
We need to use sudo before running the command since it can only be
|
We need to use sudo before running the command since it can only be
|
||||||
accessed with the sudo privileges. We have already given sudo privileges
|
accessed with the sudo privileges. We have already given sudo privileges
|
||||||
@@ -253,15 +253,15 @@ allowed to access the files and resources of another user.
|
|||||||
To see the permissions of a file, we can use the ls command. Let's look
|
To see the permissions of a file, we can use the ls command. Let's look
|
||||||
at the permissions of /etc/passwd file.
|
at the permissions of /etc/passwd file.
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
Let's go over some of the important fields in the output that are
|
Let's go over some of the important fields in the output that are
|
||||||
related to file permissions.
|
related to file permissions.
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
### Chmod command in linux
|
### Chmod command in linux
|
||||||
|
|
||||||
@@ -285,13 +285,13 @@ allowed and 0 representing False or not allowed.
|
|||||||
|
|
||||||
We will now create a new file and check the permission of the file.
|
We will now create a new file and check the permission of the file.
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
The group owner doesn't have the permission to write to this file. Let's
|
The group owner doesn't have the permission to write to this file. Let's
|
||||||
give the group owner or root the permission to write to it using chmod
|
give the group owner or root the permission to write to it using chmod
|
||||||
command.
|
command.
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
Chmod command can be also used to change the permissions of a directory
|
Chmod command can be also used to change the permissions of a directory
|
||||||
in the similar way.
|
in the similar way.
|
||||||
@@ -303,14 +303,14 @@ directories in linux.
|
|||||||
|
|
||||||
Command syntax: chown \<new_owner\> \<file_name\>
|
Command syntax: chown \<new_owner\> \<file_name\>
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
**In case, we do not have sudo privileges, we need to use sudo
|
**In case, we do not have sudo privileges, we need to use sudo
|
||||||
command**. Let's switch to user 'shivam' and try changing the owner. We
|
command**. Let's switch to user 'shivam' and try changing the owner. We
|
||||||
have also changed the owner of the file to root before running the below
|
have also changed the owner of the file to root before running the below
|
||||||
command.
|
command.
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
Chown command can also be used to change the owner of a directory in the
|
Chown command can also be used to change the owner of a directory in the
|
||||||
similar way.
|
similar way.
|
||||||
@@ -321,7 +321,7 @@ The chgrp command can be used to change the group ownership of files or
|
|||||||
directories in linux. The syntax is very similar to that of chown
|
directories in linux. The syntax is very similar to that of chown
|
||||||
command.
|
command.
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
Chgrp command can also be used to change the owner of a directory in the
|
Chgrp command can also be used to change the owner of a directory in the
|
||||||
similar way.
|
similar way.
|
||||||
@@ -354,19 +354,19 @@ Steps for setting up a passwordless authentication with a remote host:
|
|||||||
|
|
||||||
Install openssh package which contains all the commands related to ssh.
|
Install openssh package which contains all the commands related to ssh.
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
Generate a key pair using the ssh-keygen command. One can choose the
|
Generate a key pair using the ssh-keygen command. One can choose the
|
||||||
default values for all prompts.
|
default values for all prompts.
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
After running the ssh-keygen command successfully, we should see two
|
After running the ssh-keygen command successfully, we should see two
|
||||||
keys present in the \~/.ssh directory. Id_rsa is the private key and
|
keys present in the \~/.ssh directory. Id_rsa is the private key and
|
||||||
id_rsa.pub is the public key. Do note that the private key can only be
|
id_rsa.pub is the public key. Do note that the private key can only be
|
||||||
read and modified by you.
|
read and modified by you.
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
2. Transferring the public key to the remote host
|
2. Transferring the public key to the remote host
|
||||||
|
|
||||||
@@ -374,23 +374,23 @@ Steps for setting up a passwordless authentication with a remote host:
|
|||||||
We will look at one of the most common ways of doing it using the
|
We will look at one of the most common ways of doing it using the
|
||||||
ssh-id-copy command.
|
ssh-id-copy command.
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
Install the openssh-clients package to use ssh-id-copy command.
|
Install the openssh-clients package to use ssh-id-copy command.
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
Use the ssh-id-copy command to copy your public key to the remote host.
|
Use the ssh-id-copy command to copy your public key to the remote host.
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
Now, ssh into the remote host using the password authentication.
|
Now, ssh into the remote host using the password authentication.
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
Our public key should be there in \~/.ssh/authorized_keys now.
|
Our public key should be there in \~/.ssh/authorized_keys now.
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
\~/.ssh/authorized_key contains a list of public keys. The users
|
\~/.ssh/authorized_key contains a list of public keys. The users
|
||||||
associated with these public keys have the ssh access into the remote
|
associated with these public keys have the ssh access into the remote
|
||||||
@@ -401,13 +401,13 @@ Steps for setting up a passwordless authentication with a remote host:
|
|||||||
|
|
||||||
General syntax: ssh \<user\>@\<hostname/hostip\> \<command\>
|
General syntax: ssh \<user\>@\<hostname/hostip\> \<command\>
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
### How to transfer files from one host to another host ?
|
### How to transfer files from one host to another host ?
|
||||||
|
|
||||||
General syntax: scp \<source\> \<destination\>
|
General syntax: scp \<source\> \<destination\>
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
## Package Management
|
## Package Management
|
||||||
|
|
||||||
@@ -435,17 +435,17 @@ the successor to YUM which is now used in Fedora for installing and
|
|||||||
managing packages. DNF may replace YUM in the future on all RPM based
|
managing packages. DNF may replace YUM in the future on all RPM based
|
||||||
linux distributions.
|
linux distributions.
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
We did find an exact match for the keyword httpd when we searched using
|
We did find an exact match for the keyword httpd when we searched using
|
||||||
yum search command. Let's now install the httpd package.
|
yum search command. Let's now install the httpd package.
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
After httpd is installed, we will use the yum remove command to remove
|
After httpd is installed, we will use the yum remove command to remove
|
||||||
httpd package.
|
httpd package.
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
## Process Management
|
## Process Management
|
||||||
|
|
||||||
@@ -457,7 +457,7 @@ used to monitor the processes on linux systems.
|
|||||||
The ps command is used to know the information of a process or list of
|
The ps command is used to know the information of a process or list of
|
||||||
processes.
|
processes.
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
If you get an error "ps command not found" while running ps command, do
|
If you get an error "ps command not found" while running ps command, do
|
||||||
install **procps** package.
|
install **procps** package.
|
||||||
@@ -468,17 +468,17 @@ processes on the system by using the below command.
|
|||||||
Reference:
|
Reference:
|
||||||
[https://unix.stackexchange.com/questions/106847/what-does-aux-mean-in-ps-aux](https://unix.stackexchange.com/questions/106847/what-does-aux-mean-in-ps-aux)
|
[https://unix.stackexchange.com/questions/106847/what-does-aux-mean-in-ps-aux](https://unix.stackexchange.com/questions/106847/what-does-aux-mean-in-ps-aux)
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
We can use an additional argument with ps command to list the
|
We can use an additional argument with ps command to list the
|
||||||
information about the process with a specific process ID.
|
information about the process with a specific process ID.
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
We can use grep in combination with ps command to list only specific
|
We can use grep in combination with ps command to list only specific
|
||||||
processes.
|
processes.
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
### top
|
### top
|
||||||
|
|
||||||
@@ -486,7 +486,7 @@ The top command is used to show information about linux processes
|
|||||||
running on the system in real time. It also shows a summary of the
|
running on the system in real time. It also shows a summary of the
|
||||||
system information.
|
system information.
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
For each process, top lists down the process ID, owner, priority, state,
|
For each process, top lists down the process ID, owner, priority, state,
|
||||||
cpu utilization, memory utilization and much more information. It also
|
cpu utilization, memory utilization and much more information. It also
|
||||||
@@ -504,19 +504,19 @@ The free command is used to display the memory usage of the system. The
|
|||||||
command displays the total free and used space available in the RAM
|
command displays the total free and used space available in the RAM
|
||||||
along with space occupied by the caches/buffers.
|
along with space occupied by the caches/buffers.
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
free command by default shows the memory usage in kilobytes. We can use
|
free command by default shows the memory usage in kilobytes. We can use
|
||||||
an additional argument to get the data in human-readable format.
|
an additional argument to get the data in human-readable format.
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
### vmstat
|
### vmstat
|
||||||
|
|
||||||
The vmstat command can be used to display the memory usage along with
|
The vmstat command can be used to display the memory usage along with
|
||||||
additional information about io and cpu usage.
|
additional information about io and cpu usage.
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
## Checking Disk Space in Linux
|
## Checking Disk Space in Linux
|
||||||
|
|
||||||
@@ -528,19 +528,19 @@ used to view disk space on linux.
|
|||||||
The df command is used to display the free and available space for each
|
The df command is used to display the free and available space for each
|
||||||
mounted file system.
|
mounted file system.
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
### du (disk usage)
|
### du (disk usage)
|
||||||
|
|
||||||
The du command is used to display disk usage of files and directories on
|
The du command is used to display disk usage of files and directories on
|
||||||
the system.
|
the system.
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
The below command can be used to display the top 5 largest directories
|
The below command can be used to display the top 5 largest directories
|
||||||
in the root directory.
|
in the root directory.
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
## Daemons
|
## Daemons
|
||||||
|
|
||||||
@@ -562,7 +562,7 @@ The below examples shows the unit configuration files available at
|
|||||||
We are more interested in the configuration file that ends with service
|
We are more interested in the configuration file that ends with service
|
||||||
as these are service units.
|
as these are service units.
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
### Managing System Services
|
### Managing System Services
|
||||||
|
|
||||||
@@ -584,7 +584,7 @@ which can be very useful for viewing system logs and applications logs
|
|||||||
in linux. These logs can be very useful when you are troubleshooting on
|
in linux. These logs can be very useful when you are troubleshooting on
|
||||||
the system.
|
the system.
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
## Applications in SRE Role
|
## Applications in SRE Role
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user