Several programs for Linux invoked from terminal/shell use config file where options normally put to program's invocation command line string are put. For instance Vim, for instance curl and their config files ~/.vimrc, ~/.curlrc.
If to take curl and Vim they look for such file in the home directory (it works this way at least according to their man pages).
However I know Linux setups without home directories. For example a NAS.
The known NAS houses several shared volumes / directories to be accessed from client devices via several protocols and by registered users. By default however the NAS does not create home directory for each user newly registered. The administrator hesitate to enable the option "create home directory for this user" if such is needed only for the above purpose.
Is then the usage of program's config file on such setup not possible at all?
To quote from the curl manual:
When curl is invoked, it always (unless -q is used) checks for a
default config file and uses it if found. The default config file is
checked for in the following places in this order:
1) curl tries to find the "home dir": It first checks for the
CURL_HOME and then the HOME environment variables. Failing that, it
uses getpwuid() on Unix-like systems (which returns the home dir given
the current user in your system). On Windows, it then checks for the
APPDATA variable, or as a last resort the '%USERPROFILE%\Application
Data'.
2) On windows, if there is no _curlrc file in the home dir, it checks
for one in the same dir the curl executable is placed. On Unix-like
systems, it will simply try to load .curlrc from the determined home
dir.
So no home directory is needed to store the config files as long, in the case of curl, the variable CURL_HOME, which can point to any location, is set.
Other programs have similar mechanisms.
But I am asking myself: Can one can log in (via ssh?) as a user without a home directory?
Related
Here is the situation. I got a number of hosts that I'd like to maintain via Ansible. The baseline configuration of the hosts like logins/users/etc is controlled by corporate IT overlords, so I can only change things that are related to application not general host setup. Some of the tasks related to application require running as 'root' or some other privileged user.
I do have a password-less sudo access on all the hosts, however all user home directories are located on NFS mounted volume. From my understanding how ansible works it first logs in into the target host as a regular user and places some files into $HOME/.ansible directory, then it switches to root user using sudo and tries to run the stuff from that directory.
But here is the problem. As I mentioned above the home directories are on NFS volume, so after ansible process on the target machine becomes root it can no longer access the $HOME/.ansible directory anymore due to NFS restrictions. Is there a way to tell ansible to put these work files outside of home directory on some non-NFS volume.
There were two parameters for the ansible.cfg configuration file introduced in Ansible 2.1 which allow specifying the location of temporary directory on target and control machines:
remote_tmp
Ansible works by transferring modules to your remote machines, running them, and then cleaning up after itself. In some cases, you may not wish to use the default location and would like to change the path. You can do so by altering this setting:
remote_tmp = ~/.ansible/tmp
local_tmp
When Ansible gets ready to send a module to a remote machine it usually has to add a few things to the module: Some boilerplate code, the module’s parameters, and a few constants from the config file. This combination of things gets stored in a temporary file until ansible exits and cleans up after itself. The default location is a subdirectory of the user’s home directory. If you’d like to change that, you can do so by altering this setting:
local_tmp = $HOME/.ansible/tmp
My zip function isn't working when being called from a php script, but works straight from the SSH prompt.
code in the PHP file that returns nothing var_dump( exec('zip -r domains.zip "domains"') );
code in the php file which works as expected var_dump( exec('/usr/bin/zip -r domains.zip "domains"') );
I've added the path to /etc/profile, I've added it to my ~/.bashrc but can't get the web user to be able to use it.
I'm new to this and it's a VPS so I'm not sure where to go from here.
Ensure that permissions are adequate on the files being accessed - you want to ensure that the user accessing them is able to execute them.
I can't add /usr/local/bin to the apache users PATH variable. The user doesn't have a .profile, I can't su to the user, I can't export to the PATH from php using exec and adding
SetEnv PATH /usr/local/bin
To either the http.conf or the .htaccess file doesn't make a difference. I can't find the envvars file to change that but I suspect there's some other problem.
I have restarted apache, and indeed my server.
Ended up following what Alfe suggested in his answer, except rather than in the /etc/init.d/httpd file (which could be overwritten easily on update) I added to /etc/sysconfig/httpd:
export PATH=${PATH:+$PATH:}/usr/local/bin
Have a look at the /etc/passwd to see which login shell the apache user has (on EC2 Ubuntu instances it should be /bin/sh which is a link to /bin/dash). Then have a look at the man page of that shell and find out which configuration files are read upon login. (For /bin/dash that would be .login in the user's home directory.) In those you should be able to extend your $PATH as you like.
EDIT:
Since you seem to have no login shell for that user: Have a look at the /etc/init.d/* scripts which start the system services. Apache will be one of them. They are started as root and may change the current user (e. g. to the apache user). In there you might be able to adjust the PATH as you like it.
Patching those scripts, however, is not considered typical configuration. Updates might overwrite what ever you patch there.
What is purpose of "wgetrc" in the below commands.
-sh-3.00$ WGETRC=/hom1/spyga/spp/wgetrc_local wget --directory-prefix=/home1/spyga/spp/download ftp://127.0.0.1/outgoing/DATA.ZIP
wgetrc_local files having the credentials of ftp server.
normally i am downloading the files from ftp server using below command.
-sh-3.00$ wget --ftp-user=xyz--ftp-password=12345 ftp://localhost/outgoing/DATA.ZIP
what is the different between above commands.
Please help me out to understand the commands.
Thanks you.
The first command simply specifies an alternative configuration file to use instead of the default ~/.wgetrc. You could also specify it using --config=/hom1/spyga/spp/wgetrc_local as argument to wget.
This file can contain wgetrc commands that change the behaviour of wget. In this case it's probably done so user and passwords don't have to be supplied on the command line. Specially on multiuser systems it is a security risk to pass passwords on the command line, as that can possibly be viewd by other users, so it's a little better to store them in a file with restricted access permissions instead. This way only processes started by the owner of the file can access it.
Another use of the wget startup file is to change it's default settings, user agent etc...
It's all documented here.
I am currently writing an admin page for my webserver, to make it easier on myself to create new apache domains from my browser. Everything is pretty much working as I want it to, except for one thing.
To elaborate: I have a cron job on my server running a bash script as root that checks a file containing a list of domain names that I want to be created. If the file contains a domain name, it automatically creates a new virtual host for this domain, edits my hosts file, and restarts the server. This all works perfectly, however what I would like for the script to do, is that it activates the domain that it automatically creates before it restarts the server. I tried doing this using apache 2's a2ensite command, however the script returns an error saying the command is not found.
Is there a way to call this command from a bash script, or is there an alternative to this command that I can call?
Any help would be greatly appreciated.
$ which a2ensite
/usr/sbin/a2ensite
Usually, cron has a quite restrictive $PATH, not including /usr/sbin or /sbin, which are system binaries (for use by root). It's always a good idea to use fully qualified path names. So either call /usr/bin/a2ensite in your script, or define a variable:
A2ENSITE=/usr/sbin/a2ensite
...
${A2ENSITE} new-domain.com