Bash is a free shell for Unix-like operating systems, from the GNU Project
99
votes
3answers
24k views
Difference between .bashrc and .bash_profile
What's the difference between .bashrc and .bash_profile and which one should I use?
84
votes
8answers
82k views
Where does $PATH get set in OS X 10.6 Snow Leopard?
I type echo $PATH on the command line and get
...
69
votes
4answers
13k views
Why does Ctrl + V not paste in Bash (Linux shell)?
When I copy something to the clipboard and press Ctrl + V in Bash, nothing happens; However, right clicking and selecting Paste does the job.
Why? Is there any reasonable issue (I'm sure there is) ...
60
votes
6answers
3k views
How do perform commands in another folder, without repeating the folder path?
I was wondering if there's any clever way to do copy and move operations, or if there's a command to duplicate a file, without having to do a cd, then mv after, at the same folder.
For example, I ...
58
votes
13answers
4k 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?
57
votes
10answers
43k 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 ...
55
votes
2answers
1k views
Make bash terminal cursor flash to the beat of Survivor - “eye of the tiger”
I was listening to Survivor - "Eye of the Tiger" and writing some documentation in Vim and noticed that the cursor not flashing to the beat started to annoy me. Can this be fixed?
I'm using ...
51
votes
12answers
31k views
How to get git-completion.bash to work on Mac OS X?
I have followed http://blog.bitfluent.com/post/27983389/git-utilities-you-cant-live-without to
add git-completion.bash to my /opt/local/etc/bash_completion.d/git-completion
and I put ...
49
votes
5answers
2k views
How to “unextract” a zip file?
I extracted a zip file into a non-empty folder. The zip file has lots of files and a deep hierarchy, that merged with the existing tree of the target directory. How can I remove the files and ...
42
votes
5answers
16k views
How can I search the bash history and rerun a command?
Can I search history in bash and run the result?
42
votes
2answers
21k views
Go back to previous directory in shell
Is there a way to go back to previous directory we were in using bash,tcsh without using pushd/popd ?
I'd like to type something like "back" and got returned to the previous directory I was in.
Edit:
...
40
votes
4answers
34k views
chown is not changing symbolic link
I'm trying to change the user/group of a symbolic link with the command:
$ chown -h myuser:mygroup mysymbolic/
But it's not changing. I'm logged in as root. The current user/group is set to ...
39
votes
5answers
9k views
In bash, how do I escape an exclamation mark?
I want to do something like bzr commit -m "It works!". I can sort of escape the exclamation mark by doing bzr commit -m "It works\!". However, then my commit message includes the backslash. How do I ...
34
votes
9answers
2k views
Why is Bash everywhere (in most if not all Linux distributions)?
Bash is used by default in every Linux distribution I have tried, over alternatives like Z shell (zsh). Is there a technical or historical reason for this?
33
votes
12answers
3k views
How do I remove a file in Linux whose name looks like it's ONLY a hyphen, as in “-”
I've tried
rm -- -
rm "-"
rm "\-"
rm \-
Gave Perl a shot
~$ perl -e '$junk = glob("-"); chomp $junk; print "$junk\n"; `rm $junk`;'
-
rm: cannot remove `-': No such file or directory
...and...
...
31
votes
5answers
41k views
Where to find the .bashrc file on Mac OS X Snow Leopard and Lion?
I want to install rvm on my Snow Leopard machine.
It says I need to add a line to my .bashrc file (I'm using bash) but where is my .bashrc file?
30
votes
4answers
9k 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 ...
30
votes
9answers
10k views
Add directory to $PATH if it's not already there
Has anybody written a bash function to add a directory to $PATH only if it's not already there?
I typically add to PATH using something like:
export PATH=/usr/local/mysql/bin:$PATH
If I construct ...
28
votes
7answers
17k views
what to do when ctrl-c can't kill a process?
Ctrl-c doesn't always work to kill the current process (for instance, if that process is busy in certain network operations). In that case, you just see "^C" by your cursor, and can't do much else.
...
27
votes
4answers
13k views
Cygwin fatal error unable to remap.. What does it mean?
0 [main] python 6140 C:\cygwin\bin\python.exe: *** fatal error - unable to remap \\?\C:\cygwin\lib\python2.6\lib-dynload\time.dll to same address as parent: 0x2B0000 != 0x360000
Stack trace:
Frame ...
27
votes
1answer
2k views
Can history files be unified in bash?
I routinely run multiple screen sessions on my Linux desktops and servers.
A problem with this is that when I grep through my command history, I find I issued a command in a different session, and ...
26
votes
9answers
3k views
26
votes
5answers
999 views
In bash, how can I rename a file without repeating the path? [duplicate]
Possible Duplicate:
Reuse text on a bash command
If I want to rename a file a few directories deep, how can I avoid repeating the path?
For example:
mv path/to/old_filename.txt ...
26
votes
6answers
14k views
How do I add text to the beginning of a file in Bash?
Hi I want to prepend text to a file. For example I want to add tasks to the beginning of a todo.txt file. I am aware of echo 'task goes here' >> todo.txt but that adds the line to the end of ...
26
votes
4answers
7k 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 ...
25
votes
4answers
39k views
How to remove a symbolic link to a directory?
I made a symbolic link with the following commmand:
ln -s ../test5
I want to remove it now but my rm fails:
$ rm -Rf test5/
rm: cannot remove `test5/': Not a directory
$ rm test5/
rm: cannot ...
24
votes
1answer
16k views
How do i change my default shell from bash to zsh?
I want to change my shell from the default bash shell to zsh on my Amazon EC2 instances. How do I go about doing it? Thanks!
23
votes
8answers
5k views
Rename a group of files with one command
If I have a group of files with a .htm extention, how can I rename them all to .html?
mv *.htm *.html
does not work.
23
votes
4answers
27k views
Mac OS X keyboard shortcuts for terminal
After googling for some Mac OS X terminal shortcuts, I wanted to find how can I go back characters on a line on the terminal or words or similar. I found ALT + B but it does not work.
Do you know ...
22
votes
3answers
1k views
What causes bash to pause after a bad command?
When you are typing a bad command, say you want to do:
$ cd ..
$ ls
But instead you type too fast and end up hitting enter between l and s, so you get:
$ cd ..
$ l
sbash: l: command not found...
...
22
votes
4answers
1k views
Difference between “a=b” and “export a=b” in bash
What's the difference between:
a=b
and
export a=b
In bash?
I understand that they both define environment variables, but I don't fully understand the difference.
22
votes
8answers
13k views
Is it possible to `tail -f` the output of `dmesg`?
Want to do something like
dmesg | tail -f
but it doesn't work:
I use Mac OSX 10.6.7, by doing that the tail will exit, instead of monitoring the output.
I wonder if there is any way to do it, or ...
22
votes
5answers
9k views
Set the title of the terminal window to the current directory
How can I get the Terminal.app in OS X to display the current directory in its window or tab title?
I'm using the bash shell.
20
votes
10answers
13k views
Unix: ls, how to sort first directories then files etc
I would like to use ls command to first show direcotries and then files. I tried
ls -la | sort -k 1
But I got a wrong order.
20
votes
6answers
6k views
What is the difference between executing a bash script and sourcing a bash script?
What is the difference between executing a bash script like A and sourcing a bash script like B?
A
>./myscript
B
>source myscript
20
votes
2answers
3k views
Case insensitive tab completion in Bash
Is there any way to make Bash tab complete case insensitively?
$ bash --version
GNU bash, version 3.2.48(1)-release (x86_64-apple-darwin10.0)
Copyright (C) 2007 Free Software Foundation, Inc.
I am ...
20
votes
4answers
49k views
How can I change the default Python version on Snow Leopard?
I recently upgraded my Mac OS X 10.5 Leopard install to 10.6 Snow Leopard, and with that came an upgraded version of Python, 2.6.1 (instead if 2.5.1). Now when I type python in the Terminal i still ...
19
votes
4answers
20k views
How to configure PuTTY so that Home/End/PgUp/PgDn work properly in bash?
The keys Home, End, PageUp, PageDown all type a ~ in my bash session instead of moving the cursor / view around. Why does this happen and which settings do I need to change?
GNU bash, version ...
19
votes
5answers
8k views
Change default text editor for crontab to vim
I'm using ubuntu 9.10 and the default text editor is nano, which i hate. (doesn't everyone?)
Normally it's not a problem as i just vi or gedit everything but crontab -e is opening with nano. I ...
19
votes
2answers
986 views
What is /usr/bin/[ and how do I use it?
I was looking at coreutils and found this as one of the files included as part of coreutils: /usr/bin/[. What is [ and what does it do?
It is an executable. I just don't know what it does or how to ...
19
votes
4answers
5k views
Bash: Spaces in alias name
I am trying to create an aliases in bash. What I want to do is map ls -la to ls -la | more
In my .bashrc file this is what I attempted:
alias 'ls -la'='ls -la | more'
However it does not work ...
19
votes
7answers
6k views
What is the difference between bash and sh
In using i see 2 types of code
#!/usr/bin/sh
and
#!/user/bin/bash
I have Googled this and the opinions vary a lot. The explanation I have seen on most websites is that sh is older than bash, ...
19
votes
5answers
7k views
Bash vs. Gnu screen : Replace Ctrl-A with Ctrl-Shift-A
I'm a new user to GNU Screen. I've been using Bash for a very long time, and I want to give GNU Screen a try.
As you know, GNU Screen uses 'C-a' (Control-A) as as the command character. Trouble is, ...
19
votes
5answers
13k views
What does source do?
$ whatis source
source: nothing appropriate.
$ man source
No manual entry for source
$ source
bash: source: filename argument required
source: usage: source filename [arguments]
It exists, it is ...
19
votes
2answers
23k views
How to find the executable files under a certain directory in linux?
How to find the executable files under a certain directory in linux?
19
votes
3answers
12k views
Bash: Iterating over lines in a variable
How does one properly iterate over lines in bash either in a variable, or from the output of a command? Simply setting the IFS variable to a new line works for the output of a command but not when ...
19
votes
3answers
14k views
What does export do in BASH? [duplicate]
Possible Duplicate:
Difference between “a=b” and “export a=b” in bash
It is hard to admit, but I have never really understood what exactly export does to an ...
19
votes
2answers
4k views
How do I reload .inputrc?
Background (probably wrong)
I have heard that the readline module is reading ~/.inputrc and that is how it changes the behaviour of keystrokes under programs such as bash.
Question
How can I reload ...
18
votes
1answer
3k views
Git Bash Here in ConEmu
How do I create a right-click context menu entry to open Git Bash at a given folder within ConEmu? See Git Bash Here in Console2 for the equivalent question for Console2.
17
votes
5answers
12k views
How many cores I am using on a Linux Server?
I am just wondering how I can find out in bash how many CPU cores a user is now using on a Linux Server?
I am submitting a fair amount of background jobs to the server, so I'd like to write a bash ...