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

learn more… | top users | synonyms (1)

1
vote
3answers
4k views

Customize the command shell default prompt

Need help to change the command prompt. I want short name. Look below : kirti@kirti-Aspire-5733Z:~$ cd workspace kirti@kirti-Aspire-5733Z:~/workspace$ cd Ruby ...
-3
votes
3answers
8k views

how to check if $1 and $2 are null?

I am running some script which passing the string argument and I want to do if else statement shown as below: if [ $1 != '' ] && [ $2 != '' ] then do something..... but it shown Error ...
40
votes
0answers
10k views

How can I determine whether a shellscript runs as root or not? [duplicate]

Possible Duplicate: How can a script check if it’s being run as root? This is something I've been curious about. I make a lot of small bash scripts (.sh files) to do tasks that I routinely ...
16
votes
0answers
4k views

How do I set a path permanently? [duplicate]

Possible Duplicate: How to add a directory to my path? I am trying to install the play framework permanently. http://www.playframework.org/documentation/2.0.2/Installing export ...
7
votes
3answers
2k views

How to get colored output from bash script?

When I execute grep from within gnome-terminal, I get colored output - easily noticeable match, line-numbers (-n) with different colors etc But when I execute exactly same grep command through bash ...
6
votes
2answers
8k views

Undertanding .bashrc and .bash_profile

