How to install tree command on FreeBSD

To install tree command on FreeBSD you can use the ‘pkg’ command with’ install’ option as a root. Tree command generally used to  list contents of directories in a tree-like structure.

root@:~ # pkg install tree

Updating FreeBSD repository catalogue…
Fetching meta.txz: 100% 944 B 0.9kB/s 00:01
Fetching packagesite.txz: 100% 6 MiB 23.0kB/s 04:27
Processing entries: 100%
FreeBSD repository update completed. 28736 packages processed.
All repositories are up to date.
New version of pkg detected; it needs to be installed first.
The following 1 package(s) will be affected (of 0 checked):

Installed packages to be UPGRADED:
pkg: 1.10.1 -> 1.10.3_1

Number of packages to be upgraded: 1

3 MiB to be downloaded.

Proceed with this action? [y/N]: y
[1/1] Fetching pkg-1.10.3_1.txz: 100% 3 MiB 21.0kB/s 02:11
Checking integrity… done (0 conflicting)
[1/1] Upgrading pkg from 1.10.1 to 1.10.3_1…
Extracting pkg-1.10.3_1: 100%
Updating FreeBSD repository catalogue…
FreeBSD repository is up to date.
All repositories are up to date.
The following 1 package(s) will be affected (of 0 checked):

New packages to be INSTALLED:
tree: 1.7.0

Number of packages to be installed: 1

39 KiB to be downloaded.

Proceed with this action? [y/N]: y
[1/1] Fetching tree-1.7.0.txz: 100% 39 KiB 39.7kB/s 00:01
Checking integrity… done (0 conflicting)
[1/1] Installing tree-1.7.0…
Extracting tree-1.7.0: 100%
root@:~ #

How to display complete list of login and logout with times & dates in the Linux server

To display complete list of login and logout with times  and dates in the Linux server  ,you can use ‘ last ‘ command with -F option.

 [root@localhost ~]# last -F
root pts/0 192.168.26.1 Wed Jan 10 20:56:02 2018 still logged in
reboot system boot 3.10.0-693.11.1. Wed Jan 10 20:55:19 2018 – Wed Jan 10 21:21:44 2018 (00:26)
root pts/0 192.168.26.1 Wed Jan 10 20:46:37 2018 – crash (00:08)
root pts/0 192.168.26.1 Wed Jan 10 20:06:19 2018 – Wed Jan 10 20:38:34 2018 (00:32)
reboot system boot 3.10.0-693.11.1. Wed Jan 10 19:58:23 2018 – Wed Jan 10 21:21:44 2018 (01:23)
root pts/0 192.168.26.1 Wed Jan 10 19:50:41 2018 – crash (00:07)
reboot system boot 3.10.0-693.11.1. Wed Jan 10 16:49:29 2018 – Wed Jan 10 21:21:44 2018 (04:32)
root pts/0 192.168.26.1 Wed Jan 10 19:46:32 2018 – crash (-2:-57)
root pts/1 192.168.26.1 Wed Jan 10 15:28:30 2018 – crash (01:20)
root pts/0 192.168.26.1 Wed Jan 10 12:57:04 2018 – Wed Jan 10 15:42:32 2018 (02:45)
reboot system boot 3.10.0-693.11.1. Wed Jan 10 12:55:15 2018 – Wed Jan 10 21:21:44 2018 (08:26)
root pts/0 192.168.26.1 Wed Jan 10 12:36:57 2018 – down (00:17)
reboot system boot 3.10.0-693.11.1. Tue Jan 9 23:05:42 2018 – Wed Jan 10 12:54:43 2018 (13:49)
root pts/0 192.168.26.1 Tue Jan 9 23:01:20 2018 – down (00:04)
reboot system boot 3.10.0-693.11.1. Tue Jan 9 23:00:16 2018 – Tue Jan 9 23:05:27 2018 (00:05)

..

..

wtmp begins Wed Dec 28 17:12:53 2016
[root@localhost ~]#.

Linux: poweroff command to poweroff linux/Unix machine

To ‘poweroff’ the liux /Unix machine ,you can use  poweroff command as a root . There are many options used with poweroff command. With the help of these options we can halt,reboot and poweroff the linux machine.

 

==>If you want to Force immediate halt/power-off/reboot the linux / Unix machine ,you can use  ‘-f’ or ,’ –force ‘ option with ‘poweroff’ command.

[root@localhost ~]# poweroff -f

Powering off.

==>If you want to Only write wtmp shutdown entry in /var/log/wtmp, do not actually halt, power-off, reboot the linux machine, you acn use ‘-w ‘or ‘ –wtmp-only’ option with poweroff command.

