Shashikant shah

Tuesday 14 January 2014

Recycle bin and History with date,time on RHEL & CentOS


Recycle bin and History with date,time On RHEL & CentOS

In my production server, somebody executed rm -rf and my important files are removed permanently. So, I thought of having a recycle bin, so if a user do rm the file will move to RecycleBin rather than deleting from server
To add recycling bin functionality, a user can simply add an alias to their .bashrc file, in a user's home directory, that overrides the rm command.

alias rm='mv - -target-directory=$HOME/.Trash'
# init 6 {restart server}

User only run below command :-

# rm -f somefile
# rm somefile

Not run below command :-

# rm -rf somfile
{showing error}

mv: invalid option -- r

Try `mv --help' for more information.


History: Display Date And Time

How do I display shell command history with date and time under UNIX or Linux operating systems?

# HISTTIMEFORMAT="%d/%m/%y %T "
        OR
# echo 'export HISTTIMEFORMAT="%d/%m/%y %T "' >> ~/.bash_profile
%d - Day
%m - Month
%y - Year
%T – Time
To see history type
# history
  986  11/03/10 04:31:36 memcached-tool  10.10.28.22:11211 stats
  987  11/03/10 04:31:36 w
  988  11/03/10 04:31:37 iostat
  989  11/03/10 04:31:37 top
  990  11/03/10 04:31:37 at
  991  11/03/10 04:31:38 atop
  992  11/03/10 04:31:40 collectl
  993  11/03/10 04:31:41 grep CPU /proc/cpuinfo
  994  11/03/10 04:31:45 vmstat 3 100

No comments:

Post a Comment