Showing posts with label Ubuntu. Show all posts
Showing posts with label Ubuntu. Show all posts

Saturday, June 30, 2018

Setting an attractive message of the day(MOTD) banner in Ubuntu 16,Linux Teacher Sourav,Kolkata 09748184075

# install lsb-release
apt-get install lsb-release
# install figlet to enable ASCII art
apt-get install figlet
# install update-motd software
apt-get install update-motd
# delete default directory
rm -r /etc/update-motd.d/
# create new directory
mkdir /etc/update-motd.d/
# create dynamic files
touch /etc/update-motd.d/00-header ; touch /etc/update-motd.d/10-sysinfo ; touch /etc/update-motd.d/90-footer
# make files executable
chmod +x /etc/update-motd.d/*
# remove MOTD file
rm /etc/motd.dynamic


The 00-header file should contain

#!/bin/sh
#
#    00-header - create the header of the MOTD
#    Copyright (c) 2013 Nick Charlton
#    Copyright (c) 2009-2010 Canonical Ltd.
#
#    Authors: Nick Charlton
#             Dustin Kirkland
#
#    This program is free software; you can redistribute it and/or modify
#    it under the terms of the GNU General Public License as published by
#    the Free Software Foundation; either version 2 of the License, or
#    (at your option) any later version.
#
#    This program is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.
#
#    You should have received a copy of the GNU General Public License along
#    with this program; if not, write to the Free Software Foundation, Inc.,
#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.

[ -r /etc/lsb-release ] && . /etc/lsb-release

if [ -z "$DISTRIB_DESCRIPTION" ] && [ -x /usr/bin/lsb_release ]; then
        # Fall back to using the very slow lsb_release utility
        DISTRIB_DESCRIPTION=$(lsb_release -s -d)
fi

figlet $(hostname)
printf "\n"

printf "Welcome to %s (%s).\n" "$DISTRIB_DESCRIPTION" "$(uname -r)"
printf "\n"


****************************************************************************************
The 10-sysinfo file should contain


#!/bin/sh
TERM=linux
export TERM
upSeconds="$(/usr/bin/cut -d. -f1 /proc/uptime)"
secs=$((${upSeconds}%60))
mins=$((${upSeconds}/60%60))
hours=$((${upSeconds}/3600%24))
days=$((${upSeconds}/86400))
UPTIME=`printf "%d days, %02dh%02dm%02ds" "$days" "$hours" "$mins" "$secs"`

# get the load averages
read one five fifteen rest < /proc/loadavg

echo "$(tput setaf 2)
   .~~.   .~~.    `date +"%A, %e %B %Y, %r"`
  '. \ ' ' / .'   `uname -srmo`$(tput setaf 1)
   .~ .~~~..~.
  : .~.'~'.~. :   Uptime.............: ${UPTIME}
 ~ (   ) (   ) ~  Memory.............: `cat /proc/meminfo | grep MemFree | awk {'print $2'}`kB (Free) / `cat /proc/meminfo | grep MemTotal | awk {'print $2'}`kB (Total)
( : '~'.~.'~' : ) Load Averages......: ${one}, ${five}, ${fifteen} (1, 5, 15 min)
 ~ .~ (   ) ~. ~  Running Processes..: `ps ax | wc -l | tr -d " "`
  (  : '~' :  )   IP Addresses.......: `ip a | grep glo | awk '{print $2}' | head -1 | cut -f1 -d/` and `wget -q -O - http://icanhazip.com/ | tail`
   '~ .~~~. ~'    Weather............: `curl -s "http://rss.accuweather.com/rss/liveweather_rss.asp?metric=1&locCode=EUR|UK|UK001|NAILSEA|" | sed -n '/Currently:/ s/.*: \(.*\): \([0-9]*\)\([CF]\).*/\2°\3, \1/p'`
       '~'
$(tput sgr0)"


***************************************************************************************************
I also have a backup 10-sysinfo file which contains

#!/bin/bash
#
#    10-sysinfo - generate the system information
#    Copyright (c) 2013 Nick Charlton
#
#    Authors: Nick Charlton
#
#    This program is free software; you can redistribute it and/or modify
#    it under the terms of the GNU General Public License as published by
#    the Free Software Foundation; either version 2 of the License, or
#    (at your option) any later version.
#
#    This program is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.
#
#    You should have received a copy of the GNU General Public License along
#    with this program; if not, write to the Free Software Foundation, Inc.,
#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.

