Skip to content

General Snippets

Disable SSH Login Welcome Message

To disable

touch ~/.hushlogin

To re-enable

rm -rf ~/.hushlogin

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

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

Last update: September 2, 2021
Back to top