Questions tagged [bashrc]

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

Filter by
Sorted by
Tagged with
0 votes
1 answer
67 views

su command not set BASH_VERSION value and not load profile

I have a Ubuntu 20.04 LTS server version and have a strange problem creating a new user and use it in the shell from a ssh connection. The steps to reproduce it: Use he root account to create new ...
e-info128's user avatar
  • 173
1 vote
1 answer
64 views

Why is my bash script not being sourced when opening new tmux pane?

The following logic in .bash_aliases to remove duplicate paths works fine when opening a new terminal: # prune duplicate paths PATHS=("PATH" "LD_LIBRARY_PATH" "C_INCLUDE_PATH&...
Jeff_V's user avatar
  • 21
0 votes
1 answer
693 views

Refresh kerberos ticket instead of prompting for pam password

Using centralised auth against FreeIPA is working great. In order to use Kerberos SSO when using ssh, scp etc from jumphosts users must initiate their Kerberos tickets first with kinit. I've added ...
dmgeurts's user avatar
0 votes
2 answers
393 views

Use original linux user bashrc also as root user

I extended the bashrc file of my linux user. This file contains extra aliases, functions, whatever is useful. It's synchronized with a playbook across our 100+ servers. When i'm working on linux I ...
ansible_usah's user avatar
2 votes
1 answer
1k views

sourcing environment variable in bashrc: directly vs export from file yields different result - why

I am running systemd via user (i.e. enable-linger $USER) and I interact with services via systemctl --user I noticed a strange issue. Sourcing Type 1 In order for the above systemd to work for a user, ...
Newskooler's user avatar
0 votes
1 answer
662 views

How to Make the IP Address Appear as Part of Bash Prompt?

Running an Amazon EC2 instance with Ubuntu 22.04. The elastic ip address is 52.120.94.72. I want the bash prompt to read like this (no space) [email protected]:~/working_directory$ Based on some ...
Della's user avatar
  • 215
1 vote
1 answer
1k views

Starting Directory for Bash

I've a Docker container running. I connect to the container using a command like: docker exec -it container_name bash This logs in as root at /var/www/html. I want to know why this directory, and how ...
Marshall Davis's user avatar
1 vote
3 answers
855 views

Saving the date to actual bash history file

When adding "HISTTIMEFORMAT" to bashrc, the timestamps of when a command was executed are made available when running the "history" command. But the timestamps themselves are not ...
OB7DEV's user avatar
  • 125
1 vote
3 answers
3k views

Ubuntu 20.04: su command bash-autocomplete stopped working

I am using Ubuntu 20.04. The su autocomplete stopped working. For example when I type: su TabTab It lists the files and directories of the current directory, where as it should list the available ...
Ajaib Singh's user avatar
0 votes
1 answer
3k views

How to set a command alias that will be respected in a shebang

I run multiple versions of PHP on my Linux server. I've added an alias in my bashrc to point the php command to a specific version alias php='/usr/bin/php7.3'. This works as expected when I execute a ...
Dom's user avatar
  • 488
0 votes
0 answers
80 views

Custom bash prompt failing when home directory is remote

0 I am trying to configure a custom prompt for RHEL 8 users. It works very nice when the users have local home directories. However, I'm mounting home directories via pam_mount (nfs4). When ssh'ing to ...
francisaugusto's user avatar
0 votes
1 answer
277 views

Exclude or Include certain profile lines during a tmux session start

In my .bash_profile, I have a line to start tmux only if it is present on the system with: [ -z $TMUX ] && export TERM=xterm-256color && exec tmux In a similar vein, I would like to ...
YorSubs's user avatar
  • 135
0 votes
1 answer
311 views

assigning aliases in .bashrc via echo '...' >> .bashrc

running cat .bashrc gives me these two lines at the end: alias remove='rm -i' alias chamber='ls -a -i -l' when I run remove followed by a file name I get a successful removal with confirmation ...
Joel's user avatar
  • 1
0 votes
2 answers
1k views

Global use of 'aliases' on Debian 10

I've been trying to add global use of aliases on my Debian 10 instance with no luck. What I've already attempted is adding my aliases to /etc/bash.bashrc as well as adding this snippet to /etc/profile ...
CranberryPie's user avatar
0 votes
1 answer
274 views

