Sunday, May 23, 2010

Ubuntu: How to see the logged users, username with date/time

This is shell script for logged users, our username with logged date/time.

Open a text file in terminal

sudo gedit logged.sh

copy and paste the following lines

#!/bin/bash
# Write a shell script called hello which output the following:
# + Your username
# + The time and date
# + Who is logged on
# + also output a line of asterices (*******) after each section

# function to display a line of asterices
function line(){
echo "*************************************************"
}

echo "Your username : $(echo $USER)"
line # call function

echo "Current date and time : $(date)"
line

echo "Currently logged on users:"
who
line

Then save and exit

In terminal type the following command

sudo chmod +x logged.sh

./logged.sh

The out put is

2 comments:

yun said...

./loggedsh ==>./loggde.sh

arulmozhi r said...

Thanks to your comments