[root@localhost ~]# poweroff -w
[root@localhost ~]#

==>If you don’t write wtmp record in /var/log/wtmp ,you can use ‘ -d’ or ‘–no-wtmp ‘ option with poweroff command.

[root@localhost ~]# poweroff –no-wtmp

==>If you don’t send wall message before halt/power-off/reboot,you can use poweroff command witn ‘–no-wall  ‘ option.

root@localhost ~]# poweroff –no-wall ” please save your work system reboot now”

All command line options  used with the ‘ poweroff ‘ command are shown below

______________________________________________________________________________

Options                                                  Description

_______________________________________________________________________________

–halt                                         Halt the machine
-p    –poweroff                        Switch off the machine
–reboot                                     Reboot the machine
-f –force                                    Force immediate halt/power-off/reboot
-w –wtmp-only                          Don’t halt/power-off/reboot, just write wtmp record
-d –no-wtmp                             Don’t write wtmp record
–no-wall                                    Don’t send wall message before halt/power-off/reboot

_______________________________________________________________________________

Linux: halt command to halt the linux server

To halt the liux /Unix machine ,you can use  halt command as a root . There are many options used with halt command. With the help of these options we can halt,reboot and poweroff the linux machine.

==>If you want to poweroff the linux / Unix machine with halt command ,you acn use ‘-p ‘ or ‘–poweroff’ option.

[root@localhost ~]# halt –poweroff

==>If you want to Force immediate halt/power-off/reboot the linux / Unix machine ,you can use  ‘-f’ or ,’ –force ‘ option with ‘halt’ command.

[root@localhost ~]# halt -f

Halting.

==>If you want to Only write wtmp shutdown entry in /var/log/wtmp, do not actually halt, power-off, reboot the linux machine, you acn use ‘-w ‘or ‘ –wtmp-only’ option with halt command.

[root@localhost ~]# halt -w
[root@localhost ~]#

==>If you don’t write wtmp record in /var/log/wtmp ,you can use ‘ -d’ or ‘–no-wtmp ‘ option with halt command.

[root@localhost ~]# halt –no-wtmp

==>If you don’t send wall message before halt/power-off/reboot,you can use halt command witn ‘–no-wall  ‘ option.

root@localhost ~]# halt –no-wall ” please save your work system reboot now”

All command line options  used with the ‘ halt ‘ command are shown below

______________________________________________________________________________

Options                                                  Description

_______________________________________________________________________________

–halt                                         Halt the machine
-p    –poweroff                        Switch off the machine
–reboot                                     Reboot the machine
-f –force                                    Force immediate halt/power-off/reboot
-w –wtmp-only                          Don’t halt/power-off/reboot, just write wtmp record
-d –no-wtmp                             Don’t write wtmp record
–no-wall                                    Don’t send wall message before halt/power-off/reboot

_______________________________________________________________________________

reboot: command to reboot a Linux/Unix machine

To restart liux /Unix machine ,you can use reboot command as a root . There are many options used with reboot command. With the help of these options we can halt,reboot and poweroff the linux machine.

==>If you want to halt the linux /Unix machine , you can use ‘–halt’ option with reboot command .

[root@localhost ~]# reboot –halt

==>If you want to poweroff the linux / Unix machine with reboot command ,you acn use ‘-p ‘ or ‘–poweroff’ option.

[root@localhost ~]# reboot –poweroff

==>If you want to Force immediate halt/power-off/reboot the linux / Unix machine ,you can use  ‘-f’ or ,’ –force ‘ option with reboot command.

[root@localhost ~]# reboot -f

Rebooting.

==>If you want to Only write wtmp shutdown entry in /var/log/wtmp, do not actually halt, power-off, reboot the linux machine, you acn use ‘-w ‘or ‘ –wtmp-only’ option with reboot command.

[root@localhost ~]# reboot -w
[root@localhost ~]#

==>If you don’t write wtmp record in /var/log/wtmp ,you can use ‘ -d’ or ‘–no-wtmp ‘ option with reboot command.

[root@localhost ~]# reboot –no-wtmp

==>If you don’t send wall message before halt/power-off/reboot,you can use reboot command witn ‘–no-wall  ‘ option.

root@localhost ~]# reboot –no-wall ” please save your work system reboot now”

All command line options  used with the ‘ reboot ‘ command are shown below

______________________________________________________________________________

Options                                                  Description

_______________________________________________________________________________

