How to create linux user with privileges - linux

I need to install software on Linux, but it requires me to be a different user other than root. So I created a new user with useradd, created the password with passwd, but now I can't use simple commands in linux which I need to do the installation. i.e. I can't use cd, ls, or anything...
So my question is how do I create a new user which is able to use all of the same commands as the root user?

You could use "sudo" in front of your commands to use a substitute user. It allows you to have admin privileges without being root (dangerous).
e.g.
sudo apt-get thePackageIWant
See the useful instructions here

Related

How run command in CMD with administrator privileges in NSIS?

How to run command in CMD with administrator privileges after user clicks install on NSIS? I use Zip2Exe.
Am I mistaken in thinking that installers ask for these permissions anyway?
Either way it looks like you may be out of luck you might have to use makensis instead.
https://nsis.sourceforge.io/mediawiki/index.php?title=Zip2Exe&oldid=4446
It only allows you to set some very basic installer options like the
name, directory and compression method. It's not possible to add a
license, sections, script code etc.

Root Cannot Open a PDF Ubuntu while users can

I'm using Ubuntu 16.04 and I tried to open a pdf using evince.
It worked well when I'm logged in the normal user but not when I'm using sudo or switch to root user.
It's all about the permission to access the display server.
Generally, depending on your setup, you may need to allow root to access the xserver. https://askubuntu.com/a/175615/668478
If you run on mir, you should use gksudo to allow root to access mir.

node.js read protected files without running as root

I'd like to read/write files using nodejs that live in a protected directory (/etc/apache2/sites-available). I understand that I can run the script with sudo but the idea of that makes me worried. Is there some way I can have node try to elevate for certain functions/calls without having the whole script run with root access?
If you do not provide elevated rights to your script, the script will be unable to mysteriously obtain those rights out of the thin air.
Granted you still need to modify the files, then consider giving write permissinos to your app.
If you are running app as user joe, and owner of sites-available files is root, then do: chown -R joe:joe sites-available.
But if some other user already uses those files, then you might get into permissions conflict. In this case, you can workaround using shared group, or SSH as that user.
Shortly, there are several ways of achieving your goal. But it is completely unrelated to Node.js technology, and all about linux, chown and chmod.

Installing softwares witout sudo in centos for a single user only?

I am using centos 6 for which I am not having sudo access.I have a user account and have full access for that account. Is there a way to install packages/softwares for a particular user in Centos.
Just copy the executables into your home directory. You may also add it to your PATH variable. Many people has a ~/bin directory for this kind of stuffs.

Bash scripting and user home from root account (Linux)

I'm writing an install script in bash for an application on Linux.
This script copies some files into /usr/bin and /usr/share, so it needs to be executed by a root user, furthermore it makes an hidden directory in the $HOME dir for configuration files.
Here is the problem: if a normal user wants to install the program, he needs to be root. But if he is root, the $HOME directory will be /root/ instead of /home/username.
...and, further, if UserA installs the software, but UserB runs it, UserB won't have the hidden directory under /home/UserB. Also, the hidden directory under /home/UserA will be owned by root, not userA.
So, you need to have the application create the hidden directory, not the installer.
Another possible option is not to install in the system directories; one possible alternative location is /usr/local. However, even that can require root privileges. Think about whether it can be installed in other places, and how it could locate its materials.
However, requiring root privileges to install is not the end of the world - a nuisance for some, but not completely out of order. But requiring everyone who uses to have root privileges is way out of order - and if everyone who uses it needs to run the installer, that is bad.
Final point (for now): if you use sudo, it does not change the value of $HOME, even as you acquire root privileges. However, requiring everyone who uses your application to have sudo privileges is not a good thing either.
Must you use $HOME? Maybe you could prompt for the username and install to ~$username instead?

Resources