Showing posts with label Redhat. Show all posts
Showing posts with label Redhat. Show all posts

Wednesday, June 23, 2021

Redhat :RPM-Build/Make : How to make RPM File from Git Source Code : Make and RPM-Build [ make rpm]

https://docs.aws.amazon.com/efs/latest/ug/installing-amazon-efs-utils.html#installing-other-distro


sudo yum list installed |grep amazon-efs-utils


sudo yum -y install git
sudo yum -y install make
sudo yum -y install rpm-build


git clone https://github.com/aws/efs-utils
cd /path/efs-utils
sudo make rpm
sudo yum -y install ./build/amazon-efs-utils*rpm

Tuesday, June 22, 2021

Check if a Package is installed on Linux or not

https://www.cyberciti.biz/faq/apt-get-list-packages-are-installed-on-ubuntu-linux/

https://www.2daygeek.com/find-out-if-package-is-installed-or-not-in-linux-unix/


#RHEL 6, RHEL7

yum list installed openssh


#RHEL 8

dnf list installed httpd


#Ubuntu

apt list -a pkgNameHere

apt list --installed

apt -qq list nano

Redhat : IPTABLES : How to persist iptables as its changes are not saved by default

https://www.geeksforgeeks.org/iptables-restore-command-in-linux-with-examples/

https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/4/html/security_guide/s2-firewall-ipt-act-sav

7.2.2. SAVING AND RESTORING IPTABLES RULES

Firewall rules are only valid for the time the computer is on; so, if the system is rebooted, the rules are automatically flushed and reset. To save the rules so that they are loaded later, use the following command:
/sbin/service iptables save
The rules are stored in the file /etc/sysconfig/iptables and are applied whenever the service is started or restarted, including when the machine is rebooted.

Friday, June 18, 2021

Persist IpTables (firewall) Linux Redhat

repoquery iptables-services
iptables-services-0:1.4.21-35.el7.x86_64

rpm -qa | grep iptables
iptables-1.4.21-33.el7.x86_64

https://serverfault.com/questions/801350/how-to-save-iptables-configuration-on-redhat-enterprise-server-7/801352#801352

https://kerneltalks.com/virtualization/how-to-reset-iptables-to-default-settings

https://upcloud.com/community/tutorials/configure-iptables-centos/

https://forums.centos.org/viewtopic.php?t=68917

 
 So, the structure is: 
 iptables -> Tables -> Chains -> Rules.

IPTABLES 

  • Tables
  • Chains
  • Rules

sudo yum install iptables-services
Once installed, start and enable the service.


sudo systemctl start iptables
sudo systemctl enable iptables
Afterwards, you can simply save the current rules using the following command.


sudo service iptables save

/etc/sysconfig/iptables


[ec2-user@ip-10-79-197-70 sysconfig]$ sudo ls | grep ip
ip6tables
ip6tables-config
iptables
iptables-config
network-scripts

Thursday, April 1, 2021

Attach Disk, Format File System, Mount Disk - Linux Machine





3 Steps to Add Disk to Linux System
  •  Attach  (Via AWS Management Console)
  • Format (Add FileSystem/Format Disk/Format Volume)
  • Mount (Make new Disk available under a name)
  • Automatic Mount after Reboot - Edit "/etc/fstab" File
----------------------------------------------------------------------------------------------------------------
  • Find list of all devices attached to  System
      • lsblk -fa
      • du -h
  • Find out which device is unMounted - Device not having Mount Path 
  • FInd out if that Unmounted(Only Attached, Not Mounted) Device is  Blank or has Data within it.
      • sudo file -s /dev/xvdf 
  • Attached Disk can be readonly like a Bootable CD or It can be blank 
  • If The Attached Disk is having no data/raw/blank - Format it and add Filesystem to it , 
  • If the output shows simply data, as in the following example output, there is no file system on the device
  • Use "mkfs" command to create a Filesystem or Format a disk
      •  sudo mkfs -t xfs /dev/xvdf
  • Mount the Disk using below command,   mount <Device_Name> <Mount_Path>
      • sudo mount /dev/xvdf /data
  • Once we mount disk on a label, We need to edit "/etc/fstab" file to make sure that When we reboot System, We can mount these disks automatically under specified names
      • vi /etc/fstab
  • Find out <DEVICE_ID> using "blkid" 
      • blkid
