why linux id command give me different info about the same account? - linux

I am using ubuntu 13.04.
And I wonder why I get different groups info when using id command with/without account.
when I type
$id user1
uid=1000(user1) gid=1000(user1) groups=1000(user1),1001(user2)
but when I type
$id
uid=1000(user1) gid=1000(use1) groups=1000(user1),4(adm),24(cdrom),27(sudo),30(dip),46(plugdev),108(lpadmin),124(sambashare)
why use "id" command only cannot list my supplementary group?
by the way, following is one entry of my /etc/group :
user2:x:1001:user1
Any help ? Thank you.

Sounds like you've edited /etc/group but haven't logged off and back on again. I suggest starting a new shell, and trying id again.

Related

AppleScript - How can I get this string to properly go through?

set UserName to do shell script "whoami"
set AD to do shell script ("dscl "/Active Directory/YC/All Domains/" read /Users/" & UserName)
My error: Expected “,” but found identifier
So Im trying to find a users SMBHome in active directory because we map our drives based on that. But the issue with that command is the double strings. "/Active Directory/YC/All Domains/" HAS to a string otherwise it wont properly queue.
But to do shell script ("COMMAND HERE") has to be a string as well..
How do I combat this?
And is there a easier way todo this?
Full script:
set UserName to do shell script "whoami"
set AD to do shell script ("dscl "/Active Directory/YC/All Domains/" read /Users/" & UserName)
if AD contains "StaffShare" then
set SMBHome to "smb://domain/StaffShare"
else
set SMBHome to "smb://domain/EmployeeShare"
end if
set mounted_disk to list disk
mount volume SMBHome as user name UserName
Nevermind, I actually figured it out. Similar to Lua
"dscl \"/Active Directory/YC/All Domains/\" read /Users/" & UserName
Although Im still up to see if anyone has any better solutions for this. :)
You can use single quotes:
set AD to do shell script "dscl '/Active Directory/YC/All Domains/' read $HOME"
But the way you've done it, by escaping the double quotes, it perfectly legit.

zabbix monitor for read only fs

Trying to monitor filesystems with zabbix. I found this : https://github.com/vintagegamingsystems/Zabbix-Read-Only-Filesystem-Check
and been trying to implement it. But I don't understand given this user parameter: UserParameter=checkro[*],/etc/zabbix/scripts/checkro.sh $1
What should be the item key. According to the documents checkro should work but I keep getting Status Unsupported. Tried posting this on zabbix forms but it takes 3-5 days for them to approve my post :/
EDIT : Files changed : /etc/zabbix/zabbix_agentd.conf I added a line for the UserParameter and added the checkro.sh script. I restarted zabbix after was (it's a container, so technically restarted the container)
What I was expecting was for checkro[something] to be supported as item key but it isn't.
[*] indicates that this item key takes parameters. The script has this line: mountPoint=$1.
Thus the item key should have the mountpoint passed as a parameter like so:
checkro[/home]
Maybe too late. But I just used this script. It works only if / and /boot. If your FS is on say /dev/MAPPER etc it does not work.

How to get Effective User Name and Schduling Class for a process using bash - linux

I'm trying to write a bash script that takes a process ID as the user input and prints out information about that process such as the nice value, priority...etc.
I almost got all what I need with help from this site: http://linux.die.net/man/5/proc
However, I couldn't find from where I can get the effective user name and the scheduling class of the process.
Any help would be appreciated.
The negated scheduling priority can be found as the 18th field of /proc/[pid]/stat as detailed in your link.
cat /proc/207/stat | cut -d' ' -f18
As for the owner of the process, it's the owner of the /proc/[pid] directory, or of any file in it.
stat -c "%U" /proc/207/
Edit : removed my scheduling priority calculation because I don't know the first thing about it and might misinterpret the documentation. I'll just leave where the negated one can be found.

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.

Check the root password

What is the best way to check if a root linux password is correct,from a c program.One solution is tu run a command like : echo \"myPass\n"\ | sudo -S mySudoPassword and somehow check stderr to see if contains data.I am looking forward to get an elegant solution
You can validate that a given password is correct for a given username using the shadow file.
See Given a linux username and a password how can I test if it is a valid account? for the mechanics of how this is done. It should be possible to perform the same operations in a C program.

Resources