Bash function to check if it’s friday

Ever wondered if today’s Friday? Yeah me too, every day.

Keep yourself updated with this simple function.

 

1) Open your profile settings file
nano ~/.bashrc

2) Enter the following function in the bottom

yay() {
    day=$(date +%u)
    if [ "$day" == "5" ];
    then
        echo "YAY, IT'S FRIDAY!!!"
    else
        echo "Not to bring you down, but it's not friday yet :("
    fi
}

3) Reload your config file
. ~/.bashrc

4) Try it out! Just type yay in your terminal window whenever you wonder if it’s Friday or not.

Delete entry from Bash history

First type history to see your bash command history.

Find the entry/command you’d like to erase from history and note the id on the left column.

history -d 1234

Replace 1234 with the actual ID.

Example:

$ history
  640  cd ~
  641  ls -la
  642  crontab -e
  643  exit
  644  free -h
  645  df -h
$ history -d 645
$ history
  640  cd ~
  641  ls -la
  642  crontab -e
  643  exit
  644  free -h

As you can see, the df -h command was erased from the history.

Create a daemon for Linux

# !/bin/sh
# /etc/init.d/daemond

### BEGIN INIT INFO
# Provides:             daemond
# Required-Start:       $remote_fs $syslog
# Required-Stop:        $remote_fs $syslog
# Default-Start:        2 3 4 5
# Default-Stop:         0 1 6
# Short-Description:    Skeleton daemon
# Description:          Skeleton daemon
### END INIT INFO

case "$1" in
    start)
        echo 'hello world'
        ;;
    stop)
        killall daemond -q
        ;;
    *)
      echo "Usage: /etc/init.d/checkconnectiond {start|stop}"
      exit 1
      ;;
esac

exit 0