0% found this document useful (0 votes)
4 views

Linux-class-all

The document provides a comprehensive overview of Linux commands and tools, particularly focusing on Red Hat, Ubuntu, and CentOS distributions. It covers various aspects of DevOps, including AWS services, software installation, and virtual machine setup, along with detailed command usage for file management and system operations. Additionally, it includes instructions for setting up Ubuntu on VMware and managing user permissions and directories.

Uploaded by

chandrareddy1608
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

Linux-class-all

The document provides a comprehensive overview of Linux commands and tools, particularly focusing on Red Hat, Ubuntu, and CentOS distributions. It covers various aspects of DevOps, including AWS services, software installation, and virtual machine setup, along with detailed command usage for file management and system operations. Additionally, it includes instructions for setting up Ubuntu on VMware and managing user permissions and directories.

Uploaded by

chandrareddy1608
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 25

LINUX ----commands ----REDHAT UBUNTU CENTOS

AWS -----SERVICES
-------------------------------6+
DEVOPS ---TOOLS
---------------------
15 COMMANDS --6 YEARS
4 ----SCP
VMWARE MOBAXTERMS PUTTY GITBASH VSCODE vshpre
--------------------------------------SOFTWARE -----------
35
----------
3 12
-------------------
Software downloads:
------------------------
1 task:
--------------
Go to google vmware download
Workstation 17 Pro for Windows
ubuntu iso image download
Ubuntu 22.04.4 LTS 10 days
question
exam
interview
-----------------------------------------
Devops
--------
Dev+ops
-------
dev Team:
------------
plan git maven ---CI
code
build
test
-------------
ops team:
-----------
Deploy Tomcat
monitor prom newrelic
operate
Release
---------------
GIT ---100 SVN BITBUCKET--100 MAVEN ANT TOMCAT JENKINS -500 NEXUS DOCKEER R HUB
SWARM VOLUME KUBERNETES SONARQUBE ANSIBLE BLACKDUCK JENKINS GITHUB GITLAB
TERRAFORM
-----------------------------------------------------------------------------------
-----------------------------------------------------------------
SHELL
PYTHON
BASH
POWERSHELL
GROOVY
PERL
SQL MYSQL ODBC JDBC NOSQL JAVA ---WEB BASED APPLICATION MAVEN
-----------
INTERVIEW
RESUME
NAKURI
PROXY ----MAIN
------------------
AWS--------
EC2 VPC S3 IAM COLUD WATCH COLUD TRAIL RDS ROUTE53 SNS ELK
-----------------------------------------------------------
SUDO APT APT-GET INSTALL MAVEN GIT JENKINS DOCKER SONARQUBE
SUDO YUM INSTALL 14
VM SETUP
6 MONTH JOB SUPPORT
PWFH
----------------
Go to Google;
vmware 17 pro download
ubuntu iso image download
-------------------------------------
1. window
2. Linux
frist one select ---windows
vmware setup open vm
next --i accept ---next next next install
-------------------------------
liency key --setup ubuntu machine
"MC60H-DWHD5-H80U9-6V85M-8280D"

Home:
----
There are 3 Types:
1 create a new vm
2 open a vm
3 connect to a remote server
--------------------------------
First one select:
------------------
1 create a new vm
there are 2 Types:
1 Typical
2 custom
click on first select ---Typical
next
Guset os installation
click on ---I will install the os system later the vm will be created with a blank
hard disk
next
select Guset OS:
there are 4 Types:
1 microsoft window
2 linux -----select
3 vmware ESX
4 Others
------------
Version:
ubuntu ----select
redhat 1to 9
centos
suselinux
fedeora
---------------------
nextName the VM
vm name:
ubuntu-64
location:
C:/usrs/hp/oneDrive/Documents/vm/ubuntu-iso-image-amd64-bit
-----------------------------------------
specify Disk Capacity:
---------------------------
Maximum disk size {gb} ---20.0 Gb
change disk size capacity: 50.0 Gb
next
READY To create VM :
Name:
location
version: worstation 17.x
os:
HD:
memory: 2048 MB
Network adapter: NAT
*****Other Devices: 2cpu core cd/dvd, usb controller printer sound card
finsih
----------------------------------------------------------------------------
MYcomputers:
------------
Ubuntu-64-bit{5}
There are 2 Types:
1 power on the vm
2 edit vm settings
-------------------
select 2 one
edit vm settings
cd/dvd/status Autodetect
There are 2 types:
1 Device status:
connected
connect at power on ---default select
2 computer --conection--------
there 3 Types:
1 use physical drive
2 auto setect
3 use iso image file ---click on
click on Browser
showing the floder
Download
select on File name:
ubuntu-22.04-desktop-amd64-iso
click on ---open ---ok
----------------------------------------------------
after that frist one click on
1 power on the vm
install
welcome
There are 2 Types;
1 try ubuntu
2 install ubuntu
----------------------------
select 2 one click on ---install
keyboard layout
choose your keyboard layout
select english {us}
continue
Updates and other software:
click on install thrid party software for graphical and wifi-hardware and media
format -----click on
Install type or installation types;
click on ---install
now ----
write the changes to disk ---
continue
where are you?
select india map
region name: kolkata
continue
who are you?
your name: ganapathi
your computer name: ganapathi-vm-
pick a user name:ganapathi-vm-
choose a password : abc@123
confirm your password: abc@123
continue
-----------------------------------------------
File Directory system:
-----------------------
following are the directory in the ubuntu os
/ ---------it is called Root Directory it contains all the sub-directory.
--------------------------------------
/home ----1 /home/ganapathi ganapathi user home directory /home/gayatri gayatri
user home directory
/home/divya divya user home directory
----50%
/ ---root admin ---100%

