SlideShare a Scribd company logo
1 of 12
Ownership & Permissions
 Linux systems are multi user environments that allow users to create
files, run programs and share data.
 Files and directories have two types of ownership the user and group.
A Linux group consists of one or more users.
 Files and directories have three types of access permissions:
a)read permission (r)
b)write permission (w)
c)execute permission (x)
 Every file and directory has permissions for three levels or entities of
permissions:
a)user or owner (denoted by u)
b)group (one or more users denoted by g)
c)others or world (denoted by o)
Permissions triplets
Each triplet indicates the access permissions for that level – in the example
below,the user/owner has read,write & execute permission,other group
members only have read and execute permissions and all others have no
access permissions.
Changing Permissions and Ownership
 Use ‘ chmod ’ to change the file:
 chmod [ ugoa ][+/-][ rwx ] filename
 where u=user, g=group, o=others or world and a=all three
 For example, to provide group read access to a file:
 $ chmod g+r myfile
 Or to remove file access to another than the owner or group members
(in other words, others):
 $ chmod o-rwx myfile
 The ‘ chown ’ command is used to change file ownership and the
chgrp ’ command can change group ownership of a file. As a regular
user, you can not change the ownership of a file, but you can change
the group ownership if you are a member of the group to which you
are changing the group ownership.
 You can use the R argument on any of the above to recursively make
changes on a directory of files.
Lab 2
1)First go to your home directory.
2)Make a ‘LinuxClass’ directory using the mkdir command & go into
that directory.
3)Create 5 empty files in LinuxClass directory.
4)Show permission of newly created files.
5)Add execute permission for group on 2 of the files and make other 3
world readable.
6)Now, remove the execute permission of LinuxClass for all.
7)Change directory to your home directory, then try to see all files under
LinuxClass and then finally go into that directory.
8)Explain what happened and why?
Simple filter and advance filter commands
 grep–pattern matching search of a file
$ grep cat nonsense.txt
$ grep –idog nonsense.txt # case insensitive
 uniq–show or remove duplicate lines
$ uniq bears # will show all unique lines
$ uniq–d bears # show only duplicate lines
$ uniq–c bears # show a count of each unique line
 Sorting-read a file, sort the contents and output to the terminal
$ sort –r grades.txt
$ sort -k2 grades.txt
$ sort –bnr–k2 grades.txt
 awk–text manipulation
$ awk ‘{print $1,$5,$3,$4,$2,$6}’
Simple filter and advance filter commands...
 sed–stream editor for pattern matching and modification
$ sed ‘s/beat/defeated/g’ hare_tortoise # Replace ‘beat’ with ‘defeated’
The trailing ‘/g’at the end of that command indicates that the change is to be
done globally…without it, only the first occurrence of the word in the file will
be changed.
$ sed -i 's/SEARCH_REGEX/REPLACEMENT/g' INPUTFILE # Replace text in file
 head or tail
$ head mascots.txt
-prints out the first 10 lines by default. Can use the –n argument to change
the default number of lines
$ tail –20 mascots.txt
-prints out the last 20 lines
Environment Variables
Execution path
In BASH, execution of a program happens when you enter the
program name. Your PATH variable keeps you from having to enter
the full path to the program
Modifying your PATH
$ echo $PATH
$ PATH=$PATH:/data/$USER
$ echo $PATH
PATH set using above method is not persistent after reboot.
To path changes permanent, need to modify the .bashrcfile in your home
directory or update /etc/environment.
Package Management
Package Management : RPM
RPM Package Manager (RPM)
YUM and DNF are simply front-ends to a lower-level tool called RPM. The following
commands should be run as root. The flags are expanded here, but the abbreviated
syntax is also included:
 rpm --install --verbose --hash local-rpm-file-name.rpm - Installs an rpm from
the file. rpm is also capable of installing RPM files from http and ftp
sources as well as local files.
 rpm --erase package-name(s) - Removes the given package.
 rpm --query --all - lists the name of all packages currently installed.
 rpm --query package-name(s) - allows you to confirm whether a given package is
