Skip to content
Authors: fire1ce | Created: 2021-08-27 | Last update: 2022-09-22

General Snippets

Disable SSH Login Welcome Message

To disable

touch ~/.hushlogin

To re-enable

rm -rf ~/.hushlogin

Change Sudo Password Requirement Timeout In Linux

To change sudo password timeout limit in Linux, run:

sudo visudo

This command will open the /etc/sudoers file in nano editor.

Find the following line:

Defaults env_reset

Change it like below the 30 is the number of minutes you want to set the timeout to.

Defaults env_reset, timestamp_timeout=30

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 "shell Profile":

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

Run this command for "shell":

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

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