Hot answers tagged

31

There is a utility which will lookup user information regardless of whether that information is stored in local files such as /etc/passwd or in LDAP or some other method. It's called getent. In order to get user information out of it, you run getent passwd $USER. You'll get a line back that looks like: [jenny@sameen ~]$ getent passwd jenny ...


21

I don't have an OSX system handy to check on but on all *nixes, ~foo is a shorthand for the home directory of user foo. For example, this command will move into my user's $HOME (cd ~ alone will move into your home directory): cd ~terdon So, ~ and Tab will expand to all possible user names. The list should be the same as the list of users in /etc/passwd. ...


20

usq psql shell and : \deu[+] [PATTERN] such as : postgres=# \deu+ List of user mappings Server | User name | FDW Options --------+-----------+------------- (0 rows) And for all users: postgres=# \du List of roles Role name | Attributes | Member of ...


19

You have to check man passwd: If the encrypted password is set to an asterisk (*), the user will be unable to login using login(1), but may still login using rlogin(1), run existing processes and initiate new ones through rsh(1), cron(8), at(1), or mail filters, etc. Trying to lock an account by simply changing the ...


19

This is a security risk because file ownership in the FS is stored not by symbolic name, but by UID and GID. If a user is removed and files remain owned by that user, they become inaccessible under owner permission. However, if a different user is later created that is allocated the same UID, that user will gain ownership of the files. This is potentially a ...


16

TL;DR find / ! -type l -print0 | sudo -u "$user" perl -Mfiletest=access -l -0ne 'print if -w' You need to ask the system if the user has write permission. The only reliable way is to switch the effective uid, effective gid and supplementation gids to that of the user and use the access(W_OK) system call (even that has some limitations on some ...


13

The accounts with passwords are the accounts with a glob of base64 gibberish in the second field: root:8sh9JBUR0VYeQ:0:0:Super-User,,,,,,,:/:/bin/ksh lp:VvHUV8idZH1uM:9:9:Print Spooler Owner:/var/spool/lp:/bin/sh This computer appears to be using the traditional, DES-based crypt(3) password hash. This hash is quite weak by modern standards; if you can't ...


13

The following should work: sudo useradd -m -k /home/user1/ user2 where -m says create the home dir, and -k provides the skeleton directory to use.


9

With write: write <user> Some text goes here CTRL-D (eof) Alternative: echo "Some text goes here" | write <user> See man write.


8

This means that it is disabled for direct login. It is a user that is used for running services or to be used for rlogin. Check https://en.wikipedia.org/wiki/Passwd#Password_file


7

Yes. The normal/unprivileged user can write to /tmp and /var/tmp, for legitimate reasons. Also, if the user or group permissions of a given file/directory includes those of the user, he or she can write to those files or directories as well. Having said that, providing write capability to operating system files and directories to a normal user, is shooting ...


7

You submit a support call to IBM who then give you the hscpe user password, which is good for one day. That user ID and password allows you to gain access to root (assuming you recorded the root password when you installed the HMC). Then you can cat /etc/shadow. You can't do it without root access (by design), and you can't simply switch to root either ...


6

You can use eval to get someone's home directory. eval echo "~$USER" At least for local users this works for sure. I don't know if remote users like LDAP are handled with eval.


5

/tmp and possibly /var/tmp are writtable to any users.


5

An email thread: http://www.sudo.ws/pipermail/sudo-users/2002-September/001225.html http://www.sudo.ws/pipermail/sudo-users/2002-September/001226.html .. points out that sudo -u nobody [cmd ...] can be used: (Combined with the trick of How to append to a file as sudo) echo "Hello World" | sudo -u nobody tee -a /tmp/logfile.log


4

usermod is a tool for modifying the local /etc/passwd database. It cannot be used to modify accounts delivered through Active Directory. id on the other hand looks up any user account regardless of its source. (Actually this is controlled with the passwd setting in nsswitch.conf but if you have integrated AD you'll be using multiple sources.) As mentioned ...


4

Using last you can find this information. The following may be useful: last <username> | less It will return something like this: benlavery@Talantinc:bin $>last benlavery | less benlavery ttys005 Mon Aug 31 09:58 still logged in benlavery ttys005 fe80::105e:6b27:29ff:d967%en0 Mon Aug 31 09:14 - 09:36 (00:22) benlavery ...


4

You can use NFSv3 to map on user and group IDs. If you don't want to map on IDs use NFSv4 instead which maps on user- and groupnames. So if you have two different clients who have a user called user-host-a and user-host-b who both have UID 500 they both have access to the files when NFSv3 is used. When you have two different clients who have a user called ...


4

Easier to do groups [username] If you want to list all local users and their local groups you can do cat /etc/passwd | awk -F':' '{ print $1}' | xargs -n1 groups If you get "groups: command not found", it is likely you've edited your environmental path for the worse, to reset your path do PATH=$(getconf PATH)


4

The user pagagne will need to logout and login to his/her shell for the group to be visible in his groups. You could also check if the user has indeed been added to the group: groups pagagne


4

You cannot do that on the usual Linux filesystems, as it doesn't keep track of the creator of the file, only of the owner of the file. The creator and owner are usually, but not necessarily the same. If you want to find the owner of the file, you can, as Bratchley indicated, use find / -type f -user user_name to find those files and display the names. ...


4

The really right way? Say you want to change user 'peter' to 'paul'. groupadd paul usermod -d /home/paul -m -g paul -l paul peter This changes the name, the group, the home directory and ownership and group of of that directory to the new ones, along with all the files. You end up with a user indistinguishable from having been originally created as ...


4

chage -l <username> Example Output: Last password change : Dec 17, 2015 Password expires : Mar 16, 2016 Password inactive : never Account expires : never Minimum number of days between password ...


4

I figured I can use the following. id -g


4

When extracting files as root, tar will use the original ownership. You can override that using the --no-same-owner option (alternatively, -o). Your tar file referred to user/group which do not exist on the system where you extracted it. If you extract files as yourself (a non-privileged user), you can only create files owned by yourself. The GNU tar ...


4

You're editing the wrong file, and you're not actually modifying the system accounts database, which is why you aren't seeing any modifications. This is not Linux. The master source file for the accounts database is /etc/master.passwd. /etc/passwd is a Version 7 Unix compatibility file, a subordinate file generated from the source. The actual system ...


3

This is typically done using groups. Ownership Files have two owners: a user, and a group. For example: $ ls -l file1.txt -rw-rw-r-- 1 foo foo 6 Nov 9 15:37 file1.txt Here, the user and group are both foo. We can change file ownership using chown. Note that the link links to a manpage for Linux, but chown is pretty standard so it will probably work. ...


3

This essentially does nothing more than changing the username to !user, so if you try to login as user you will get: No passwd entry for user 'user' as the username has been changed to !user. Now if you change the /etc/shadow too and set the username as !user, then you can login as the user !user using the same password used for user. If you want to ...


3

sg allows switching the primary group to a different supplementary group (i.e. a group for which the user is listed in /etc/group) without providing any authentication, or to switch the primary group to one that's mentioned in /etc/group by entering the password listed in /etc/group or /etc/gshadow. Thus, using sg, “without typing any passwords” and ...


3

check out the hidepid option for mounting /proc On multi-user systems, it is often useful to secure the process directories stored in /proc/ so that they can be viewed only by the root user. You can restrict the access to these directories with the use of the hidepid option. To change the file system parameters, you can use the mount command with the -o ...



Only top voted, non community-wiki answers of a minimum length are eligible