--------------------------------------------------------------------------------------------------------------------------
3.4. NFS

NFS (Network File System) is a distributed filesystem protocol that allows us to share remote directories over a network.

To mount an NFS share, we must install the NFS client package first.

Let’s say we have a well-configured NFS shared directory “/export/nfs/shared” on a server 192.168.0.8.

Similar to the Samba share mount, we first create the mount point and then mount the NFS share:

root# mkdir /mnt/nfsShare
root# mount -t nfs 192.168.0.8:/export/nfs/shared /mnt/nfsShare

root# mount | grep nfsShare
192.168.0.8:/export/nfs/shared/ on /mnt/nfsShare type nfs (rw,addr=192.168.0.8)

3.5. Commonly Used mount -o Option

The mount command supports many options.

Some commonly used options are:

  • loop – mount as a loop device
  • rw – mount the filesystem read-write (default)
  • ro – mount the filesystem read-only
  • iocharset=value – character to use for accessing the filesystem (default iso8859-1)
  • noauto – the filesystem will not be mounted automatically during system boot

3.6. The /etc/fstab FileSo far, we’ve seen several examples of the mount command to attach to various filesystems. However, the mounts won’t survive after a reboot.

For some filesystems, we may want to have them automatically mounted after system boot or reboot. The /etc/fstab file can help us to achieve this.The /etc/fstab file contains lines describing which filesystems or devices are to be mounted on which mount points, and with which mount options.

All filesystems listed in the fstab file will be mounted automatically during system boot, except for the lines containing the “noauto” mount option.

Let’s see an /etc/fstab example:

$ cat /etc/fstab
# <file system> <mount point>   <type>  <options>       <dump>  <pass>
/dev/sdb1	/	ext4	rw,defaults,noatime,commit=120,data=ordered	0	1
/dev/sdb2	/home	ext4	rw,defaults,noatime,data=ordered	0	2
/dev/sda3	/media/Backup	ntfs-3g	defaults,locale=en_US.UTF-8	0	0
/dev/sda2	/media/Data	ntfs-3g	defaults,locale=en_US.UTF-8	0	0
...

Thus, if we add the following line in this file, the archLinux.iso image will be automatically mounted on /mnt/archIso after system boot:

/media/Data/archLinux.iso /mnt/archIso udf ro,relatime,utf8 0 0

Once a filesystem is mentioned in /etc/fstab, we can mount it by just giving the mount point or the device.

For instance, with the above fstab configuration, we can mount the /dev/sda2 partition with either of the two short commands:

root# mount /media/Data

or

root# mount /dev/sda2

4. Unmounting a Filesystem

The umount command notifies the system to detach the given mounted filesystems. We just provide the filesystem name or the mount point following the umount command.

For example, if we want to unmount the previously mounted USB stick and ISO image:

root# umount /dev/sdd1
root# umount /mnt/archIso

We can also umount multiple mounted filesystems in one shot:

root# umount /dev/sdd1 /mnt/archIso

4.1. Lazy UnmountWhen we want to umount a filesystem, we don’t always know if there are operations still running on it. For instance, a copy job could be running on the filesystem.

Of course, we don’t want to break the copy and get inconsistent data. The option -l will let us do a “lazy” umount.

The -l option informs the system to complete pending read or write operations on that filesystem and then safely unmount it:

root# umount -l mount_point

4.2. Force UnmountIf we pass -f option to the command umount, it’ll forcefully unmount a filesystem even if it’s still busy:

root# umount -f mount_point

We should be careful while executing umount with -f as it could lead to corrupt or inconsistent data in the unmounted filesystem.

One real-world use case for force unmounting could be unmounting a network share because of a connection problem.

-------------------------------------------------------------------------------------

[root@ip-172-31-58-120 ec2-user]# blkid
/dev/xvda1: LABEL="/" UUID="74fc4c15-c86f-4c31-92f6-0df873546b85" TYPE="xfs" PARTLABEL="Linux" PARTUUID="ed868158-eb4b-43a5-8ed5-8b58aa998193"
/dev/xvdf: UUID="2008-11-19-03-48-46-00" LABEL="CDROM" TYPE="iso9660" PTUUID="4971ec01" PTTYPE="dos"

