Connect to vCenter Server using the vSphere Client
Right-click the virtual machine and click Edit Settings.
Click Network adapter and note the MAC Address.
For example, you see a MAC Address similar to:
00:50:56:86:00:00
Power on the Linux virtual machine.
Open a console and log in as root.
Change directory to etc/sysconfig/network-scripts.
Edit ifcfg-eth0 and update the MAC address to reflect the MAC address in Step 1
Edit /etc/udev/rules.d/70-persistent-net.rules and update the MAC address to reflect the MAC address in Step 1
Activate the ethernet card by running this command:
ifup eth0.
Thursday, October 27, 2016
Friday, October 14, 2016
Reset the permissions of all installed Programs
Reset the permissions of all installed RPM packages
for p in $(rpm -qa); do rpm --setperms $p; done
for p in $(rpm -qa); do rpm --setugids $p; done
Above command combination will reset all the permissions to the default permissions under CentOS / RHEL / Fedora Linux.
for p in $(rpm -qa); do rpm --setperms $p; done
for p in $(rpm -qa); do rpm --setugids $p; done
Above command combination will reset all the permissions to the default permissions under CentOS / RHEL / Fedora Linux.
Wednesday, September 28, 2016
Restart Gnome 3 Shell without logging out and without loosing running applications.
press Alt + F2, type "r" then Enter. This will work so long the shell isn't unusable.
if Shell is unusable then try
Ctrl +Alt + F1 to take you into a shell
and then send SIGQUIT to the gnome-shell process which will terminate only the shell:
killall -3 gnome-shell
if Shell is unusable then try
Ctrl +Alt + F1 to take you into a shell
and then send SIGQUIT to the gnome-shell process which will terminate only the shell:
killall -3 gnome-shell
Monday, September 5, 2016
Restart KDE Plasma windows environment without logging out
Alt f2
then type
killall plasmashell
Alt f2
then type
kstart plasmashell
Monday, August 29, 2016
Replace Firewalld with iptables
Fedora/CentOS7 / RHEL 7 are completely systemd based, So on these versions of Linux we need to use systemd commands to disable firewalld and enable iptables
# systemctl mask firewalld
# systemctl stop firewalld
# yum -y install iptables-services
# systemctl enable iptables
If you do not want ip6tables, You can skip following command
# systemctl enable ip6tables
# systemctl start iptables
If you do not want ip6tables, You can skip following command.
# systemctl start ip6tables
Firewalld Service is now disabled, You can use iptables.
- Disable Firewalld Service.
# systemctl mask firewalld
- Stop Firewalld Service.
# systemctl stop firewalld
- Install iptables service related packages.
# yum -y install iptables-services
- Make sure service starts at boot:
# systemctl enable iptables
If you do not want ip6tables, You can skip following command
# systemctl enable ip6tables
- start the iptables services.
# systemctl start iptables
If you do not want ip6tables, You can skip following command.
# systemctl start ip6tables
Firewalld Service is now disabled, You can use iptables.
Monday, August 8, 2016
How to Roll back a yum update or a yum install
Easy backout of yum patching
yum install screen
Dependencies Resolved
=================================================================================
Package Arch Version Repository Size
=================================================================================
Installing:
screen i686 4.0.3-16.el6 rhel-6-server-rpms 484 k
Installed:
screen.i686 0:4.0.3-16.el6
Complete!
Next, identify the transaction ID that we want to 'undo'
type
yum history
Loaded plugins: product-id, refresh-packagekit, subscription-manager
Updating Red Hat repositories.
ID | Login user | Date and time | Action(s) | Altered
-------------------------------------------------------------------------------
8 | root | 2011-10-03 14:40 | Install | 1
7 | root | 2011-09-21 04:24 | Install | 1 ##
6 | root | 2011-09-21 04:23 | Install | 1 ##
5 | root | 2011-09-16 13:35 | Install | 1
4 | root | 2011-09-16 13:33 | Erase | 1
3 | root | 2011-09-14 14:36 | Install | 1
2 | root | 2011-09-12 15:48 | I, U | 80
1 | System | 2011-09-12 14:57 | Install | 1025
The transaction ID we are interested in is '8', so move forward with undo step. If want to see additional information to verify this is transaction interested in, use yum history info 8 prior to doing the undo
yum history undo 8
Loaded plugins: product-id, refresh-packagekit, subscription-manager
Updating Red Hat repositories.
Undoing transaction 8, from Mon Oct 3 14:40:01 2011
Install screen-4.0.3-16.el6.i686
Resolving Dependencies
--> Running transaction check
---> Package screen.i686 0:4.0.3-16.el6 will be erased
--> Finished Dependency Resolution
Dependencies Resolved
================================================================================
Package Arch Version Repository Size
================================================================================
Removing:
screen i686 4.0.3-16.el6 @rhel-6-server-rpms 783 k
Removed:
screen.i686 0:4.0.3-16.el6
Complete!
yum install screen
Dependencies Resolved
=================================================================================
Package Arch Version Repository Size
=================================================================================
Installing:
screen i686 4.0.3-16.el6 rhel-6-server-rpms 484 k
Installed:
screen.i686 0:4.0.3-16.el6
Complete!
Next, identify the transaction ID that we want to 'undo'
type
yum history
Loaded plugins: product-id, refresh-packagekit, subscription-manager
Updating Red Hat repositories.
ID | Login user | Date and time | Action(s) | Altered
-------------------------------------------------------------------------------
8 | root
7 | root
6 | root
5 | root
4 | root
3 | root
2 | root
1 | System
The transaction ID we are interested in is '8', so move forward with undo step. If want to see additional information to verify this is transaction interested in, use yum history info 8 prior to doing the undo
yum history undo 8
Loaded plugins: product-id, refresh-packagekit, subscription-manager
Updating Red Hat repositories.
Undoing transaction 8, from Mon Oct 3 14:40:01 2011
Install screen-4.0.3-16.el6.i686
Resolving Dependencies
--> Running transaction check
---> Package screen.i686 0:4.0.3-16.el6 will be erased
--> Finished Dependency Resolution
Dependencies Resolved
================================================================================
Package Arch Version Repository Size
================================================================================
Removing:
screen i686 4.0.3-16.el6 @rhel-6-server-rpms 783 k
Removed:
screen.i686 0:4.0.3-16.el6
Complete!
Friday, July 22, 2016
Thursday, May 19, 2016
yum install from CD rom
insert CD rOM
mount -t iso9660 /dev/cdrom /mnt/cdrom
vim /etc/yum.repos/cdrom.repo
add the following lines
[dvd-source]
name=RHEL dvd repo
baseurl=file:///mnt/cdrom/Server/
enabled=1
gpgcheck=0
yum repolist
yum repolist all
to see new active repo
Monday, May 9, 2016
Windows service wont start access denied
start ,search and type:- cmd, right click on returned cmd.exe and select "run as administrator" at the prompt type:-
net localgroup Administrators /add networkservice
press enter then type:
net localgroup Administrators /add localservice
press enter then type:
exit
press enter and restart your computer
Open services and make sure the service is started.
net localgroup Administrators /add networkservice
press enter then type:
net localgroup Administrators /add localservice
press enter then type:
exit
press enter and restart your computer
Open services and make sure the service is started.
Saturday, February 13, 2016
Vim: Change search syntax highlighter colour
When you search in Vim the results are highlighted
if the highlighting colour is wrong you cannot read the text.
There are two sets of default colour maps: One for a light and another one for a dark background.
If you have a black background, use the following command to get a better colour map for syntax highlighting:
:set background=dark
Likewise if you have a light background you would want to use the following command to get a better colour scheme for the highlighter.
:set background=light
These commands can either be run inside of vim by going into command mode and entering them.
or you can add them to your .vimrc file
Friday, January 22, 2016
dig Examples
Below are a couple of examples on how you can use dig. These are common examples and include queries such as mail exchange lookup, address record lookup, reverse dns lookup, etc.
you can always add the '+short' option at the end of any dig command to keep the output manageable:
eg dig www.example.com +short
This is simply going to tell us what the IP address is for the domain www.example.com. The output will be an IP address which will be something like 1.2.3.4.
dig www.example.com
Reverse DNS Dig
Perform a reverse DNS dig lookup. This will translate an IP address into its domain name. The output will be a domain name such as www.example.com.
dig -x 1.2.3.4
Dig MX Record Lookup
An MX (Mail Exchange) record tells us that the record is a domain name that is responsible for accepting email. The below command will tell us what domain name the mail record below is pointing as well as the priority of the mail records. . The output will be the domain name the record points to such as mail.example.com, which tells us that the mx record example.com resolves to mail.example.com.
dig -t MX example.com
Show the TXT or SPF records
dig example.com txt
Directly Query A DNS Server
By default the dns query will resolve off of your own dns server (which is usually the dns server of your ISP or local server), however we can manually specify the dns server we want to query by adding @ns1.example.com to the dns dig command.
dig @ns1.example.com www.somedomain.com
Directly Query the TXT records of a specific name server
dig @ns1.example.com www.somedomain.com txt
Show the Name servers of a domain
Here's how to query for a list of nameservers for a given domain,
dig example.com ns
dig traceroute information
If you like the traceroute command, you can do something similar with dig to follow DNS nameservers, like this, using the
dig example.com +trace
or to keep the output manageable:
dig example.com +trace +short
Saturday, December 12, 2015
Block IP using blackole route
A null, also known as Blackhole, is a routing table entry that discards a matching packet without sending it further. It is mainly used for preventing/ blocking an unwanted IP to attack your system. It drops the IP using IPtables. for instance, if you want to block an IP address 192.168.0.1, you can write the command:
# ip route add blackhole 192.168.0.1/32
# ip route add blackhole 192.168.0.1/32
your system will now drop all packets coming from 192.168.0.1
Teaming 2 Network cards
If we have two network interfaces, eth0 and eth1 and we want it to be shown in a single bond as bond0, we need to first create a config file with the name bond0. The network configuration in Linux stores files in etc/sysconfig/network-scripts/ directory.
The work parameters must be set as follows:
#vi /etc/sysconfig/network-scripts/bond0
DEVICE=bond0
IPADDR=192.168.1.20
NETWORK=192.168.1.0
NETMASK=255.255.255.0
USERCTL=no
BOOTPROTO=none
ONBOOT=yes
The IP address must be replaced with your actual setup.
Open eth0 and eth1 configuration files
# vi /etc/sysconfig/network-scripts/ifcfg-eth0
# vi /etc/sysconfig/network-scripts/ifcfg-eth1
Modify the parameters as follows:
DEVICE=eth0
USERCTL=no
ONBOOT=yes
MASTER=bond0
SLAVE=yes
BOOTPROTO=none
DEVICE=eth1
USERCTL=no
ONBOOT=yes
MASTER=bond0
SLAVE=yes
BOOTPROTO=none
Save and close the file.
Now load the bond driver/module when the channel bonding interface is brought up. The kernel configuration files are also modified using # vi /etc/modprobe.conf
Add these lines :
alias bond0 bonding
options bond0 mode=balance-alb miimon=100
Test configuration using these two steps:
Firstly, load the bonding module:
# modprobe bonding
Restart the network to see bond0 interface:
# service network restart
Both Nic's should now be working as one
The work parameters must be set as follows:
#vi /etc/sysconfig/network-scripts/bond0
DEVICE=bond0
IPADDR=192.168.1.20
NETWORK=192.168.1.0
NETMASK=255.255.255.0
USERCTL=no
BOOTPROTO=none
ONBOOT=yes
The IP address must be replaced with your actual setup.
Open eth0 and eth1 configuration files
# vi /etc/sysconfig/network-scripts/ifcfg-eth0
# vi /etc/sysconfig/network-scripts/ifcfg-eth1
Modify the parameters as follows:
DEVICE=eth0
USERCTL=no
ONBOOT=yes
MASTER=bond0
SLAVE=yes
BOOTPROTO=none
DEVICE=eth1
USERCTL=no
ONBOOT=yes
MASTER=bond0
SLAVE=yes
BOOTPROTO=none
Save and close the file.
Now load the bond driver/module when the channel bonding interface is brought up. The kernel configuration files are also modified using # vi /etc/modprobe.conf
Add these lines :
alias bond0 bonding
options bond0 mode=balance-alb miimon=100
Test configuration using these two steps:
Firstly, load the bonding module:
# modprobe bonding
Restart the network to see bond0 interface:
# service network restart
Both Nic's should now be working as one
Wednesday, September 30, 2015
Add a windows domain user to a computers local administrator group remotely
To Add a windows domain user to a computers local administrator group remotely
first download and install PsExec from
https://technet.microsoft.com/en-us/sysinternals/bb897553.aspx
open command prompt
use psexec to connect to computer
psexec \\computer_name -u \domain\administrator -p password cmd
a command prompt of the remote computer will open on your computer
then type in the command prompt
net localgroup administrators domain\user /add
should return command completed succesfully
Done.
Monday, August 3, 2015
Ethtool Examples
Ethtool is the defacto tool for interacting with your network adapters.
ethtool ethn0 (or whichever eth device you want information on)
gives you detailed information about your network adapter.
ethtool -i eth0 Will display the driver settings, driver version,firmware version and bus details
ethtool -a eth0 will show you the auto negotiation details of your adapter.
ethtool -S eth0 will display network statistics IE how many bytes have been sent and how many bytes have been received by the adapter.
And then my favourite
ethtool -p eth0 will physically identify your network card by causing the LED's on the network card to flash on and off. this is very useful when you have multiple network interfaces and need to know which interface is bound to which eth device on your system.
ethtool -t eth0 offline will bring the adapter offline to perform diagnostics and testing
ethtool -t eth0 online will perform testing whilst the adapter is online and available to your system)
provided your Nic supports this feature ethertool will perform diagnostics on your network adapter
Thursday, July 30, 2015
Output from rpm -qa, how to extract only the name of the package?
If you need to migrate to a new computer and want to install the same packages that were on your old computer on the new one, the following pipes all the packages into a list that you can then use to install on the new computer.
rpm -qa --qf "%{NAME}\n" > filelist.txt
Then to install the packages
yum -y install `cat filelist.txt`
or
yum -y install $(cat filelist.txt)
rpm -qa --qf "%{NAME}\n" > filelist.txt
Then to install the packages
yum -y install `cat filelist.txt`
or
yum -y install $(cat filelist.txt)
Wednesday, July 29, 2015
How to show only settings and not the comments in a file
In Bash , ZSH or most shells. Comments are added in files using # or sometinmes ;
Sometimes files are full of comments and finding the settings that are set amongst all the comments can be confusing.
The following will show you the contents of a file excluding lines begining with #
substitute the # with a ; if your program uses ; to comment
grep -v '^#' filename
Sometimes files are full of comments and finding the settings that are set amongst all the comments can be confusing.
The following will show you the contents of a file excluding lines begining with #
substitute the # with a ; if your program uses ; to comment
grep -v '^#' filename
Sunday, February 8, 2015
nmcli basics and examples
nmcli is the cli for network manager which is the new way to configure network and network adaptors in Redhat/Centos 7 and Fedora 21
Here are some basic nmcli commands to get you going.
The nice thing with nmcli is that you can tab through all options ie you don't need to remember all the commands, tab completion will bring them up.
nmcli hitting tab here brings up the following options
con -- NetworkManager connections
dev -- devices managed by NetworkManager
nm -- NetworkManager status
nmcli dev hitting tab here will bring up the following options
disconnect -- disconnect device and prevent it from automatically activating
list -- get detailed information about devices
status -- print status of devices
wifi -- list available WiFi access points
similarly
nmcli con hit tab will bring up the following
delete -- delete a connection
down -- deactivate a connection
list down -- list configured connections
status -- print status of active connections
up -- activate a connection
nmcli nm
enable -- get status or enable/disable networking
sleep -- get sleep status or put to sleep/awake NetworkManager
status -- show overall status of NetworkManager
wifi -- inquire or set status of WiFi in NetworkManager
wwan -- inquire or set status of WWAN in NetworkManager
To show all configured connections
nmcli con
To connect to a wifi network
first nmcli dev wifi
to see list of available networks then
nmcli dev wifi connect networkname password inputpassword
switch wifi off
nmcli nm wifi off
Bring eth0 adaptor up
nmcli -p con up id "My wired connection" iface eth0
activates the connection with name "My wired connection" on interface eth0. The -p option makes nmcli show progress of the activation.
Get list
nmcli con
Stop interface
nmcli con down id 'Connection'
Start interface
nmcli con up id 'Connection'
Here are some basic nmcli commands to get you going.
The nice thing with nmcli is that you can tab through all options ie you don't need to remember all the commands, tab completion will bring them up.
nmcli hitting tab here brings up the following options
con -- NetworkManager connections
dev -- devices managed by NetworkManager
nm -- NetworkManager status
nmcli dev hitting tab here will bring up the following options
disconnect -- disconnect device and prevent it from automatically activating
list -- get detailed information about devices
status -- print status of devices
wifi -- list available WiFi access points
similarly
nmcli con hit tab will bring up the following
delete -- delete a connection
down -- deactivate a connection
list down -- list configured connections
status -- print status of active connections
up -- activate a connection
nmcli nm
enable -- get status or enable/disable networking
sleep -- get sleep status or put to sleep/awake NetworkManager
status -- show overall status of NetworkManager
wifi -- inquire or set status of WiFi in NetworkManager
wwan -- inquire or set status of WWAN in NetworkManager
To show all configured connections
nmcli con
To connect to a wifi network
first nmcli dev wifi
to see list of available networks then
nmcli dev wifi connect networkname password inputpassword
switch wifi off
nmcli nm wifi off
Bring eth0 adaptor up
nmcli -p con up id "My wired connection" iface eth0
activates the connection with name "My wired connection" on interface eth0. The -p option makes nmcli show progress of the activation.
Get list
nmcli con
Stop interface
nmcli con down id 'Connection'
Start interface
nmcli con up id 'Connection'
Friday, February 6, 2015
Booting into single user mode and changing root password Centos / Redhat 7
since among other things this process is also now different in redhat 7 / CentOS 7
here is how you do it in redhat 7
During boot, press "e" at the grub loader.
Scroll down using the arrow keys to the line starting with "linux". It would look like this.
linux16 /vmlinuz-3.10.0......
Remove the following from that line. "rhgb" and "quiet".
Add the following to the end of the line. "init=/bin/sh".
Press ctrl+x to continue the boot process.
Once the system is booted, you will be at the root user in single user mode. But this is in a read only file system.
You need to mount the / filesystem.
mount -o remount, rw /
Test that you can write to /, following command should work without error.
touch /tmp/test
Now change your password for root
passwd
Touch the following file to make sure things are ok on SELinux, this is a fix file process.
touch /.autorelabel
Finally start the normal boot process.
exec /sbin/init
You're Done.
Saturday, January 10, 2015
Upgrade from Fedora 20 to Fedora 21
make sure your fedora 20 is up to date
yum update
reboot
then
sudo fedup --network 21 --product=nonproduct
Once Fedup completed
Reboot the system
Once the system reboots, there should be a new entry in the GRUB menu titled System Upgrade.
Select the System Upgrade option from the GRUB menu
Remark: If the System Upgrade item is not shown in the grublist at boot, it is most often caused by having a different grub, most often installed by another Linux distribution you may have in multiboot. To correct this quickly: reinstall grub:
grub2-mkconfig -o /boot/grub2/grub.cfg
grub2-install /dev/sda (replace /dev/sda by any other device you prefer to boot from)
The system should boot into the upgrade process and a plymouth boot screen should be displayed
There is a root shell on VT2 so you can tinker with the system if something goes wrong. (To disable this, boot with rd.upgrade.noshell)
Press 'esc' to see a more detailed log. If you switch back to the graphical progress indicator, it may show 0% for the remainder of the upgrade but that does not mean the upgrade has stopped.
Once the upgrade process has completed, the system will reboot and an option to boot Fedora 21 will be on the grub menu.
Cleaning Up Post Upgrade
It is worth rebuilding the RPM DB to prevent RPMDB checksum error when doing a distribution sync:
sudo rpm --rebuilddb
There are a collection of post-upgrade things to do. Some of which are fixed by doing a distro sync:
sudo yum distro-sync --setopt=deltarpm=0
This tool search for .rpmnew, .rpmsave and .rpmorig files and ask you what to do with them: Keep current version, place back old version, watch the diff or merge.
sudo yum install rpmconf
sudo rpmconf -a
If you are using google-chrome from the Google repository, you must re-install google-chrome due to a packaging bug on the Google side of things. Make sure to adjust the command to the build type you would like to install:
sudo yum remove google-chrome-\* && sudo yum install google-chrome-stable
Enjoy Fedora 21
yum update
reboot
then
sudo fedup --network 21 --product=nonproduct
Once Fedup completed
Reboot the system
Once the system reboots, there should be a new entry in the GRUB menu titled System Upgrade.
Select the System Upgrade option from the GRUB menu
Remark: If the System Upgrade item is not shown in the grublist at boot, it is most often caused by having a different grub, most often installed by another Linux distribution you may have in multiboot. To correct this quickly: reinstall grub:
grub2-mkconfig -o /boot/grub2/grub.cfg
grub2-install /dev/sda (replace /dev/sda by any other device you prefer to boot from)
The system should boot into the upgrade process and a plymouth boot screen should be displayed
There is a root shell on VT2 so you can tinker with the system if something goes wrong. (To disable this, boot with rd.upgrade.noshell)
Press 'esc' to see a more detailed log. If you switch back to the graphical progress indicator, it may show 0% for the remainder of the upgrade but that does not mean the upgrade has stopped.
Once the upgrade process has completed, the system will reboot and an option to boot Fedora 21 will be on the grub menu.
Cleaning Up Post Upgrade
It is worth rebuilding the RPM DB to prevent RPMDB checksum error when doing a distribution sync:
sudo rpm --rebuilddb
There are a collection of post-upgrade things to do. Some of which are fixed by doing a distro sync:
sudo yum distro-sync --setopt=deltarpm=0
This tool search for .rpmnew, .rpmsave and .rpmorig files and ask you what to do with them: Keep current version, place back old version, watch the diff or merge.
sudo yum install rpmconf
sudo rpmconf -a
If you are using google-chrome from the Google repository, you must re-install google-chrome due to a packaging bug on the Google side of things. Make sure to adjust the command to the build type you would like to install:
sudo yum remove google-chrome-\* && sudo yum install google-chrome-stable
Enjoy Fedora 21
Subscribe to:
Posts (Atom)