Skip to main content

Questions tagged [bash]

Bash is a free shell for Unix-like operating systems from the GNU Project.

568 votes
6 answers
209k views

Difference between .bashrc and .bash_profile

What's the difference between .bashrc and .bash_profile and which one should I use?
cfischer's user avatar
  • 9,093
128 votes
8 answers
68k views

Forward SSH traffic through a middle machine

SSH tunneling is very confusing to me. I am wondering if I can do this in Linux. I have 3 machines.. A. My local machine at home. B. Machine at work that I can SSH into (middle man). C. My desktop ...
user avatar
491 votes
7 answers
261k views

What is the difference between executing a Bash script vs sourcing it?

What is the difference between executing a Bash script like A and sourcing a Bash script like B? A > ./myscript B > source myscript
Scottie T's user avatar
  • 5,111
403 votes
21 answers
565k views

How do I detach a process from Terminal, entirely?

I use Tilda (drop-down terminal) on Ubuntu as my "command central" - pretty much the way others might use GNOME Do, Quicksilver or Launchy. However, I'm struggling with how to completely detach a ...
user avatar
145 votes
6 answers
67k views

Does bash have a hook that is run before executing a command?

In bash, can I arrange for a function to be executed just before running a command? There is $PROMPT_COMMAND, which is executed before showing a prompt, i.e., just after running a command. Bash's $...
131 votes
17 answers
179k views

How to delete all files in a directory except some?

I need to delete all files in a directory, but exclude some of them. For example, in a directory with the files a b c ... z, I need to delete all except for u and p. Is there an easy way to do this?
Ashot's user avatar
  • 1,449
125 votes
6 answers
231k views

Windows 10 Ubuntu Bash Shell: How Do I Mount Other Windows Drives?

I'm using Windows 10's Ubuntu Bash shell. It maps the C drive fine as /mnt/c. I have other local physical hard drives, mounted in Windows as E: and F: How do I tell Bash to mount these drives too (...
Jason Champion's user avatar
72 votes
5 answers
25k views

Why is . not in the path by default?

On UNIX-like systems over the years (most relevantly to me, Linux), I've noticed that . (current dir) is never in the $PATH by default. Why is this? I recall reading years ago that it was a security ...
dirtside's user avatar
  • 1,061
6 votes
1 answer
4k views

How can I single-quote or escape the whole command line in Bash conveniently?

Introduction Consider a tool like watch that can take another command (e.g. ls -l) like this: watch ls -l # or equivalently watch 'ls -l' If the command is more complicated, it's all about quoting/...
Kamil Maciorowski's user avatar
4 votes
1 answer
5k views

Bash terminal not wrapping text correctly [duplicate]

I am using the gnome-terminal with bash, and when I have a command that should go over the line, it just stays on the same line. So instead of: echo "abcdefghijklmnopqrstuvwxyz" I would get ...
user avatar
127 votes
5 answers
230k views

How can I SSH into "Bash on Ubuntu on Windows 10"?

I have Windows 10 Anniversary Edition with "Bash on Ubuntu on Windows" installed and working. I'd like to be able to SSH into this Ubuntu instance, but although I have openssh-server installed and ...
Mick's user avatar
  • 1,961
53 votes
5 answers
63k views

Create permanent DOSKEY in Windows cmd

I think the title is pretty self explanatory. The question is how can I create an alias in a Windows cmd that will also work after I close and then reopen it. For example I would like an alias ...
nick zoum's user avatar
  • 605
40 votes
2 answers
12k views

Linux: coloring bash prompt will break carriage return

When I try to colorize the bash prompt like this: export PS1="\e[0;31m[\u@\h \W]\$ \e[m " it breaks the carriage return (instead of going to a new line when line is full, it starts in the same line ...
Abonec's user avatar
  • 502
22 votes
2 answers
14k views

Unix: Files starting with a dash, -

Ok, I have a bunch of files starting with a dash, -. Which is not so good... and I want to rename them. In my particular case I would just like to put a character in front of them. I found the ...
Svish's user avatar
  • 40k
15 votes
3 answers
4k views

Leave bash script running on remote terminal while not logged in?

I have a bash script that takes several hours to run. While it's running, I would like to do other things, which may involve logging out or disconnecting from the internet (my script runs network ...
Ritwik Bose's user avatar

15 30 50 per page
1
2 3 4 5
67