–halt                                         Halt the machine
-p    –poweroff                        Switch off the machine
–reboot                                     Reboot the machine
-f –force                                    Force immediate halt/power-off/reboot
-w –wtmp-only                          Don’t halt/power-off/reboot, just write wtmp record
-d –no-wtmp                             Don’t write wtmp record
–no-wall                                    Don’t send wall message before halt/power-off/reboot

_______________________________________________________________________________

shutdown: command to shutdown a Linux/ Unix machine

The shutdown command used to root privilege to perform the shutdown a linux / Unix machine, it supports a time argument. This is generally used for scheduled maintenance and give more time for users to react on the warning when a system shutdown has been scheduled .

There are many options used with shutdown command. With the help of these options we are halt,reboot and poweroff the linux machine.

==>If you want to shutdowna linux machine  immediatly

[root@localhost ~]# shutdown -h now

Note: The now keyword is an alias for + 0

==> To Halt the linux machine with ‘shutdown’ command ,you can use ‘ shutdown ‘ command with ‘ -H’ or ‘ –halt ‘ option.

[root@localhost ~]#  shutdown -H
Shutdown scheduled for Tue 2018-01-09 12:11:13 IST, use ‘shutdown -c’ to cancel.
[root@localhost ~]#
Broadcast message from root@localhost.localadmin (Tue 2018-01-09 12:10:13 IST):

The system is going down for system halt at Tue 2018-01-09 12:11:13 IST!

[root@localhost ~]#

==>If you want to poweroff a Linux / Unix machine with a specific time , you can use ‘shutdown ‘ command with ‘ -P ‘ or ‘ –poweroff ‘ option.

[root@localhost ~]# shutdown -P +10 ” The system is shutdown after 10 minute due to hardware replace “
Shutdown scheduled for Thu 2018-01-04 12:27:43 IST, use ‘shutdown -c’ to cancel.
[root@localhost ~]#
Broadcast message from root@localhost.localadmin (Thu 2018-01-04 12:17:43 IST):

The system is shutdown after 10 minute due to hardware replace
The system is going down for power-off at Thu 2018-01-04 12:27:43 IST!

[root@localhost ~]# 

==>If you want to reboot a linux machine with ‘ shutdown’ command , you can use ‘ shutdown ‘ command with ‘-r ‘ or ‘ –reboot ‘ option.

[root@localhost ~]# shutdown -r
Shutdown scheduled for Tue 2018-01-09 12:45:34 IST, use ‘shutdown -c’ to cancel.
[root@localhost ~]#
Broadcast message from root@localhost.localadmin (Tue 2018-01-09 12:44:34 IST):

The system is going down for reboot at Tue 2018-01-09 12:45:34 IST!

[root@localhost ~]# 

==>If you don’t want to halt/power-off/reboot the linux machine only send warning  message to logged in users , you can use ‘ k’ option with shutdown command .

[root@localhost ~]# shutdown -k +10 ” please save your work system shutdown after 10 minute”
Shutdown scheduled for Tue 2018-01-09 13:09:00 IST, use ‘shutdown -c’ to cancel.
[root@localhost ~]#
Broadcast message from root@localhost.localadmin (Tue 2018-01-09 12:59:00 IST):

please save your work system shutdown after 10 minute
The system is going down for power-off at Tue 2018-01-09 13:09:00 IST!

[root@localhost ~]# 

==>If you don’t send wall message before halt/power-off/reboot, you can use shutdown command with ‘ –no-wall ‘ option

[root@localhost ~]# shutdown –no-wall +10 “shutdown your system after 10 minutes.”
Shutdown scheduled for Tue 2018-01-09 14:29:02 IST, use ‘shutdown -c’ to cancel.
[root@localhost ~]#

==>If you want to cancel Linux / Unix pending shutdown  , you can use ‘ shutdown ‘ command with ‘ -c ‘ option .

[root@localhost ~]# shutdown -c

Broadcast message from root@localhost.localadmin (Tue 2018-01-09 14:19:37 IST):

The system shutdown has been cancelled at Tue 2018-01-09 14:20:37 IST!

[root@localhost ~]#

All command line options  used with the ‘ shutdown ‘ command are shown below

______________________________________________________________________________

Options                                                  Description

_______________________________________________________________________________
-H –halt                                       Halt the machine
-P –poweroff                              Power-off the machine
-r –reboot                                   Reboot the machine
-h                                                Equivalent to –poweroff, overridden by –halt
-k                                                Don’t halt/power-off/reboot, just send warnings
–no-wall                                     Don’t send wall message before halt/power-off/reboot
-c                                                Cancel a pending shutdown

________________________________________________________________________________