Find list of active users in UNIX - unix

Get the list of active users[ users who has connected atleast once in last 6 months] in Solaris.

You could solve this by creating a script that date stamps a file somewhere when any user logs in. it could be run by the shell's system-wide init (/etc/profile for bourne compatible shells)
for instance, create a directory called /var/log/logintimes and have /etc/profile run touch /var/logintimes/$USER
then, to see the last login time, do ls -l /var/logintimes

Related

Udev does not have permissions to write to the file system

I have been fighting with udev all afternoon. Basically I have created a rule that detects when a mass storage device is plugged into the system. This rule works and I can get it to execute a script without any issues, here it is for review purposes:
ACTION=="add", KERNEL=="sd?*", SUBSYSTEM=="block", RUN+="/usr/local/bin/udevhelper.sh"
The problem I am running into is that the script is executed as some sort of strange user that has read-only permissions to the entire system. The script I am executing is quite simple:
#!/bin/sh
cd /usr/local/bin
touch .drivedetect
echo "1" > .drivedetect
exit
Basically I would like udev to run this script and simply output a 1 to a file named .drivedetect within the /usr/local/bin folder. But as I mentioned before it sees the rule and executes the rule when I plug in a drive however when it tries to run the script it comes back with file system is read-only script quit with error code 1.
I am currently running this on a raspberry pi zero and the latest Debian image. udev is still being run from init.d from what I can tell because there is no systemd service for it registered. Any help would be great and if you need any more information just ask.
Things I've tried:
MODE="0660"
GROUP="plugdev"
Various combinations of RUN+="/bin/sh -c '/path/to/script'" and /bin/bash
OPTIONS="last_rule"
And last but not least I tried running the script under the main username as well
#!/bin/sh
su pi drivedetect
I had same issue, when I just used
udevadm control --reload-rules
after editing a udev rule. But, if I do:
sudo /etc/init.d/udev restart
The script can edit a file.
It's not enough to reboot. I have to do the restart after booting. It then works as expected until the next reboot.
This is on an rpi with stretch-lite.

Informatica Repository Backup file is created by powercenter user but command is executed by pmprod user

We have UNIX based Informatica. We have recently upgraded Informatica from 9.6 to 10.1 .
We have two users:
a) pmprod - Other Application user
b) powercenter - Used for installation purpose
We have shell script file to take repository backup, which we used to run on daily basis.
The problem is even if we execute this script from "pmprod" user, the
repository backup file is created by "powercenter" user, which we
don't want.
Before upgrade it was running successfully
Executing shell script with pmprod user
After execution of script if we checked the user it shows powercenter and not pmprod. PFB screenshot
Repository backup is created with "powercenter" user
We have used below command in shell script file
cd /app/powercenter/server10/server/bin/
pmrep connect -r PCREPO_TALEN_AWS_QA -n Administrator -X PMPASS -d PCDOMAIN_TALEN_AWS_QA
pmrep backup -o backup_qa_20170717.rep
Please suggest do we need to provide specific permission to any file or any workaround we need to to.
I'm going to discuss a few ques.... which will help you to arrive at a solution...
First set of discussion....
so, because of this user difference, are you facing any prob?
because, the command , pmrep is using the "repository" Administrator's user and pwd to rep bkp and rep restore.
So, even if you have to restore a repository, the same user which generated the rep bkp would wrk.
I'm not sure, what prob you are facing because of this?
Did you try running a restore ? Did you face any probs?
Second set of discussion...
Can u tell me in whose user-account you ran the bkp commands?
Did you use the pmprod unix user or powercenter unix user's account to run the pmrep comands?
Ok... that makes sense... so before you upgraded, you had pmprod as the default user for starting your powercenter processes. Now after the upgrade, you have configured for powercenter user to start your processes.. as such, any file created by an informatica command will have its owner as the informatica user which in this case is powercenter regardless of which user invokes the command. You could create a command task in workflow manager to chown the file and that will sort your problem out or look here for alternatives https://network.informatica.com/thread/12401

What is the condition for iexpress restart

I use iexpress.exe to quickly create a simple installer based on a batch file. The IExpress Wizards provides the option "Only restart if needed".
But how can I tell from the batch file that a restart is required? I tried using exit code 3016 as in windows updates. But that doesn't work.
BTW: I call the batch file with
cmd.exe /c my.bat
The contents of my.bat:
exit /b 3010
I tried to get IExpress to recognize the return code. I think you want 3010, not 3016, though. Also the command would be:
exit 3010
[No /b – we want to return an exit code from cmd, not set errorlevel].
But it didn’t work, which makes me wonder if IExpress even bothers to check that.
Anyhow, I did a bit of investigation with Process Monitor. Immediately after the install process runs, it seems IExpress checks the PendingFileRenameOperations registry value to see whether files have been marked for rename (or deletion). If there are any, it determines that a reboot is needed, and takes the action you specified in your SED file (eg prompt the user for a reboot; or just reboot; or nothing).
In case you’re not familiar with it, the PendingFileRenameOperations registry value is a list of files to be moved or deleted on the next system boot.
You can use Sysinternals MoveFile to simulate one of these scheduled-at-next-startup renames. Add movefile.exe to your IExpress archive, and add a line like this in your batch file:
movefile.exe -accepteula foo bar
The actual filenames aren’t important – just use a file that you know is certain to not exist. (As long as you didn’t change directory in the batch file, that’ll still be a file in, eg, %temp%\IXP000.TMP.)
Note that you need to be running elevated for that (Run as administrator).
Worked well here. IExpress pops up after each run, prompting the user to reboot.

