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
The results are in! See what nearly 90,000 developers picked as their most loved, dreaded, and desired coding languages and more in the 2019 Developer Survey.

Questions tagged [bashrc]

.bashrc is the primary configuration file for the bash shell.

3
votes
1answer
2k views

Where can I find a good boilerplate bashrc?

I've used unix/linux at work in the past, and recently started developing on a Mac. I'd always (lovingly) borrow co-workers' bashrc's for a good starting point, such as common aliasing and commands, ...
1
vote
0answers
27 views

su - <username> hangs if I added a line in /etc/bashrc

I added this line to /etc/bashrc file export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/glibc-2.14/lib I log in as root throw SSH normally, but if I wanted to change my user by su - myusername the ...
-1
votes
2answers
2k views

put “source /etc/profile” in /etc/bash.bashrc and unable to open terminal window in ubuntu 16.04

I put "source /etc/profile" in /etc/bash.bashrc and unable to open terminal window in ubuntu 16.04, and now, whenever I try to open a terminal window, it closes after a few seconds. During those few ...
1
vote
2answers
997 views

Date & Time loop in bash

I am trying to download the yesterday logs through an external API, For API I need to provide a date range from & to as input parameters. From API I can download 1 hour log max for each call. ...
15
votes
7answers
4k views

Is it possible to check where an alias was defined?

An alias, such as ll is defined with the alias command. I can check the command with things like type ll which prints ll is aliased to `ls -l --color=auto' or command -v ll which prints alias ll='...
0
votes
3answers
111 views

command not available in bash script

My company has a custom tool we install in Linux to upload files to a server (among other things) called oTools. When I open a new Terminal, I can run (from any folder) oTools upload file and file is ...
1
vote
1answer
880 views

~/.bash_profile being executed for non-login shells

My bash_profile looks like: takeapic #print status #do other stuff source ~/.bashrc For some reason, every terminal emulator I call executes this script. Shouldn't it be executed only once, when I ...
-1
votes
2answers
70 views

sudo without sudo, implying sudo in script

I made some scripts containing some functions which by design needs sudo permission. I have added those path in .bashrc for Linux and .bash_profile for MacOS so that it can be called from anywhere. ...
1
vote
1answer
39 views

Set to non-default user group upon login in bash

Upon login with .bashrc, how to set the user's group to a non-default one, say targetgroup? Specifically, my problem is that I can execute, on the command line: newgrp - targetgroup but when I ...
0
votes
2answers
946 views

I need to know about 'source' and the use of 'bashrc' in context to installing any package in ROS

I am trying to install Robot Operating system (ROS)in my system. At some point I need to use the following: echo "source /opt/ros/indigo/setup.bash" >> ~/.bashrc Then the following source ~/....
1
vote
1answer
179 views

Set up .bash_profile and .bashrc for local and remote access

I've noticed that when I open a terminal on my ubuntu machine locally, it sources .bashrc, but when I connect via ssh, it sources .bash_profile. I added a line in .bashrc to source .bash_profile so I ...
2
votes
5answers
654 views

What does bashrc PS1 check [ “$PS1” = “\\s-\\v\\\$ ” ] mean?

In /etc/bashrc file in Fedora/Red Hat I see following line: [ "$PS1" = "\\s-\\v\\\$ " ] && PS1="[\u@\h \W]\\$ " What is the check being done in [ "$PS1" = "\\s-\\v\\\$ " ] and why is PS1 set ...
1
vote
2answers
32 views

wrong echo command

I am having a little problem with my ubuntu16.04 terminal. I wanted to have access to a data-base through the use of the : echo source /Infos/bd/config11 >> .bashrc echo source /Infos/bd/...
845
votes
11answers
2.0m views

How to correctly add a path to PATH?

I'm wondering where a new path has to be added to the PATH environment variable. I know this can be accomplished by editing .bashrc (for example), but it's not clear how to do this. This way: export ...
25
votes
6answers
42k views

sftp gives an error: “Received message too long” and what is the reason?

I was able to do sftp yesterday to a RHEL 5.4 box (RedHat) and today I can't. The message is "Received message too long 778199411", and after some investigation, it was due to my RHEL box's .bashrc ...
0
votes
0answers
17 views

Can some or all profile/login scripts be bypassed on local console login?

The situation I'm thinking of is that something in /etc/profile or ~/.profile or ~/.login or similar is causing you to be logged out immediately or some other problem/mischief, and you're at a text-...
0
votes
1answer
1k views

Bash script for Angstrom

I have written a bash script to automate cross-compiling an OpenCV program: echo "Compiling started for: $1" if [[ $1 == *.c ]] then gcc -ggdb `pkg-config --cflags opencv` -o `basename $1 .c` $1 `...
0
votes
2answers
52 views

