Linux, Send USR1 signal to pid

In Linux you can send signals to a process id to trigger actions for the program. Useful scenario for this is to renew an IP address on a device that uses udhcpc. You should be able to change udhcpc for other programs, you’ll just need to read the help for that specific program.

In the udhcpc help it says

Signals:
         USR1    Renew lease
         USR2    Release lease

But how do we send those signals to udhcpc? Answer, use the kill command.

kill: kill [-s sigspec | -n signum | -sigspec] pid | jobspec … or kill -l [sigspec]
     Send a signal to a job.

Send the processes identified by PID or JOBSPEC the signal named by SIGSPEC or SIGNUM.  If neither SIGSPEC nor SIGNUM is present, then SIGTERM is assumed. 

Options:   
-s sig    SIG is a signal name   
-n sig    SIG is a signal number   
-l        list the signal names; if arguments follow `-l' they are             
          assumed to be signal numbers for which names should be listed   
-L        synonym for -l 

Kill is a shell builtin for two reasons: it allows job IDs to be used instead of process IDs, and allows processes to be killed if the limit on processes that you can create is reached.
Exit Status:
Returns success unless an invalid option is given or an error occurs. 

We see from above that we can pass a signal name in using the -s option.

So to send USR1 signal to udhcp we do the following

kill -s USR1 pid_of_udhcpc

Replace pid_of_udhcpc with the actual pid or use the following command to find the pid

kill -s USR1 $(pgrep udhcpc)

“pgrep udhcpc” prints the pid of the searched for process.

Helpful links
https://www.thegeekstuff.com/2011/02/send-signal-to-process/
https://www.linux.org/threads/kill-signals-and-commands-revised.11625/

Install Microsoft Teams Preview on Linux

Download the correct package for your distribution of Linux from
https://teams.microsoft.com/downloads

You should be able to open the installer and it should install, if not you can run the following commands from a terminal

The install instructions are for Debian/Ubuntu/Linux Mint.

Install using dpkg

sudo dpkg -i Downloads/teams_1.2.00.32451_amd64.deb

Launch Teams by typing

teams

Or you can launch it from your Applications Menu

After Teams is installed and launched, sign in to your Microsoft account.

DD show show status of progress

You can have dd show the progress of a write by specifying “status=progress” in the command line arguments.

sudo dd if=Downloads/CentOS-8-x86_64-1905-boot.iso of=/dev/sdb status=progress

Example:

bob@localhost:~$ sudo dd if=Downloads/CentOS-8-x86_64-1905-boot.iso of=/dev/sdb status=progress
559690240 bytes (560 MB, 534 MiB) copied, 96 s, 5.8 MB/s    <-- This is shown while writing.
1093632+0 records in
1093632+0 records out
559939584 bytes (560 MB, 534 MiB) copied, 96.0339 s, 5.8 MB/s

Find system uptime in Linux

There are a few different ways to find out the system up time in Linux.

cat /proc/uptime

admin@localhost [~]# cat /proc/uptime
 306350.37 2218975.63
admin@localhost [~]#

Taking the above command one step further, we can run it in the date command to see the system start up date.

date  --date="cat /proc/uptime | awk '{print $1}'seconds ago"

uptime command

[admin@localhost ~]$ uptime
  6:25AM  up 2 days,  6:24, 3 users, load averages: 0.00, 0.00, 0.00
[admin@localhost ~]$

w command

[admin@localhost ~]$ w
  6:27AM  up 2 days,  6:25, 2 users, load averages: 0.00, 0.00, 0.00
 USER             TTY      FROM              LOGIN@  IDLE WHAT
 admin       p1       localhost.  6:09AM    13 su (bash)
 admin       p2       localhost.  6:25AM     - w
[admin@localhost ~]$

Reference links

https://www.cyberciti.biz/faq/server-uptime-command-to-find-out-how-long-the-system-has-been-running/

https://sharadchhetri.com/2013/03/18/4-different-commands-to-find-system-uptime-in-linux/