installed in your system.
 rpm --query --info package-name(s) - displays the information about an
installed package.
 rpm --query --list package-name(s) - generates a list of files installed by a
given package. This is complemented by:
 rpm --query --file - checks to see what installed package “owns” a given file.
Package Management : dpkg
Debian Package Manager (DEB)
Apt-get and apt-cache are merely frontend programs that provide a more usable
interface and connections to repositories for the underlying package management tools
called dpkg.
 dpkg -i package-file-name.deb - Installs a .deb file.
 dpkg --list search-pattern - Lists packages currently installed on the
system.
 dpkg --configure package-name(s) - Runs a configuration interface to set
up a package.
 dpkg-reconfigure package-name(s) - Runs a configuration interface on an
already installed package.
 dpkg --purge --force-all package – Remove/ uninstall package.
Start and Stop services
 systemctl commands
sudo systemctl [action] [service name]
 service commands
sudo service [service name] [action]
To start a service:
sudo systemctl start ufw
sudo service ufw start
To stop a service:
sudo systemctl stop ufw
sudo service ufw stop
To restart a service:
sudo systemctl restart ufw
sudo service ufw restart
To check the status of service:
sudo systemctl status ufw
sudo service --status-all
Set service to start at boot:
sudo systemctl enable ufw
sudo chkconfig ufw on
Disable service to start at boot:
sudo systemctl disable ufw
sudo chkconfig ufw off
Lab 3
1. Install httpd using yum.
2. check status of httpd service.
3. Check httpd is running under which user using ps.
4. Download file index.html from below link, in your home directory.
http://3.93.79.170:9090/webfile.tar.gz
5. Extract that tar file. You will have one file called index.html
6. Next, copy that index.html to /var/www/html/ (You might be asked to overwrite an
existing file, do that.)
7. Set ownership and permission on that file as per the permission of /var/www/html
8. Restart httpd service.
9. Check if your webserver is working or not with below command:
# curl http://localhost
Output should be like:
Note: If your webserver is having issue run below command and try again.
# setenforce 0

More Related Content

What's hot

What's hot (20)

Linux basic commands
Linux basic commandsLinux basic commands
Linux basic commands
 
Linux
LinuxLinux
Linux
 
Unix Command-Line Cheat Sheet BTI2014
Unix Command-Line Cheat Sheet BTI2014Unix Command-Line Cheat Sheet BTI2014
Unix Command-Line Cheat Sheet BTI2014
 
Linux class 10 15 oct 2021-6
Linux class 10   15 oct 2021-6Linux class 10   15 oct 2021-6
Linux class 10 15 oct 2021-6
 
Basic unix commands
Basic unix commandsBasic unix commands
Basic unix commands
 
Linux class 9 15 oct 2021-5
Linux class 9   15 oct 2021-5Linux class 9   15 oct 2021-5
Linux class 9 15 oct 2021-5
 
Anandha ganesh linux1.ppt
Anandha ganesh linux1.pptAnandha ganesh linux1.ppt
Anandha ganesh linux1.ppt
 
Basic linux commands
Basic linux commands Basic linux commands
Basic linux commands
 
Compression
CompressionCompression
Compression
 
101 2.4 use debian package management
101 2.4 use debian package management101 2.4 use debian package management
101 2.4 use debian package management
 
101 3.3 perform basic file management
101 3.3 perform basic file management101 3.3 perform basic file management
101 3.3 perform basic file management
 
Basic linux commands for bioinformatics
Basic linux commands for bioinformaticsBasic linux commands for bioinformatics
Basic linux commands for bioinformatics
 
101 2.1 design hard disk layout
101 2.1 design hard disk layout101 2.1 design hard disk layout
101 2.1 design hard disk layout
 
