Check the previous article too.
How to change the default port value for SSH to listen to?
Go to /etc/ssh/sshd_config and change the line saying
Port 22 # < --- this line to something else. e.g. 2222
#AddressFamily any
#ListenAddress 0.0.0.0
#ListenAddress ::
Restart SSH daemon by invoking /etc/rc.d/rc.sshd restart as root. This will make SSH to listen to port 2222.
How to make colorful grep command?
Suppose you like the Ubuntu’s colorful grep command. It’s actually very easy to be made on every Linux flavor. You need to alias the grep command this way:
alias grep='grep --color'
This ways grep will always be with option –color. And you need to set the color:
export GREP_COLOR=';32m'
“;32m” here means green. But you may prefer other color. They are:
red 31
green 32
yellow 33
blue 34
magenta 35
cyan 36
white 37
If you want those settings remembered, enter the 2 lines for alias and export at the end of your ~/.bashrc file. That’s all.
How to make Xfce4 to support Cyrillic keyboard?
Put the following in the file /etc/X11/xorg.conf
Section "InputDevice" Identifier "Keyboard0" Driver "kbd" Option "XkbModel" "pc105" Option "XkbLayout" "en,bg" Option "XkbOptions" "grp:alt_shift_toggle" EndSection
The option XkbLayout can also say [ru], [ua] or other Cyrillic using nations. The Option to set the button to Alt+Shift can also be changed.
The next step is to set your window manager to show the state changes. You only need to install the package xfce4-xkb-plugin.
How to change forgotten root password!?
I suppose it is YOUR own machine, and you are not trying to ruin it for someone else.
It’s a bit tricky if you don’t have root access to the machine. It can take forever to brute force a password with CLI or over SSH. I frankly don’t recommend this method. It’s for forgetful idiot script kiddies.
The only method good enough is if you have physical access to the machine.
Reboot with a live CD (or live USB stick). Your root file system is probably /dev/hdc or /dev/sda1. If unsure – use cfdisk and see which partition is made bootable. This is probably your root partition. Mount the filesystem in any mount point (e.g. /mnt/hdc).
mount /dev/hdc /mnt/hdc
Have a look at the file /mnt/hdc/etc./shadow. The file should look like this:
root:$1$w4BtrTq5$4NwUXg/ite/GysUCmaHf6.:15114:0::::: bin:*:9797:0::::: daemon:*:9797:0::::: adm:*:9797:0::::: lp:*:9797:0::::: sync:*:9797:0::::: ...
Now… The first method is to clean everything in the first line from the $ (dollar sign) to the first : (colon sign) so it looks like the other lines below. But this will leave your machine vulnerable to anyone, because your root account will not have password. SSH forbids passwordless logins, but a little healthy paranoia is never in excess. Execute the following 2 commands:
adduser idiot passwd idiot
Confirm the adduser dialog with dummy data. It’s temporary user after all.
Enter any password for the user “idiot” we just made and have a look at the live CD’s temporary /etc/shadow file:
bash-4.1# cat /etc/shadow | grep idiot idiot:$1$.Zf3P/ya$SISp/sFHX.gLPGKMDv5HJ1:15220:0:99999:7::: bash-4.1##
We have the new password hash (or encrypted password if you like it more). We copy the string starting from the $ (dollar sign) up to the first : (colon sign) without the colon sign itself in the /mnt/hdc/etc/shadow file replacing the hash written there for root password.
That’s all. You only need to reboot the machine and remove the live CD. Your new root password is set.
*(The hash shown here is for the password “alabala” and It is for an example only. I don’t recommend using such short and weak palindrome for password.)