143

The functionality you are looking for is implemented in glibc. You can define a custom hosts file by setting the HOSTALIASES environment variable. The names in this file will be picked up by gethostbyname (see documentation). Example (tested on Ubuntu 13.10): $ echo 'g www.google.com' >> ~/.hosts $ export HOSTALIASES=~/.hosts $ wget g -O /dev/null ...


68

I was looking for a way to run a program with modified DNS resolution for testing purposes. For me, the solution was using the HOSTALIASES environment variable: $ echo "foo www.google.com" >> ~/.hosts $ HOSTALIASES=~/.hosts wget foo See hostname(7). (Side note: In the example the HOSTALIASES environment variable only affects the wget process. Of ...


65

Figures that I'd figure this out on my own. The clue was here, in the user service output: Dec 23 19:43:27 redmine systemd[613]: Reached target Default. My unit was asking to be loaded with multi-user.target, but there is no such target in the user systemd. I changed this to default.target in the unit file, disabled and re-enabled the service, and it now ...


56

You need to compile these from source. It should just be a matter of apt-get source PACKAGE ./configure --prefix=$HOME/myapps make make install The binary would then be located in ~/myapps/bin. So, add export PATH="$HOME/myapps/bin:$PATH" to your .bashrc file and reload the .bashrc file with source ~/.bashrc. Of course, this assumes that gcc is installed ...


51

There are a couple approaches, some of them mostly secure, others not at all. The insecure way Let any use run mount, e.g., through sudo. You might as well give them root; it's the same thing. The user could mount a filesystem with a suid root copy of bash—running that instantly gives root (likely without any logging, beyond the fact that mount was run). ...


47

The easiest way to do this is to install R from source: $ wget http://cran.rstudio.com/src/base/R-3/R-3.4.1.tar.gz $ tar xvf R-3.4.1.tar.gz $ cd R-3.4.1 $ ./configure --prefix=$HOME/R $ make && make install The second-to-last step is the critical one. It configures R to be installed into a subdirectory of your own home directory. To run it on ...


45

Just add all needed commands to sudoers separately: %webteam cms051=/usr/bin/systemctl restart httpd.service %webteam cms051=/usr/bin/systemctl stop httpd.service %webteam cms051=/usr/bin/systemctl start httpd.service %webteam cms051=/usr/bin/systemctl status httpd.service


44

Beside the LD_PRELOAD tricks. A simple alternative that may work on a few systems would be to binary-edit a copy of the system library that handles hostname resolution to replace /etc/hosts with a path of your own. For instance, on Linux: If you're not using nscd, copy libnss_files.so to some location of your own like: mkdir -p -- ~/lib && cp /lib/...


43

The --disabled-password option will not set a password, meaning no password is legal, but login is still possible (for example with SSH RSA keys). To create an user without a password, use passwd -d $username after the user is created to make the password empty. Note not all systems allow users with empty password to log in.


36

Compile and install into ~/bin (and edit your .bashrc to set the PATH to include it). libraries can similarly be compiled and installed into ~/lib (set LD_LIBRARY_PATH to point to it), and development headers can be installed into e.g. ~/includes. Depending on the specific details of the programs you want to install and the libraries they depend upon, you ...


36

@jofel's answer was exactly what I needed to get a working setup. POsting this for anyone else stumbling on this question. I needed a way to have capistrano restart my Ruby application after deploying from my local machine. That means I needed passwordless access to restarting systemd services. THIS is what I have and it works wonderfully! Note: my user and ...


34

As uther mentioned, /usr/local is intended as a prefix for, essentially, software installed by the system administrator, while /usr should be used for software installed from the distribution's packages. The idea behind this is to avoid clashes with distributed software (such as rpm and deb packages) and give the admin full reign over the "local" ...


32

You've created a user with a “disabled password”, meaning that there is no password that will let you log in as this used. This is different from creating a user that anyone can log in as without supplying a password, which is achieved by specifying an empty password and is very rarely useful. In order to execute commands as such “system” users who don't ...


28

Private mountspaces created with the unshare command can be used to provide a private /etc/hosts file to a shell process and any subsequent child processes started from that shell. # Start by creating your custom /etc/hosts file [user] cd ~ [user] cat >my_hosts <<EOF 127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4 127....


24

Symlink issue? I had a similar error message when using symbolic links. Apparently systemd doesn't follow symbolic links, the solution is simply to copy or move the file. User service? I believe that you need to add --user to the command line for units in user/: sudo systemctl --user enable arkos-redis.service


24

Give the other users permission to kill the processes as the low priority user through sudo -u lowpriouser /bin/kill PID A user can only signal their own processes, unless they have root privileges. By using sudo -u a user with the correct set-up in the sudoers file may assume the identity of the low priority user and kill the process. For example: %...


22

You can do it, but you need to modify the entry in /etc/fstab corresponding to the filesystem you want to mount, adding the flag user to this entry. Non-privilege users would then be able to mount it. See man mount for more details.


21

“Error mounting location: volume doesn't implement mount” apparently translates to “I need D-Bus but it isn't available”. (Thanks to venturax's guru colleague for this information.) Within an SSH session, I can use gvfs-mount provided that dbus-daemon is launched first and the environment variable DBUS_SESSION_BUS_ADDRESS is set. export $(dbus-launch) gvfs-...


21

Use the start-stop-daemon utility to start your daemon. Pass the -c (or --chuid) option to run it as a different user. You'll find some examples in /etc/init.d/*. case $1 in start) echo -n "Starting $DESC: " start-stop-daemon --start --chuid deploy --pidfile "$PID" --start --exec "$DAEMON" -- $DAEMON_OPTS echo "$NAME." ;; …


21

The Bluetooth protocol stack for Linux checks two capabilities. Capabilities are a not yet common system to manage some privileges. They could be handled by a PAM module or via extended file attributes. (see http://lxr.free-electrons.com/source/net/bluetooth/hci_sock.c#L619) $> sudo apt-get install libcap2-bin installs linux capabilities ...


20

To reference a few more tools. htop http://hisham.hm/htop/ https://github.com/hishamhm/htop Command line tool, packaged in most distributions, is able to show the I/O without root privileges but only for your processes. run htop(1), you'll find an interface similar to top(1) hit F2 to enter the configuration use ↓ to select "Columns" use → to select "...


18

The problem is not occurring because of the UID of the user. 500 is just fine as a UID, and that UID doesn't make it a 'non-login' user except in the eyes of the default settings of some few display managers. The error message No protocol specified sounds like an application-specific error message, and an unhelpful one at that, but I am going to guess that ...


17

There are ways to install rpms in a user directory using rpm, but I don't believe it is straight-forward. I don't believe there is a way with yum. My standard practice has become to compile from source to a local directory in my home $ mkdir ~/local $ mkdir ~/local/bin $ mkdir ~/local/lib $ mkdir ~/local/include I download source as I would to /usr/local ...


17

You can use cron if your version has the @reboot feature. From man 5 crontab: Instead of the first five fields, one of eight special strings may appear: string meaning ------ ------- @reboot Run once, at startup. … You can edit a user-local crontab with the command crontab -e without root privileges. Then add the ...


17

Debian (and hence probably Ubuntu, too) has been known to ship a kernel with such a restriction of user_namespaces, and there the way to enable it was/is: sysctl -w kernel.unprivileged_userns_clone=1 (Source: https://blog.mister-muffin.de/2015/10/25/unshare-without-superuser-privileges/.) ALT has such a restriction in kernel-image-std-def, too. ...


16

If you as an ordinary user decide to run a program, the natural place for its logs are in your home directory. Your home directory is meant for you to store all your files, whether they are logs of a program you run or anything else. If the program is executed as part of the system, running as a typically dedicated system user, then the natural place for ...


16

You haven't added any sudo rule, so you can't use sudo for anything. The command adduser USERNAME sudo adds the specified user to the group called sudo. A group with that name must exist; create it with addgroup sudo if it doesn't. After adding the user to the group, the user must log out and back in for the group membership to take effect. sudo is not a ...


15

On Linux, you need the CAP_CHOWN capability to chown. root is granted such. Refer to: http://vouters.dyndns.org/tima/Linux-OpenVMS-C-Implementing_chown.html for explanations. If you intend to give the CAP_CHOWN capability, build your code with libcap-ng or libcap as demonstrated by: http://vouters.dyndns.org/tima/Linux-PAM-C-...


15

In the image you show that the "other" group has read permissions; if you tried to append echo testline >> useradd or execute ./useradd it would give you a permission denied. If you're looking to remove read permissions for the 'other' users you can use sudo chmod o-r useradd


14

you can install it locally in your home directory. Ususally it can be done by specifying the parameter prefix for configure script. For example, ./configure --prefix=$HOME So, when you compile sources configured in such way, then you will call make install the binaries will install into you $HOME/bin Also, you should alternate PATH variable. You can do ...


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