date=`date`
load=`cat /proc/loadavg | awk '{print $1}'`
root_usage=`df -h / | awk '/\// {print $(NF-1)}'`
memory_usage=`free -m | awk '/Mem:/ { printf("%3.1f%%", $3/$2*100) }'`
swap_usage=`free -m | awk '/Swap:/ { printf("%3.1f%%", $3/$2*100) }'`
users=`users | wc -w`
time=`uptime | grep -ohe 'up .*' | sed 's/,/\ hours/g' | awk '{ printf $2" "$3 }'`
processes=`ps aux | wc -l`
ip=`ifconfig $(route | grep default | awk '{ print $8 }') | grep "inet addr" | awk -F: '{print $2}' | awk '{print $1}'`

echo "System information as of: $date"
echo
printf "System Load:\t%s\tIP Address:\t%s\n" $load $ip
printf "Memory Usage:\t%s\tSystem Uptime:\t%s\n" $memory_usage "$time"
printf "Usage On /:\t%s\tSwap Usage:\t%s\n" $root_usage $swap_usage
printf "Local Users:\t%s\tProcesses:\t%s\n" $users $processes
echo
/usr/lib/update-notifier/update-motd-reboot-required
/usr/lib/update-notifier/apt-check --human-readable
echo

*************************************************************************************************

The 90-footer file contains

#!/bin/sh
#
#    99-footer - write the admin's footer to the MOTD
#    Copyright (c) 2013 Nick Charlton
#    Copyright (c) 2009-2010 Canonical Ltd.
#
#    Authors: Nick Charlton
#             Dustin Kirkland
#
#    This program is free software; you can redistribute it and/or modify
#    it under the terms of the GNU General Public License as published by
#    the Free Software Foundation; either version 2 of the License, or
#    (at your option) any later version.
#
#    This program is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.
#
#    You should have received a copy of the GNU General Public License along
#    with this program; if not, write to the Free Software Foundation, Inc.,
#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.

[ -f /etc/motd.tail ] && cat /etc/motd.tail || true

***********************************************************************************************


Now you should see this motd message when you try to login in a different run level

to see this in gui which is run level 7 you have to type

cat /var/run/motd.dynamic



Source:
https://oitibs.com/ubuntu-16-04-dynamic-motd/
https://ownyourbits.com/2017/04/05/customize-your-motd-login-message-in-debian-and-ubuntu/

reference
https://www.resellerspanel.com/articles/cloud-web-hosting-articles/crontab/which-files-can-be-executed-with-crontab/
https://askubuntu.com/questions/319528/how-to-see-the-details-which-ubuntu-shows-at-the-time-of-login-anytime




Tuesday, January 13, 2015

Pen Drive mounted as read only error

Recently I have come across this error in Ubuntu

using mount command find the mounted location

and then

mount -o remount,rw /mount/point

Thursday, December 18, 2014

Install lazarus on Ubuntu 14.04


I could not install fpc because it is broken

So I installed

apt-get install fpc-source

Then Downloaded 64 bit version of fpc 

http://ftp.psu.ru/programming/fpc/2.6.2/x86_64-linux/

then 

tar -xvf fpc-2.6.2.x86_64-linux.tar

cd fpc-2.6.2.x86_64-linux/

sudo sh install.sh

apt-get install lazurus



"The package "leakview" is installed, but no valid package file (.lpk) was found" error solved when installing lazarus on Ubuntu 14.04


Create a file in /usr/lib/lazarus/1.0.10/packager/globallinks named leakview.lpk.

 Write these lines on that file..

