1.history display time, user and command
Vim /etc/profile
Export histtimeformat= "%F%T ' who-u am I 2>/dev/null| awk ' {print $NF} ' |sed-e ' s/[()]//g ' WhoAmI ' "
2. View the System log
Cat/var/log/messages # # #以centos7为例
Earlier version may need to set up, first download bash source code, you can download from gnu.org, here do not elaborate, the system needs to install GCC and other compilation environment. We use the bash4.4 version to do the demo.
Modify Source: bashhist.c
Modify the source Config-top.h, Cancel/#define syslog_history/this line of comments
The compilation parameters used in this article are:./configure–prefix=/usr/local/bash, after successful installation, the following directories:
You can modify the user shell environment in/etc/passwd, or you can replace the original bash binaries directly with the compiled files, but it is best to back up the original files.
There are two points to note when replacing:
1, must give executable permissions, the default is some, but sometimes downloaded to the Windows system, then upload there is no executable permission, here must be sure, otherwise you will regret;
2, replace the original bash is occupied, you can modify the original user's bash environment and then replace.
3. View recently changed files
Find the. php file in the current directory that was modified in the last 24 hours, and list the details of find.-name ' *.inc '-mtime 0-ls find the regular files that were modified in the current directory, the last 1 days ago. find.-type f-mtime +1 Note: You can view the command book with find--help and man find
4. Lock system File boot directory
Vim/etc/fstab
Plus the last line.
Label=/boot/ boot ext2defaults,ro1 2
Set the owner of the file
Chown Root:root/etc/fstab
Set/etc/grub.conf owner (owner) and group as root user:
Chown root:root/etc/grub.conf
The/etc/grub.conf file is set to read and write to root only:
chmod og-rwx/etc/grub.conf
Single-user mode requires authentication:
Sed-i "/single/s/sushell/sulogin/"/etc/sysconfig/init
Sed-i "/prompt/s/yes/no/"/etc/sysconfig/init
5. Enhanced SSH security, modify the default port
Reference https://www.ssh.com/ssh/sshd_config/
Linux Learning Essay 3 Linux Security