How to view all messages generated by the system since the last reboot on RHEL7/CentOS 7?
journalctl
journalctl | grep ssh
The boot process, kernel, and all systemd services put messages into the systemd journal.
What are 7 different ways of showing the kernel messages?
dmesg
journalctl -k
cat /var/log/kern.log
tail -f /var/log/syslog
less /var/log/messages
grep kernel /var/log/messages
sudo find /var/log -name 'kern*'
How can you continuously monitor logs as they come in?
journalctl
tail -f /var/log/messages
You can use tail -f /var/log/messages
to continuously monitor the messages log file.
Where can you find messages related to the installation of Linux?
anaconda.log
/var/log/anaconda/anaconda.log
Messages related to the installation of Linux can be found in the anaconda.log
file or /var/log/anaconda/anaconda.log
.
Where are most of the log files located?
/var/log
Most of the log files are located in the /var/log
directory.
How to check system load without the top
command?
w
uptime
By default, load average is shown in how many intervals?
glances
shows load average by time.How can you get the physical and virtual memory statistics?
free
-m or -g
vmstat -a
(active and inactive memory), d
(disk stats)vmstat -a 2 4
(every 2 seconds with 4 intervals)How to check CPU utilization and other statistics?
sar
, which is part of the sysstat package.sar -u
shows CPU utilization stats for the current day.sar -u 2 3
shows real-time CPU stats every 2 seconds with 3 intervals.sar -r
for memory utilization.sar -S
for swap space.How to find the process ID of a process and kill it immediately?
cat
command and then:pidof cat
to find the process ID.kill -9 <PID>
to kill the process. -9
is the priority.How to list all open files by a specified user?
lsof -u <user>
How to list all files opened by a particular command?
lsof -c <command>
How can you list all network connections by port 22?
lsof -i :22
How to check scheduled jobs?
crontab -l
If your cron job didn't work, how would you check?
time
,crontab
entry,/var/log/messages
How to check open port on Linux system?
netstat putan | grep :22
How to check the IP of the VM
hostname -I