Bash is the shell used in Ubuntu's command-line interface.

learn more… | top users | synonyms (1)

19
votes
3answers
1k views

iPython Like Command History For Shell

For those of you who don't do python programming on ubuntu, ipython is a python shell on steroids, but it has this amazing feature that it not only autcompletes based on known names (i.e. the same way ...
16
votes
5answers
13k views

How can I get mv (or the * wildcard) to move hidden files?

I am migrating my home directory from an old system to a new one, and the tarball I made contains everything, including hidden files like .bashrc. However, when I move the contents of the unpacked ...
13
votes
1answer
545 views

Opening a file from terminal only by typing its name

I know that xdg-open will open from terminal a file in the user's preferred application like this: xdg-open filename But I wonder how can I open a file from the current directory in its default ...
10
votes
6answers
15k views

How to log all Bash commands by all users on a server?

Our small company runs an Ubuntu Server 11.10, to which a couple of people have SSH access. The actual terminals are sometimes used, too. How can we locally log all Bash commands run, along with user ...
12
votes
2answers
15k views

Configure gnome-terminal to start bash as a login shell, doesn't read .bashrc

I'm trying to integrate RVM with gnome-terminal. Per default, gnome-terminal does not start bash as a login shell. I enabled run command as a login shell as suggested in this answer about the same ...
14
votes
4answers
12k views

How do I set up an email alert when a ssh login is successful?

Does anyone have a bash script that will email or notify someone in the case of a successful login to a ssh server? I want to be notified if anyone logs into my personal box. I'm using Ubuntu 12.04 ...
13
votes
4answers
4k views

What does /dev/null mean in a shell script?

I've started learning bash scripting by using this guide: http://www.tldp.org/LDP/abs/abs-guide.pdf However I got stuck at the first script: cd /var/log cat /dev/null > messages cat /dev/null ...
26
votes
5answers
4k views

Removing folder named ~

This is the output of ls -l ls -l total 53484 drwxr-xr-x 3 root root 4096 2011-02-10 05:59 ~ -rw-r--r-- 1 root root 54313810 2011-02-13 05:09 jobs.jar -rw-r--r-- 1 root root 384035 2011-02-15 ...
18
votes
3answers
436 views

What is the $BASH_COMMAND variable good for?

According to the Bash manual, the environment variable BASH_COMMAND contains The command currently being executed or about to be executed, unless the shell is executing a command as the result of ...
13
votes
2answers
4k views

How can a script detect a user's idle time?

I want to check, inside a bash script (*), how long the user of a X session has been idle. The user himself does not have to be using bash, but just X. If the user just moved the mouse, for example, ...
9
votes
3answers
16k views

How to escape file path in SED?

I would like to replace $fileWithPath in $file, however this not works because (I think) path is not escaped. how to escape it? sed -i 's/${fileWithPath}/HAHA/g' $file
7
votes
4answers
7k views

How do I check virtualbox version from CLI

I am writing a Bash script to store the version number of Virtualbox, but cannot succeed. My Script is: #!/bin/bash installed_virtualbox=$(virtualbox --version) # --version this is what I want to ...
5
votes
2answers
11k views

What does outputting to /dev/null accomplish in bash scripts?

Oftentimes I run into small bash scripts that use this sort of syntax in if statements: "some command" > /dev/null 2>&1 What is the purpose of outputting to /dev/null like that, and what does ...
3
votes
2answers
10k views

Using up arrow to run previous command

What setup do I need to use up-arrow to run previous command? With Mac, I can use up-arrow to rerun the command that I just run, but it doesn't seem to work with my bash shell. I use 8.04 (I can't ...
0
votes
2answers
6k views

Change the terminal prompt [duplicate]