On a server when I login as root I see .bashrc (ubuntu 10.10). On my Mac I have a .bash_profile, does ubuntu always have only a .bashrc file and not .bash_profile? (just confused so asking, I realize ...
5
votes
1answer
3k views

Ubuntu alias not applied in bashrc

I am under Ubuntu 12.04 LTS. I have added such line to ~/.bashrc alias myconf="sudo nano /opt/nginx/conf/sites-available/efiling" I tried with single quotes too: alias myconf='sudo nano ...
4
votes
2answers
2k views

terminal closes immediately after open

I rebooted recently, and now terminal fails to work. If I click the terminal shortcut or use Guake or ctrl-alt-T, the terminal opens briefly with no prompt, then immediately closes again. I installed ...
3
votes
2answers
153 views

Can alias command pass arguments?

I want to know if i can pass an argument with an alias command. for example: alias d="dmesg|grep -iw usb|tail -5" Now d will print the last 5 lines. if i want to use d to print a different number ...
3
votes
2answers
164 views

Bash built-ins with no manual entries

Why do some bash built-ins (such as dirs, pushd or help) don't have manual entries?
3
votes
1answer
878 views

Why must I do `. .bash_profile` every time I create a new alias?

Every time I add a new alias in my .bash_profile file, I found that I must do the command . .bash_profile in my terminal to make it work. Why does the alias not work automatically?
2
votes
1answer
45 views

Print characters behind the digits

function/script, that for argument in format (alphas and digits) afa5hgt3tt, errerew9ax66w, prints characters behind the digits many times as value of digit, e.g. hgthgthgthgthgttttttt ...
2
votes
4answers
1k views

Comparing two text files

I have 2 big csv files, file1.csv which looks like this 1,2,3,4 1,4,5,6 1,7,8,9 1,11,13,17 file2.csv which looks like this 1,2,3,4 1,7,8,9 2,4,9,10 13,14,17,18 These are just random numbers that ...
2
votes
2answers
391 views

How can I compare two directories recursively and check if one of the directories contains the other?

I have two directories, they contain common files. I want to know if one directory contains the same file as the other. I found a script on the net but I want to need improve it to do recursively. ...
2
votes
1answer
382 views

How to remove element from gsettings array in script?

Array in dbus/gsettings has a format [element1, element2, element3, ...]. Gsettings' interface allows only replacing existing array with another, so for instance, adding another item element can be ...
2
votes
1answer
343 views

How can one run a shell script just before the desktop session begins?

I want my system to run with 1366x768 resolution. Note that this resolution is not detected by the open source driver. So I created a bash script as follows :- xrandr --newmode "1368x768_60.00" ...
2
votes
3answers
233 views

How to remove a strange-looking directory

I have a directory in my home dir, but I am unable to remove it in any ways. Using rm -rf JsZ-r6K.50/ crashes the konsole. I also tried to use sudo rm, but it is the same. drwxr-xr-x 3 volkan ...
2
votes
2answers
68 views

How to get the directrory name in shell script

I have a script which sets some environment variable to paths: export VAR1=/home/xyz/DIR_IN_WHICH_THIS_FILE_EXISTS export VAR2=$VAR1/abc/qwe ... Can I use something to get the ...
2
votes
2answers
2k views

How to pause a running aria download

When downloading big files it necessary to pause the download many times. A big file can be downloaded by using wget. First start download, then kill wget, then resume download by wget -c. I want to ...
1
vote
2answers
106 views

How can I run a bash script without affecting the file system?

I am trying to create some soft of a sandbox for linux systems (ubuntu). My main goal is to find out which files are executed by a bash script of my choice, without actually letting it run them. I ...
1
vote
1answer
289 views

how to run command in an already opened terminal through a shell script

I'm running a shell script.sh which is supposed to open terminal and then run some commands in this opened terminal. What happens is that the terminal starts but the following commands are not ...
1
vote
2answers
126 views

Unable to delete file

I am unable to delete file: sudo rm /usr/local/bin/Katy Perry - Dark Horse (Official) ft. Juicy J-0KSOMA3QBU0.mp4.part It is showing an error: bash: syntax error near unexpected token `(' How to ...
1
vote
2answers
167 views

Specify password for sudo in script

I am making a script that will update my system (and do some other things, but that doesn't matter). I want the script to run sudo apt-get update and sudo apt-get dist-upgrade --yes automatically. I ...
1
vote
3answers
424 views

How to install RevKit

I’m trying to install a software called RevKit on Ubuntu 12.10 and the following instructions1 need to be followed: RevKit can be downloaded from the www.revkit.org website. Opening a Bash ...
1
vote
2answers
222 views

How would I make a program go back to the start.

So I have my program and I cannot figure out how to make the program loop back to the start. I have more of a program however this is the part where I would like the program to restart if I picked yes ...
1
vote
1answer
180 views

What is the best way to add a new user using the command line?

I am familiar with the useradd and adduser commands but if I create a new user using any of them it can't log into the GUI?! Does this mean I am forced to use the GUI for adding a new user when the ...
0
votes
1answer
298 views

Terminal error (some typo somewhere?) with .bashrc disables all aliases etc

I can't use any of my aliases or custom defined variables in bash. The error when I open the terminal is immediately: : command not found bash: /home/khaverim7/.bashrc: line 6: syntax error near ...
0
votes
1answer
4k views

How to fix invalid identifier error after setting environment variables?

I'm trying to setup cocos2dx in Ubuntu 14.04 LTS but after setting the environmental variables (in .bashrc) I start getting this error: bash: export: dev/cocos2d-x-3.2/tools/cocos2d-console/bin': not ...
0
votes
2answers
3k views

How do I determine the Mime type of a file?

I recently switched to gnome3 and was surprised to find that there was no way by which we could set the default applications. I am writing a nautilus extension using bash. I want to find the mime ...
111
votes
10answers
39k views

Moving from bash to zsh

I'm considering moving from bash to zsh as I often come across posts praising zsh. I'm an experienced command line user and I'm assuming the basics are pretty much the same, so I'm looking for advice ...
33
votes
3answers
119k views

'chmod u+x' versus 'chmod +x'

What is the difference between chmod u+x and just chmod +x? I have seen a ton of tutorials that say to use u+x to make scripts executable. However, the u is not mentioned in the chmod help or ...
36
votes
1answer
8k views

What's the difference between set, export and env and when should I use each?

Every so often I'll bash out a bash script and it strikes me there are a few ways of setting a variable: key=value env key=value export key=value When you're inside a script or a single command ...
21
votes
3answers
32k views

How to see time stamps in bash history?

Is there any way I can see at what time the commands were executed from the bash history? We can see the order but is there any way I can get the time also? Bottom-Line: Execution time in the Bash ...
20
votes
5answers
7k views

Run a command with the argument from the last command

When running commands, sometimes maybe you need to run a command with the argument from the last command. How can you do this? Of course, excepting the use of the arrow keys and Del keys: ...
30
votes
3answers
8k views

Find directories that DON'T contain a file

Yes, I'm sorting out my music. I've got everything arranged beautifully in the following mantra: /Artist/Album/Track - Artist - Title.ext and if one exists, the cover sits in ...
32
votes
4answers
13k views

Removing files with a certain extension except one file from terminal

I need to remove all files with .gif extension except one file with name say "filename.gif". What is the optimal way to go about doing this in terminal? The command rm *.gif removes all gif files ...
28
votes
3answers
20k views

Bash history handling with multiple terminals

I use mainly Terminator, and it's usually opened with 3 split terminal windows. I also use Gnome terminal for various reasons. I'm wondering how is bash history handled in this case as I sometimes ...
25
votes
5answers
19k 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 ...
23
votes
3answers
19k views

Changing colors for user, host, directory information in terminal command prompt

Is it possible to change the colors in the command prompt for the user@computer, as well as the the current directory and command parts of the prompt display? I've already seen something like this ...
19
votes
4answers
16k 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 ...
11
votes
6answers
18k 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 ...
37
votes
6answers
9k views

Is there a difference between the '&&' and ';' symbols in a standard BASH terminal?

They seem to both signal BASH to commence with another command following the symbols but is there a distinct difference?
20
votes
4answers
8k views

Bash auto complete for environment variables [closed]

The bash autocomplete feature does not seem to work with environment variables in 11.04. The current behavior is indicated below export SCRIPT=/home/user/script cd $SCRIPT/<tab> results in a ...
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 ...
15
votes
3answers
17k 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 ...
13
votes
1answer
568 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 ...
13
votes
4answers
16k 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 ...
19
votes
3answers
624 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 ...
15
votes
2answers
11k 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)?
12
votes
4answers
13k 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 ...