Basic shell programs assignment 1_solution_manual
Basic shell programs assignment 1_solution_manualBasic shell programs assignment 1_solution_manual
Basic shell programs assignment 1_solution_manual
 
HaskellとDebianの辛くて甘い関係
HaskellとDebianの辛くて甘い関係HaskellとDebianの辛くて甘い関係
HaskellとDebianの辛くて甘い関係
 
Linux day 3ppt
Linux day 3pptLinux day 3ppt
Linux day 3ppt
 
Directories description
Directories descriptionDirectories description
Directories description
 
Linux Commands
Linux CommandsLinux Commands
Linux Commands
 
Http
HttpHttp
Http
 
Lession1 Linux Preview
Lession1 Linux PreviewLession1 Linux Preview
Lession1 Linux Preview
 

Similar to Introduction to linux day-3

Similar to Introduction to linux day-3 (20)

Introduction to linux day1
Introduction to linux day1Introduction to linux day1
Introduction to linux day1
 
8.1.intro unix
8.1.intro unix8.1.intro unix
8.1.intro unix
 
Examples -partII
Examples -partIIExamples -partII
Examples -partII
 
Linux file commands and shell scripts
Linux file commands and shell scriptsLinux file commands and shell scripts
Linux file commands and shell scripts
 
Basics of Linux
Basics of LinuxBasics of Linux
Basics of Linux
 
An Introduction to Linux
An Introduction to LinuxAn Introduction to Linux
An Introduction to Linux
 
Linux
Linux Linux
Linux
 
Linux command line cheatsheet
Linux command line cheatsheetLinux command line cheatsheet
Linux command line cheatsheet
 
Linux day 2.ppt
Linux day  2.pptLinux day  2.ppt
Linux day 2.ppt
 
Linux Presentation
Linux PresentationLinux Presentation
Linux Presentation
 
Linux basics part 1
Linux basics part 1Linux basics part 1
Linux basics part 1
 
Linux
LinuxLinux
Linux
 
linux-lecture4.ppt
linux-lecture4.pptlinux-lecture4.ppt
linux-lecture4.ppt
 
50 Most Frequently Used UNIX Linux Commands -hmftj
50 Most Frequently Used UNIX  Linux Commands -hmftj50 Most Frequently Used UNIX  Linux Commands -hmftj
50 Most Frequently Used UNIX Linux Commands -hmftj
 
Linux file system nevigation
Linux file system nevigationLinux file system nevigation
Linux file system nevigation
 
Linux commands and file structure
Linux commands and file structureLinux commands and file structure
Linux commands and file structure
 
The one page linux manual
The one page linux manualThe one page linux manual
The one page linux manual
 
The one page linux manual
The one page linux manualThe one page linux manual
The one page linux manual
 
Unix Basics Commands
Unix Basics CommandsUnix Basics Commands
Unix Basics Commands
 
58518522 study-aix
58518522 study-aix58518522 study-aix
58518522 study-aix
 

More from Gourav Varma

Jenkins introduction
Jenkins introductionJenkins introduction
Jenkins introductionGourav Varma
 
Docker introduction (1)
Docker introduction (1)Docker introduction (1)
Docker introduction (1)Gourav Varma
 
Version control git day03(amarnath dada)
Version control   git day03(amarnath dada)Version control   git day03(amarnath dada)
Version control git day03(amarnath dada)Gourav Varma
 
Version control git day02
Version control   git day02Version control   git day02
Version control git day02Gourav Varma
 
Version control git day01
Version control   git day01Version control   git day01
Version control git day01Gourav Varma
 
Shell programming 2
Shell programming 2Shell programming 2
Shell programming 2Gourav Varma
 
Introduction to linux
Introduction to linuxIntroduction to linux
Introduction to linuxGourav Varma
 
Version control git day03
Version control   git day03Version control   git day03
Version control git day03Gourav Varma
 
Version control git day02
Version control   git day02Version control   git day02
Version control git day02Gourav Varma
 
