logins -axo command in linux oracle - linux

Anyone know what "logins -axo" means in linux os (for Oracle database)? and how to read the result?
i've got result below:
root:0:root:0:Super-User:/root:/sbin/sh:PS:092222:-1:28:21:-1:0

I don't know Linux, but - the only logins command I found is related to IBM's AIX.
Flags you used mean:
-a: In addition to the default output, the -a flag adds two password expiration fields to the display. These fields show how many days a password can remain unused before it automatically becomes inactive and the date that the password will expire.
-o: Formats output into one line of colon separated fields.
-x: Prints an extended set of information about each selected user. Information for each user is printed on a separate line containing the home directory, login shell, and password aging information. The extended information includes the following:
The password status
The date on which the password was last changed
The number of days required between changes
The number of days allowed before a change is needed
The number of days that the user will receive a password expiration warning message before the password expires
The password status is displayed in an abbreviated form as PS for logins with password, NP for no password or LK for locked.

Related

Execute shell commands with excel VBA and collect output [duplicate]

This question already has answers here:
Capture output value from a shell command in VBA?
(8 answers)
Closed last year.
I am trying to make a ticket tool we have where I work a little better and make it so the tech team doesn't have to open Active Directory to make sure the ticket sender is eligible to make certain requests. What I need is the ability to run net user /domain <username> then collect the comment line and store it in a variable in VBA. The variable will then be sent in an email to the ticket software along with anything the user entered in the text boxes.
My thoughts were to run the command and send the output string to another variable then pull the line information from the larger output since I cant seem to find a way to get only the comment.
I've added a sample of the output below with an arrow pointing at the data that needs extracted into the variable.
I'm still pretty new to VBA so bear with me.
C:\Users\jdoe\Desktop>net user /domain jdoe
The request will be processed at a domain controller for domain StackOverflow.wh.
User name jdoe
Full Name John Doe
Comment Anlst Tech Supp <----- this is what needs extracted
User's comment
Country/region code 000 (System Default)
Account active Yes
Account expires Never
Password last set 11/1/2021 8:58:44 AM
Password expires 1/30/2022 8:58:44 AM
Password changeable 11/1/2021 8:58:44 AM
Password required Yes
User may change password Yes
Workstations allowed All
Logon script
User profile
Home directory
Last logon 1/15/2022 11:43:12 AM
Logon hours allowed All
Local Group Memberships
Global Group memberships *Domain Users
The command completed successfully.
On Error Resume Next
Set objWMIService = GetObject("winmgmts:\\.\root\cimv2")
Set config = objWMIService.ExecQuery("Select * From Win32_UserAccount")
For Each thing in Config
Msgbox thing.caption & " " & thing.Description
Next
Programmers don't call user's commands. They are for humans not programs.
See https://learn.microsoft.com/en-us/windows/win32/cimwin32prov/win32-useraccount for more info.

How to use p4tickets with p4python

