New answers tagged

3

If you really want to do it, there is a way. Add the following at the end of .bashrc in your home directory, and set PATHEXT to extension names without dots separated by :. Use it at your own risk. if declare -f command_not_found_handle >/dev/null; then eval "original_command_not_found_handle() $(declare -f command_not_found_handle|tail -n +2)" fi ...


11

The simplest solution is to just not use extensions for your scripts. They are not necessary and only serve to identify the script's type to you, but not to the computer. While Windows uses extensions to identify the file type, *nix systems (with very few exceptions such as gzip) do not. Note that binaries have no .exe extension in *nix, they're just ...


5

short: no longer: shell scripts require a full filename, but you can define aliases for your commands to refer to them by various names. For example alias my-script=my-script.pl


1

Normally, screen accepts a command and arguments, so this might work: screen -m -S 'test' nohup ~/<script-to-be-run>.sh Because it is not expecting a variable assignment, and the variable might otherwise be reset, you would probably have to add env to set the variable: screen -m -S 'test' env DISPLAY=:0 nohup ~/<script-to-be-run>.sh'


1

/etc/environment is a configuration file for pam_env, not a file read by a shell. The syntax is somewhat similar, but it is not the same. In particular, you can't refer to existing variables: you've set your search path to contain $ORACLE_HOME/bin and $PATH, i.e. directories with a dollar sign in their name. To set variables for all users, you can edit ...


1

