Thursday, September 19, 2024

Enable bash history timestamp Linux

From ChatGPT

1. **Open or create the `.bashrc` file** in your home directory:

   ```bash

   $ nano ~/.bashrc

   ```

2. **Add the following lines** at the end of the file to enable timestamps in `bash_history`:

   ```bash

   # Enable timestamps in bash history

   HISTTIMEFORMAT="%F %T "

   ```

   - `%F` will add the date in `YYYY-MM-DD` format.

   - `%T` will add the time in `HH:MM:SS` format.

3. **Save and exit** the file (`Ctrl+O` to save, `Enter`, and then `Ctrl+X` to exit).

4. **Apply the changes** by running the following command to reload your `.bashrc`:

   ```bash

 $  source ~/.bashrc

   ```

Now, every command in your Bash history will be prefixed with the timestamp. To view the history with timestamps, simply run:

```bash

$ history

```

Add

  • แยกทำแต่ละ  user

No comments:

Post a Comment

Popular Posts