Skip to content

gauravchile/LinuxCommandLogging

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

8 Commits
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ“ Linux Command Logger

Automates hourly command logging for Linux users and optionally backs up logs to a remote server.
Logs typed commands only (not output) with user, timestamp, current directory, TTY/IP, and command details.


🌟 Features

  • Hourly log files per user
  • Logs include: user, timestamp, current directory, TTY/IP, command
  • Optional remote backup using rsync
  • Automatic log rotation with logrotate
  • Minimal performance impact

πŸ“ Project Structure

Linux_Command_Logger/
β”‚
β”œβ”€ README.md                     # Project documentation
β”œβ”€ session_record.sh        # Setup and configuration script
└─ /etc/profile.d/command_logging.sh  # Script sourced by users' shells

βš™οΈ Setup Instructions

  1. Make the setup script executable:
sudo chmod +x session_record.sh
  1. Run the setup script:
sudo ./session_record.sh
  1. Source the command logger script manually:
source /etc/profile.d/command_logging.sh
  1. Add it to all new and existing users’ shells:
echo "source /etc/profile.d/logging.sh" | sudo tee -a /etc/bash.bashrc

πŸ’‘ Tip: This ensures all future users automatically log commands when they log in.


🎯 Skills Demonstrated

  • Linux user session monitoring
  • Bash scripting for automation
  • Log rotation and management (logrotate)
  • Remote backup using rsync
  • Security-conscious logging

πŸ’‘ Best Practices

  • Store logs in a secure directory with proper permissions.
  • Regularly check backup logs to ensure remote sync is working.
  • Combine with cron jobs for hourly automation.
  • Useful for auditing, training, or lab monitoring.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages