2018年6月19日 星期二

How do I clear the terminal History?

I am using Linux Mint 17.1 Rebecca for about 2 days and accidentally typed my password into the terminal which is now displayed in the history list of commands I have previously typed.
I want to clear the terminal history completely. I have tried using the following commands in the terminal which I thought would clear the history forever but they do not:
history -c
reset
tput reset
The above commands "will" clear the history from the terminal but when I exit and bring up a new one all my previous history is still there and can all be listed again using the - history command and also by pressing the UP arrow on my keyboard. I do not want this to happen until I have totally cleared my history, then I want to continue using it.
How can I clear my terminal history completely - forever and start fresh?
Please Note: I do not want to exit the terminal without saving history just clear it forever in this one instance.

2018年6月18日 星期一

(GUI) on an Ubuntu Server

How to Install the Desktop Components (GUI) on an Ubuntu Server


If you find yourself wanting a desktop environment after you have installed Ubuntu server you can easily add it.  Pick your favorite desktop environment from the list below and run the associated command.  Remember that installation software requires root privileges so use “sudo” or switch to the root user before you begin the installation.

Unity (The Default Desktop)

sudo apt-get install ubuntu-desktop

KDE

sudo apt-get install kubuntu-desktop

LXDE (Lubuntu)

sudo apt-get install lubuntu-desktop

MATE

sudo apt-get install ubuntu-mate-desktop

Gnome

sudo apt-get install ubuntu-gnome-desktop

XFCE (Xubuntu)

sudo apt-get install xubuntu-desktop

2018年6月7日 星期四

CentOS / RHEL 7 : Change default kernel (boot with old kernel)

GRUB2 is the most common bootloader for RHEL 7 systems. A symlink to the GRUB2 config file should be present at /etc/grub2.cfg. The post describes changing the default kernel to a old kernel.

How GRUB2 selects which kernel to boot from

By default, the value for the directive GRUB_DEFAULT in the /etc/default/grub file is “saved”.
# cat /etc/default/grub
GRUB_TIMEOUT=5
GRUB_DEFAULT=saved
GRUB_DISABLE_SUBMENU=true
GRUB_TERMINAL_OUTPUT="console"
GRUB_CMDLINE_LINUX="nomodeset crashkernel=auto rd.lvm.lv=vg_os/lv_root rd.lvm.lv=vg_os/lv_swap rhgb quiet"
GRUB_DISABLE_RECOVERY="true"
This instructs GRUB 2 to load the kernel specified by the saved_entry directive in the GRUB 2 environment file, located at /boot/grub2/grubenv.
# cat /boot/grub2/grubenv 
# GRUB Environment Block
saved_entry=Red Hat Enterprise Linux Server (3.10.0-327.10.1.el7.x86_64) 7.2 (Maipo)
One can set another GRUB record to be the default, using the grub2-set-default command, which will update the GRUB 2 environment file. By default, the saved_entry value is set to the name of latest installed kernel of package type kernel. This is defined in /etc/sysconfig/kernel by the UPDATEDEFAULT and DEFAULTKERNEL directives.
# cat /etc/sysconfig/kernel
# UPDATEDEFAULT specifies if new-kernel-pkg should make
# new kernels the default
UPDATEDEFAULT=yes

# DEFAULTKERNEL specifies the default kernel package type
DEFAULTKERNEL=kernel

# MAKEDEBUG specifies if new-kernel-pkg should create non-default
# "debug" entries for new kernels.
MAKEDEBUG=yes

Change default kernel

To force a system to always use a particular menu entry, use the menu entry name as the key to the GRUB_DEFAULT directive in the /etc/default/grub file. The following command will print a list of the menu entries present in GRUB2’s configuration.
# awk -F\' /^menuentry/{print\$2} /etc/grub2.cfg
Red Hat Enterprise Linux Server (3.10.0-327.10.1.el7.x86_64) 7.2 (Maipo)                          ===> entry 0
Red Hat Enterprise Linux Server (3.10.0-229.el7.x86_64) 7.2 (Maipo)                               ===> entry 1
Red Hat Enterprise Linux Server (0-rescue-0cb6313ed65e4b36ba5daace11f3ad50) 7.2 (Maipo)           ===> entry 2
GRUB 2 supports using a numeric value as the key for the saved_entry directive to change the default order in which the kernel or operating systems are loaded. To specify which kernel should be loaded first, pass its number to the grub2-set-default command. The IDs are assigned in order the menu entries appear in the /etc/grub2.cfg file starting with 0. So the kernel 3.10.0-229.el7.x86_64 get an ID of 1.
# grub2-set-default 1
This will make 3.10.0-229.el7.x86_64 as defaul kernel which was the old kernel in the system.

Verify the new default kernel

Check the below file to see the kernel which will be loaded at next boot, crosscheck the numeric value with the menuentry in the /etc/default/grub file.
# cat /boot/grub2/grubenv |grep saved
saved_entry=1

Rebuild GRUB2

Changes to /etc/default/grub require rebuilding the grub.cfg file as follows:
# grub2-mkconfig -o /boot/grub2/grub.cfg

Reboot

Once you have verified everything and rebuilt the GRUB2 configuration file, you can go ahead an reboot the server for changes to take effect.
# shutdown -r now