Saturday, October 8, 2016

shutdown command

Linux PC can be shut down by using "shutdown" command.

# shutdown

By using options, shutdown command is used for a variety of purposes.

  • -h  : shut down PC
  • -r   : Restart PC after shut down
  • -f   : fsck[1] is skipped when PC is re-started
  • -F  : fsck is forced when PC is re-started
  • -k  : Send warning messages as if the shutdown is real but PC isn't shutdown actually.
  • -c  : Cancel a pending shutdown. (This does not apply to "shutdown now", which does not wait before shutting down.)


The following command shutdowns PC in 15 minutes and sends a warning message saying "please prepare for the shutdown in 15 minutes." But you need to be root to perform this command.

# shutdown -h +15 "please prepare for the shutdown in 15 minutes."

If you just want to send warning messages as if the shutdown is real, use -k option. But you need to be root to perform this command also.

# shutdown -k now "please prepare for the shutdown."

The following command shuts down the PC at 22:00.

# shutdown -h 22:00

The following command restarts the PC immediately.

# shutdown -r now

Once shutdown command is executed, users can't log in the system since then until the system is actually shut down and get restarted. The closer the planned time to be shutdown becomes, the more the users get warning messages.

[1] Linux fsck utility is used to check and repair Linux filesystems


References
Computer Hope http://www.computerhope.com/unix/ushutdow.htm Visited on 9th October 2016

Tuesday, October 4, 2016

PCI device and lspci

Citation from wikipedia "device file"
In Unix-like operating systems, a device file orspecial file is an interface for a device driverthat appears in a file system as if it were an ordinary file. There are also special files inMS-DOSOS/2, and Microsoft Windows. They allow software to interact with a device driver using standard input/output system calls, which simplifies many tasks and unifies user-space I/O mechanisms.
Device files often provide simple interfaces to peripheral devices such as printers and serial ports, but they can also be used to access specific resources on those devices, such asdisk partitions. Finally, device files are useful for accessing system resources that have no connection with any actual device such asdata sinks and random number generators.

And... device information like PCI devices which Linux kernel is detecting can be seem by using lspci command:

$ lspci

The detail of lspci is:

Citation from https://linux.die.net/man/8/lspci
lspci is a utility for displaying information about PCI buses in the system and devices connected to them.

By default, it shows a brief list of devices. Use the options described below to request either a more verbose output or output intended for parsing by other programs.

If you are going to report bugs in PCI device drivers or in lspci itself, please include output of "lspci -vvx" or even better "lspci -vvxxx" (however, see below for possible caveats).

Some parts of the output, especially in the highly verbose modes, are probably intelligible only to experienced PCI hackers. For exact definitions of the fields, please consult either the PCI specifications or the header.h and/usr/include/linux/pci.h include files.

Access to some parts of the PCI configuration space is restricted to root on many operating systems, so the features of lspci available to normal users are limited. However, lspci tries its best to display as much as available and mark all other information with <access denied>text.

Options

Basic display modes

-m

Dump PCI device data in a backward-compatible machine readable form. See below for details.

-mm

Dump PCI device data in a machine readable form for easy parsing by scripts. See below for details.

-t

Show a tree-like diagram containing all buses, bridges, devices and connections between them.

Display options

-v

Be verbose and display detailed information about all devices.

-vv

Be very verbose and display more details. This level includes everything deemed useful.

-vvv

Be even more verbose and display everything we are able to parse, even if it doesn't look interesting at all (e.g., undefined memory regions).