How to remove first segment or segments from PATH in shell script [duplicate]

I wanted to remove a CUDA directory from PATH by a sh script. The directories are showed by doing echo $PATH /usr/local/cuda-9.0/bin:/usr/sbin:/usr/bin: I want only: /usr/sbin:/usr/bin: My script ...
0
votes
2answers
38 views

Bash Shell takes variable amount of time to load

I use bash on Ubuntu 18.04. I have added a lot of functions and a lot of scripts are sourced in my bashrc. I am able to time the total time it takes to load my terminal, sometimes it takes 0.9 seconds ...
0
votes
1answer
1k views

Execute script in new gnome-terminal loading bashrc

I have a script in a gnome-terminal shell and I would like to open a new terminal, load the bashrc configuration, execute a new script and avoid the closure of the new terminal window. I have tried ...
1
vote
1answer
25 views

Modifying the default bashrc alert command

I was scrolling through my bashrc (bored) and I got interested in the alert command that is concatenated in there by default. It's practical and everything, but it requires you to type ; alert at the ...
0
votes
1answer
189 views

How to change default text edior for virsh edit? (setting EDITOR env variable didn't work)

I recently installed virt-manager on an Arch Linux install, and unlike under Ubuntu, I was not prompted to choose a text editor on the first launch of virsh-edit. Instead, the XML file was opened in ...
13
votes
4answers
6k views

why deleting bash history is not enough?

I used to think deleting my bash history was enough to clear my bash history, but yesterday my cat was messing around the right side of my keyboard and when I got back into my computer I saw something ...
1
vote
4answers
238 views

How can I simplify this bash script that prints the number of files in working directory?

I'm working on my bash prompt PS1 and I'd like to print the number of files in the current directory. I write a working code, but, Is there a way to simplify this (redundant) script? $(ls -l | grep ^...
5
votes
2answers
86 views

Any occasion where .bashrc is favorable to .bash_profile?

I understand the difference between .bashrc and .bash_profile (or .bash_login and ~/.profile for that matter), but is there any particular reason to choose .bashrc over .bash_profile for bash shell ...
11
votes
4answers
29k views

how to execute a bash script without typing ./ [duplicate]

It has been bugging me for a very long time and I'm really sick of it. For example there's a script called testscript that compares two directories. In class the prof can just type testscript dir1 ...
7
votes
3answers
27k views

Terminal, Prompt changed to “-Bash-4.2” and colors lost

Usually my terminal prompt was username place$ now it only shows bash-4.2$ and all the color settings have been lost (on the terminal profile I have the same color scheme, but it just don't show ...
0
votes
0answers
82 views

Is a .zshenv or .zprofile necessary for a proper/function zshell?

I have an issue where every terminal I open up has the first line: $home/.zshrc:1: command not found: followed by whatever I have as the first line in my .zshrc file. (See "What changes to a .zshrc ...
0
votes
0answers
35 views

Modifying .bashrc to send history to syslog, problems with quotes

Attempting to enable logging of bash commands to syslog, including the ip of the logged in ssh user. The end goal is to have a script which will echo 'export PROMPT_COMMAND=....'' >> ~/.bashrc ...
17
votes
2answers
932 views

How to retrieve lost aliases?

I made an echo command to my .bash_aliases file and erased all of my aliases, except the test alias. However, I still have a session open that has the aliases loaded (into the tcl?). Can I retrieve ...
2
votes
1answer
46 views

how to pipe to a sourced function in bashrc file?

we all know how to pipe to shell scripts and installed programs like grep,awk ... but what about a sourced function in .bashrc or .zshrc ? this is a test function : function fff(){ echo "$@" } ...
1
vote
2answers
1k views

How to format history file to contain username too?

tail -2 /root/.bashrc export HISTTIMEFORMAT="%d/%m/%y %T " export PROMPT_COMMAND='builtin history 1 >> /var/log/root.log' With this all the commands could be logged (even the ones that were in ...
0
votes
0answers
20 views

Bash promt (.bashrc) working not properly if added color [duplicate]

Before I used Zsh and some themes are not work properly, I thought that because of Zsh, but when I returned to Bash shell it still got same problem. Here is the problem: It doesn't jump right into the ...
1
vote
1answer
466 views

Alias for perl script

So far while surfing web I've discovered nice addition to my gpg password generator and I've decided to adjust my alias with these commands. Here is the code gpg --gen-random 1 20 | perl -ne'print "...
1
vote
1answer
83 views

A command that takes a single numeric argument and prints out the day of the week based on the formula

days=('Sunday''Monday') days=('Tuesday''Wednesday') days=('Thursday''Friday') days=('Saturday') for numbers in "S@"; do if [ $numbers -ge 0 ]; then result=$(($numbers ...
0
votes
0answers
45 views

Sourced .bashrc detection

At the user level is there a way for me to craft a sort of 'tripwire' in my .bashrc file to detect if another user has sourced my .bashrc? What I would like to do is have some sort of log created ...
1
vote
1answer
122 views

Switch capslock and ctrl with config file on ubuntu 18.04

Recently, I tried to switch capslock and ctrl on my Ubuntu 18.04. I did it by add the following line into my .bashrc: # swap capslock and ctrl /usr/bin/setxkbmap -option "ctrl:swapcaps" This worked,...
0
votes
1answer
76 views

Bash prompt configuration

I've recently switched to Parrot linux and I'm very happy with it, but there's just one thing, this default fancy bash prompt is really ugly. I used zsh before, and for some reasons I want to go back ...
70
votes
13answers
70k views

How can I set my default shell to start up tmux

I would like my default bash shell to go straight into tmux instead of my always having to type tmux every time.
1
vote
2answers
62 views

How can I get the Linux terminal to look like Windows Git Bash?

Before anyone says it, yes, I know this is a duplicate, except when I copy/paste that code into tilde slash period bash(no period)rc, the terminal hasn't changed at all. I'm running Debian on Virtual ...
0
votes
0answers
1k views

should I export PATH in .bash_profile or .bashrc? [duplicate]

I understand that ~/.bash_profile is for login shells and ~/.bashrc is for non-login shells. From what I understand of this, the options in .bash_profile would be invoked only once upon login, and ...
4
votes
4answers
4k views

Can I recover my .bash_profile from an open Terminal tab?

I'm actually using a Macbook Pro, and am quite new to non-Windows OS' (I know, for shame!), and I've made the mistake of overwriting my bash profile, instead of appending to it... (n00b!). What I do ...
0
votes
0answers
19 views

Ending slogin session with exit command freezes due to PROMPT_COMMAND modification

I recently embedded an "alert" command into my PROMPT_COMMAND to give me a little notify-send screen notification with the exit code of each command (because I always forget to append the alert when a ...
0
votes
1answer
114 views

Where you set path for golang or java in ubuntu?

In some tutorials path is set in ~/.profile however in some other tutorials they use etc/path or ~/.bashrc, can you explain whats the difference and how it works in linux.
1
vote
1answer
3k views

Reset $PATH Variable to Default Kali setting

Running Kali Linux Rolling Distro. Attempted to install Cuda Toolkit to the /opt/ directory using the following syntax: chmod +x cudatoolkit_4.1.28_linux_64_ubuntu11.04.run ./cudatoolkit_4.1....
0
votes
1answer
68 views

How to fix key mapping for control key [closed]

As I have mentioned here for some reason whenever I try to use CTRL key for any of the keyboard shortcuts, it prints the caret sign ^. Here is my .bashrc file: # ~/.bashrc: executed by bash(1) for ...
0
votes
0answers
19 views

Corrupt prompt display after customizing it [duplicate]

I'm using GNU bash, version 4.4.23(1)-release and customized my prompt-look in ~/.bashrc via PS1="\e[0;36m\\u:\e[m\e[0;32m\\w\e[m $ " This gives me following look, including a lengthy command passed ...
4
votes
2answers
7k views

How to print last login time?

I'd like to know how to set in .bashrc file to print the last login time of users when logging into another user in terminal. I do know that with who or last, but I'd like something a little more ...
126
votes
3answers
335k views

What is the purpose of .bashrc and how does it work?

I found the .bashrc file and I want to know the purpose/function of it. Also how and when is it used?
3
votes
1answer
4k views

Make xterm transparent

I'm going through the process of making XTerm transparent, I've followed the steps on this site. I installed transset-df and Xcompmgr and added this line to my .bashrc file [ -n "$XTERM_VERSION" ] &...