Version control git day01
Version control   git day01Version control   git day01
Version control git day01Gourav Varma
 

More from Gourav Varma (20)

Jenkins introduction
Jenkins introductionJenkins introduction
Jenkins introduction
 
Docker introduction (1)
Docker introduction (1)Docker introduction (1)
Docker introduction (1)
 
Aws day 4
Aws day 4Aws day 4
Aws day 4
 
Aws day 3
Aws day 3Aws day 3
Aws day 3
 
Aws day 2
Aws day 2Aws day 2
Aws day 2
 
Ansible day 4
Ansible day 4Ansible day 4
Ansible day 4
 
Ansible day 3
Ansible day 3Ansible day 3
Ansible day 3
 
Adnible day 2.ppt
Adnible day   2.pptAdnible day   2.ppt
Adnible day 2.ppt
 
Ansible day 1.ppt
Ansible day 1.pptAnsible day 1.ppt
Ansible day 1.ppt
 
Version control git day03(amarnath dada)
Version control   git day03(amarnath dada)Version control   git day03(amarnath dada)
Version control git day03(amarnath dada)
 
Version control git day02
Version control   git day02Version control   git day02
Version control git day02
 
Version control git day01
Version control   git day01Version control   git day01
Version control git day01
 
Dev ops
Dev opsDev ops
Dev ops
 
Shell programming 2
Shell programming 2Shell programming 2
Shell programming 2
 
Introduction to linux
Introduction to linuxIntroduction to linux
Introduction to linux
 
Final terraform
Final terraformFinal terraform
Final terraform
 
Version control git day03
Version control   git day03Version control   git day03
Version control git day03
 
Version control git day02
Version control   git day02Version control   git day02
Version control git day02
 
Version control git day01
Version control   git day01Version control   git day01
Version control git day01
 
Docker swarm
Docker swarmDocker swarm
Docker swarm
 

Recently uploaded

Unleashing the Power of the SORA AI lastest leap
Unleashing the Power of the SORA AI lastest leapUnleashing the Power of the SORA AI lastest leap
Unleashing the Power of the SORA AI lastest leapRishantSharmaFr
 
1_Introduction + EAM Vocabulary + how to navigate in EAM.pdf
1_Introduction + EAM Vocabulary + how to navigate in EAM.pdf1_Introduction + EAM Vocabulary + how to navigate in EAM.pdf
1_Introduction + EAM Vocabulary + how to navigate in EAM.pdfAldoGarca30
 
Verification of thevenin's theorem for BEEE Lab (1).pptx
Verification of thevenin's theorem for BEEE Lab (1).pptxVerification of thevenin's theorem for BEEE Lab (1).pptx
Verification of thevenin's theorem for BEEE Lab (1).pptxchumtiyababu
 
PE 459 LECTURE 2- natural gas basic concepts and properties
PE 459 LECTURE 2- natural gas basic concepts and propertiesPE 459 LECTURE 2- natural gas basic concepts and properties
PE 459 LECTURE 2- natural gas basic concepts and propertiessarkmank1
 
Online electricity billing project report..pdf
Online electricity billing project report..pdfOnline electricity billing project report..pdf
Online electricity billing project report..pdfKamal Acharya
 
Double Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torqueDouble Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torqueBhangaleSonal
 
HOA1&2 - Module 3 - PREHISTORCI ARCHITECTURE OF KERALA.pptx
HOA1&2 - Module 3 - PREHISTORCI ARCHITECTURE OF KERALA.pptxHOA1&2 - Module 3 - PREHISTORCI ARCHITECTURE OF KERALA.pptx
HOA1&2 - Module 3 - PREHISTORCI ARCHITECTURE OF KERALA.pptxSCMS School of Architecture
 
data_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdfdata_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdfJiananWang21
 
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXssuser89054b
 
