Hot answers tagged users
13
When you delete a user, the user information is completely removed, so there is no direct information that that ID was ever used.
(The authoritative user information is stored in /etc/passwd, which is a simple list.)
To prevent this, either
force another ID when creating new users, or
keep the user entry around (just disable logins) as long as you ...
13
/etc/passwd shows each user's primary group. /etc/group shows users who have a given group as one of their supplementary groups. For example, my username dan has the group dan as its primary group, so that is what appears in the group field in /etc/passwd. The user dan is also in the groups wheel, mailadmin and svn, so the entries for those groups in ...
12
You are thinking that the !, * or x has a special meaning here, and are therefore worrying that there might be some distinction among them.
The fact is that these characters are chosen simply because they stand out, at least to the eyes of those who developed Unix and its descendants. To Western eyes, these characters all have a connotation of "missing" or ...
11
/etc/passwd is sometimes called the user database. That should give us a clue as to why it needs to be readable by everyone. Any utility that inspects file metadata needs to be able to read /etc/passwd (and /etc/group) in order to be able to resolve the numerical IDs used by the kernel and its subsystems to the human-friendly names that we rely on. Tools ...
10
su (mostly) uses pam for authentication and pam has a module called pam_wheel which checks group membership of the authenticating user. In short, by adding
auth required pam_wheel.so group=becomeroot
to the file /etc/pam.d/su, only users who are members of the group becomeroot may become root using su. Now you make sure only your user EMERG is a ...
8
Check the file /etc/ttys which contains list of terminals. Only those marked "secure" will allow root to login. By default this is the console and all virtual terminals. Pseudo terminals do not allow root login.
Also, in this day and age, where security is a big concern, may I ask why you are still using an unsecure protocol like telnet and not ssh ?
...
7
The following will work with GNU find and awk:
find /path -type f -printf '%u %k\n' | awk '{
arr[$1] += $2
} END {
for ( i in arr ) {
print i": "arr[i]"K"
...
6
No, a crontab file is not a shell script you can't just introduce arbitrary commands or variables. If you want to do this, run the script as root and change users in the script.
To determine sessions have a look at consolekit which you can use to get all active sessions on your system either via dbus or ck-list-sessions
6
Not a bug according to chown documentation:
$ info coreutils 'chown invocation'
The `chown' command sometimes clears the set-user-ID or set-group-ID
permission bits. This behavior depends on the policy and functionality
of the underlying `chown' system call, which may make system-dependent
file mode modifications outside the control of the `chown' ...
6
You can use the usermod command to change a user's login shell.
usermod -s /sbin/nologin myuser
If your OS does not provide /sbin/nologin, you can set the shell to a NOOP command such as /bin/false:
usermod -s /bin/false myuser
6
Use su <user>, optionally with the - option (also known as -l or --login) to make the shell behave as a login shell (different initialization).
You can't really send it to background, since the shell of that user catches the SIGTSTP signal that is used to move it to background and exits (usually). Instead of that you might be interested in a terminal ...
6
There are two obvious answers:
Give each user his own virtual machine image. Inside the virtual machine, the user has root access; outside the virtual machine, none at all. If your hardware supports it, kvm will work pretty well for this. And virtual machine images are just files, so they're easy to copy around, etc. You can use copy-on-write storage, ...
5
Instead of sudo vim /etc/rc.conf use sudoedit /etc/rc.conf or sudo -e /etc/rc.conf. You may need to set the EDITOR environment variable to vim. This will run vim itself as the normal user, using your normal configuration, on a copy of the file which it will copy back when you exit.
5
This is a pretty standard reason to change the shell. Typically /bin/false or other shells like /bin/cat are used.
Typically you can't escape from /bin/cat and it is unlikely that cat has a security bug but other methods may still work, like creating a DoS or bypassing Firewall rules.
Another probably more severe problem is if you are using the ...
5
To list all available groups with users in them you can use
getent group
or just look the content of /etc/group file.
By the way, on ubuntu there is only one superuser too. It is root. All others just are allowed to use it privilleges via sudo. You can modify rules in /etc/sudoers via visudo as mentioned above, if sudo is installed. This is true for any ...
5
On Linux,
ss sport = :5900
Would tell you the currently established TCP connections on port 5900.
For anything else, we'd need to know what VNC server you're using as there exist dozens.
If you know the name of the VNC server command,
lsof -ai tcp -c that-command
(as the user running the VNC server or as root) would also tell you the currently ...
5
The usernames in /etc/group only contain users who are in the group as a supplementary group, not a primary group. Primary group information is stored in /etc/passwd. The initgroups(3) manpage was the only documentation I could find to indicate this:
NAME
initgroups - initialize the supplementary group access list
FILES
/etc/group ...
5
It's likely that
the list of users come from a network service: probably LDAP, maybe NIS if the network has been around for a very long time;
the home directories are automounted, i.e. mounted from some file server when the user logs in.
The file /etc/nsswitch.conf defines what sources provide user lists (the passwd setting).
The Solaris commands ...
5
I would suggest allowing to connect only via public key. Then you can connect that public key with your own command by supplying it in ~/.ssh/authorized_keys like that:
command="/path/to/mycommand" ssh-rsa ...
Whenever the user logs into that account with that key your command is executed instead of the usual shell. That command can for example be a shell ...
5
Hint
Each field in a /etc/passwd line is separated by a colon, and the username is the first field, so you need to filter each line to only show the characters up to the first colon
Answer
grep is not even close to the best tool for doing this, but if you're required to use it, this will work:
grep -oE '^[^:]+' /etc/passwd
-o tells it to only return ...
5
The presence of system account such as root, sys, nobody, bin, daemon, etc. has been the topic of many security audits that I've been through over the years and it really comes down to a few things.
Yes these types of accounts can be security holes, especially if they have a shell enabled:
Bad
bin:x:1:1:bin:/bin:/bin/sh
Good
...
4
Try info coreutils 'who invocation':
`-u'
After the login time, print the number of hours and minutes that
the user has been idle. `.' means the user was active in the last
minute. `old' means the user has been idle for more than 24 hours.
info documentation of GNU tools is usually far more complete than man pages.
4
You can use -u to tell vim which rc file to load. e.g.
sudo vim -u ~user/.vimrc /etc/rc.conf
if typing that every time you need to do it is tedious, make an alias:
alias sudovim='sudo vim -u ~user/.vimrc'
Note that vim -u may cause plugins or called rc files to fail if they load other files relative to $HOME - $HOME is now root's home dir, not the ...
4
There is no such thing as a group being a member of a group. A group, by definition, has a set of user members. I've never heard of a feature that would let you specify “subgroups” where members of subgroups are automatically granted membership into the supergroup on login. If /etc/group lists group1 as a member of group2, it designates the user called ...
4
The shell may need to be set in some circumstances, for example if you want to initiate jobs remotely over SSH as the mysql user, or through sudo. These aren't common needs. You don't need to have a shell set for cron jobs, /bin/false will do fine.
Giving the mysql user a shell isn't a security hole on its own. The reason it's frowned upon is that ...
4
You can change your username and move all files in your current home directory to your new home directory using
usermod -l alok -md /home/alok abhishek
Got the answer from another reply: http://unix.stackexchange.com/a/40611/26851
4
This information is not stored by traditional filesystems. You have three main options:
See who is accessing it in real time using lsof/fuser or similar;
Set up auditing (take a look at auditd);
Use something like LoggedFS.
4
A user's BASH environment variables can be defined in ~/.profile. Add a line to this file:
export PATH=$PATH:~/bin
To read the new PATH variable now:
. ~/.profile
or
source ~/.profile
(The . and source are synonyms.)
Then to see that the PATH variable was updated:
echo $PATH
Update
I have never seen {} in a PATH environment variable?
...
4
Good way for nice output of /etc/passwd file:
$ column -nts: /etc/passwd
Now you can sort it:
$ column -nts: /etc/passwd | sort
With groups names in last column (no parenthesis):
$ paste -d: /etc/passwd <(groups $(cut -d: -f1 /etc/passwd) | sed 's/.*: //') | column -nts: | sort
4
If you have root access on the machine, you can do the following:
sudo grep -vE '^[^*!]+:[*!]:' /etc/shadow | sort | cut -d: -f1 | while read user; do id $user; done | column -ts' ,' | vi '+set nowrap' -
How it works
Become root to read the shadow file. You only require root privileges if you want to check if the user has a password set (human user), ...
Only top voted, non community-wiki answers of a minimum length are eligible