There's a large number of examples of using your user/pass as credentials to connect to the p4 server using p4python, but very little describing how to use a p4ticket. It's unclear how to use a p4tickets file with p4python.
It turns out the perforce documentation is really, really precise. The documentation basically says that if the user isn't logged in, then you have to provide a password to login. The flip side of that coin is that if the user is logged in then no password is needed. So, for instance, assume the user is logged in:
>>> p4 -u 'username' login
Then, in your p4python script, the following will connect:
p4con = P4.P4()
p4con.user = 'username'
p4.con.connect()
The p4python connection will naturally use the ~/.p4tickets file.
To use a ticket in a P4 Python script (or the P4 command line) you essentially just put the ticket anywhere that asks for a password. With that, there's an issue of precedence of where P4 Python takes the ticket from that is not consistent with how the P4 command line works.
In P4 Python:
If the environment variable P4PASSWD is set it is used.
If there is an entry for the user in whatever file p4.ticket_file looks at (from P4TICKETS, the default of ~/.p4tickets, or a value that was placed there by the script) that will be used if P4PASSWD is not set
If the p4.password field is set it will be used if neither of the above conditions have been met.
Running P4 from the command line:
If run with -P the ticket from the command line is used
If P4PASSWD is set that is used if the above condition has not been met
If there is an entry for the user in whatever file p4.ticket_file looks at (from P4TICKETS, the default of ~/.p4tickets, or a value that was placed there by the script) that will be used if neither of the above conditions have been met.
Example 1 - This will override the value set in p4.password on line 4 with the value for the user set on line 3 if there is an entry in the ticket file. If there's no entry in the ticket file it will use the supplied credentials AND update the ticket file so that the second time the script is run it will use that and not the supplied credentials.
from P4 import P4
p4 = P4()
p4.user = user
p4.password = ticket
Example 2 - This will always use the supplied credentials because we're not actually using a real file.
from P4 import P4
p4 = P4()
p4.user = user
p4.password = ticket
p4.ticket_file = '/dev/null'
tl;dr - Use the ticket anywhere Perforce asks for a password. If you want to use a ticket in your script, set ticket_file='/dev/null' first to ensure the expected behaviour.
run_login(): Runs p4 login using a password or ticket set by the user.
from P4 import P4
p4 = P4()
p4.port = "xxx.xxx.xxx.xxx:1666"
p4.user = "xxxxx"
p4.connect()
p4.run_login("-s", p4.user)

Windows compatible passwords in bash

I have a script that takes windows compatible passwords and uses them to create an account for the user on the computer with that as their system password.
I have run into an issue where if I escape them and pass it to create the account it is taken literally. Single ' and double " quotes are allowed in windows.
Example user enters hello'world
escaped as hello\'world and stored in the database as hello\'world.
user inputs hello'world login.
Computer expects hello\'world as the correct password, user can not login.
Adding code:
echo "somepass" | sudo -S /Applications/Setup\ user.app/Contents/Resources/nugget "Joe User" "juser" "ju$er'Pa$$".345"
Essentially the account for the user is created, another admin account has to be used and the password set from the gui where ju$er'Pa$$".345 is entered and from there the user can login fine.
Does this do what you want? (Obviously you need a safe method to retrieve the password, either from read input or by reading from a file handle or pipe).
neech#nicolaw.uk:~ $ read -r password ; printf '%q\n' "$password"
ju$er'Pa$$".345
ju\$er\'Pa\$\$\".345
neech#nicolaw.uk:~ $

linux command "getent" not returning all numeric usernames (ex. 10798) in linux file system

i am using "getent" command to fetch user information in my linux file system.
I have a user with the username "10798" and another user with the username "user" and user ID "10798",i am using getent command to fetch the user info of user with the name "10798"
but the command is not giving any output
I think the command "getent" will only look for the user id number if you give all numeric value as input to the command
here is the scenario
# cat /etc/passwd
10798:x:10799:10799::/home/10798:/bin/bash
user:x:10798:10798::/home/user:/bin/bash
# getent passwd 10798
user:x:10798:10798::/home/user:/bin/bash
how to get the user with the username 10798 using the getent command
passwd When no key is provided, use setpwent(3), getpwent(3),
and endpwent(3) to enumerate the passwd database. When
one or more key arguments are provided, pass each
numeric key to getpwuid(3) and each nonnumeric key to
getpwnam(3) and display the result.
I got this from the linux man page is there a way to redirect numeric keys to getpwnam
ls already performs that lookup. You can perform a user information lookup from the command line with getent passwd.
If ls shows a user ID instead of a user name, it's because there's no user by that name. Filesystems store user IDs, not user names. If you mount a filesystem from another system, or if a file belongs to a now-deleted user, or if you passed a numerical user ID to chown, you can have a file that belongs to a user ID that doesn't have a name.
On a shared host, you may have access to some files that are shared between several virtual machines, each with their user database. This is a bit weird (why share files but not the users that own them?), but it's technically possible.

Last login Since specified time

How can I check the last logins of a given user since a given time?
Tried:
`last -s $timeVariable $userName`
But that option is invalid.
I know -t is good to check the logins until the specified time, but I want the exact opposite. Any ideas?

Resources