Wadi Rum luxhotel lodge Analysis case study.pptx
Wadi Rum luxhotel lodge Analysis case study.pptxWadi Rum luxhotel lodge Analysis case study.pptx
Wadi Rum luxhotel lodge Analysis case study.pptxNadaHaitham1
 
Moment Distribution Method For Btech Civil
Moment Distribution Method For Btech CivilMoment Distribution Method For Btech Civil
Moment Distribution Method For Btech CivilVinayVitekari
 
Computer Lecture 01.pptxIntroduction to Computers
Computer Lecture 01.pptxIntroduction to ComputersComputer Lecture 01.pptxIntroduction to Computers
Computer Lecture 01.pptxIntroduction to ComputersMairaAshraf6
 
Employee leave management system project.
Employee leave management system project.Employee leave management system project.
Employee leave management system project.Kamal Acharya
 
Online food ordering system project report.pdf
Online food ordering system project report.pdfOnline food ordering system project report.pdf
Online food ordering system project report.pdfKamal Acharya
 
Standard vs Custom Battery Packs - Decoding the Power Play
Standard vs Custom Battery Packs - Decoding the Power PlayStandard vs Custom Battery Packs - Decoding the Power Play
Standard vs Custom Battery Packs - Decoding the Power PlayEpec Engineered Technologies
 
GEAR TRAIN- BASIC CONCEPTS AND WORKING PRINCIPLE
GEAR TRAIN- BASIC CONCEPTS AND WORKING PRINCIPLEGEAR TRAIN- BASIC CONCEPTS AND WORKING PRINCIPLE
GEAR TRAIN- BASIC CONCEPTS AND WORKING PRINCIPLEselvakumar948
 
A Study of Urban Area Plan for Pabna Municipality
A Study of Urban Area Plan for Pabna MunicipalityA Study of Urban Area Plan for Pabna Municipality
A Study of Urban Area Plan for Pabna MunicipalityMorshed Ahmed Rahath
 
Generative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPTGenerative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPTbhaskargani46
 

Recently uploaded (20)

Unleashing the Power of the SORA AI lastest leap
Unleashing the Power of the SORA AI lastest leapUnleashing the Power of the SORA AI lastest leap
Unleashing the Power of the SORA AI lastest leap
 
1_Introduction + EAM Vocabulary + how to navigate in EAM.pdf
1_Introduction + EAM Vocabulary + how to navigate in EAM.pdf1_Introduction + EAM Vocabulary + how to navigate in EAM.pdf
1_Introduction + EAM Vocabulary + how to navigate in EAM.pdf
 
Verification of thevenin's theorem for BEEE Lab (1).pptx
Verification of thevenin's theorem for BEEE Lab (1).pptxVerification of thevenin's theorem for BEEE Lab (1).pptx
Verification of thevenin's theorem for BEEE Lab (1).pptx
 
PE 459 LECTURE 2- natural gas basic concepts and properties
PE 459 LECTURE 2- natural gas basic concepts and propertiesPE 459 LECTURE 2- natural gas basic concepts and properties
PE 459 LECTURE 2- natural gas basic concepts and properties
 
Online electricity billing project report..pdf
Online electricity billing project report..pdfOnline electricity billing project report..pdf
Online electricity billing project report..pdf
 
Double Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torqueDouble Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torque
 
HOA1&2 - Module 3 - PREHISTORCI ARCHITECTURE OF KERALA.pptx
HOA1&2 - Module 3 - PREHISTORCI ARCHITECTURE OF KERALA.pptxHOA1&2 - Module 3 - PREHISTORCI ARCHITECTURE OF KERALA.pptx
HOA1&2 - Module 3 - PREHISTORCI ARCHITECTURE OF KERALA.pptx
 
data_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdfdata_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdf
 
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
 
Wadi Rum luxhotel lodge Analysis case study.pptx
Wadi Rum luxhotel lodge Analysis case study.pptxWadi Rum luxhotel lodge Analysis case study.pptx
Wadi Rum luxhotel lodge Analysis case study.pptx
 
