Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [bashrc]

The Bashrc file is used by the Bourne Again Shell in Unix/Linux to set environment variables and run commands.

0
votes
0answers
17 views

How to call environmental variable file in bashrc?

I was mentioned all the environmental variable in the env.sh and it's located in the /opt/env.sh. And i called out env.sh in the .bashrc file which is in the root. But i didn't get the any results. ...
0
votes
1answer
38 views

~/.bashrc is NOT sourced on ssh 'command'

At the end of .bashrc I added: touch /tmp/bash_noninteractive_test Run: /usr/bin/ssh -v -C root@example.com 'ls' On the host (logged in interactively before): % ls -l /tmp/...
2
votes
2answers
69 views

Displaying complete host name when login to linux

How can I display hostname along with user when I login to Linux machine? Now I can see only part of host name where I could not able to identify the server name. would like to display as below; For ...
0
votes
1answer
33 views

Source bash.rc / aliasses from external file (LEMP)

I'm running several LEMP VMs with mostly identical setups. Each of these VMs has a /etc/profile.d/00-aliases.sh containing a bunch of aliasses and functions to run on the server. Now, whenever I make ...
0
votes
0answers
16 views

My bash prompt reverts to default when running script. Is there a way to have it load the PS1/bash-it prompt from my bash_profile?

This is what tends to happen with bash-it: Last login: Mon Apr 16 09:00:38 on ttys002 Script started, output file is /Users/cutecycle/typescript bash-3.2$ exit exit Script done, output file is /...
1
vote
0answers
31 views

How to tell screen use use different bash_profile?

How can I tell to screen to use different bash_profile? Problem is we use a technical user to log in, but I edited a custom PS1. Normally I login with putty like: ssh user@host -t "bash --rcfile ~/....
2
votes
3answers
238 views

Bash commands not found after syntax error

I'm running into an issue where running common bash commands (e.g. ls, mv, rsync, vi) on an Ubuntu 14.04.5 LTS results in something like this: bash: rsync: command not found. When I ssh in I get ...
1
vote
1answer
156 views

How can I apply “shopt -s extdebug” to my shell by default?

