Linux for DevOps!
Table of contents
Why Linux?
Open source
multi user friendly
no need for an antivirus.
Flavors of Linux
Ubuntu
centos
Amazon Linux
RHEL
Fedora
Mint os
Linux Architecture
kernel
kernel is the heart of an operating system. By using kernel we can pass instructions to the hardware.
Shell
By using a shell we can communicate with kernel.
CLI (Command line interface)
GUI (Graphical User Interface)
What is vagrant?
Vagrant is an automation tool that manages the virtual environment. In backend it installs operating system for you.
Commands in Linux
mkdir
mkdir is used for creating a directory.
ls
is used for listing directories.
cd
for changing directory.
cd ..
this command is used when you want to get back in previous directory or folder.
touch
for creating a new file.
vim
vim is nothing but a editor. It likes a normal text editor. It used when you want to create a new file and write it in same time.
cat
cat command is used for displaying content in file.
rm
remove command is used for removing file.
copy
this command is used for copy file files from one folder to another.
mv
this move command is used for renaming the file.
clear
this command is used for clearing the screen.
history
command is used for displaying all command history.
ping
this command is used for checking internet connectivity as well as sending request to the browser.
wget
this command is used for reading or downloading a file.
curl
Curl is stand for client URL. curl command is used for sending request and getting response from internet. with curl command we can use HTTP methods.
su
stands for superuser. by using su we can able to give privileges of the super user.
sudo su -
this command is used for doing login as a root user without password.
df
Stands for disk free. this Command is used for checking the disk space
df -h
this command is used for checking the disk space in human readable format.
Difference between vim and nano
Both are like Text editor in Linux. Then whats the difference between vim and nano?
Nano is the more advance it gives instructions as a help at bottom.
In Vim we have to find it selfly.
Difference between curl and wget
Curl stands for client URL. we can use both the commands for sending the request and getting the response. But wget we only use for reading and downloading content. However By using curl we able to see full processing means how the request reached to the destination. Curl command also used with HTTP methods like create, read, delete, update.
What is a script?
Script is a line by line execution of a command which having .sh in extension.
#! bin/bash
above is the starting of a shell script. bash stands for Bourne-again-shell.
To run shell script-
bash filename.sh OR ./filename.sh
How to change permissions to the file?
There are three types of permissions we can give to file
read
write
execute
r will be displayed if reading is permitted
w will be displayed if writing is permitted
x will be displayed if execution is permitted
- will be displayed in the place of r, w, and x, if the respective permission is not permitted
Permissions on Unix and other systems like it are split into three classes:
User
Files and directories are owned by a user.
Group
Files and directories are also assigned to a group.
Other
If a user is not the owner, nor a member of the group, then they are classified as other.
Changing permissions
In order to change permissions, we need to first understand the two notations of permissions.
1. Symbolic notation
Here are some examples of symbolic notation:
-rwxr--r--: A regular file whose user class has read/write/execute, group class has only read permissions, other class has only read permissions
drw-rw-r--: A directory whose user class has read/write permissions, group class has read/write permissions, other class has only read permissions
crwxrw-r--: A character special file whose user has read/write/execute permissions, group class has read/write permissions, other class has only read permissions
2. Octal notation
Here are some examples of Octal notation:
The read bit (r in symbolic notation) adds 4 to its total.
The write bit (w in symbolic notation) adds 2 to its total.
The execute bit (x in symbolic notation) adds 1 to its total.
AWK Command
AWK command allows programmer to write program. It allows user to use String functions, variable, numeric functions and logical operators.
AWK Command uses
Splitting the lines/inputs into fields.
pattern matching
Scanning file line by line
Compare input to pattern
performed actions on matched lines.
How to split lines into fields by using awk?
- suppose we have to only display the first column of available disk space chart, then use following command-
df -h | awk '{print $1}'
here $1 represents first column of output.
- For displaying specific rows,
Suppose we have to display 1,2,3 column with first 5 rows from free disk chart,
df -h | awk '{print $1 " " $2 " " $3} NR==5 {exit}'
Hope you find it helpful.
Thank you for reading!
- Techarti!
Subscribe to my newsletter
Read articles from Arti Deshmukh directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
Arti Deshmukh
Arti Deshmukh
Arti is a Highly motivated and solution-oriented professional with a Post Graduate Diploma in CDAC. She is known for her positive attitude and adept problem-solving skills. Proficient in Java development, and SQL database management, and possesses a solid foundation in cloud computing and DevOps fundamentals. Eager to leverage technical expertise to drive innovation and achieve organizational objectives.