(less then)?xml version="1.0" encoding="UTF-8"?(greater than)
(less then)CONFIG(greater than)
  (less then)Package Version="4"(greater than)
    (less then)PathDelim Value="\"/(greater than)
    (less then)Name Value="leakview"/(greater than)
    (less then)AddToProjectUsesSection Value="True"/(greater than)
    (less then)Author Value="Dmitry 'skalogryz' Boyarintsev"/(greater than)
    (less then)CompilerOptions(greater than)
      (less then)Version Value="12"/(greater than)
      (less then)PathDelim Value="\"/(greater than)
      (less then)SearchPaths(greater than)
        (less then)UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)\$(LCLWidgetType)"/(greater than)
      (less then)/SearchPaths(greater than)
      (less then)Parsing(greater than)
        (less then)SyntaxOptions(greater than)
          (less then)CStyleOperator Value="False"/(greater than)
          (less then)UseAnsiStrings Value="False"/(greater than)
        (less then)/SyntaxOptions(greater than)
      (less then)/Parsing(greater than)
      (less then)Linking(greater than)
        (less then)Debugging(greater than)
          (less then)GenerateDebugInfo Value="False"/(greater than)
          (less then)UseLineInfoUnit Value="False"/(greater than)
        (less then)/Debugging(greater than)
      (less then)/Linking(greater than)
      (less then)Other(greater than)
        (less then)CompilerPath Value="$(CompPath)"/(greater than)
      (less then)/Other(greater than)
    (less then)/CompilerOptions(greater than)
    (less then)Description Value="Leak View. allows fast navigation trough HeapTrc (and other?) leaks."/(greater than)
    (less then)Version Major="1"/(greater than)
    (less then)Files Count="4"(greater than)
      (less then)Item1(greater than)
        (less then)Filename Value="heaptrcview.lfm"/(greater than)
        (less then)Type Value="LFM"/(greater than)
      (less then)/Item1(greater than)
      (less then)Item2(greater than)
        (less then)Filename Value="heaptrcview.pas"/(greater than)
        (less then)HasRegisterProc Value="True"/(greater than)
        (less then)UnitName Value="HeapTrcView"/(greater than)
      (less then)/Item2(greater than)
      (less then)Item3(greater than)
        (less then)Filename Value="leakinfo.pas"/(greater than)
        (less then)UnitName Value="leakinfo"/(greater than)
      (less then)/Item3(greater than)
      (less then)Item4(greater than)
        (less then)Filename Value="dbginforeader.pas"/(greater than)
        (less then)UnitName Value="DbgInfoReader"/(greater than)
      (less then)/Item4(greater than)
    (less then)/Files(greater than)
    (less then)i18n(greater than)
      (less then)EnableI18N Value="True"/(greater than)
      (less then)OutDir Value="languages"/(greater than)
    (less then)/i18n(greater than)
    (less then)Type Value="RunAndDesignTime"/(greater than)
    (less then)RequiredPkgs Count="2"(greater than)
      (less then)Item1(greater than)
        (less then)PackageName Value="CodeTools"/(greater than)
      (less then)/Item1(greater than)
      (less then)Item2(greater than)
        (less then)PackageName Value="IDEIntf"/(greater than)
      (less then)/Item2(greater than)
    (less then)/RequiredPkgs(greater than)
    (less then)UsageOptions(greater than)
      (less then)UnitPath Value="$(PkgOutDir)\"/(greater than)
    (less then)/UsageOptions(greater than)
    (less then)PublishOptions(greater than)
      (less then)Version Value="2"/(greater than)
      (less then)IgnoreBinaries Value="False"/(greater than)
    (less then)/PublishOptions(greater than)
  (less then)/Package(greater than)
(less then)/CONFIG(greater than)


The xml file is modified ,The "<" symbol replaced by less then and ">" is replaced by greater than

However the xml file is at 

http://svn.freepascal.org/svn/lazarus/trunk/components/leakview/leakview.lpk


Then go the /usr/lib/lazarus/1.0.10/packager/globallinks directory and chek if there is a file called leakview.lpl,open the file in nano and see if this line is there

$(LazarusDir)/components/leakview/leakview.lpk

restart lazarus and you are done

source:http://forum.lazarus.freepascal.org/index.php?topic=22500.0



Sourav Bhattacharya

Linux Faculty/Enthusiast for 7 years

Kolkata




Tuesday, December 2, 2014

Log out from ubuntu 14.04

gnome-session-quit was not working for me

So I used

sudo pkill -u username

however sudo service lightdm restart did not work for me,got in a unresponsive blank screen