/bin ---2 ---mkdir ls cd ps


/sbin ---but only root user can access

/etc --3 mtod sudoers group shadow ---configuration file


/tmp --4 it contains a temporary files

/proc ---it contain RAM process and kernel information application kernel cpu
memory device
/dev
/opt --5 ---very important optional floder installation thrid party software
/usr --6 unix system resources was ihs var db2
/var --7 system log files /var/log , /var/mail /var/tmp
/mnt
/net
/boot
/media
/srv
/root --8
-----------------------------------------------------------------------------------
-----------------
-
cd ---change directory
pwd ---present working directory
/home/ganapathi
ls ---list of files and directory
user {owner) & Group:
ganapathi -----50%
root ---100% prev
sudo su -
adduser hema
sudo ---super key
su ---switch user -
adduser gayatri
adduser sunil
su sunil
cat /etc/passwd
userdel gayatri
su sunil
hostnamectl ----Total system configuration
uptime -----How long the system is active from how many user stroed how long system
is running ....
who ---how many users are connected to this linux
whoami ---username of the current user linux
uname
uname -a
uname -s
cal ---calender
date --Today display date
cal ---install ----ubuntu
sudo apt-get install ncal -y
date "+%Y" ---Current Year
date "+%m" ---current month
date "+%d" ---current date
date "+%d-%m-%Y" ---current day-month-year
date "+%d-%m-%y"
----------------------------------------------
cal 2023 --Display the particcalr year calender
cal 3 2023 ---display the 3rd month calender of 2023 year
cal -3 --Display current month previous month next month
cal -y ---calender of current year
cal -1 display the current month

-------------------------
hostname
cat
touch
date
------------------
hostname <option>
1 hostname ---Display hostname of the computer
Linux server Linux box linux machine server ----usr1 usr2 usr3 To connect to server

2 hostname -a --Display Aliasname of the host, if used if not display one hostname
3 hostname -i ---Display the port number ---but default port number
127.0.1.1 ---default
hostname -I ---if we connected to linux machine then it will give you separated IP
Address.
ifconfig
ipaddress
192.168.150.132 ---every machine changing the ip address
hostname -A ----Display all {FQDN} of the machine
FQDN ---Fully Qulified domain Name
hostname -s ---short hostname
hostname -V --version
hostnamectl ---System total configuration
------------------------------------------------
Very Import:
cat ----file ---color ---white color
There are 3 Functionalites:
------------------------
1 Display content of exiting file
2 create a file & write txt into that file
3 merging two files
------------------------
< ---open the file
> --- create a file
>> ---add the file
cat >ANU ---<file-name> ---create a file along with write access
hi
hru
welcome
"{ctrl +d ----save the files }"
cat < ANU
cat ANU
cat >>ANU ---To append new content into an existing file
WEL TO BANGALORE
ctrl +d ---save the file
cat ANU
----------------
cat >HTML.TXT
<HTML>
<BODY>
<h1> first message </h1>
</body>
</html>
ctrl +d ---save
cat ANU HTML.TXT ---display the content of multiple file together
cat -b <file-name> ---Number nonempty/nonblank lines
1 hi
2 hru
3 welcome

cat -n <filename> ---Number all output lines including blankline


1 hi
2 hru
3 welcome

cat -s <file-name> ---multiple blank lines are shown as squeze order