Moment Distribution Method For Btech Civil
Moment Distribution Method For Btech CivilMoment Distribution Method For Btech Civil
Moment Distribution Method For Btech Civil
 
Computer Lecture 01.pptxIntroduction to Computers
Computer Lecture 01.pptxIntroduction to ComputersComputer Lecture 01.pptxIntroduction to Computers
Computer Lecture 01.pptxIntroduction to Computers
 
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak HamilCara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
 
Call Girls in South Ex (delhi) call me [🔝9953056974🔝] escort service 24X7
Call Girls in South Ex (delhi) call me [🔝9953056974🔝] escort service 24X7Call Girls in South Ex (delhi) call me [🔝9953056974🔝] escort service 24X7
Call Girls in South Ex (delhi) call me [🔝9953056974🔝] escort service 24X7
 
Employee leave management system project.
Employee leave management system project.Employee leave management system project.
Employee leave management system project.
 
Online food ordering system project report.pdf
Online food ordering system project report.pdfOnline food ordering system project report.pdf
Online food ordering system project report.pdf
 
Standard vs Custom Battery Packs - Decoding the Power Play
Standard vs Custom Battery Packs - Decoding the Power PlayStandard vs Custom Battery Packs - Decoding the Power Play
Standard vs Custom Battery Packs - Decoding the Power Play
 
GEAR TRAIN- BASIC CONCEPTS AND WORKING PRINCIPLE
GEAR TRAIN- BASIC CONCEPTS AND WORKING PRINCIPLEGEAR TRAIN- BASIC CONCEPTS AND WORKING PRINCIPLE
GEAR TRAIN- BASIC CONCEPTS AND WORKING PRINCIPLE
 
A Study of Urban Area Plan for Pabna Municipality
A Study of Urban Area Plan for Pabna MunicipalityA Study of Urban Area Plan for Pabna Municipality
A Study of Urban Area Plan for Pabna Municipality
 
Generative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPTGenerative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPT
 