NPPExec Console in NotePad

Thanks in advance:
I'm attempting to use Notepad++ to log-in to a UNIX system. I am using the NPPExec console to do this, and the login process works... kind of. I use NPPExec to execute this script, named "sasunix.sh":
"C:\userblah\username\Desktop\plink.exe" -load "SUN4" -l myloginname -pw mypassword
As you can see I am using Putty's command line program "plink.exe" to send the command; "SUN4" is the session profile I am using. The problem is, the next screen logs me in (successfully), but proceeds to ask me for my password an additional time (which is part of the login procedure), followed by a request for my my terminal emulation setting (for me, this is 'xterm').
THE QUESTION: What additional lines would I add to my script to execute this sequence of inputs on the UNIX system (i.e. typing them in individually and pressing "ENTER" each time):
1.) thepassword 2.) xterm 3.) sas -nodms -nonews
I think this boils down to a misunderstanding of how commands are passed between NotePad++ and the NPPExec console window. At any point, if I press "F6", a prompt pops up, saying "WARNING: Console process still running...". This messagebox prompt allows me to type in a line which is then sent to the console... but how do I put a series of these inputs into the script?
You prob have this solved by now,
but i have done the following
a windows batch script that creates a file with unix commands, based on the a directory path
#ECHO OFF
:: store input variable
set str=%1
:: remove C:\ or Z:\ etc
set str=%str:~3%
:: replace \ with /
set str=%str:\=/%
:: append cd command
set str1=cd
set str=%str1% %str%
echo.%str%
:: make
echo make clean
echo make all
Install the NppExec plugin to Notepad++
Place the *.bat scripts and plink.exe in the Notepad++ program directory
Create the NppExec commands
// This line calls the bat file and creates a file tempcmd.sh with unix commands in it
"$(NPP_DIRECTORY)\unix_make_all.bat" $(CURRENT_DIRECTORY) >tempcmd.sh`
// This line connects to a remote machine and runs all the commands stored in tempcmd.sh
"$(NPP_DIRECTORY)\plink.exe" -ssh -2 -l username -pw password 192.168.000.000 -m "$(NPP_DIRECTORY)\tempcmd.sh"
Using the NppExec options i save the above commands and place a shortcut in the macros menu

How do you share zsh history between multiple machines?

I have a setup I'm pretty happy with for sharing my configuration files between machines, but I find that I often want to search back in zsh (Ctrl + R) and I can't remember which machine I typed the command on. Ideally I'd like this to search a canonical de-duped list of previous commands from any of my machines. Given that I sometimes work on these machines concurrently and without a network connection, what's a sensible way of merging history files and keeping everything in sync?
I wrote this plugin for oh-my-zsh:
An Oh My Zsh plugin for GPG encrypted, Internet synchronized Zsh history using Git
https://github.com/wulfgarpro/history-sync
Hmm, I guess you could identify your accounts somehow... then you could do the following:
modify your .zshrc to catenate the history of the OTHER accounts from dropbox or SCM with the current history IF this is the first zsh launched on the current computer
then sort the entries with -n (sort by timestamp)
I guess zsh would remove the duplicates if you have setopt HIST_SAVE_NO_DUPS
Then you need to trap shell exit, and copy the existing history to the dropbox/SCM/whatever shared place.
You could have a NFS mount point for the involved machines with the .zsh_history in it. Each machine would need the HISTFILE env var set to that file path in the NFS.
HISTFILE env var is compulsory, since ZSH does not accept a symlink, and it would be replaced by a file using the last version of the symlink target.
I have not tested what is said above, since my setup is between VM's using OSX and Parallels shared folders. Hence, with NFS the integrity (order?) of the file could be something to consider, also VS the Dropbox solution.
Not sure, something like https://gist.github.com/elim/f77e3e9f06b6f8a5e788 could be used to fix versions to be merged...
I use the command below:
ssh username#example.com cat ~/.zsh/.zhistory | cat ~/.zsh/.zhistory - | sort | uniq | tee ~/.zsh/.zhistory | ssh username#example.com cat \> ~/.zsh/.zhistory

Resources