Operate running systems Flashcards
To reboot the system
# reboot # systemctl reboot # shutdown -r now # init 6 #telinit 6
To shutdown the system
# halt # systemctl halt # shutdown -h now # init 0 #telinit 0
To switch off the system
# poweroff # systemctl poweroff
To suspend the system
systemctl suspend
To put the system into hibernation
systemctl hibernate
To put the system into hibernation and suspend it
systemctl hybrid-sleep
using systemd
systemctl rescue: to move to single user mode/maintenance level with mounted local file systems,
systemctl emergency: to move to single user mode/maintenance with only /root mounted file system,
systemctl isolate multi-user.target: to move to multi-user level without graphical interface (equivalent to previous run level 3),
systemctl isolate graphical.target: to move to multi-user level with graphical interface (equivalent to previous run level 5),
systemctl set-default graphical.target: to set the default run level to multi-user graphical mode,
systemctl get-default: to get the default run level.
Interupt boot process
In RHEL 7, the procedure to get access to a system during the boot process and modify the root password has changed because of the adoption of systemd.
At the beginning of the boot process, at the GRUB 2 menu, type the e key to edit.
Then, go to the kernel line, remove the rhgb quiet options and add the following string at the end:
init=/bin/sh
Press Ctrl+x to resume the boot process.
When the shell prompt appears, load the SELinux policy: # /usr/sbin/load_policy -i
Then, mount the / partition as read/write: # mount -o remount,rw /
Change the root password: # passwd Changing password for user root.
Mount the / partition as read-only: # mount -o remount,ro /
To get an instantaneous image of a server activity (use ‘virt-top‘ on a KVM hypervisor), type:
top
To get details about processes, type:
ps -edf
To start a process (here script.sh) with a low priority, type:
nice -n 10 ./script.sh
To change the priority (here +5) of an already running process, get its PID (Process ID) through top or ps (here 789) and type:
renice +5 789
alternatively # renice +5 `pgrep script.sh`
To kill the process, get its PID through top or ps (here 789) and type:
kill -9 789
alternatively # pkill script.sh
To display details about IO activities, type:
iostat
To show network card activities, type:
netstat -i
To display socket activities, type:
netstat -a
To get details about virtual memory activities (memory, swap, run queue, cpu usage, etc) every 5 second, type:
vmstat 5
To get a full report of a server activity, type:
sar -A
ystemd primary task is to manage the boot process and provides informations about it.
To get the boot process duration, type:
systemd-analyze