Anzeige
Anzeige

Más contenido relacionado

Anzeige
Anzeige

Introduction to linux day1

  1. Introduction to Linux-4 DevOps Essentials 2020
  2. Simple filter and advance filter commands  grep–pattern matching search of a file $ grep cat nonsense.txt $ grep –i dog 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}’
  3. 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
  4. 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.
  5. Package Management
  6. 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.
  7. 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.
  8. 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
  9. 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
Anzeige