cat -E <file-name> -----Adds a $symbol at the end of every line
hi$
hru$
welcome$
cat Anu HTML.TXT > mano ----merge file1 file2 and save in file3
-----------------------------------------------------------------------------------
--------
touch ---To create multiple file but are all empty file {zero file}
To create empty file & to change the time stamp of particluar file
touch file1
touch file2 file3 file4
touch .mano .hema .gayatri .maggie .mandha
{. ---hodden files}
ls -a ---list of hidden files
----------------------------------------------------------
date: To display date
------------------------
date "+%Y" ---current Year --2024
date "+%m" ---current month --03
date "+%d" ---current date 28
date "+%d%m-%Y" ---day-month-year 28-03-2024
----note : inplace --we can use any symboallike "/,.*^#@!~|"
date "+%d=%m=%Y"
date "+%y" ---display two number 24 now y always give only last digit of year 24
date "+%a" ---to display the day of the week 3 characters
date "+%A" ---to display the day of the week fullname
date "+%b" ---to display the month name 3 characters
date "+%B" ---to display the full month name
date "+%h" --same
date "+%H" ---current hours 24 format
date "+%k" ---same
date "+%l" ----current hours 12 hours format
date "+%I" ----same
date "+%M" minutes of the current hours
date "+%s" current seconds
date "+%S" current full number of seconds
date "+%H%M-%S" ---current hours minutes seconds
date "+%H%M-%s" ---same
date "+%D" ---date ; same as day month year
date "+%r" ---12 hours clock time
date "+%R" ---24 hours clock time
date "+%S" seconds
date "+%x" ---local date representaion
date "+%X" ---local time representaion
date "+%z" ---Timezone aberivation IST
date "+%c" --- THURSDAY MAR 28 11:30:34 2024
-----------------------------------------------------------------------------------
----------
mkdir
ls
cp
-------------------------------
mkdir ---directory ---blue colors
make directory or create directory
mkdir <dir-name> ---To create a directory
mkdir manohar
mkdir -p <dir-name> <sub-directory>
--p <parent directory>
To create a sub-dir into the existing directory
note: we cant create a sub-dir for non-existing directory by using this command
mkdir -p <dir> <sub-dir>
mkdir anu apple song devops ------to create multiple directory
mkdir -v <dir-name> ---print a message for each created directory {V---Verbose}
cd Devops
ls -R
tree
sudo apt-get install tree -y
-------------------------------------------------------------------------------
pwd ---present working directory
pwd -L --symbolic path
pwd -p ---actual path
-----------------------------------
ls ---List file and directory content
ls <option> file-dir-name>
ls / ----"/" --Root Directory
list out the content in the root directory
ls ~ ---list the content of Home directory ls =ls "~" Home-dir root-dir "till-cmd"
ls -l --long list format with Alphabetical order
ls -a ---list out the content with "Hidden file" folder" "."
"hidden files start with "." --current directory ..---parent directory "one level
back directory"
touch .abc .mnc .company
ls -la ----list out of the content with longlist format including hidden files
ls -s ---sort out the content based on the size
ls *.txt ---list out all the files with the execution of .txt file inthe present
working directory
ls -d*/ ---list out only the directory
ls -lt ---long list with "time"
ls -lrt ---long list with "time sort Ascending order in older or latest"
ls -g ---long list with "owner" cloumn
ls -i ---print the index number of each file or directory {i --inode}
ls -m ---comma seperated
ls -n ---numeric numbers of "uid" & "gid"
ls -o ---donot list "group" information like "ls -l"
ls -r ---reverse order {Alphabetically reverse}
ls -R ---list sub-dir recursively "indiviually name based sort"}
ls -F*/ ----list out only the files
ls -lsh ---long list sort by size with like 1k 2m 3g human readble format
-----------------------------------------------------------------------------------
---------
cp ---copy:
------------
cp <option> <source> <destination>
cp file1 file2 -----copy the content from file and file1 save it into file2
cp file directory ---copy a file into a directory
cp mano.txt ravi ---this floder is located with in the pwd
***cp -r tar.gz ---source-path /home/ganapathi/mano ----destination-path
cp -r /home/ganapathi/Download/tar.gz /home/ganapathi/mano
cd Desktop
mkdir ravi
cd ravi
cp -r ../../Download/jdk-17.0.0.tar.gz .
cp -r ../../Download/jdk-17.0.0.tar.gz /home/ganapathi/Documents
-----------------------------------------------------------------------------------
---
mv
vi or vim
---------------------
mv ---move
mv <option> <source> <destination-server>
mv file vijay ---Acts as "rename" it moves the content of file to vijay and discard
the file non existing
mv -i file devops ---interactive mode, above example ask you whether to overwrite
or not ?
yes or No
mv dir dir2 ---move dir inside the directory2
--------------------------------------------------
vi or vim :
--------------
virtual editor or machine ------------file ---colors --white
sudo apt-get install vim -y
There are 3 modes:
1 insert mode: Display typing text write instruction
2 command mode: command for applying the task
3 ; colon mode : save the data and quit the data
-----------------------
intitially it is in command mode:
i --insert mode
I --insert mode
a --insert mode
A --insert mode
o --insert mode
O --insert mode
-------------------------
ESC : command mode
Navigation:
----------
h ----cursor moves forwards left side of text
I --cursor moves towards right side of text
k --upward
j --downward
-----------------------------
copy to paste:
yy ---copy
p --paste
dd --delete
u --undo changes
----------------------
save and quit:
----------------
w ---to save the content
q ---quit without any modifications files
q! ---quit the file without saving the content
wq! --save & quit
caps lock press two times ZZ ---save & quit
--------------------------------------------
Important:
se nu ---Total lines with line numbers
------------------------------------------------------
$ --- Normal user --half permission :ganapathi
# --- root user or Admin user ---full permission :root
sudo su -
sudo --super key
su --switch user
---/opt ---optinal floder ---thrid party user
/ --root dirctory
opt --sub-directory
cd /opt
pwd
/opt
mkdir java
permssion denied ----frist issue
sudo mkdir java
drwxr-xr-x 2 root root 4096 Apr 1 10:54
java
permmsion no of users user/owner group size month/date/timestamp
file/dirctory
root root java

chown: ---To change the file owner ot group whenever u want to ownership u can use
chown command
chown <option> <owner>:<group> </file/directory> ---syntax
chown ganapathi:ganapathi java
-----to change and owner and group of the particular file/dirctory
chown : changing ownership of 'java': operation not permitted. --second issue
sudo chown ganapathi:ganapathi java ---Assume that if u are user name or group name
root and u want to change ownership or group to ganapathi {where your current
directory is ganapathi}
sudo chown ganapathi manohar ---only owner change command
sudo chown :ganapathi manohar ---only group change command
---------------------------------------------------------------------
chmod: --- that to change mode: file or dirctory permission
suppose as owner i created a file dirctory i want to give some permission
to some user on that particular file i can use chmod command
before understanding chmod we need to understanding "Roles & permission first
Roles:
There are 3 Types of Roles:
----------------------------
1 owner/usr ---u
2 groups ----g
3 others ---o
--------------------
permission :
there are 3 Types:
1 read --r
2 write --w
3 execute --x
----------------------
Note:
d --dirctory
c ---character special file
b ---binary special file
- ====file
-------------------------------------
Number method:
r --4
w --2
x --1
Total : 4+2+1 ==7
--------------------------
d /rwx/ r-x/ r-x/
7 5 5

