2.Linuxh
2.Linuxh
==============
What is OS ?
==============
===========
Windows OS
===========
=========
Linux OS
=========
==============
Linux History
==============
-> Linus Torvalds identified one OS which is matching with his ideas
i.e Minux os
-> Linus Torvalds used Minux OS code and made some changes and released into market
was new OS
=====================
Linux Distributions
=====================
-> So many companies downloaded Linux OS source code and modified according to
their requirement and released into market with their brand names those are called
as Linux Distributions/ Linux Flavours.
Ex: Amazon Linux, Ubuntu, CentOS, RedHat, Debian, SUSE, Kali, Fedora....
==============================
How to setup Linux Machine ?
=============================
Approach-2) We can use Virtual Box and install Linux OS as Guest OS in Windows
============================
Setup Linux VM in AWS Cloud
============================
Step-1 : Login into AWS cloud account
=======================
🔥 Today's Assignment
=======================
================
Linux Commands
================
whoami
pwd
date
cal
cal 2025
mkdir ashokit
mkdir java python aws devops
rmdir devops
touch f1.txt
cat : create file with data + append data to file + print file data
cat > f1.txt : Create new file with data/overwrite exiting file
data
after adding data ctrl+ D to come out of file
rm : Remove files
cp f1.txt f2.txt
Note: To copy the data from multiple files we need to use cat command like below
mv linux.txt linux-os.txt
mv git.txt devops/
=======================================================================
tac : Read file data from bottom to top (opposite of cat cmd)
tac f1.txt
wc : word count
wc f1.txt
========================================
head app.log
head -n 20 app.log
head -n 25 app.log
tail app.log
tail -n 20 app.log
Note : We will use this grep command for keyword search in file
=======================
Text Editors in Linux
=======================
=> using 'vi' we can create new files and we can edit existing files also
$ vi f1.txt
b) insert mode (to edit the file) ---> press 'i' in keyboard
c) esc mode (to comeout from insert mode) --> press 'esc' in keyboard
Note: vi command will open the file if it is already avilable otherwise it will
create new file and it will open that file.
===================================
File creation commands in linux
===================================
====================================
Reading file data commands in linux
====================================
vi : open file
=============
SED command
=============
=> Using SED command we can perform operations on the file without opening the
file.
===========================
Working with User Accounts
===========================
=> Multiple users can acces single linux machine and can perform multi tasking
Note: For every user we can create new account to access linux vm.
# create user
sudo useradd <uname>
# switch user
$ sudo su <uname>
================================
What is sudoers file in Linux
=================================
=> Using this file we can control which user can run command as a superuser.
Note: We should be very careful while working with sudoers file. If we do any
mistakes in sudoers file then system will be crashed.
# configure user like below in sudeors file (after root user details)
<username> ALL=(ALL:ALL) ALL
=> After making changes to close sudoers file => ( CTRL + X + Y + Enter)
========================================================
How to enable password based authentication in linux ?
========================================================
=> To enable password based authentication we need to set the value as yes.
=====================
Log Server Details
=====================
Public IP : 43.204.143.144
username : loguser
pwd: log@123
===========================
Working with User Groups
===========================
=> When we create user in linux, for every user one user group also will be created
with the given username.
=======================================
2) Networking commands
4) Linux Architecture
=================
File Permissions
=================
Note: One user can modify the file created by other user in linux vm.
r => read
w => write
x => execute
group => g
others => o
rwxrwxrwx f1.txt
rw-r--r-- f2.txt
rwxr-xr-x java
r-xr----x sbms
====================================
File Permissions in Numeric Format
====================================
0 => No Permission
1 => Execute
2 => Write
3 => (2+1) => Write + Execute
4 => Read
5 => (4+1) => Read + Execute
6 => (4+2) => Read + Write
7 => (4+2+1) => Read + Write + Execute
====================
Ownership change
====================
# changing owner
sudo chown new-owner file/directory
# changing owner-group
sudo chown :new-group file/directory
============================================
Q) What is the diff between chmod & chown ?
============================================
=====================
Networking Commands
=====================
$ ping www.google.com
$ ping www.google.com
$ ping 192.168.1.20
$ wget https://dlcdn.apache.org/tomcat/tomcat-9/v9.0.91/bin/apache-
tomcat-9.0.91.zip
$ ifconfig
=======================================
whoami
pwd
date
cal
cal 2050
mkdir
rmdir
touch
ls -ltr
cat
cp
rm -rf
mv
tac
head
tail
grep
vi
sed
useradd
userdel
usermod
groupadd
groupdel
id
chmod
chown
ping
wget
curl
ifconfig
==========================
Package Managers in Linux
==========================
================================
Install WebServer in Linux VM
================================
ex : wikipedia
##### To access our webserver we need to enable 80 port number in EC2 VM security
group inbound rules (firewell setting) ####
=> Access our webserver using EC2 VM public ip address in our browser.
=============================
What is systemctl in linux ?
=============================
#start service
sudo systemctl start <service_name>
#stop service
sudo systemctl stop <service_name>
#re-start service
sudo systemctl restart <service_name>
=====================================
How to change hostname in linux vm ?
=====================================
# set hostname
$ sudo hostname <new-name>
# re-start session
$ exit
=================
whereis command
================
whereis java
whereis maven
whereis git
==============
find command
===============
===============
Assignment
===============
========
Summary
=========
3) Windows Vs Linux
4) Linux History
5) Linux Distributions
6) Linux VM Setup
7) Linux commands