Skip to content

Posts from the ‘Unix / Linux’ Category

How to check when was the last time any local user password was changed in Unix?

How to check when was the last time any local user password was changed in Unix?

When ever any local user account password is changed the file /etc/shadow is updated.
So, if you want to check when was the last time any local user password was changed then just run:

[root@TestServer ~]# ls -lrt /etc/shadow
-r——– 1 root root 1035 Oct 11 11:11 /etc/shadow

From above output, its clear that last time any local user password was changed was on 11th Oct of this year.

For example, if you want to see when was the last time root user password was changed, just run below command:

[root@TestServer ~]# chage -l root
Last password change : Oct 11, 2016
Password expires : never
Password inactive : never
Account expires : never
Minimum number of days between password change : -1
Maximum number of days between password change : -1
Number of days of warning before password expires : -1

How to move Unix script to run in background after it was started?

Say for example, you started nz_groom Netezza script and then want to move it to background so that you cna disconnect your session
without aborting the script.
Just follow below steps to make this happen:

1) Say, you have already started below script at command prompt
$->nz_groom DBName -records all

2) Now just issue [ ctrl + z ] to stop this job
[1]+ Stopped nz_groom DBName -records all

NOTE: THis step will just stop the job temporarily and will not abort/kill the job.

3) Now issue a command [ jobs ] to verify the curren tstatus of your script
$->jobs
[1]+ Stopped nz_groom DBName -records all

4) Issue a command [ bg ] to move this script to run in back ground
$->bg
[1]+ nz_groom DBName -records all &

5) Again issue a command [ jobs ] to verify the curren tstatus of your script. This script will be running now in background.
$->jobs
[1]+ Running nz_groom DBName -records all &

6) Now issue a command [ disown ] to disconnect this job form your session
$->disown

7) Now, if you run jobs you will not see any. BEcause its already disowned from your session
$->jobs

8) Just run [ ps -ef ] and you will see that job running in background just as it would have if you just run the job in background
at very first place.
$->ps -ef | grep nz_groom
nz 17348 30322 0 17:02 pts/1 00:00:00 grep nz_groom
nz 19605 23341 0 16:53 pts/1 00:00:00 /bin/sh /nz/support/bin/nz_groom DBName -records all
nz 23341 30322 0 14:03 pts/1 00:00:00 /bin/sh /nz/support/bin/nz_groom DBName -records all