rwx-wx--x
7 3 1
r-xw-x-rw-
5 3 6
------------
666
rw-rw-rw
700
rwx------
543
r-xr---wx
--------------------------------
ugo ---user group others:
ugo=rwx
u=5
g=2
0=7
u+rx,g+w,o+rwx
ugo=rwx
u+5
g-3
0-2
u+rx,g-wx,o-w
-------------------------------------------
chgrp: To change the group ownership of a file or dirctory
all file in linux belong to an owner a group u can owner by using chown command and
the group by chgrp command
syntax
chgrp <option> <group> <file/dirctory>
sudo chgrp root java mano madhavi
----------------------------------------------------
rm
cd
rmdir
more
head
tail
-------------------------------
rm ---romve files or directoryies
rm <option> <file/directoryies>
rm f1 f2 f3 ---remove a multiple file in the same directoryies
rm <file-name> --remove a particular file not in use in pwd rm mano
rm -f file-name ---remove forcefully
rm -f f1 f2 f3 f4
rm -i <file-name> prompt before every removal
rm -i mano.txt
rm: remove regular file 'mano.txt'? yes or no
rm -rf --recursive remove directoryies
rm -R <file/dir>
rm -d <dir-name> ---empty floder remove
rm -v <file/dir> --verbose prompt information
rm -rf --dir-name --remove frocefully all directoryies
real time 2 command only use :
rm file remove
rm -rf dir remove command
-------------------------------------------------------------
cd --whereever you are it take you to be Home directoray eg: /home/ganapathi
/root /home/sunny /home/jyothi
cd ----change directory
cd / --Root directory
cd ~ ---Home directory eg:root /home/linux, /home/ganapathi till directory
cd .. ---one level directory back or parent directory
cd ../../ ---Two level back directory
cd ../../../ ---Three level back directory
cd . ----current directory
cd - ====previous path directory
if you change your pwd manohar floder to hari then you want to go back to the
previous directory
cd <Absolute-path> --it takes you to the absolute path you have given
eg: /root/manohar/arjun/rama
cd manohar
cp -r ../../homeganapathi/Download/jdk-17.tar.gz . ----absolute path
cd <Relative path> ---it takes you to the relative path you given
eg: now i am in manohar floder if i give command like cd Arjun ---takes me to arjun
floder
cp -r ../../homeganapathi/Download/jdk-17.tar.gz /home/ganapathi/manohar --relative
path
-----------------------------------------------------------------------------------
------------
rmdir: Remove directories
rmdir <option> <dir-name>
rmdir manohar
rmdir /home/ganapathi/manohar/raja/vijay
note: we can't remove the pwd by using rmdir command

rmdir -p A/B/C/D ---empty-directories --- To remove parent directories as well as


by using this we can only remove "D" directories but not all parent
rmdir -p A/B/C/D ===removes all parents
------------------------------------------------
more: To display the content page by page : it display only the content which fits
in the terminal window
more <file-name> ---display 1st page quit ----q

-----------------------------------------------------------------------------------
----------------------
head ---To disply frist 10 lines of a file {default}
head mano.txt ---to display only first 10 lines --default
head -15 <filename> ---display first 15 lines without "n" flag
head -15 manohar.txt
tail ---To display the last 10 lines of a file
tail <file-name> ---To display the last 10 lines default
tail -n 20 <file-name> ---to display the last 20 lines
tail -20 manu.txt
--------------------------------------------------------
note: ls -lart |head -----10 lines from the list
ls -lart |head -3 ---frist 3 lines
ls -lart |tail ---last 10 lines display
ls -lart |tail -5 ---last 5 lines only
--------------------------------------------------
tar ---Zipping & Extracting files
zip
gzip
-----------------------------
c --create a new.tar archive files
v --verbosely show the .tar files progress
f --file name types of the archive files
x --extract the archive
t --displays or lists files in archive files
u --archive and adds an existing archive files
v --display verbose information
A --concatenates the archive file
z --zip tells tar command that create tar files using gzip
j ---filter archive tar files using tbzip
w --verify an archive file
r --update or add file or directory in already existing .tar file
tar -cvzf jdk-17-linux-tar.gz ---name to the zipped directory to be zipped
unzipping | extracting
tar -xvf jdk-17-linux-tar.gz
note: if we dont mention target directory if extract in current directory only
-----------------------------------------------------------------------------------
-------------
cd /opt
sudo mkdir java
ls -lart
root:root
sudo chown ganapathi:ganapathi java
ls -lart
ganapathi:ganapathi
cd java
ls
go to google java 17 download .tar.gz
Download: jdk-17-linux-x64_bin.tar.gz
pwd
/home/ganapathi/Download
jdk-17-linux-x64_bin.tar.gz
/opt/java
cp -r ../../home/ganapathi/Download/jdk-17-linux-x64_bin.tar.gz .
cp -r ../../home/ganapathi/Download/jdk-17-linux-x64_bin.tar.gz /opt/java
cd /opt/java
jdk-17-linux-x64_bin.tar.gz ----red color ----no permission ---bug issue
chmod 755 jdk-17-linux-x64_bin.tar.gz
tar -xvf jdk-17-linux-x64_bin.tar.gz
--------------------------------------
ubuntu
sudo apt-get install java -y
redhat
sudo yum install java -y
--------------------------------------
cd jdk-17.0.9
ls -lart
/bin
pwd
/opt/java/jdk-17.0.10 ----copy
echo $JAVA_HOME ---env set or not path
env
----------------------------
Environment variable file setup
/opt/java/jdk-17.0.10
cd
vi .bashrc
sudo apt-get install vim -y
-------------------------
vi .bashrc ---perment env setup
vi /etc/profile
------------------- very very import
i ---insert mode
export JAVA_HOME=/opt/java/jdk-17.0.10
export PATH=$PATH:$JAVA_HOME/bin
esc
shift:
wq! --save & quit
java -version
source .bashrc --------very import
java -version
----------------------------------------------------------------
du
df
free
top
htop
---------------------------------
du ---Disk ultization estimate file space usages
du <option> <fie-name>
4000 /home/ganapathi/manohar.txt
8200 /root/ganesh.txt
du -h/H --Human readble format size file path
4m
5k
4GB
----The total disk ultization can be shown in human readble format
like 20k 50m 60G
du -sh --h --human readble format
--s --summary
du -sh <dir-name> ---particular directory disk ultization
du -a --all files and floders
du --inodes ---list inode usages information instead of block usages
du -k ---block size ==1k
du -m --block size ==2m
du --time ---with times
-----------------------------------------------------
df ---"Disk free" Report file system disk space usages
df <option> <file>
df
filesystem 1k-block size used Avaiable use% mounted on
/dev/sda1 12345 1234 1234 1234545 71% /dev/sda1
df -h/H ---Human readble format
filesystem 1k-block size used Avaiable use% mounted on
/dev/sda1 18g 12G 6g 13g 76% /dev

