Category Archives: Linux

Cron jobs in Linux

To create cron jobs in Linux:

Just remember the following syntax
.—————- minute (0 – 59)
| .————- hour (0 – 23)
| | .———- day of month (1 – 31)
| | | .——- month (1 – 12) OR jan,feb,mar,apr …
| | | | .—- day of week (0 – 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat
| | | | |
* * * * * user-name command to be executed
1. run crontab -e
and append your command/tasks as following
i.e.
* * * * * python /etc/script.py

2. can also edit crontact file directly
vim /etc/crontab and append your tasks
i.e.
* * * * * root touch filename

To view view cron jobs in Linux:

$ crontab -l

$ cat /etc/crontab

 

Advertisements

How to burn ISO file using ‘dd’ on USB drive

Using simple dd command we can copy ISO file directly USB drive
# dd if=input_file.ISO of=usb_drive_path

To speed up transfer we can increase block size
# dd bs=8192 if=input_file.ISO of=usb_drive_path

To view progress of the transfer
Method 1 (requires GNU Coreutils 8.24+ – Ubuntu 16.04+ ):
# dd bs=8192 if=input_file.ISO of=usb_drive_path status=progress

Method 2 – using pipe viewer
# dd bs=8192 if=input_file.ISO | pv | ds of=usb_drive_path status=progress

To get time estimation based on a file size
# dd bs=8192 if=input_file.ISO | pv -s 4G| ds of=usb_drive_path status=progress

TO DO
using ‘watch’

How to exclude packages from update Red Hat/Centos

Sometimes you only want to update packages without upgrading kernel, there are two ways of doing this:

1. Temporarily
# yum update –exclude=<package_name>
# yum update –exclude=kernel*

2. To make it more permanent edit /etc/yum.conf file and append “exclude” keyword
[main]
cachedir=/var/cache/yum/$basesearch/$releasever
keepcache=0
debuglevel=2
logfile=/var/log/yum.log
exclude=kernel* redhat-release*

Expand Logical Volume in Red Hat VMware

After adding a separate disk run to verify if the space was added:

  1. fdisk -l
  2. create a new partition fdisk /dev/sdb
    1. p – to print current partition table
    2. n – to create a new partition
    3. p – for primary
    4. 1 – depending on the output of the partition table output
    5. press return two times to accept the defaults (first and last sector)
    6. t – to change the system’s partition ID
    7. 8e – to change to Linux LVM
    8. w – to write the changes
  3. restart VM
  4. fdisk -l – to verify that partition was successfully created
  5. convert a partition to physical volume
    $ pvcreate /dev/sdb1
    Physical volume “/dev/sdb1” successfully created
  6. Extend current volume group
    vgextend rhel /dev/sdb1
    Volume group “rhel” successfully extended
  7. Run vgdisplay to verify if free space was added
    vgdisplay rhel | grep “Free”
    Free  PE / Size       4095 / 16.00 GiB
  8. extend logical volume with free space
    lvextend -l +100%FREE /dev/rhel/root
    Extending logical volume root to 66.00 GiB
    Logical volume root successfully resized
  9. Expand ext3 file system online inside of Logical Volume
    xfs_growfs /dev/rhel/root – Red Hat 7
    ext2online /dev/rhel/root
    resize2fs /dev/rhel/root

Setup Proxy in SUSE/VCSA

To setup proxy manually in VCSA 5.5 login as root and look into the following file:

/etc/sysconfig/proxy

PROXY_ENABLED=”yes”

HTTP_PROXY=”http://<IP address or FQDN>:<port_number>”

HTTPS_PROXY=”http://<IP address or FQDN>:<port_number>”

FTP_PROXY=”http://<IP address or FQDN>:<port_number>”

NO_PROXY=”localhost, 127.0.0.1″

 

If you need to authenticate via proxy

Create a file in your home directory,

/root/.curlrc with permissions 644

and contain the following:

# Proxy credentials

proxy-user = “<username>:<password>”

source the file to apply the changes

source /root/.curlrc

 

Modify Ubuntu ens network interface card to eth0

  1. Display current interface cards and verify that eth0 doesnt exist:
    ifconfig -a
  2. Edit grub file configuration to disable new naming convention
    vim /etc/default/grub
  3. Look for GRUB_CMDLINE_LINUX= include the following net.ifnames=0 biosdevname=0″
    From:
    GRUB_CMDLINE_LINUX=””
    To
    GRUB_CMDLINE_LINUX=”net.ifnames=0 biosdevname=0″
  4. Save and exit the file
  5. Reload grub config file:
    update-grub
  6. Edit interfaces file
    vim /etc/network/interfaces
    From:
    # The primary network interface
    auto ens16
    iface ens16 inet dhcpTo:
    # The primary network interface
    auto eth0
    iface eth0 inet dhcp
  7. Reboot your machine/Restart networking service

 

Reference:
https://www.freedesktop.org/wiki/Software/systemd/PredictableNetworkInterfaceNames/