I am trying to build a pre-exec checker in bash (using bash-preexec.sh) In order to fail the command when the pre-exec hook fails, I need to run shopt -s extdebug (which fails the command when trap ...
2
votes
1answer
750 views

Scripts in /etc/profile.d are being executed twice on login

Background Info: I am trying to configure a Linux server running CentOS 7 for multiple users. After installing java I want to globally set the $JAVA_HOME environment variable for all users and add it ...
1
vote
0answers
18 views

Linux environment variable setting issue in cluster from single point

I have a cluster of few machines. I have to control all configuration from single system. For that I have decided to used .bashrc in Centos 7 servers (I push same .bashrc in each system via rsync from ...
1
vote
0answers
600 views

ansible-playbook not able to use .bashrc env variables

I'm using ansible-playbook to deploy my django application to Ubuntu servers. I'm storing my django environment variables in .bashrc file of the user ubuntu in the server. But my ansible-playbook is ...
0
votes
2answers
50 views

How to export a file to another user's bash while logging in via SSH (using Putty) to RHEL?

I am running RHEL 7.3, however the procedure may be similar on other Linux systems. I have logged in as root. I have a file called openrc which is full of lines like export OS_IDENTITY_API_VERSION=3....
4
votes
4answers
8k views

Where does the bash PATH on CentOS 7 get /usr/local/bin from?

I've just spun up a brand new CentOS 7 VM (bash version 4.2.46) with Vagrant using the centos/7 box, and when I'm logged in as the vagrant user, this is my PATH: /usr/local/bin:/usr/bin:/usr/local/...
0
votes
3answers
115 views

Enable confirmation for commands with force flag

Is there any option to enable confirmation for the rm -rf . We had an alias setup for rm=rm -i so whenever we delete a file it asks for confirmation but when -f flag is supplied it will not asks for ...
2
votes
2answers
54 views

Convenient date/time stamping console interaction e.g. using shell aliases?

So, I often find that I really want to know when I started a process (or script) after I discovered that it was taking ages.. meaning I couldn't pre-pend date before and after it on the command line (...
1
vote
1answer
69 views

Logout user if they break a bashrc command

I'm running a small script when a user accesses my Linux host via SSH. This script should verify and/or set up Google Authenticator MFA access for the user. Right now it works as intended with one ...
0
votes
1answer
7k views

Running a bash script from systemd as if I logged in

I have a service implemented as a Bash script. Inside it's actually a node.js application, but it could be anything for the purposes of this question. The basic use case is that we develop/debug the ...
1
vote
2answers
339 views

'source .bash_profile' fails but 'source path/to/.bash_profile' works

I am trying to source my .bashrc file on remote host inside sudo-less user. I am getting following responses. sh-4.2$ source .bash_profile sh-4.2$ source: .bash_profile: file not found sh-4.2$ ...
2
votes
1answer
33 views

How to define envrionment variables accesisble by crontab's run and bash shell

I want to define environment variables in one place which will be accessible through different user's crontabs, and from bash shell running. How can I write it once in one place to be accessible to ...
1
vote
0answers
321 views

Why my profile looks for /usr/local/etc/profile.global (NIS)

My Ubuntu ID is manged by NIS/yellowpage. For some reason, when I log in, I'm getting this message. cat@local:~$ ssh catserver cat@catserver's password: Welcome to Ubuntu 15.10 (GNU/Linux 4.2.0-25-...
2
votes
2answers
94 views

printing user of subshell obtaining root via su -

Can I print the username which is obtaining root access via su - on the root console upon obtaining root? user1$ su - password: obtained root via user1 #
4
votes
4answers
3k views

bashrc not loaded in /bin/bash shell

When I ssh into a server (4.3.3-2-ARCH), my .bashrc is not loaded (however, I can load it manually by sourcing it). I don't have any other files in my home folder, like .profile. The shell is also ...
1
vote
3answers
176 views

Best Practice to obscure path to keypair in bash_profile?

I have dotfiles saved in a public github repo, which include the path to my aws keys, which seems like a terrible thing waiting to happen. So it's like this: function superssh { ssh user@something -...
0
votes
3answers
582 views

RBASH how to prevent users exiting to normal bash?

I have set up some test account to beta implement rbash to limit users from doing to much on the server. Currently I am using .bash_profile to set bash -r for these profiles. But when a user types ...
1
vote
1answer
984 views

Can't use functions exported from .bashrc in a bash script

My .bashrc file exports a function called lookup: lookup() { grep -r -ne "$1" * | grep -v "TAGS:" | grep -v "tags:" } export -f lookup I can use that function in a shell. But if I put it in a ...
2
votes
2answers
182 views

Setting systemwide environment variables which are read when a shell is started

What's the preferred way to set environment variables for all users (on Ubuntu) such that the new variables are read whenever a new shell/terminal is started? Presently, we're using a file in /etc/...
6
votes
1answer
828 views

How to protect from dangerous bash commands? [closed]

When using bash with or without sudo there are many traps. For example when logged in as root between rm -rf ~/bin and rm -rf /bin there is just one character but this difference can make you ...
1
vote
2answers
375 views

User created with useradd instead of adduser loads a wrong Prompt

I've designed my bash prompt like this \u@\h> When i now create the User example with adduser, my prompt looks like example@host> But when i create a User with useradd, my prompt looks like \u@\...
0
votes
0answers
97 views

Sudoers, allow user to use root alias

Actually, my root have to aliases: alias unpool='/path/to/my/scripts/unpool.sh' alias pool='/path/to/my/scripts/pool.sh' I have the same for my user in ~/.bashrc I defined my /etc/sudoers.d/user ...
25
votes
2answers
46k views

Straight forward way to run ssh-agent and ssh-add on login via SSH?

I'm trying to have the following commands be auto-executed when I login to my server via ssh: ssh-agent /bin/bash ssh-add ~/.ssh/id_rsa My ssh key has a passphrase and I'm fine with entering it once ...
1
vote
1answer
93 views

Should I be adding aliases to /etc/profile instead of /etc/basrhc?

I've been adding them to /etc/basrhc, and that works most of the time. But I noticed that when I su to another user, I lose all my aliases. It turns out that /etc/bashrc is only loaded when the ...
0
votes
1answer
344 views

Bashrc function called ssh doesn't work

I created a function in my bashrc file so that when i ssh into something it automatically opens a tmux session. function ssht () { /usr/bin/ssh $@ -t 'tmux a || tmux || /bin/bash' } This ...
1
vote
1answer
1k views

Different bash path variables when using ssh script vs interactive ssh [closed]

I'm trying to run some ruby (bundler/rvm) commands via a script using Plink. I noticed that it was complaining about not knowing where some commands were. It seems as though my $PATH variable ...
0
votes
1answer
991 views

Where is this bash shell alias being configured?

While logged in as root onto a CentOS 6.5 system, I run ># alias alias cp='cp -i' alias l.='ls -d .* --color=auto' alias ll='ls -l --color=auto' alias ls='ls --color=auto' alias mv='mv -i' alias ...
0
votes
1answer
714 views

Modify the command line that gets saved to history / .bash_history in Linux

When commands are saved to history in Linux, is there some way to prepend the command line in the history with the remote SSH IP address and process ID so that it's easy to group commands from the ...
5
votes
0answers
1k views

CentOS colors in php-cli applications [closed]

I'm managing a server with CentOS 6.5 x64 installed. In my Ubuntu server, when I run composer or Laravel's artisan php cli command, parameters are colorful. But this doesn't happen when I SSH into a ...
5
votes
4answers
12k views

How do I restore the default bashrc?

I have accidentally overwritten .bashrc. I did the following echo 'export EDITOR=/usr/bin/nano' >> /etc/bashrc Bur I accidentally typed > instead of >>. I guess, it was a bad idea. I ...
1
vote
0answers
768 views

EC2 - editing .bashrc causes terminal to hang and checks to fail

I've been testing this for the past few hours with no luck. When launching an Ubuntu 12.04 EC2 micro instance, I SSH to it, create a new user and continue with installing Ruby version manger under ...
-1
votes
1answer
393 views

Changing path to basedir of mysql

When-ever I need to start mysql from command line, I need to cd to the base directory and then use mysql command as shown below: # cd /home/ec2-user/percona-5.5.30-tokudb-7.0.1-fedora-x86_64/ # ./...
1
vote
1answer
2k views

Change PS1 value for all Bash users

I am trying to change the prompt value for all users of a system (the $PS1 variable) to the same value. I have the following stored in file /etc/ps1: PS1='` if [ $? -eq 0 ]; then echo -n "\[\...
0
votes
2answers
1k views

ssh SendEnv from windows to linux server using cygwin

I am doing ssh to a Open SUSE linux server from windows cygwin. I am trying to send one of my local environment variable through the ssh command so that I can load some specific .bashrc file right ...
0
votes
1answer
65 views

Red Hat 5.4 - Add time to bashrc

I am trying to add the current time to my bash in Redhat. I'd like it to read: [user@hostname 01:01:01 ~] and obviously be relative to when the bash prompt was placed there. Any ideas if this is ...
35
votes
4answers
15k views

Standard place for user defined bash_completion.d scripts?

I have user access (no root) into a Linux (Suse) machine where I developed some bash scripts and the corresponding bash autocompletion rules. Since the scripts belong only to my user and therefore I ...
0
votes
2answers
3k views

.bashrc not loaded, .bash_profile exists

In a ubuntu terminal my .bashrc isn't available until I run: source ~/.bashrc I have a ~/.bash_profile with contents: [[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # ...
2
votes
2answers
505 views

Added line to bashrc, now bash is not responding

I added the following line to the end of my ~/.bashrc (This is on a Linode box) and logged out of my ssh session. source ~/.profile Now when I log in, the shell is unresponsive. I never get to the ...
2
votes
1answer
819 views

Bash Prompt Colors Ubuntu

I am attempting to use a simple shell script on a base Ubuntu 12.04 server install to set prompt colors for users system wide. I would like to have Puppet place the file color.sh in /etc/profile.d/ --...
18
votes
4answers
9k views

Use .bashrc without breaking sftp

My problem is that I need to set a few variables, and output a few lines every time I login to the ssh shell, and at the same time I have to be able to use sftp to tarnsfer files via Filezilla. Now, ...
0
votes
1answer
98 views

Command works independently, but not as SSH callback

A MySQL cloud server only allows remote access to a certain server (in this example, 11.22.33.44). Running the following commands from the terminal is verified to work: ssh -p 40000 user@11.22.33.44 ...
3
votes
2answers
333 views

Using Linux autocompletion with wordlist AND files of the current directory

I have set auto-completion in my .bashrc as follows: complete -W "$(echo `cat ~/.ssh_complete`;)" scp but this ONLY used the words given in the file ~/.ssh_complete. How is it possible to extend ...
5
votes
2answers
15k views

.bash_profile not being read

So I am using CentOS 6.3 a fresh install and I was trying to add things to my path for OpenMPI so I edited my .bash_profile file to read: FOO='test' export FOO # Add support for MPI PATH=$PATH:/usr/...