High Availbility

OS & Virtualization

Showing posts with label linux. Show all posts
Showing posts with label linux. Show all posts

Tuesday, June 27, 2017

Getting X11 forwarding through ssh working after running su

Getting X11 forwarding through ssh working after running su



$ xauth list $DISPLAY
You'll get something like

somehost.somedomain:10 mit-magic-cookie-1 4d22408a71a55b41ccd1657d377923ae

Then, after having done su, tell the new user what the cookie is:

$ xauth add somehost.somedomain:10 MIT-MAGIC-COOKIE-1 4d22408a71a55b41ccd1657d377923ae

Wednesday, April 06, 2016

Linux & command - Firewalld

Firewall

The firewall on Redhat 7 Linux system is enabled by default.
  1. Stop and Start RHEL7 firewall

    root@rhel7 ~] service firewalld stop
    root@rhel7 ~]# service firewalld start |
  2. Disable and Enable RHEL7 firewall

    [root@rhel7 ~]# systemctl disable firewalld
    [root@rhel7 ~]# systemctl enable firewalld
  3. How to open http port 80 on Redhat 7 Linux using firewall-cmd

    [root@rhel7 ~]## firewall-cmd --zone=public --add-port=80/tcp

    Once you add the above firewall rule reload firewall service:

    [root@rhel7 ~]# firewall-cmd --reload 4.
  4. List all the port

    [root@SGNWH01HP1DB1 firewalld]# firewall-cmd --zone=public --list-all public


Start, Stop and Restart services on systemd RHEL



  1. list all currenly running services

    [root@rhel7 ~]# systemctl list-units --type=service | grep running
  2. list all active services available

    [root@rhel7 ~]# systemctl list-units --type=service

Journal Analysis

  1. To get the content of the Systemd journal,
    # journalctl
  2. To get all the events related to the crond process in the journal
    # journalctl --unit=chronyd
  3. To get all the events that appeared today in the journal, type:
    # journalctl --since=today
  4. To display the disk space used by Journald# journalctl --disk-usage
  5. To get the 10 last events
    # journalctl -f

Boot Process

  1. To get the boot process duration
    # systemd-analyze


Service Management

Systemd deals with all the aspects of the service management. The systemctl command replaces the chkconfig and the service commands
  1.  To activate the NTP service at boot
    # systemctl enable ntpd
  2. To deactivate it, start it, stop it, restart it, reload it, type:
    # systemctl disable ntpd
    # systemctl start ntpd
    # systemctl stop ntpd
    # systemctl restart ntpd
    # systemctl reload ntpd
  3. To get the status of the Apache service
    # systemctl status httpd
  4. To get the list of services that failed at boot, type:
    
    
    # systemctl --failed
  5. To get all the configuration details about a service (here httpd), type:
    
    
    # systemctl show httpd

Other commands

  • nmtui
  • nmcli
  • ip


How to add a user to the sudoers list

How to add a user to the sudoers list?



 
cat << END >> /etc/sudoers
oracle ALL=(ALL) NOPASSWD:ALL
Defaults:oracle !requiretty
END





Wednesday, July 01, 2015

Getting Started with Docker on Oracle Linux

Learn how to customize a Docker container image and use it to instantiate application instances across different Linux servers. This article describes how to create a Dockerfile, how to allocate runtime resources to containers, and how to establish a communication channel between two containers (for example, between web server and database containers).

Docker containers wrap up a piece of software in a complete filesystem that contains everything it needs to run: code, runtime, system tools, system libraries 

 

Common Docker commands





Commands
 Purpose
 docker info
 information
 docker images
 images
 docker ps -a
List all containers
 docker rm $(docker ps -a -q)
 Remove containers
 docker rmi $(docker images)
 Remove images
docker save mynewimage > /tmp/mynewimage.tar
Export images
docker load < /tmp/mynewimage.tar
Import images


docker pull oracle/nosql




Monday, February 16, 2015

Linux Containers

Linux Containers


Linux Containers (LXC) allow running multiple isolated Linux instances (containers) on the same host.

  • Lightweight and resource-friendly
  • Run multiple versions of an operating system on a single server
  • Rapid and Easy deployment

Installing Oracle Linux containers


https://blogs.oracle.com/OTNGarage/entry/linux_container_lxc_part_2

Installing Oracle on Linux containers

https://bdrouvot.wordpress.com/2014/04/25/reduce-resource-consumption-and-clone-in-seconds-your-oracle-virtual-environment-on-your-laptop-using-linux-containers-and-btrfs/

Tuesday, June 04, 2013

Howto Setup Yum repositories ISO CDROM

Q : How do you use yum to update / install packages from an ISO of CentOS / FC / RHEL CD?

Solution 1 : Use your DVD directly without creating any repo
  1. Mount the ISO file
    # mkdir /media/cdrom
    # mount /dev/sr0 /media/cdrom
  2. Create config file
    # vi /etc/yum.repos.d/iso.repo

    [dvd]
    baseurl=file:///media/cdrom
    enabled=1
    gpgcheck=0
  3. Run the command
    # yum install --enablerepo=dvd packagename
Solution 2 : Creation of yum repositories is handled by a separate tool called createrepo, which generates the necessary XML metadata. If you have a slow internet connection or collection of all downloaded ISO images, use this hack to install rpms from iso images

  1. Step # 1: Mount an ISO file
    # rpm -i createrepo*
    # mkdir /media/cdrom
    # mount /dev/sr0 /media/cdrom
  2. Step # 2: Create a repository
    # mkdir /tmp/repo
    # cd /mnt/iso
    # createrepo -o /tmp/repo .
  3. Step # 3: Create config file
    # vi /etc/yum.repos.d/iso.repo

    Append following text:
    [ISO Repository]
    baseurl=file:///media/cdrom
    enabled=1
Now use yum command to install packages from ISO images:
# yum install package-name

Monday, February 18, 2013

Copying & Moving Files efficiently with xargs

How to move and/or copy a subset of files from one directory

 
eg 1 zip files older than 10 days


 find . -type f -name '*.trc' -mtime +10 | xargs tar -cvzf bdump_$(date +%Y%m%d).gz.tar --remove-files

From time to time I need to move and/or copy a subset of files from one directory to another


 #-- delete
find . -type f -ctime -1 | xargs -i rm {}

 #-- COPY
find . -type f -ctime -1 | xargs -I '{}' cp {} /some/other/directory

 #-- MOVE
find . -type f -ctime -1 | xargs -I '{}' mv {} /some/other/directory

 

It is very easy to compress a Whole Linux/UNIX directory. It is useful to backup files, email all files, or even to send software you have created to friends. Technically, it is called as a compressed archive. GNU tar command is best for this work. It can be use on remote Linux or UNIX server. It does two things for you:
=> Create the archive
=> Compress the archive

You need to use tar command as follows (syntax of tar command):





 
 tar -zcvf archive-name.tar.gz directory-name