Problem scenario: In Linux, you want to view log activity captured recently. Looking through all the logs in /var/log can take a great deal of time. How do you correlate a recent event by finding log files that were modified in the past 10 minutes?
Solution Run this command: find /var/log -mmin -10
This command will find files in /var/log and its subdirectories. It will only find files that were modified within the past 10 minutes. This should help you find the event in the logs to the extent was captured.
Problem scenario: You know the Linux username that you want to use. But you do not know its corresponding UID or GID. How do you find the UID when you only know the username?
Problem Scenario: You downloaded an .ova file. You want to create a virtual server (a clone) with this pre-configured OS. How do you use Oracle VirtualBox to use this .ova file?
Solution 1. Open Oracle VirtualBox 2. Go to File -> Import Appliance (or press Ctrl-i) 3. Select the OVA file 4. Click "Next" 5. Now you are ready to start the VM.
Problem scenario You are running Oracle VirtualBox on a Windows host. You have Linux CentOS guest server. Guest additions fails to install. You tried to run this script VBoxLinuxAdditions.run. The run fails with an error saying " check /var/log/VBoxGuestAdditions.log for details."
You examined /var/log/VBoxGuestAdditions.log, and it said this: "vboxadd.sh: failed: Look at /var/log/vboxadd-install.log to find out what went wrong. vboxadd.sh: failed: Please check that you have gcc, make, the header files for your Linux kernel and possibly perl installed."
You have already installed gcc, make, Perl and updated the Linux kernel. To investigate the kernel you use a "uname -r" command. You also go to /usr/src/kernels/ and find a directory name that does not match the results of the "uname -r" command. In /usr/src/kernels/ you execute the "ls" command and find this directory: 3.10.0-514.10.2.el7.centos.plus.i686
You then issue this command: uname -r You find this result: 3.10.0-327.el7.i686
Under normal circumstances, these strings match. What do you do to install Oracle VirtualBox Guest Additions on a Linux CentOS server?
Solution Reboot the CentOS guest. After you run "yum update kernel*" the changes (assuming changes were made) will not take effect completely until you reboot. Then install guest additions. The errors should go away.
Problem scenario: You edited the /etc/hosts file and the /etc/sysconfig/network file to have a new hostname. You used the "hostname newHostname" command (where newHostname is the desired new host name). You rebooted the server and the hostname is still localhost.localdomain. How do you configure the host name to be different?
Solution None of the above steps were necessary for changing the hostname for the purposes of having the "hostname" command return a new hostname. The above steps by themselves would not change the hostname that you see on the command prompt either. To change the hostname for the "hostname" command to return the new hostname, and to have the character prompts reflect a new hostname, do this:
1. Modify /etc/hostname to the desired new hostname. 2. Save the file. 3. Reboot for the hostname on the character prompts to reflect the new hostname.
Problem scenario: You want to find the name of the network interface that can connect to the default gateway on your Linux CentOS 7.x server. Typical new deployments of CentOS 7.x using the minimal .ISO do not have the "route" utility nor the "ifconfig" utility installed. How do you find the interface's name (e.g., eth0) without using the "route" command?
Solutions
Solution #1 (preferred)
The easiest solution is to use this command: ip route | awk '{print $3}'
Solution #2
This solution avoids the "ip route". This solution takes more time.
a. Run this command: ip addr show b. Evaluate the results. The results of the above command will have integer values followed by discrete interfaces. For example you'll see "1: lo" and "2: ..."
The first result, "1: lo", is a loopback interface. The second result, "2: enp0s3", will be the interface you want (assuming there are only two interfaces). The lo interface by default will never have the default gateway. For a simple CentOS server the other interface will.
For CentOS 7.3 servers installed from the current .ISO (as of March 17, 2017) with the default settings, the name of the interface that can connect to the default gateway is "enp0s3" as shown above. There may be multiple interfaces with multiple default gateways for servers in complex environments with multiple NICs.
Also note that the corresponding file for this interface name will have a name that is prefaced with "ifcfg-". Therefore in /etc/sysconfig/network-scripts/ the file that governs the interface will be "ifcfg-enp0s3".