13 July 2015

system wide execution code

/etc/profile

Runs all executables in

/etc/profile.d/

system control

systemctl start/stop postgres
systemctl list-units --type=service

    systemctl -t service

Copy & paste in console

copy selection: ctrl+shift+insert

cut selection: shift+insert

SFTP

sudo yum install vsftpd

https://docs.fedoraproject.org/en-US/Fedora/17/html/System_Administrators_Guide/s3-ftp-vsftpd-conf.html

systemctl start/stop/restart vsftpd.service

systemctl enable service_name.service » start auto when reboot

System upgrade

Linux version

ls -ld /etc/*release* /etc/*version*

    -rw-r--r-- 1 root root  11 feb 20  2014 /etc/debian_version
    -rw-r--r-- 1 root root 105 jul 22  2014 /etc/lsb-release
    -rw-r--r-- 1 root root 249 jul 22  2014 /etc/os-release

    cat /etc/lsb-release
    cat /etc/os-release

    cat /etc/*release* /etc/*version*
  

Linux shutdown/restart

Restart linux

  # reboot

Delayed reboot and with message to other connetions

The shutdown command can be used to restart a system with the r option instead of the h option. Usage is same as before. Just replace the h option with r option.

  # shutdown -r +5 "Server will restart in 5 minutes. Please save your work."

All other logged in users will see a broadcast message in their terminal like this

  [root@dhcppc1 ~]# 
    Broadcast message from root@dhcppc1
    (/dev/tty1) at 21:35 ...
  The system is going down for reboot in 5 minutes!
      Server will restart in 5 minutes. Please save your work.

At this point a shutdown can be cancelled by calling shutdown with “c” option.

  # shutdown -c

REISUB - R E I S U B key strokes

The above shown commands can be used when you are in control of your system. What if the system has hanged and is not responding at all. And you do not want to press the power button on the CPU which might lead to data corruption. To save from such a situation, comes the magic sysRQ keys.

A special combination of key presses that will allow you to reboot your linux system, no matter how much it is hanged. Check the wikipedia article. for more information.

A common use of the magic SysRq key is to perform a safe reboot of a Linux computer which has otherwise locked up. This can prevent a fsck being required on reboot and gives some programs a chance to save emergency backups of unsaved work.

Warning : Pressing the following keys would instantly reboot your system. Its similar to pressing the power button of your CPU or executing the reboot -f command.

ALT + PrintScreen + B

Now in place of the B key we have to use R E I S U letters first. Each key does a task as mentioned below

unRaw      (take control of keyboard back from X),
 tErminate (send SIGTERM to all processes, allowing them to terminate gracefully),
 kIll      (send SIGKILL to all processes, forcing them to terminate immediately),
  Sync     (flush data to disk),
  Unmount  (remount all filesystems read-only),
reBoot.
  1. Hold down the Alt and SysRq (Print Screen) keys.
  2. While holding those down, type the following keys in order, several seconds apart: R E I S U B
  3. Computer should reboot.

Make sure to have some time gap between each of keys R E I S U B.

The sysrq feature can be controlled by changing the value of /proc/sys/kernel/sysrq. To check if sysrq is enabled on the system or not, echo the value. It should be non zero.

  $ cat /proc/sys/kernel/sysrq
  176