The assignments in /etc/environment should be exported. Otherwise their values are not used. If you use "." to source a file, then you would use this syntax: export ORACLE_HOME=/usr/lib/oracle/12.1/client64 export PATH=$ORACLE_HOME/bin:$PATH export LD_LIBRARY_PATH=$ORACLE_HOME/lib But as noted, /etc/environment is not intended to be sourced (see for ...


2

sudo sanitizes environment before running any command, so unless you save the desired environment variable in /etc/sudoers using env_keep the varible will not be preserved by sudo. Alternately, for a single command, you can do: sudo LANG=en_US.UTF-8 some_command In order to preserve the current environment: sudo -E some_command


1

Use exec bash at the end A bash script operates on its current environment or on that of its children, but never on its parent environment. However, this question often gets asked because one wants to be left at the bash prompt in a certain directory after the execution of a bash script from another directory. If this is the case, simply execute a ...


0

You can check the default values of your system in /etc/default/useradd or with sudo useradd -D, this will output the default value for $SHELL and other variables.


3

Traditionally, by login(1): ENVIRONMENT login sets the following environment variables: HOME The user's home directory, as specified by the password database. SHELL The user's shell, as specified by the password database. Though these days it might be a window manager or terminal program making those ...


1

The list of files that bash loads during startup is documented in the manual. There's ~/.bash_profile, ~/.profile, ~/.bash_login and /etc/profile for a login shell, and ~/.bashrc (and /etc/bash.bashrc or similar on some systems) for an interactive shell. It's common for these files to include other files, and there's no general rule that would give you an ...


0

See man xsession: /etc/X11/Xsession.d/40x11-common_xsessionrc Source global environment variables. This script will source anything in $HOME/.xsessionrc if the file is present. This allows the user to set global environment variables for their X session, such as locale information.


1

Create a file like the following: #!/bin/sh USER=u PASSWORD=p IP=10.10.10.10 node app.js ... or ... #!/bin/sh USER=u; export USER PASSWORD=p; export PASSWORD IP=10.10.10.10; export IP node app.js ... where you put your own values in there instead of "u", "p", and "10.10.10.10". Save the file as, say, runapp, then make it executable with chmod u+x ...


3

You need to run export against the name of the variable. Right now, the variable is being referenced and replaced before export sees it. Change it to this: export user Note the lack of $ Your current version is essentially this: export ubuntu Because $user is interpreted first. You also lost your environmental variables when using sudo. There are ...


0

I finally added a profile.desktop file in ~/.config/autostart that looks like this: ~/.config/autostart$ cat profile.desktop [Desktop Entry] Encoding=UTF-8 Version=0.9.4 Type=Application Name=profile Comment= Exec=/bin/bash /home/nicoco/.profile OnlyShowIn=XFCE; StartupNotify=false Terminal=false Hidden=false This is the only workaround I found that ...


2

~/.xinitrc is only read when you start a GUI session with startx (or otherwise calling xinit) after logging in in text mode. So that won't help you. Whether ~/.bash_profile, ~/.profile, ~/.xprofile and ~/.xsessionrc are read when logging in with a display manager depends on how the display manager is configured and what session type you select when logging ...


0

Managed to fix it with this: env PUB_CACHE=/app/src/.pub-cache dart-sdk/bin/dart server.dart Didn't realise you could pass commands on the end (thanks cuonglm for getting me on to this in the comments!)


1

Environment variables are specific to each process. When a process starts, it is given a copy of the environment (built up by the process which is starting it), and once it's started no other process can touch that copy. In your example, when you change the value of x, you're doing so in the shell you're running. By exporting variables, you tell the shell ...


2

An environment variable is not meant to do such a trick. The script inherits the environment as a copy once it is run; the two environments are then independent. You may need to look for interprocess communication methods. If you really, really have to do this via variable, check this; although it's not the right way to communicate with a running process in ...


1

On Linux: As root, iterate su <username> -c 'echo $VARNAME' --login over all relevant usernames. Should work in a similar way on HP-UX, but please check man su. It's important to use single quotes to prevent your local shell to expand the variable.


0

you can look in the dot files, environment variables are set in .files in the users /home directory (like .bashrc or .localrc etc)if you know the name of the variable you are looking for you can find the string with grep, in the example below it looks for 'set' or 'setenv' cat /home/*/.* | grep 'setenv\|set'


0

To make Modules exclude !:: from its TCL setup, modify init.c as shown in this unified diff, and recompile. @@ -703,6 +703,11 @@ envsize += strlen( environ[i]) + 1; +#ifdef __CYGWIN__ + if( *environ[i] == '!') + continue; +#endif + /** ** Locate the equal sign and terminate the string at its position. **/ ...


1

You can setup a pager to capture output and then quit if it fits on one screen. When it doesn't fit, you can use the pager to scroll and search. export PAGER=less export LESS=-FSXRi # -F and -X are relevant here, but that's what I use # also, less quickly toggles most by typing '-' and the option I imagine zsh has a way to automatically modify commands ...


0

You should be able to do a multi-line script eg ExecStart=/bin/bash -c '\ source /opt/environmentname/bin/activate environmentname; \ exec /var/programname/programname -f /etc/programname/programconfig.conf'


1

To understand this... does ExecStart depend on the environment set by this command? Because these lines are actually not executed in the same shell, so you can't expect them to share the environment. What you need is to use the Environment keyword in the unit file. That way, the ExecStart will get the environment defined by your file. ...


1

whoami on Linux does not read the USER variable. On a "regular system" (meaning not using for example LDAP) it just does a geteuid(2) system call to get your current effective userid and then reads /etc/passwd to look up your username.


0

Here's a working solution for it (RHEL 7 tested): $ export test1='git --git-dir' $ export test2='my-folder/.git/ add Steps-to-follow.txt' $ #; git --git-dir' $ export test3='my-folder/.git/ commit' $ export git1=$test1=$test2 $ export git2=$test1=$test3 $ $git1 $ $git2 This will work. I cannot say this is the most optimal solution, however, it works the ...


0

I’m not familiar with git, so I don’t really understand what you are trying to do — in particular, why does your first command have the word echo twice, but then you didn’t put it into your variables?  But I guess that you want to do something like this: Avineshwar_func() { git --git-dir="$1" echo test-folder/.git/ add Steps-to-follow.txt && git ...


-1

Try this: varname='value' export varname and don't put 'export equal==' in your bash profile, because it may cause errors Hope this helps!



Top 50 recent answers are included