This can be really trivial,but it helps in ways of making it more comfortable while coding and sending commands to terminal. My terminal source/bash/root name(my apologies, I dunno which is the right ...
19
votes
2answers
825 views

Why does it take so long for Ubuntu to say “command not found”

For some reason, with my setup, it can take Ubuntu several seconds to respond with "command not found" when I accidentally typo a command. Why does it take so long? Is there any way to shorten the ...
16
votes
3answers
4k views

What does “${debian_chroot:+($debian_chroot)}” do in my terminal prompt?

In my terminal prompt definition in my .bashrc file, among other things, I have this snippet of code: ${debian_chroot:+($debian_chroot)} What does this do, and do I need it?
14
votes
2answers
5k views

What has 'rm -r ~' done to my home directory?

gedit creates hidden backup files ending with '~'. I wanted to do a recursive cleanup of my directory tree. The command rm *~ will delete all local files ending with '~' I thought rm -r *~ . would ...
13
votes
7answers
4k views

Auto complete for often used command line commands?

For some projects I often type in a couple commands, like for example: cd an/extremely/long/path/in/which/I/have/some/kinda/project and ./runmyproject --with some --command line --options set ...
12
votes
2answers
7k views

Split a large file into smaller files and then integrate them to get the original file

How do I split a 7GB (movie) file into smaller files of (say) 1GB, and then (in another Ubuntu computer) integrate them to get the original file (using just bash commands)?
10
votes
4answers
30k views

sudo: source: command not found

I've been updating some of the default profile for bash, and saw from the tutorials I was following that I could reload the new profile with the new environment settings by using: source ...
9
votes
7answers
4k views

How do I sort by human readable sizes numerically?

for example I have command that shows how much space folder takes du folder | sort -n it works great, however I would like to have human readable form du -h folder however if I do that than I ...
9
votes
1answer
3k views

Why does /bin/sh point to /bin/dash and not /bin/bash?

As far as I understand bash is the default shell in Ubuntu, so why does /bin/sh point to /bin/dash?
8
votes
2answers
2k views

Is there a difference between “.” and “source” in bash, after all?

I was looking for the difference between the "." and "source" builtin commands and a few sources (e.g., in this discussion, and the bash manpage) suggest that these are just the same. However, ...
8
votes
3answers
15k views

I can't find .bash_profile

I am trying to learn how to tweak my shell in the file but can't seems to find the file in my home directory or in /etc/profile. Is there any other file I need to search for, or am I expected to ...
7
votes
3answers
5k views

How do I install utorrent by hand?

So I'm new to Ubuntu, in fact I've only installed it yesterday. There are a few programs I want to install.. both of which are a .tar.gz and a .tar.bz2 file. When I double click on them, they just ...
5
votes
3answers
16k views

How to execute sudo commands with Expect & send commands in bash script?

Can any body let me know how to execute sudo commands with expect. I tried the following but this is not working. Can anyone give me suggestion please? set login "sasuke" set addr "hostname" set pw ...
3
votes
1answer
253 views

Saw an interesting command but can't alias it

Saw an command from this post http://askubuntu.com/a/266839/75967 that I would like to alias find {,/usr}/{,s}bin -printf '%f\0' | xargs -0 whatis | sort | less I assume the less or the | is ...
3
votes
2answers
3k views

What is the difference between “source x”, “. x” and “./x” in Bash?

I have one bash source run.sh as follows, #!/bin/bash if [ $# -ne 1 ]; then exit fi ... when I execute it in two ways, there are different behaviors. The first way is, source run.sh It will ...
3
votes
2answers
3k views

Differences between fish and bash to pass commandline arguments to alias functions?

From the answers to my other question here i learned about the possibility to pass commandline arguments to a alias function in Bash. In Fish i can edit an alias by editing the file config.fish in ...
13
votes
3answers
387 views

Deleting input back to the last forward slash

I will very often be flitting between several files on a server. I will run the following example commands in sequence: nano /web/site/path/to/file /web/site/script.py nano ...
12
votes
2answers
8k views

Shell does not show typed in commands, “reset” works, but what happened?

My problem is that the Bash shell stops showing the characters I type into it. It does read the commands though. I've come across this problem quite a few times and I don't understand what causes it. ...
11
votes
5answers
12k views

Commandline shortcut for current directory similar to ~ for home directory?

When i use the cp or move command in a terminal window, i'm currently with bash in a certain folder like this. NES@server:~/Desktop/dir1$ And now i wanna copy a file from here ~/anotherdir/dir2 ...
10
votes
2answers
2k views

Pressing enter produces ^M instead of a newline

For example, if I am tail -fing a file or reading user input, <Enter> will produce ^M in the terminal instead of ending the read or adding a newline to stdout. ^J works fine. I'm sshing into ...
9
votes
2answers
1k views

What does the first '.' mean in '. ~/.bashrc'? [duplicate]

I saw a post about fix your alias in .bashrc. And he says after you put your alias in .bashrc , you need to use: . ~/.bashrc I do not quite understand what the first dot(' . ') does here. What's ...
8
votes
2answers
5k views

xclip on headless server

I've been using xclip to copy the output of bash commands like so: pwd | tr -d "\n" | xclip -selection c So that I can then paste the output into another terminal session. I was trying to use it ...
7
votes
1answer
169 views

Bash history keyboard shortcut for !*

In Bash, there are some handy operators to repeat parts of the last command: !^ expands to the first argument of the previous command, e.g., $ echo one "two three" one two three $ echo !^ echo one ...
7
votes
2answers
524 views

Get bash history to remember only the commands run with space prefixed!

The commands executed in the terminal prefixed with blank space(s) are not recorded in the command history file. But is there a way to get the reverse i.e. the history should only record those which ...
6
votes
2answers
7k views

What is my crontab -e local file path? I want to set it via BASH script

In my Ubuntu, my username is "meuser". When i do crontab -e, i can setup my rules. But instead of doing it with crontab -e, how can i do it directly to a file? Which file i cant modify?
6
votes
2answers
1k views

How do I use bash's “<<” operator?

I know bash has a >> operator, to append output to files, but what is the use of the << operator?
5
votes
2answers
731 views

How can I return to an application in the background?

I know that I can run an application in the background by putting an ampersand ('&') behind the command. For instance: user@ubuntu:~$ rtorrent & [1] 4618 starts rtorrent in the background. ...
5
votes
3answers
13k views

How to change directory using script

I have this script #!/bin/bash cd /home/user/somedir pwd it works as expected, but I would like this script to transport me to /home/user/somedir, but I stay in the same dir. How to write script ...
4
votes
3answers
2k views

Bash one-liner to delete only old kernels

I've seen lots of threads on how to free space on the /boot partition and that is my objective as well. However, I'm only interested in deleting old kernels and not each one of them but the current ...
4
votes
1answer
4k views

What could be a reason for `.bash_profile` and `.bashrc` not to execute the exports?

the CUDA installation tutorial tells me to add the following two lines to my .bash_profile. export PATH=/usr/local/cuda/bin:$PATH export LD_LIBRARY_PATH=/usr/local/cuda/lib64:$LD_LIBRARY_PATH But ...
3
votes
2answers
625 views

Script doesn't work when it is run using '#!/bin/sh'

I have a script that use shebang : #!/bin/sh, but when I run it in my Ubuntu 14.04 terminal, it doesn't work and it says that some lines has unexpected operator. My friend in another computer could ...
3
votes
1answer
2k views

Is it possible to do an unattended/silent lamp installation?

Is there a way to set up and pre-configure a lamp environment within a bash script without user prompting by dpkg and present data like mysql or root user password and such kinds of things?
3
votes
4answers
4k views

execute script after desktop loaded?

I want to execute bash script on startup that opens several terminals in different workspaces. Script works just fine if I call it from terminal, but it doesn't work if executed from crontab using ...
2
votes
3answers
14k views

Paswordless Rsync Over SSH Without Key Authentication [Un-Safe]

I want to set up an RSync job that would connect through SSH. I have my computer ( backup@myhost ) and the remote host ( test@remhost ) and I need to backup the folder ~/something with all it's ...
1
vote
2answers
197 views

Deleted /bin instead of /android-project/bin

An android project has its /bin directory and what I wanted to do is to deleted this. What I actually mean is delete /path/to/android-project/bin not the /bin directory. So I executed this command, ...
1
vote
2answers
526 views

Creating a directory of recently created files

On a system I have, files are uploaded through a series of various mechanisms into one central "incoming" directory. Once a day those files are processed and they are moved off to where they need to ...