Posts

Showing posts from August, 2023

Bash Script

  Introduction to the Bash Shell :- The Linux command line is provided by a program called the shell. File extension of .sh. ex:- example.sh #! /usr/bin/bash echo "Hello World" Provide execution rights to your user:- chmod u+x example.sh Run the script :- You can run the script in the following ways: ./example.sh How to define variables We can define a variable by using the syntax  variable_name=value . To get the value of the variable, add  $  before the variable. #!/usr/bin/bash # A simple variable example greeting=Hello name=Tux echo $greeting $name How to read user input #!/usr/bin/bash echo "Enter a numner" read a echo "Enter a numner" read b var = $(( a + b )) echo $var

RHEL Subscription Management

#subscription-manager remove --all #subscription-manager clean #subscription-manager register --username <redhatusernamehere> --auto-attach #dnf repolist or yum repolist

Swap Partition in Linux

  URL :-   https://www.tecmint.com/disable-swap-partition/ Swapping or swap space represents a physical memory page that lives on top of a  disk partition or a special disk file  used for extending the RAM memory of a system when the physical memory fills up. Some suggest that the swap space should be set as twice the amount of machine RAM. However, on systems with more than 4 GB of RAM, swap space should be set between  2  or  4  GB. In case your server has sufficient RAM memory or does not require the use of swap space or the swapping greatly decreases your system performance, you should consider disabling the swap area. How to Check Swap Space in Linux # free -h How to Check Swap Partition in Linux # blkid # lsblk How to Disable Swap in Linux # swapoff /dev/mapper/centos-swap # swapoff -a # free -h How to Disable Swap Permanently in Linux In order to permanently disable swap space in Linux, open  /etc/fstab  file, search for the swap...

Static IP In Linux

  Configure a static IP address on CentOS 7 / RHEL 7 URL :-  How to configure a static IP address on CentOS 7 / RHEL 7 Path :-   cat /etc/sysconfig/network-scripts/ifcfg-enp0s3                      BOOTPROTO=static                             IPADDR=192.168.1.150                             NETMASK=255.255.255.0                             GATEWAY=192.168.1.1                               DNS=8.8.8.8 Path :-     cat /etc/resolv.conf                          # Generated by NetworkManager ...

Kubernetes Cluster URL & Troubleshooting

  * [ERROR CRI]: container runtime is not running [Solved] URL :-  https://k21academy.com/docker-kubernetes/container-runtime-is-not-running/ * Deploy multi-node K8s cluster on Rocky Linux 8 [Step-by-Step] URL :-  https://www.golinuxcloud.com/deploy-multi-node-k8s-cluster-rocky-linux-8/ *  How to Add Workers to Kubernetes Clusters [On Master]:- # kubeadm token list # kubeadm token create --print-join-command * How to add roles to nodes in Kubernetes? # kubectl label nodes <your_node> kubernetes.io/role=<your_label> # kubectl label nodes wakeup1 kubernetes.io/role=worker

File Permissions In Linux

  permission on a file on a directory r (read) read file content (cat) read directory content (ls) w (write) change file content (vi) create file in directory (touch) x (execute) execute the file enter the directory (cd)   File permissions for (-rw-rw-r--)   Syntax: chmod  <groupName> + <permissionName>   <fileName>   Example :- chmod u+x file  < To add Permission > chmod g-x file  < To remove Permission > chmod  u = rwx , g = rw , o = r  file < To set explicit permissions >   Setting Octal Permissions Octal permissions can also be set for the groups. For example, to set  r  octal will be  4,  to set  w  octal will be  2,  to set  x  octal will be  1. Octal Table: ...

Linux Logs Explanation

*/var/log/syslog or /var/log/messages: general messages, as well as system-related information. Essentially, this log stores all activity data across the global system. Note that activity for Redhat-based systems, such as CentOS or Rhel, are stored in messages, while Ubuntu and other Debian-based systems are stored in Syslog. * /var/log/auth.log or /var/log/secure: store authentication logs, including both successful and failed logins and authentication methods. Again, the system type dictates where authentication logs are stored; Debian/Ubuntu information is stored in /var/log/auth.log, while Redhat/CentrOS is stored in /var/log/secure. */var/log/boot.log: a repository of all information related to booting and any messages logged during startup. */var/log/maillog or var/log/mail.log: stores all logs related to mail servers, useful when you need information about postfix, smtpd, or any email-related services running on your server. */var/log/kern: stores Kernel logs and warning data. T...

Linux Directory Structure

  /bin/ -> Essential User Command Binaries /boot/ -> Static Files of the Boot Loader /dev/ -> Device Files /etc/ -> Host Specific System Configuration /home/ -> User Home Directories /lib/ -> Essential shared Libraries and Kernel Modules /media/ -> Mount Point for Removable Media /mnt/ -> Mount Point for a Temporarily Mounted FileSystems /Opt/ -> Add-On Application S/W Packages /sbin/ -> System Binaries /srv/ -> Data for Services Provided by This System /tmp/ -> Temporary Files /usr/ -> Multi -User Utilities And Applications /var/ -> Variable Files /root/ -> Home Directory for the Root User /proc/ -> Virtual File System Documenting Kernel and Process Status as Text Files