Có một số bạn thắc mắc là khi sử dụng ESXi Shell thì liệu có chương trình lệnh “history” để xem lại lịch sử lệnh đã gõ trên ESXi shell không ? Thì mình cũng xin trình bày là trên ESXi shell hiện không hỗ trợ lệnh nào giống ‘history‘ của Linux cả .
Có thể bạn sẽ quan tâm chủ đề khác:
– Hướng dẫn kích hoạt SSH trên vSphere ESXi
– Hướng dẫn cài đặt VMWare ESXi 6.5 với hình ảnh chi tiết
– Hướng dẫn reset mật khẩu root trên ESXi
Vậy làm thế nào để có thể xem thông tin lịch sử lệnh đã gõ trên ESXi Shell đây ? Đối với VMWare vSphere ESXi phiên bản 5.x trở lên thì VMWare đã thực hiện lưu các câu lệnh đã đánh trên ESXi shell tại file ‘/var/log/shell.log‘. File ‘shell.log‘ này sẽ lưu toàn bộ lệnh đã được gõ bởi toàn bộ user trên ESXi. Cực kì tiện lợi phải không nào.
# ssh root@192.168.100.100 Password: The time and date of this login have been sent to the system logs. VMware offers supported, powerful system administration tools. Please see www.vmware.com/go/sysadmintools for details. The ESXi Shell can be disabled by an administrative user. See the vSphere Security documentation for more information. # cat /var/log/shell.log 2017-11-26T13:15:40Z shell[328760]: Interactive shell session started 2017-11-26T13:18:20Z shell[328760]: [root]: vim-cmd /hostsvc/hostsummary | grep inMaintenanceMode 2017-11-26T13:19:00Z shell[328760]: [root]: vimsh -n -e /hostsvc/hostsummary | grep inMaintenanceMode 2017-11-26T13:22:41Z shell[328760]: [root]: vim-cmd vmsvc/getallvms 2017-11-28T05:50:21Z shell[447298]: Interactive shell session started 2017-11-28T05:50:23Z shell[447298]: [root]: cd /vmfs 2017-11-28T05:50:24Z shell[447298]: [root]: ll 2017-11-28T05:50:24Z shell[447298]: [root]: ls 2017-11-28T05:50:26Z shell[447298]: [root]: cd volumes/ 2017-11-28T05:50:26Z shell[447298]: [root]: ls 2017-11-28T05:50:28Z shell[447298]: [root]: cd datastore1/ 2017-11-28T05:50:29Z shell[447298]: [root]: ls 2017-11-28T05:50:32Z shell[447298]: [root]: cd ISO/ 2017-11-28T05:50:32Z shell[447298]: [root]: ls 2017-11-28T05:50:58Z shell[447298]: [root]: pwd
Như vậy bạn đã biết cách xem lại lịch sử lệnh (history command) trên ESXi Shell rồi phải không nào ?! Chúc các bạn thành công. Nếu có vấn đề gì đừng ngại comment trao đổi cùng Cuongquach.com nhé.
Tham khảo:
– https://kb.vmware.com/s/article/2014494
Nguồn: https://cuongquach.com/