Tag Info

New answers tagged

0

The issue was that the file had windows line endings (crlf instead of lf) Thank You @jdeBP For explanation see http://unix.stackexchange.com/questions/154408/cant-cd-to-home-user-when-sourcing-a-script


2

Especially if your "targeted" user has no sudo privileges, the solution below is pretty "waterproof". It can be used not only to block users from the terminal, but (any user) from using any application. What it is The solution exists of a simple and very light-weight background script that you can use in a flexible way to block users from applications. ...


0

From useradd man page: -e, --expiredate EXPIRE_DATE The date on which the user account will be disabled. The date is specified in the format YYYY-MM-DD. If not specified, useradd will use the default expiry date specified by the EXPIRE variable in /etc/default/useradd, or an empty string (no expiry) by default. So you should ...


0

Well, that user had some processes running. 22220 is probably a process ID, the fd/0, fd/1, fd/2 are stdin, stdout and stderr of that process. It is not a surprise that these can't be deleted. They go when the process goes. I don't thing that anything bad happened.


0

Almost everything in /usr is owned by root:root I run find /usr -not -gid 0 -printf "%M\t%u\t%g\t%p\n" here using 15.04 and the output is -r-xr-sr-x root postdrop /usr/sbin/postqueue -rwsr-xr-- root dip /usr/sbin/pppd -r-xr-sr-x root postdrop /usr/sbin/postdrop drwxrwsr-t root lpadmin /usr/share/ppd/custom drwxrwsr-x root staff ...


2

Open the terminal and type: sudo newusers /tmp/userlist.txt In the userlist.txt file, each line should contain user data in the following syntax: username:password:User ID:Group ID:Comments:Userhome directory:User shell Since the userlist.txt file contains users' passwords, it should not be stored in a human readable form after you have ...


0

You will need pwgen tool to make random passwords Make a file (users.txt) with usernames delimited with \n: userA userB userC Write a bash script that reads from stdin: while read user do password=$(pwgen -N 1) sudo useradd $user -m -s /bin/bash sudo passwd $user $password echo Created $user with password $password done Lastly, call the ...


1

Maybe you can put this at the end of your script? read -p "$USER"


1

You can execute script with ./ if you are in same directory as script. But if you want to run it from anywhere , you have to put the script into one of the folders listed in your $PATH preferably /usr/bin or add a custom folder to the list. As for creating a file, if you specify full path to script , like nano /usr/bin/myscript.sh , yoi don't have to be ...


2

Here is the improved version of my original script I've linked in the comments. This script uses all the tools that come with ubuntu, namely at(for task scheduling) , date, and gnome-session-quit so no additional installation of software is necessary. This script can be called from ~/.config/autostart or /etc/xdg/autostart in a .desktop file. date will ...


0

You can loop through the file twice: awk -F: 'FNR==NR{count[$3]++; next} count[$3]>1 && !seen[$1] { print $1, $3, "("count[$3]" times)"; seen[$1]++ }' /etc/passwd{,} First time to keep a counter of how many times each UID appears. Second time to print all those values who were noted to appear more than once. ...


0

Another bash way: #! /bin/bash read -p "Username: " user if IFS=: details=($(getent passwd $user)) then printf "Username: %s\nUser ID: %d\nGroup ID: %d\nShell: %s\nDirectory: %s\n" "${details[0]}" "${details[2]}" "${details[3]}" "${details[6]}" "${details[5]}" fi One can, in a single step run a command, taking its output - $(getent passwd $user) ...


0

Keep a count for each UID, and save UIDs, and then print those entries whose UIDs have appeared more than once: awk -F: '{count[$3]++; users[$3] = $1 " " users[$3]} END {for (i in count) {if (count[i] > 1) { print users[i] } } }' /etc/passwd


0

If with "the user's" name you meant the username of the user running the script: #!/bin/bash read -p "Username: " username if [ "${username}" == "${USER}" ] then user_data="$(< /etc/passwd sudo grep "^${username}:")" echo "Username: ${username}" echo "User ID: $(<<<"${user_data}" cut -d: -f3)" echo "Group ID: ...


0

Here is a python solution: #!/usr/bin/env python2 import sys with open('/etc/passwd') as f: for line in f: if line.startswith(sys.argv[1] + ':'): parts = line.rstrip().split(':') print 'Username: ' + parts[0] + '\n' + 'User ID: ' + parts[2].rstrip() print 'Group ID: ' + parts[3] + '\n' + 'Shell: ' + ...


1

Here's one way to get the gid, uid, shell and directory: printf "Enter username: " read user groupid=$( id -g $user ) userid=$( id -u $user ) usershell=$( grep $user /etc/passwd | awk -F':' '{ print $7 }' ) userdirectory=$( grep $user /etc/passwd | awk -F':' '{ print $6 }' )


1

Using awk: awk -F: '{if ($3 > 10) { print $1 ":" $3 } }' /etc/passwd this will list all users with their associated UID where UID > 10. Thanks to @sadi note, to list only usernames awk -F: '{if ($3 > 10) {print $1}}' /etc/passwd


0

The standard permission system in Linux does not support well the use case that you are describing (for example "deny access to the entire hard-disk"). A better approach would be to try using chroot or docker, to make sure that the program runs in an environment that is isolated from the main system.


2

SOLUTION 1 : You can use: #!/bin/bash while IFS= read -r line; do [[ "$(cut -d: -f3 <<<"$line")" -gt 10 ]] && echo "$line" done </etc/passwd Considering you have no username containing :. If you just want the usernames: #!/bin/bash while IFS= read -r line; do [[ "$(cut -d: -f3 <<<"$line")" -gt 10 ]] && echo ...


4

You can parse the passwd database using awk. In the passwd format, each entry is a list of fields delimited by :, with the first field being the username and the third field being the UID. So, in awk, you could do: getent passwd | awk -F: '$3 > 10 {print $1}'


0

The important property of administrators on Ubuntu is that they can perform whatever actions they choose, as root, using sudo and polkit. This is necessary, in order for them to have the power to fully administer the system. And this is already how an administrator changes the password of another user. Considerable restrictions would have to be put in place ...


1

For the reason muru stated in his comment above, it is impossible to restrict some actions for administrator accounts. Even if you can achieve that the admin may not do this from within his/her own account, he/she still has the right to become root (sudo) and have no restrictions at all. Sorry, but the only thing to restrict an admin's rights is to convert ...


0

I'd break your problem into 2 parts: 1) How do I find the processes started by me? Run this: ps -u `whoami` The whoami is just in case you don't know the name of the account you are using, otherwise just type the name of the account without the back quotes. This will list all processes that can be deleted by your account. 2) The ps command will list ...


1

sudo apt-get install gnome-system-tools How to manage users and groups?


0

Actually Umain and Uclone are the same user. And yes you can't modify the UID of your user since you are login using its credentails and thus you can't chnage ot modify its behavior unless you are not using any other process of your system. To solve your problem(if you think it's) you have many solutions: Use a live cd and do whatever you want Easiest is ...


0

That's the same user. You can use vipw and vipw -s commands to remove the line that points to the Uclone user. Vipw command use vi as default editor, so you can replace it with some easier, like for example is nano: sudo EDITOR=nano vipw


0

TL;DR: Do things as root only when you have to. sudo makes this pretty easy. If you enable root logins, you can still follow this rule, you just have to be careful to do so. Although enabling root logins is not actually insecure if done right, you don't need to enable root logins because you have sudo. There are really two related questions here. Why is ...



Top 50 recent answers are included