Skip to content

Linux General Topics

Fix Locales (Fix Bash Local Error)

Generate en_US.UTF-8 locale

locale-gen "en_US.UTF-8"

Set the Locale, Find the en_US.UTF-8 in the list and select it, at the following screen select it.

dpkg-reconfigure locales

Set System Time With Time Zone (timedatectl ntp)

Find your time zone with timedatectl list-timezones use grep for easier results:

timedatectl list-timezones | grep "Toronto"

The output should look like this:


Now set the Time Zone and active it.

timedatectl set-timezone America/Toronto
timedatectl set-ntp true

Now test timedatectl status

timedatectl status

Check your system time


Disable SSH Login Welcome Message

To disable

touch ~/.hushlogin

To re-enable

rm -rf ~/.hushlogin

Run Script On Boot - Crontab

Only add sudo if your script needs superuser privileges. Then add this to your crontab:

(sudo) crontab -e

Add to the end of the Cront tab:

@reboot /path/to/

Redirect Output to a File and Stdout With tee

The command you want is named tee:

foo | tee output.file

For example, if you only care about stdout:

ls -a | tee output.file

If you want to include stderr, do:

program [arguments...] 2>&1 | tee outfile

2>&1 redirects channel 2 (stderr/standard error) into channel 1 (stdout/standard output), such that both is written as stdout. It is also directed to the given output file as of the tee command.

Furthermore, if you want to append to the log file, use tee -a as:

program [arguments...] 2>&1 | tee -a outfile

Add Permanent Path to Application

First find the location of the Application/Service:

find / -name ApplicationName

Go to the path where the application is located

cd "../../../ApplicationName"

Run this command for ZSH:

echo 'export PATH="'$(pwd)':$PATH"' >> ~/.zshrc && source ~/.zshrc

Run this command for "Bash Profile":

echo 'export PATH="'$(pwd)':$PATH"' >> ~/.profile && source ~/.profile

Run this command for "Bash":

echo 'export PATH="'$(pwd)':$PATH"' >> ~/.bashrc && source ~/.bashrc

To create a symbolic link in Unix/Linux, at the terminal prompt, enter:

ln -s source_file target_file

to remove symbolic link use the rm command on the link

Disable IPv6

For current session:

echo 1 > /proc/sys/net/ipv6/conf/<interface-name>/disable_ipv6
echo 1 > /proc/sys/net/ipv6/conf/eth0/disable_ipv6


edit /etc/sysctl.conf and add to the end of the config

net.ipv6.conf.all.disable_ipv6 = 1

Save. Then run:

sudo sysctl -p /etc/sysctl.conf

Find PTR Owner - Reversal Look Up

dig NS

Open Last Edited File

less `ls -dx1tr /usr/local/cpanel/logs/cpbackup/*|tail -1`

Kill Process That Runs More Than X Time

Kill cgi after 30 secs:

for i in `ps -eo pid,etime,cmd|grep cgi|awk '$2 > "00:30" {print $1}'`; do kill $i; done