df -a ---all include pseudo duplicates inaccessiable filesystem


df -k --block size ==1k
df -h/H ---block size ==1G
df -l ---limit to local file system
df -x <type> ---excluding particular filesystem type
eg: df -x wslfs
tmpfs
drvfs
-------------------------------------------------------------------------
free ----memory related --disk amount of free and used memory in the system
{"physical and swap memory"}
free
total used free shared buff cache Avaiable
mem: 12333 123 23e 2344 1234 234 2345
swap: 123 1234 234 234 23444 1222 2333

free -b --Bytes
free -k --kilobyte
free -m --megabyte
free -g --giga byte
free -h ---human readble --gigabyte by deafult
free -w --wide; buffer & cache separated
free -l --show detailed low-high memory statistics
free -t --total rows will be displayed
----------------------------------------------------
top & htop -- Display Linux process
cpu, memory related {%}
it provide dynamic real time view of your running system
to see which process consuming most of cpu & memory
just like "Task Manger" in windows
top
pid user pr ni virt res shir s %cpu%mem time command
note " to quit from the windows server we need to press
quit
ctrl +c ---kill
ctrl +z ---save
-------------------------------------------------------------
useradd
adduser
groupadd
groupdel
userdel
usermod
passwd
gpasswd
------------------------------------------------------------------
useradd
adduser
groupadd
groupdel
userdel
usermod
passwd
gpasswd
-----------------------------------------------
useradd ---To create a new user or updated default new user information
useradd <username>
useradd manu ********************
useradd -m sagar --to create a Home directory for a new user
useradd -s /bin/sh hema --default shell creation default login shell specified by
the shell variable like /bin/bash
useradd -b /bin/bash hari ----the default "based directory"
/etc/default/useradd
/home
useradd -c --"comment"
useradd -e yyyy/mm/dd <user-name> ---"Expire date to create an user with expire
date. ***
-----------------------------------------------------------------------------------
--------
How to check user command:
cat /etc/passwd
----------------------------
adduser sagar ----To create a Home directory ----50 % access -----------"very very
import in real time cmd"
-----------------------------------------------------------------------------------
----------------------
userdel ---Delete a user account and related files
userdel <user-name>
sudo userdel -r <user-name> --To delete user and it's directory
sudo rm -r <user-directory> ---To remove user directory after running /deletting a
user
sudo rm -r /home/ganapathi/manohar
userdel -f <user-name> --removing user forcefully
----------------------------------------------------
groups: To see what are the groups your current user connected to print the group a
user is in group
note: cat /etc/group
it display total number of users to location of groups
groupadd <group-name> -- to add a new group
groupdel <group-name> ---To delete a particular group
usermod -a -G groupname username
passwd <user-name> ---To create a passwd add in user
gpasswd <user-name> ---To create a gpasswd add in group user
-----------------------------------------------------------------------------------
----------------------
manohar ------dev
sunny -----Build & Relase ----Dev
gayatri
vinod
swathi
siri
------------------
QA
----naresh
mano
naven
manoj
----------------------
sudo apt-get update -y
sudo apt-get install openssh-client
sudo apt-get install openssh-server ii
sudo service ssh status
Active: Running status
----------------------------------
ssh locahost
welcome to ubuntu 22.04.5 LTS {GNU/Linux/*****generic x86_64}
ssh-keygen
---------------generating public and private key pair id_rsa id_rsa.pub known_host
pwd
ls
.ssh
ls -a
cd .ssh
ls
id_rsa ---beging openssh private key
id_rsa.pub ---public key
-------------------------------------------
server to server connection:
ssh username@ipaddress {hostname -I}
eg: ssh [email protected]
ganapathi password: abc@123
ssh [email protected]
linux password: abc@123
--------------------------------------------------
scp ---secure copy file one server to another server & source server and
destination server
scp <option> source path & destination path
i ---inode
r --reverse order
v --verbose
h --human-readble format
p --parameter
a --hidden files
l --long list
s --size
source id :192.168.150.131
destination id: 192.168.150.132
scp -r jdk-17-linux-bin-tar.gz {source-path} [email protected] {destination
serverid} :/home/linux/manohar
scp -r jdk-17-linux-bin-tar.gz [email protected]:/home/linux/manohar
-----------------------------------------------------------------------------------
----------------------------
more
wc
echo
diff
comm
------------------------------
more --to display the content page by page it display only the content
which files inthe terminal window
more <file-name> display first page
more -s mano.txt ----seueze multiple blank line into file
more -u mano.txt --supress underling -p -c dont scroll
----almost everything is same we cant navigate to previous page with in more but it
can possible
with less command
less <file-name>
ls -lart |more ---list with more command
----large list
ls -lart |less ---list with less command ---large list
----------------------------------------------------------
wc ---word count
----count new lines , word, byte/charcters
wc <file-name>
eg:20 ---lines
20 --words
20 --charcters
wc file1 file2
----count from multiple files
wc -l <file-name> ---only lines count
wc -w <file-name> ---only word count
wc -c <file-name> --only charcters counts
wc -c <file-name> --only byte counts
both are same
Combinations:
----------------
wc -lw <file-name>
wc -lc <file-name>
wc -wc <file-name>
--------------------multiple file together
wc -L <file-name> max-line-length; print the maximum display width
eg: wc -L mano.txt
wc -l mano.txt
---------------------------------------------------------------------------
echo
-----------
display a line of line of text; string that are environment. bashrc files an
arguments this is build in command that is mostly used in shell script and batch
files
to output status text to the screen or file.
syntax:
echo <option> <string>
echo Hello World
printing text |string
eg:
echo $variable-name----------printing a variable name
eg: myvar="hello world"
-------only for single session of terminal
echo $myvar
hello world
eg:2
x=10
echo "The value of x is $x"
The value of x is 10
option:
-------
echo -e ---enable the interpretation of backslash escapes
echo -e "\b"
it removes all the spaces in b/w the text
eg: echo -e "manohar\bfrom\bnellore"

echo -e "\c"
supress trailing new lines with backspace interpretor "-e" continue without
emitting new lines
eg: echo -e "manohar \cfor manu"
manohar
text after \c not printed and emitted training new lines
echo -e "\n"
creates new lines
eg: echo -e "kalyani \nfrom \n tirupathi
kalyani
from
tirupathi
-------------------
echo -e "\t"
-----------
Tab ---
eg: echo -e kalyani \tfrom \tbangalore
kalyani from banalore

echo -e "\r"
----------------
carriage return
echo -e manohar \rfrom TPT"
from TPT
text before /r not printed

echo -e "\v" ******************************


-------------
vertical tab spaces:
eg:
echo -e "manohar \vfrom \vTPT"
manohar
from
TPT
----------------------------
echo -e "\a"
alert {BH}: sound alert. alarm sound
eg: echo -e "manohar /afrom /atirupati"

************echo *
----------------------
print all files/floder; simalar to ls command
echo *
-------------------
echo -e -n "text"
this option is used to omit echaing trailing new lines
eg: echo -n "manohar from tirupati"
manohar from tirupati
-----------------------------------------------------------------
diff:
----compare file line by line give mismatch
diff <option> <file/directory>
< ---frist file *****
> ---second file ****
c ---change
d ---delete
a ---add
---------------------
eg: diff.txt
hi
hru
welcome

eg:2 diff2.txt
hi
hello
hru

diff file file1


-------compare; give mismatch changes
diff diff.txt diff2.txt
-------------------compare; give mismatches {delete}
c --content
u --unfied
y --side-by-side
t --expandd tabs
T --intialize tab
r --recursiely
n --new lines
i --ignore case
E -- ignore tab expansion
Z --ignore white space at line end
b --ignore space changes
w --ignore all spaces
B --ignore blank lines
diff -q file1 file2
report only when file differ
diff -s file1 file2
-----------report when two files are the same identical

comm:
--------
----compare two sorted files line by line
comm <option> file file2
pre-requisite: sorted file only otherwise
we need to sort them before apply commn
note: it provides file o/p in columns 1st column display unique lines of 1st files
-----------------------------------------------------------------------------------
-------
nslookup
grep
find
ps
kill
firefox
firefox &
netstat
ping
-------------------------------------------------------------
git
------bare-remote
10 ----task
------
---------------------
nslookup:
-----------
Name server lookup getting into from the DNS server --53
dns three server primary server, secondary servers, and caching servers.
it is a network administration tools for querying the domain name system {DNS} to
obtain
domain name or ip address mapping or any other speific dns-record it is also used
to
troubleshoot DNS-related problem
vpn {virtual private network}
click on "start", then "setting", network & internet", "wi-fi". selet the network
you're connectted to . click on "properties." Scroll down to the bottom
of the window your IP will be shown next to "IPV4 address.
tcp or udp ---transmission control protocol
user datagram protocol
A, AAAA, CNAME, PTR, NS, MX, SOA and TXT
syntax:n
nslookup {option}
nslookup -type= google.com
------------------------
lookup for any record; we can also view all the aviable DNS records using the
-type="any" option
2. nslookup <IPAddress>
to findout domain name
nslookup -type= nsgoogle.com
-----------------
lookup for an ns {name server} record
ns record maps a domain name to a list of dns servers authoritative for that
domain it will output the name server which are associated with the given domain

nslookup -type= agoogle.com


-------------------------
lookup for an a record;
"a" we can also view all the avaiable DNS records for a particular record.

nslookup -type= mxgoogle.com


--------------------------------
lookup for an mx {" mail exchange"} records
mx records maps a domain name to alist of mail exchange server for that domain the
mx
record filesthat all the mailssent to google.com should be routed to the mail
server
in the domain

nslookup -type= txtgoogle.com


------------------------------
lookup for an txt record;
txt records are useful for multiple type ofrecords like DKIM, SPF ETC you
can find all txt records configured for any domain using the below command
-----------------------------------------------------------------------------------
------------
grep: --------Global Regular experssion print/pattern
this command is used for searching a requested pattern in a files
syntax:
1 grep <option> 'pattern' [file]
cat file-name |grep "pattern"
grep "pattern" <file> searching a required pattern in a particular file.
eg:--- grep "Nellore" manohar.txt
grep -i "pattern" <file> ignore the case sensitive
-y {same} grep -i "nelore" manohar.txt
grep -n "pattern" <file> --Display the line {numbers before matching pattern lines}
eg:-- grep -n "nellore" manohar.txt
12 nellore
20 nellore
32 nellore
grep -c "pattern" <file> --count of give matching pattern
grep -c "nellore" manohar.txt
13
grep -v "pattern" <file> ---verbose; to display unmatching lines
grep -v "nellore" manohar.txt
grep -l "pattern" <file> --to display the file which contains the matching pattern
file with out match.
eg:--grep -l "nellore" *all files in pwd
grep -h "pattern" <file> ---display all lines in which the pattern matching
grep -h "nelore" manohar.txt

egrep ----search for multiple patterns: "egrep"


grep -e "delhi" -e "mumbai" -e ----<file-name>
e --search for multiple patterns.
egrep *(delhi|mumbai)" <file-name>
instead of "e" we can you egrep command.
egrep "Delhi" "Mumbai" "Hyderabad" <file-name>
this format also valid.
grep vs egrep:----
egrep "(delhi|mumbai)" ---consider as Regular experession
grep "(delhi|mumbai)" ----consider as string pattern
note:---grep command understand patterns but not all regluar egrep command
understand
all the patterns.
fgrep:---- no need
search for fixed strings (no pattern)
grep -F "Delhi
>mumbai
>hyderabad" manohar.txt
syntax for fgrep
replaced with "fgrep"
fgrep "Delhi
>mumbai
>hyderabad" manohar.txt
No regular expression are allowed.
note fgrep '^D' manohar.txt
---does not work.
-----------------------------------------------------------------------------------
-------------------------
find: --------------sarch for files in a directory hirarchy
it can be used to find files & directory and perform subsuest operations on them
it supports searching by files, floders, name, creation date, modifiation, date
owner and permission.
by using the '-exec' other Unix commands can be executed on files or folder found.
syntax:
find; <path> <expression> <option> <what to find>
note:---.--pwd
/ ---/root directory
<path> Relevantpath/Absolte path
find . ---name "*.log" -------to display all log files
eg: .txt, .pdf, .jpg, .xlsx, .xls, .docx, etc.
find . -mtime +/- <days> --to display all files which are created/modification days
before/after.
eg:---find . -m time -2 -------------modifed less than 2 days
find . -mtime +2 ------------modifed morethan 2 days {m----modified time}
find . -time -2 --------------created lessthan 2 days
find . -time +2 -------------- created morethan 2 days
find . -msize +/- --to display all files which with modification size
lessthan/greater than nk/nm/mg
k----kilobytes {kb}
m----megabytes {mb}
g----giga bytes {gb}
eg:----find . -msize +/- 10 ---default kb
to display files switch size morethan/less than 10 kb
find . -msize +/- 10k =====10kb
find . -msize +/- 10M =====10mb
find . -msize +/- 10G =====10gb
find . -name "abc.txt" -mtime +10 -msize +500k
to display all the files with the file name "abc.txt" with morethan 10 days & with
the size of morethan 500kb
----path--------
find <path> -name <file-name> or particular directory its subdirectory
eg:----to display all files from a particular path with the particular name or
relevent
eg:----find /root/manohar -name "manohar.txt"
find /root/manohar -name "manohar.txt"
for example -mtime, -msize same as above
---------Root Directory------------
find / -name <file-name> <root directory its subdirectory> ****
to find or display all files with a particular file name or relevant in the root
directory
eg:---find / -name manohar.txt ---quotations are not mandetory ***
note:----mtime, -msize; same as above ****
other important flags:----
find . -iname <file-name> ---ignore case sensitive
find . -newer <file-name> ----display files which are newer than give file ****
eg:----find . -newer manohar.txt ----newer files will be displayed ****
find . -empty ---to display all empty files
find -user <username> --to find all the files with the specifed username on ID name
find -perm <octal permissions> --to find the file with its octal permissions ****
eg:----find -perm 777 <file-name>
find -perm 565 manohar.txt
options:-----
-exec cmd ----other unix commands can be executed on files or folders found
-ok cmd -----same as -exec except the user it prompted first
-inum N -----search for files with inode number 'N'
-links N ----'n" links
-print ------display the path name of the files found by using the rest of criteria
\(expr\)-----True if 'expr' is true; used for grouping criteria combined with OR
and AND
! expr ----True if 'expr' is false.
How to find delete a file with confirmation?
find . -name sample.txt -exec rm -i {}\;
or
-exec rm -i "{}"
search text within multiple files?
find / type f -name "*.txt" -exec grep 'manohar.txt' {}\;
-----------------------------------------------------------------------------------
----
netstat: ----Network statistics: ---to show network connection routing tabel
tables,
and a number of network interface in addition to that to view network protocal
statistics.
netstat -a to show you all the connections which are aviable in your system they
are view
they are TCP, UDP or UNIX connection
netstat -a |less
netstat 0at to show the TCP connections
eg:---netstat -at |less
netstat -au ---to show the udp connection
netstat -au |less
netstat -l --to show the ports which are listening "listen state"
netstat -l |less
netstat --lt --tcp which are listening
eg:--- lu lx ---udp which are listening /unix
netstat -lu |less
netstat -s ---statistics;
eg:---netstat -s |less
netstat -su/st/sx ---statistics of udp /tcp/unix
netstat -su |less
netstat -st |less
netstat -pt pid with tcp
eg:---nestat -pt |less
netstat -p pid/programm name
netstat pu/px --pid with udp unix
netstat -pu |less
netstat -px |less
netstat -n |less ---Numeric code {inode}
**netstat -c ---continous status
netstat -ie ---extented interface same as "ifconfig"
netstat -an |grep :"80" ---what are the parts from the output of netstat which has
the part 80.
-----------------------------------------------------------------------------------
-------------------
ping
-----
to check the network connectivity between host and server host this command takes
as input the ip address or the url and sends a data
packet to the specified address with the message ping and get a response from the
server/host this time is recoreded which is called
'latency' fast ping low latency means faster connection ping uses 'ICMP' internet
control message protocol]
to send an 'icmp' echo message to the specified host if that host aviable then it
sends 'icmp' reply message
ping is generally measured in multidecond every modern operating system has this
ping pre-instaled
ping <url> eg: ---ping www.youtube.com
note: to stop pinging we should use ctrl +c otherwise it will keep on sending
packets
ping -c number <url> ---controlling the number of ping
ping -c 5 www.youtube.com
ping -s 40 -c 5 contolling the size of packets send
ping -q <url> to get only summary
eg: ping -q c 5 -q wwww.youtube.com
ping -w 3 <url> --to timeout ping : to stop pining after some-time-use
eg: ping -w 3 www.youtube.com
ping -f <url> ---flooding with ping to send packets as soon possible this is used
to test n/w performance
eg: ping -f www.youtube.com
To add TimeStamp:
----------------
ping -T tsonly ---timestamponly
ping -T tsandaddr --timestamp & address
ping -T tsprespec --timestamp pre-specified for multiple hosts
eg: ping -T tsonly -c 2 127.0.0.1
-------------------------------------------------------------------------------
ps ---Report a snapshot of current process
ps <option> <pid?>
what is process"?
a process is an instance of running program whenever you run a shell command or
shell script
a process will create for that in linux | unix machine box
Types of process :
---------------------
1 Foreground process
2 Background process
-------------------------
FG process vs BG process
pwd /root ----fg
pwd & [1] 379 ---bg
ampersand or and symbol
ps ---pid tty time cmd
ps -f ---all running process with standard full from or by the user
uid pid ppid c stime tty time cmd

Note:
no commands
uid ---user id
pid --process id
ppid ---parent process id
c ---cpu ultization
stime ---starting time
tty ---type of terminal
cmd ---command
---------------------------------------
ps -e ---Display all process /internal process which are also running by the linux
or unix vm
eg: pid tty time cmd
ps -ef ---Full information of all rinning process by the user as well as linux
machine
ps -H --tree structure like;
if we execute multiple shell script files with in this we have multiple tree
structure like command this command shows hierarchical way of representation
ps <pid> --to display particular process information
examples: to see every process on the system using standard syntax
ps -e
ps -ef
ps -eaf
ps -e/f
to print a process tree
ps -ejh
to get info about threads
ps -elf to get security info
ps -eo ---user, ruser, fuser, f, comm, local
ps -em
to see every process running as root real & effective id in user format
ps -U root -u root u
ps -aux
to see every process running with a user-defined format
ps -l -c to show different sehedular information {long format}
ps -ux --to print long list of process
ps -U <user-name> --process with particlar user-name
ps -C <user-name> to print multiple instance of user name
-----------------------------------------------------------------------------------
-------
kill ---To kill the process
kill <option> <pid>
kill <pid> ---to kill particlar process with its id
eg: kill 793
kill <pid>, <pid> --to kill multiple process with thier ids
kill 765,664,735
kill -L/l ---list the Available signal choices in a nice table
kill -9 <pid> ----to forcefully kill multiple process with thier ids
kill -9 567,678,988
kill -3 <pid> --gracefully killing firefox
firefox --fg
firefox & --bg
-----------------------------------------------------------------------------------
-

You might also like