Introduction to linux day-3

  • 1. Ownership & Permissions  Linux systems are multi user environments that allow users to create files, run programs and share data.  Files and directories have two types of ownership the user and group. A Linux group consists of one or more users.  Files and directories have three types of access permissions: a)read permission (r) b)write permission (w) c)execute permission (x)  Every file and directory has permissions for three levels or entities of permissions: a)user or owner (denoted by u) b)group (one or more users denoted by g) c)others or world (denoted by o)
  • 2. Permissions triplets Each triplet indicates the access permissions for that level – in the example below,the user/owner has read,write & execute permission,other group members only have read and execute permissions and all others have no access permissions.
  • 3. Changing Permissions and Ownership  Use ‘ chmod ’ to change the file:  chmod [ ugoa ][+/-][ rwx ] filename  where u=user, g=group, o=others or world and a=all three  For example, to provide group read access to a file:  $ chmod g+r myfile  Or to remove file access to another than the owner or group members (in other words, others):  $ chmod o-rwx myfile  The ‘ chown ’ command is used to change file ownership and the chgrp ’ command can change group ownership of a file. As a regular user, you can not change the ownership of a file, but you can change the group ownership if you are a member of the group to which you are changing the group ownership.  You can use the R argument on any of the above to recursively make changes on a directory of files.
  • 4. Lab 2 1)First go to your home directory. 2)Make a ‘LinuxClass’ directory using the mkdir command & go into that directory. 3)Create 5 empty files in LinuxClass directory. 4)Show permission of newly created files. 5)Add execute permission for group on 2 of the files and make other 3 world readable. 6)Now, remove the execute permission of LinuxClass for all. 7)Change directory to your home directory, then try to see all files under LinuxClass and then finally go into that directory. 8)Explain what happened and why?
  • 5. Simple filter and advance filter commands  grep–pattern matching search of a file $ grep cat nonsense.txt $ grep –idog nonsense.txt # case insensitive  uniq–show or remove duplicate lines $ uniq bears # will show all unique lines $ uniq–d bears # show only duplicate lines $ uniq–c bears # show a count of each unique line  Sorting-read a file, sort the contents and output to the terminal $ sort –r grades.txt $ sort -k2 grades.txt $ sort –bnr–k2 grades.txt  awk–text manipulation $ awk ‘{print $1,$5,$3,$4,$2,$6}’
  • 6. Simple filter and advance filter commands...  sed–stream editor for pattern matching and modification $ sed ‘s/beat/defeated/g’ hare_tortoise # Replace ‘beat’ with ‘defeated’ The trailing ‘/g’at the end of that command indicates that the change is to be done globally…without it, only the first occurrence of the word in the file will be changed. $ sed -i 's/SEARCH_REGEX/REPLACEMENT/g' INPUTFILE # Replace text in file  head or tail $ head mascots.txt -prints out the first 10 lines by default. Can use the –n argument to change the default number of lines $ tail –20 mascots.txt -prints out the last 20 lines
  • 7. Environment Variables Execution path In BASH, execution of a program happens when you enter the program name. Your PATH variable keeps you from having to enter the full path to the program Modifying your PATH $ echo $PATH $ PATH=$PATH:/data/$USER $ echo $PATH PATH set using above method is not persistent after reboot. To path changes permanent, need to modify the .bashrcfile in your home directory or update /etc/environment.
  • 9. Package Management : RPM RPM Package Manager (RPM) YUM and DNF are simply front-ends to a lower-level tool called RPM. The following commands should be run as root. The flags are expanded here, but the abbreviated syntax is also included:  rpm --install --verbose --hash local-rpm-file-name.rpm - Installs an rpm from the file. rpm is also capable of installing RPM files from http and ftp sources as well as local files.  rpm --erase package-name(s) - Removes the given package.  rpm --query --all - lists the name of all packages currently installed.  rpm --query package-name(s) - allows you to confirm whether a given package is installed in your system.  rpm --query --info package-name(s) - displays the information about an installed package.  rpm --query --list package-name(s) - generates a list of files installed by a given package. This is complemented by:  rpm --query --file - checks to see what installed package “owns” a given file.
  • 10. Package Management : dpkg Debian Package Manager (DEB) Apt-get and apt-cache are merely frontend programs that provide a more usable interface and connections to repositories for the underlying package management tools called dpkg.  dpkg -i package-file-name.deb - Installs a .deb file.  dpkg --list search-pattern - Lists packages currently installed on the system.  dpkg --configure package-name(s) - Runs a configuration interface to set up a package.  dpkg-reconfigure package-name(s) - Runs a configuration interface on an already installed package.  dpkg --purge --force-all package – Remove/ uninstall package.
  • 11. Start and Stop services  systemctl commands sudo systemctl [action] [service name]  service commands sudo service [service name] [action] To start a service: sudo systemctl start ufw sudo service ufw start To stop a service: sudo systemctl stop ufw sudo service ufw stop To restart a service: sudo systemctl restart ufw sudo service ufw restart To check the status of service: sudo systemctl status ufw sudo service --status-all Set service to start at boot: sudo systemctl enable ufw sudo chkconfig ufw on Disable service to start at boot: sudo systemctl disable ufw sudo chkconfig ufw off
  • 12. Lab 3 1. Install httpd using yum. 2. check status of httpd service. 3. Check httpd is running under which user using ps. 4. Download file index.html from below link, in your home directory. http://3.93.79.170:9090/webfile.tar.gz 5. Extract that tar file. You will have one file called index.html 6. Next, copy that index.html to /var/www/html/ (You might be asked to overwrite an existing file, do that.) 7. Set ownership and permission on that file as per the permission of /var/www/html 8. Restart httpd service. 9. Check if your webserver is working or not with below command: # curl http://localhost Output should be like: Note: If your webserver is having issue run below command and try again. # setenforce 0