linux
linux
==========================================
==============
What is OS ?
==============
===========
Windows OS
===========
Linux OS
=========
==============
Linux History
==============
-> Linus Torvalds identified some challenges/issues in Unix OS
-> 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 Flavors.
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
============================
============================
=======================
Today's Assignment
=======================
================
Linux Commands
================
whoami
pwd
date
cal
cal 2025
mkdir : Make directory
mkdir ashokit
rmdir devops
touch f1.txt
cat : create file with data + append data to file + print file data
rm : Remove files
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
=======================
=======================
=> 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.
===================================
===================================
====================================
====================================
vi : open file
=============
SED command
=============
=> Using SED command we can perform operations on the file without opening the file.
===========================
===========================
=> 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
cat /etc/passwd
# switch user
$ sudo su <uname>
$ cd ~
================================
=================================
=> 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.
$ sudo visudo
# configure user like below in sudeors file (after root user details)
=> After making changes to close sudoers file => ( CTRL + X + Y + Enter)
========================================================
========================================================
=> To enable password based authentication we need to set the value as yes.
$ sudo vi /etc/ssh/sshd_config
=====================
=====================
Public IP : 43.204.143.144
username : loguser
pwd: log@123
$ ssh uname@public-ip
===========================
=> When we create user in linux, for every user one user group also will be created with the
given username.
$ cat /etc/group
=======================================
2) Networking commands
=================
File Permissions
=================
Note: One user can modify the file created by other user in linux vm.
w => write
x => execute
group => g
others => o
rwxrwxrwx f1.txt
rw-r--r-- f2.txt
r-xr----x sbms
====================================
====================================
0 => No Permission
1 => Execute
2 => Write
4 => Read
====================
Ownership change
====================
# changing owner
# changing owner-group
============================================
============================================
=====================
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
$ curl https://type.fit/api/quotes
$ 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
==========================
==========================
================================
================================
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.
cd /var/www/html
sudo vi index.html
=============================
=============================
=> systemctl is a command-line utility in Linux systems which is used to manage system services
#start service
#stop service
#re-start service
=====================================
=====================================
# set hostname
# 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