New answers tagged

1

This is a bare minimum script to get the job done. It makes sure that neither the username nor the uid is already in use. It makes a matching group for each user (with gid=uid) - it doesn't check if the gid or group name already exists (left as an exercise for the reader - hint: use getent group). Note: the script below is untested but I've written ...


2

Lets say your file is named just file. This script will do the job: USERNAME=$(cat file | cut -d: -f1) echo "$USERNAME" ID=$(cat file | cut -d: -f2) echo "$ID" USER_SHELL=$(cat file | cut -d, -f2 | cut -d: -f2) echo "$USER_SHELL" useradd -m -s "$USER_SHELL" -u "$ID" "$USERNAME"


3

These folders are not made/used by the system during user creation because the system doesn't generate them. They are generated the package xdg-user-dirs-update (Ubuntu) and xdg-user-dirs (Fedora/RHEL). The file /usr/bin/xdg-user-dirs-update is run at logon and creates the files based on defaults in /etc/xdg/user-dirs.defaults, or if it exists $HOME/....


1

"root" (aka "superuser") is the name of the system administrator account. The origins of the name are a little archaic, but that doesn't matter. Root user has user id 0 and nominally has unlimited privileges. Root can access any file, run any program, execute any system call, and modify any setting. (But see below┬╣). Prior to the invention of the "sudo" ...


2

To give Tim access to iptables, you can edit /etc/sudoers, with visudo: tim ALL=NOPASSWD: /sbin/iptables This will allow him to used the iptables as root without inputing his password. The path is full, for security reasons, otherwise if only iptables as you have, Tim would be able run any binary called iptables as root, and would be enough to create a ...


0

I have two aliases added to my .zshrc.local file to create strong passwords. The first is: alias pw.graph="cat /dev/urandom | tr -dc '[:graph:]' | fold -w 1000 | perl -pe 's/(.)(?=.*?\1)//g' | head -n 5" The output of typing pw.graph is five lines of every character that can be typed on a keyboard with the exception of the space bar: /d=|&mRq!g$...


0

create exampleuser , and set password to it then change firefox permissions to 700 and change firefore own to exampleruser ; after this you can run firefox only root or exampleuser with sudo or su command. for exmaple: sudo useradd exampleuser sudo passwd exampleuser sudo chown exampleuser:exampleuser ../firefox sudo chmod 700 ../firefox test: $ ../...


0

There's another simplier way with /usr/sbin/groupmems groupmems -p -g group_to_clean All members will be removed from the group. Tested in CentOS.


0

try adding at the end of .profile ./myscriptshell.sh > myscriptshell.log 2>&1 this sould start myscriptshell, logging any error to myscriptshell.log as cas pointed out, you'd better add & at the end of line.


-1

I'm not sure I would call it a technical reason, but the rule boils down to "the username must be a valid programming-language identifier". Identifiers have some nice properties due to their restricted syntax: They cannot be mistaken for numbers, even when reading characte by character, and they do not need to be quoted when going through a parser. In short, ...


1

Is there a technical reason why? Is this an artifact from the early days of Linux or Unix, and if so is there a reason why it persists? I cannot think of a technical reason - historically, it's just ASCII. How it is read in and then typed is in the hands of the coder. unix-history-repo/usr/src/cmd/passwd.c char *uname; insist = 0; if(argc < 2) { ...


74

here is a test on ubuntu 14.04 using numbers: root@ubuntu:~# useradd 232 root@ubuntu:~# mkdir /home/232 root@ubuntu:~# chown 232.232 /home/232 root@ubuntu:~# passwd 232 Enter new UNIX password: Retype new UNIX password: passwd: password updated successfully root@ubuntu:~# login c2 login: 232 Password: Welcome to Ubuntu 14.04.4 LTS (GNU/Linux 4.4.0-22-...


122

Some commands (eg chown) can accept either a username or a numeric user ID, so allowing all-numeric usernames would break that. A rule to allow names that start with a number and contain some alpha was probably considered not worth the effort; instead there is just a requirement to start with an alpha character. Edit: It appears from the other responses ...


9

A *Nix username is generally a 32 character long string created by the utility useradd. This is, as you said, a direct result of early Unix (BSD technically) standards. According to the FreeBSD Man Page passwd(5): The login name must not begin with a hyphen (`-'), and cannot contain 8-bit characters, tabs or spaces, or any of these symbols: ...


2

nfs4 does not use uid numbers but usernames. You can add to your /etc/idmapd.conf [Translation] Method=static [Static] fred@remote = localfred where fred is the username on the remote, and localfred is the local username.


0

According to Mark Cohen's answer, you need some kind of change permission action. But simple sudo chmod 777 javalib will crash with another permission denied. You need to add mount options -o username=guest,dir_mode=777,file_mode=666 to make directories executable for everyone. If this method won't help, then you may need to add options, such as -o uid=$(...


3

You can use ps together with awk to find the physical memory usage by a user: ps -U root --no-headers -o rss | awk '{ sum+=$1} END {print int(sum/1024) "MB"}' Here it prints memory used by root to the output.


1

I think smem is the better tool in your case. Install smem and try smem -uk If you are using debian you can install it using: apt-get install smem If you cant install nothing on the server you can try: ps haux | awk -v user=$USER '$1 ~ user { sum += $4} END { print user, sum; }' Remember that $USER is a environment variable so you don't need to ...


2

Nowadays, on a correctly-configured system there shouldn't be any way of determining this. On a badly-configured system, you might see different behaviour when attempting to log in depending on whether the user you're trying to log in as exists or not. (Hopefully not in the messages returned, but perhaps in the timing of the responses.) In the past, finger ...


2

First sorry for my bad english. Lets show something for you using only unix concepts, cause i think it can help (or maybe not). Imagine that i want that the executable nano can be executed by every users, but must never run as the user that call its executable, but with a limited environment, with access to edit the apache configuration only or files in ...



Top 50 recent answers are included