Aliasing Server Name in SSH Command [closed]

This may be trivial, but I am not sure how do it safely and optimally. I have a few servers (AWS EC2) into which I ssh from the bash. Those server names are long. How can I alias them, so instead of ...
MadPhysicist's user avatar
0 votes
0 answers
82 views

/etc/profile, /etc/bash.basrc, ~/.profile, ~/.bashrc are not read

I am a running "Ubuntu 16.04.6 LTS" Linux. I've installed/upgrade some packages, but i do not remember exactly which packages. Since this operation, i have lost ls coloration for all users ...
Bob5421's user avatar
  • 361
2 votes
0 answers
166 views

How to auto init direnv on Google Cloud Shell?

my .bashrc has these lines at the bottom: if [ -f $HOME/tools/bashrc ]; then source $HOME/tools/bashrc fi and $HOME/tools/bashrc has this code at the bottom: eval "$(pyenv init -)" pyenv ...
Noel Pure's user avatar
  • 121
1 vote
1 answer
577 views

Global Bash Completion Scripts

I have a Bash completion script. Is there a place I can put it on my system, so that it will be automatically source-ed for any user that uses a Bash shell? I would prefer a solution that does not ...
user avatar
0 votes
2 answers
259 views

How to rename system commands e.g., shutdown in Ubuntu Linux

While working on redis server, I come to know there is an option to rename you scracy command to avoid accidental update. Is there any option for bash i.e., Ubuntu Linux especially shutdown, rm and ...
Hafiz Muhammad Shafiq's user avatar
21 votes
2 answers
24k 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 [email protected] 'ls' On the host (logged in interactively before): % ls -l /tmp/bash_noninteractive_test ...
LetMeSOThat4U's user avatar
2 votes
2 answers
2k 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 ...
guru's user avatar
  • 33
0 votes
1 answer
51 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 ...
Asitis's user avatar
  • 97
1 vote
0 answers
75 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 ~/....
János Geringer's user avatar
2 votes
3 answers
496 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 ...
bjnsn's user avatar
  • 121
1 vote
1 answer
1k 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 ...
DVK's user avatar
  • 151
4 votes
1 answer
7k 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 ...
tjwrona1992's user avatar
1 vote
0 answers
27 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 ...
Hafiz Muhammad Shafiq's user avatar
4 votes
2 answers
10k 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 ...
Nijo 's user avatar
  • 202
0 votes
2 answers
273 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....
Zac's user avatar
  • 101
9 votes
5 answers
31k 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/...
Iain Hallam's user avatar
0 votes
3 answers
628 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 ...
Geo's user avatar
  • 575
2 votes
2 answers
66 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 (...
user73225's user avatar
1 vote
1 answer
322 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 ...
Joum's user avatar
  • 151
4 votes
2 answers
14k 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 ...
Jim B.'s user avatar
  • 141
1 vote
2 answers
1k 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$ ...
v78's user avatar
  • 113
2 votes
1 answer
59 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 ...
user370717's user avatar
1 vote
0 answers
616 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-...
Nullptr's user avatar
  • 111
2 votes
2 answers
158 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 #
mahatmanich's user avatar
  • 2,984
8 votes
4 answers
12k 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 ...
intrixius's user avatar
  • 195
1 vote
3 answers
353 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 -...
John's user avatar
  • 119
0 votes
3 answers
1k 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 ...
user2821177's user avatar
3 votes
1 answer
4k 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 ...
Jan Stolarek's user avatar
2 votes
2 answers
434 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/...
user avatar
7 votes
1 answer
1k 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 ...
WeSee's user avatar
  • 486
2 votes
2 answers
2k 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@\...
Leon Mydla's user avatar
0 votes
0 answers
316 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 ...
Bouffe's user avatar
  • 293
71 votes
6 answers
112k 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 ...
Click Upvote's user avatar
1 vote
1 answer
524 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 ...
Buttle Butkus's user avatar
0 votes
1 answer
778 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 ...
cwiggs's user avatar
  • 69
0 votes
1 answer
1k 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 ...
Gaia's user avatar
  • 1,895