Stack Exchange Network

Stack Exchange network consists of 175 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.

141
votes
39answers
119k views

What useful things can one add to one's .bashrc? [closed]

Is there anything that you can't live without and will make my life SO much easier? Here are some that I use ('diskspace' & 'folders' are particularly handy). # some more ls aliases alias ll='ls -...
71
votes
17answers
82k views

Login without running bash_profile or bashrc

So let's say one typoed something in their .bashrc that prevents him (or her) from logging in via ssh (i.e. the ssh login exits because of the error in the file). Is there any way that person could ...
48
votes
1answer
14k views

What is the difference between a 'Login' and an 'Interactive' bash shell

What is the difference between a ‘Login’ and an ‘Interactive’ bash shell? I have quoted Wikipedia below but can anybody give a better answer? EDIT: This is a community wiki so maybe rather than ...
38
votes
4answers
18k 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 ...
31
votes
2answers
52k 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 ...
25
votes
10answers
11k views

I screwed up, exit in .bashrc

I put "exit" in my .bashrc file. I don't have physical access to the machine so to connect to it I use ssh. I don't have root privileges. Every time I connect to the server, the connection ...
19
votes
6answers
19k views

How to use a custom .bashrc file on SSH login

I've found that with the new company I'm working with I often have to access linux servers with relatively short lifetimes. On each of these servers I have an account, but whenever a new one is ...
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, ...
10
votes
4answers
10k views

Why is my .bashrc not read under cygwin?

My .bashrc looks like this: alias name@server="ssh server sname" echo "bashrc read" The echo statement is just for checking if it is read. But the echo does nothing. I want to set an alias for a ...
8
votes
6answers
5k views

Prune duplicate entries from PATH variable

I modify my .bashrc frequently and then source it. However, when I have things like export PATH="~/bin:~/perl5/bin:$PATH" in my file, then the PATH environment variable grows every time I source the ...
8
votes
3answers
4k views

.bashrc or .bash_profile for ssh-agent?

Which profile, .bashrc or .bash_profile, is the appropriate spot for ssh-agent? I'm looking for an answer that explains the different between an interactive shell and a login shell.
7
votes
6answers
9k views

crontab environment

I have written various scripts to launch Java server applications, which are typically run for 24 hours before being shut down (by invoking the same script with a different parameter). The script ...
7
votes
4answers
13k 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 ...
7
votes
2answers
14k views

How do I reset default .bashrc (debian wheezy)? [closed]

I messed up my .bashrc file. How do I get to the default one that was initially created with my home directory?
7
votes
4answers
4k views

How can one set a terminal's title with the 'tput' command?

I discovered through this answer that I've been setting terminal colours in my prompt in a naive way for years. I've now modified my .bashrc to use 'tput' commands to colourise various elements of my ...
7
votes
1answer
2k views

bash tab completion only works for root

I set up an Ubuntu 12 server (on rackspace cloud using their preconfigured image) and created a non-root user. When I log in as the standard user, pressing [TAB] at the terminal outputs an actual tab ...
6
votes
4answers
10k 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/...
6
votes
1answer
845 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 ...
6
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
2answers
17k 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/...
5
votes
4answers
4k 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 ...
5
votes
4answers
5k views

Prompt customization: how to detect when there is no tty

I have a customized prompt with colors (using tput) and every time I start a non-interactive session in the server I get a bunch of errors. For instance if I start a non-interactive session like this: ...
5
votes
2answers
3k views

`ssh foo “<command/>”` not loading remote aliases?

summary: Why does this fail $ ssh foo 'R --version | head -n 1' bash: R: command not found but this succeeds $ ssh foo 'grep -nHe 'bashrc' ~/.bash_profile' /home/me/.bash_profile:3:# source the ...
4
votes
8answers
21k views

How to specify root's environment variable?

I do rails development. In this app, I need to specify the environment variable LD_LIBRARY_PATH = /usr/local/oracle/lib, but when I run the app with sudo script/server, it doesn't run because that ...
4
votes
3answers
4k views

How to Add Options to Bash Function

I'm new to linux (using Ubuntu 10.10) and I'd like to add a function to .bashrc that starts/stops a tomcat server. I'm trying to parse two options for the command "tomcat". I've tried the following ...
4
votes
2answers
2k views

linux: how to permanently and globally change environment variables

I want to do the following for every user that logs into my linux box: export PATH=$PATH:~/.path And I don't know how to do that besides manually adding that line in every ~/.bashrc file. Also, a ...
4
votes
3answers
17k views

.bashrc: shopt: not found

Just provisioned a new Rackspace instance with Ubuntu 12.04 and pulled down rbenv from their github and installed it. I'm getting the following errors when executing . ./~bashrc $ . ~/.bashrc sh: 18:...
4
votes
3answers
924 views

exporting bashrc file over an ssh connection

I have my bashrc file set up to my liking.I usually work on a hardware that is plugged into a remote server.I ssh into that remote server.I would like my .bashrc to be run when I ssh into the remote ...
3
votes
1answer
378 views

What creates ~/.bashrc

I am setting up a ubuntu web server. Id like to customize everyones bash prompt a bit. (As in $PS1) Editing /etc/bash.bashrc doesn't seem to work, I assume cause ~/.bashrc over writes it. The question ...
3
votes
2answers
678 views

Why is my .bashrc script executing out of order / not waiting for steps to complete?

I have the need for teachers to fill in electronic registers in remote areas, and they need to be able to do it fast and with the least fuss necessary. To accomplish this I have set up netbooks with a ...
3
votes
2answers
338 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 ...
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 (...
2
votes
2answers
512 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
2answers
2k views

.bashrc and .ssh/ disappearing seemingly at random

I have a server that has been running Fedora 16 ( 3.1.0-7.fc16.x86_64 ) for about a month now. I only log in every few days or weeks, but when I do, sometimes files are missing from my home directory. ...
2
votes
3answers
3k views

GNU Screen and .bashrc

I am trying to launch GNU Screen using my .bashrc. I'm almost there: if [ -z "$STY" ]; then exec screen -dR else exec gnome-terminal fi This is wrong though! The first case works, screen ...
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 ...
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 #
2
votes
2answers
4k views

How do you run “source” when starting a shell?

In order to use rvm (https://rvm.beginrescueend.com/), I need to run source ~/.bash_profile each time when I start a new shell. How do I automatically do this when I start my computer, rather than ...
2
votes
3answers
275 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 ...
2
votes
1answer
862 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/ --...
2
votes
2answers
9k views

Solarized Colour Theme in .bashrc

I am looking to see if there is a way to implement the solarized them through just a .bashrc file. Would it be possible to do so? Has anyone tried this before? I guess I would start by modifying ...
2
votes
2answers
75 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 ...
2
votes
1answer
328 views

Bash Function to Export .bashrc to a Remote Server

I am trying to write a bash function shown below. I am trying to scp my .bashrc to the target machine. I want to do modify the following function in the below two ways. I want to enter the password ...
2
votes
1answer
1k 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 ...
2
votes
2answers
197 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/...
1
vote
3answers
181 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 -...
1
vote
3answers
4k views

Changes to /etc/bashrc?

Are there any changes you make to the default bash reconfiguration script that would be helpful for others to know? Note that /etc/bashrc affects all users, where a .bashrc in a user's home directory ...
1
vote
3answers
107 views

Where do I put the Alias?

alias py='python' Do I put that in my .bashrc?
1
vote
2answers
185 views

Alias for Kate editor

How can I create an alias in .bashrc for Kate editor, in order not to write kate file1 file2, but k file1 file2 for opening those files.
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 "\[\...