[root@ip-172-31-58-120 ec2-user]# lsblk -f
NAME  FSTYPE  LABEL UUID                                 MOUNTPOINT
xvda
xvda1 xfs     /     74fc4c15-c86f-4c31-92f6-0df873546b85 /
xvdf  iso9660 CDROM 2008-11-19-03-48-46-00               /media/census

[root@ip-172-31-58-120 census]# cat /etc/fstab
UUID=74fc4c15-c86f-4c31-92f6-0df873546b85    /            xfs     defaults,noatime  1   1
UUID=2008-11-19-03-48-46-00                 /media/census iso9660 defaults 0 0

Sunday, March 21, 2021

Linux Unix Redhat Tutorial VirtualBox, Install Ubuntu/Redhat on Virtualbox

ifCommand1Suceeds && RunCommand2

RunCmd1 ; IrrespectiveOfResultRunCmd2 ;

IfCommand1DoesNotRun || ThenRunCmd2


For those users who are switching from Fedora to Ubuntu, the yum tool is replaced with another great tool apt-get.
http://www.geekinterview.com/question_details/49964


-----------------Unix-------------------

https://www.if-not-true-then-false.com/2010/install-virtualbox-guest-additions-on-fedora-centos-red-hat-rhel/
BEST BEST BEST



CD's and DVDs are using ISO9660 filesystem
https://www.linuxnix.com/how-to-mount-dvd-or-cdrom-in-linux/


I have gnome Desktop etc
Install XWindows
Resolution A: Install the desktop related package groups after system install (Recommended)
Resolution B: Select "Desktop" mode (Server with a GUI in RHEL 7) as the default installation mode in Anaconda

https://access.redhat.com/solutions/5238  [Imp]
https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/6/html/Installation_Guide/sn-switching-to-gui-login.html



https://blog.paranoidpenguin.net/2017/08/red-hat-7-4-virtualbox-guest-additions-issues/
sudo mount -o loop ~/VBoxGuestAdditions_5.1.27-117460.iso /mnt/vboxguest
mkdir /media/VirtualBoxGuestAdditions
mount -r /dev/cdrom /media/VirtualBoxGuestAdditions


etc/yum.repos.d/

yum install firefox
yum repolist all


x window System
startkde gnome-session xfce

http://www.faqs.org/docs/lnag/lnag_xwindows.html
https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/4/html/Reference_Guide/ch-x.html
https://en.wikipedia.org/wiki/Comparison_of_X_Window_System_desktop_environments

dnf vs yum vs apt
dnf??
https://www.linux.com/learn/what-you-need-know-about-fedoras-switch-yum-dnf



3
down vote
You can redirect output and run the ls process in the background.

ls > myls.txt &


VBoxManage.exe setextradata "Redhat 7.3" CustomVideoMode1 1366x768x32

/dev/disk/by-label/VBOXADDITIONS

https://access.redhat.com/solutions/253273
subscription-manager register --username (username used in RH web registration) --password (password in RH web login) --auto-attach

https://www.digitalocean.com/community/tutorials/how-to-set-up-and-use-yum-repositories-on-a-centos-6-vps

https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/6/html/Deployment_Guide/chap-Subscription_and_Support-Registering_a_System_and_Managing_Subscriptions.html

https://www.if-not-true-then-false.com/2010/install-virtualbox-guest-additions-on-fedora-centos-red-hat-rhel/


https://blog.paranoidpenguin.net/2017/08/red-hat-7-4-virtualbox-guest-additions-issues/

https://access.redhat.com/documentation/en-us/red_hat_subscription_management/1/html-single/rhsm/index

subscription-manager register --username kawkaran --password FxsxED97 --auto-attach


RESET FORGOTTEN Password - Emergency Mode - Single User Mode

https://linuxconfig.org/recover-a-forgotten-root-password-on-redhat-7-linux-selinux-system

Azure - Pipeline - Add Approver for Stage

https://learn.microsoft.com/en-us/azure/devops/pipelines/process/approvals?view=azure-devops&tabs=check-pass