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

learn more… | top users | synonyms (1)

14
votes
4answers
11k 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
3k 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 ...
12
votes
2answers
14k 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 ...
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
393 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
3k 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
15k 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
6k 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
5k 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
824 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
3k 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?
13
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 ...
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)?
9
votes
7answers
3k 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 ...
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
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
3answers
14k 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
4k 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 ...
4
votes
3answers
15k 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
247 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
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
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
11k 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 ...
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 ...
9
votes
3answers
26k views

How do I create a script file for terminal commands?

In Windows I can write a file containing commands for cmd (usually .cmd or .bat files). When I click on those files it will open cmd.exe and run them commands the file contains. How would I do this ...
8
votes
2answers
4k 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
161 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
471 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 ...
7
votes
4answers
29k 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 ...
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?
5
votes
2answers
635 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 ...
5
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?
4
votes
3answers
1k 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
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
13k 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
190 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
516 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 ...
0
votes
2answers
3k views

Bash Script using a Firefox Profile to open URLs

Working on a script to automate some tasks in Firefox. These tasks should run through a clean Firefox profile, so they are fast and don't interfere with any of my regular surfing. #!/bin/bash # ...
12
votes
5answers
934 views

Using cd command to navigate directories in Ubuntu which have special characters [duplicate]

When I want to navigate into directories having special characters in their names I get an error message. For example: aman@desktop:~/Aman$ cd !)e$!gn&(reate bash: !: event not found ...
10
votes
5answers
13k views

difference between bash.bashrc and /etc/environment file

Till data I was used to set my environment variables in the bash.bashrc file. Recently I told to use the /etc/environment file. Well, both work fine. So, what is the difference between them? I ...
7
votes
1answer
200 views

How to execute a terminal command every time the firefox windows closes

I need to execute this: rm -rf ~/.wine-pipelight/*; rm -rf ~/.wine-pipelight/./.*; cp -a ~/viewright_backup/. ~/.wine-pipelight every time the Firefox window closes. But not necessarily when all ...
7
votes
6answers
49k views

Every command fails with “command not found” after changing .bash_profile?

I was updating my .bash_profile, and unfortunetly I made a few updates and now I am getting: env: bash: No such file or directory env: bash: No such file or directory env: bash: No such file or ...
7
votes
2answers
574 views

What is the difference between `VAR=…` and `export VAR=…`?

What is the difference in doing $ MAVEN_OPTS="-Xmx512m -XX:MaxPermSize=384m" to doing $ export MAVEN_OPTS="-Xmx512m -XX:MaxPermSize=384m" and is there any side-effect of doing either in an SSH ...