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

learn more… | top users | synonyms (1)

4
votes
1answer
63k views

Run executable file on terminal

I'm new to Ubuntu and currently on it because of assignment. I would like to ask few questions: How do I make new command to run a shell script? For example, when you type passwd on terminal it runs ...
19
votes
6answers
19k views

How to start a terminal with certain text already input on the command-line?

Rather than rephrasing my question, let me describe to you the desired user-case: I create a short shell-script to run command "gnome-terminal --someoptionflagname 'my text to be posted'", and ...
18
votes
2answers
24k views

How to grep 2 or 3 lines, one containing the text I want, and the others just below it?

This is a snapshot of error log: 06:16:29,933 ERROR EmailRMManager$:45 - Exception In get Message com.rabbitmq.client.AlreadyClosedException: clean connection shutdown; reason: Attempt to use closed ...
10
votes
2answers
13k views

How to pass results of bc to a variable

I'm writing a script and I would like to pass the results from bc into a variable. I've declared 2 variables (var1 and var2) and have given them values. In my script I want to pass the results from ...
9
votes
3answers
18k views

How is the default TERM shell variable value set?

After upgrading to Maverick I have my TERM variable set to 'dumb', this does not happen with the same home dir running from Lucid and I didn't manually changed anything related to TERM. Any idea ...
6
votes
4answers
2k views

Keep a program running in terminal

So I am well aware of nohup and suffixing commands with & to ensure that they go into the background. However if I run a graphical application - sometimes using neither seems to do the job. So ...
5
votes
1answer
573 views

Getting the default text editor used in system

I have been searching and browsing for a long time and have not been able to find an answer to my question. I have used select-editor and I note that I am using /usr/bin/nano. Is this the default ...
5
votes
1answer
45k views

How to run Bash script as root with no password? [duplicate]

Possible Duplicate: How do I use sudo in my script without needing a password? I want to run a bash script as root with no password prompt. I tried visudo with no luck(your_username ...
3
votes
3answers
986 views

How do I list all available shell builtin commands?

We know bash supports number of buitin commands like: $ type type cd help command type is a shell builtin cd is a shell builtin help is a shell builtin command is a shell builtin I want to get ...
3
votes
1answer
4k views

How do I launch a bash script using a keyboard shortcut?

Just like the title says, how do I launch a bash script in my ~/Downloads folder using a keyboard shortcut? I've tried binding cd ~/Downloads && ./bash-script.sh to different accelerators (ex. ...
2
votes
1answer
4k views

bash comparing multiple column in two files with different length

I have following data set in text file data.txt d1,40,gold d2,30,silver d3,20,bronze d4,10,iron d5,5,wood d6,20,gold d7,10,wood d8,5,gold d9,10,silver . . . def.txt gold,40 silver,30 bronze,20 ...
25
votes
4answers
3k views

Can someone explain tilde usage?

I was confused, trying to copy some files from one PC to another. I have it figured out, but the syntax is still confusing to me. This works: scp ~/Desktop/Volenteer.png jay@server.ip:~j0h/b which ...
18
votes
1answer
1k views

Why use env in shebang?

What is the purpose of using #!/usr/bin/env <sh|bash|python> shebang compared to #!/bin/bash, #!/bin/sh or #!/usr/bin/python?
15
votes
3answers
28k views

How to delete selected results from bash history?

history command shows all the results but we can filter to get particular command using history | grep searchingCommand. It is really helpful. But the problem is it shows those commands also which ...
10
votes
1answer
3k views

How do I show a message with username and date at login?

How to show the message "hello $username, today's date is $date" as soon as you login to Ubuntu.
8
votes
1answer
25k views

Find file or directory in whole directory structure

How can I find a file with a specific name in bash. I want to search through the whole system. I tried with find, but that only work through one level.
7
votes
3answers
2k views

How to check the password entered is a valid password for this user?

The scenario: In a bash script, I have to check if a password given by a user is a valid user password. I.e suppose I have a user A with password PA.. In the script I asked user A to enter his ...
6
votes
1answer
33k views

The fastest way to create a file from a terminal

What is the simplest way to create a file using a command-line? Usually I use: touch filename But is this the simplest/fastest way?
6
votes
2answers
4k views

“No such file” when running a 32-bit program on a 64-bit system

I downloaded a Chromium snapshot and unzipped it, like this: michael@ubuntu:/opt/chrome-linux$ ls chrome libffmpegsumo.so nacl_irt_x86_32.nexe chrome.1 ...
6
votes
1answer
7k views

How to execute script on shutdown?

I want to execute script before I shutdown my machine that writes date to a file (so I do know what time I finish working). How to do it?
6
votes
5answers
23k views

Add a string to a text file from terminal

I would like to modify a bunch of text files from the terminal, more precisey: add the string '50' to the first line of every text file in /mydat/ ? Alternatively, if you know of a link to a page on ...
5
votes
2answers
10k views

How to write Bash script What is the command to open a terminal with two different tabed terminals and execute some commands separately tabs?

How to write Bash script to open a terminal with two tabs, and execute commands in both tabs? for instance: tab 1 opens skype tab 2 opens chromium-browser In the end, I want one more thing: write a ...
5
votes
2answers
890 views

How do the environments of a standard Terminal command-line and a bash script differ?

I know there is something different about the environment of the Terminal command-line and the environment in a bash script, but I don't know what that difference is... Here is the example which ...
3
votes
3answers
21k 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 ...
3
votes
1answer
911 views

How to extract/inject ID3 tags via bash?

I have a huge collection of MP3 files that have ID3 metadata. Is it possible to extract existing tags and images to plain text (e.g. JSON, XML)? Can I inject from plain text to MP3 file? How can I do ...
2
votes
1answer
1k views

Sort files in directory by creation date(Birth)

In my Download folder I have a lot of files.I need first a way to arrange them by type second files with same type arrangement become by the type that i added(or can say downloaded or birth (if i am ...
0
votes
2answers
71 views

Select Command not working while run shell scripts on remote machine

I want to run my shell script on a remote machine and I need user want to give value for some variable for that we use Read command while run script on local machine but I use the same command while ...
0
votes
3answers
161 views

How to cd into a directory with blanks?

I have a directory called "foo bar baz blob". How can I $ cd "foo bar baz blob" I have tried with quoting (" and ') and with escaping the blanks (\ ). It does not work. Tab-completion does not work ...
20
votes
4answers
3k views

What is the meaning of ./ before a given path?

I've been told to run this: ./yiic message ./app/messages/config.php But I don't understand the ./ meaning, can anyone clarify please. Note: Believe me, we can't google that. I've tried: ./ ...
19
votes
5answers
8k views

Showing a “cowsay” fortune in every new terminal session

I wish to display a cowsay message in every terminal window. The command I use is fortune | cowsay Any ideas how to make it appear whenever I start a new terminal session?
11
votes
3answers
2k views

Running a script created in Notepad (Windows) on Ubuntu

I created a Notepad file on Windows and copied it to Ubuntu. The file contains some iptables rules. After making the file executable using chmod +x and executing it, it didn't work. However, when I ...
10
votes
4answers
23k views

error while loading shared libraries libSDL-1.2.so.0

I am trying to install ioquake on my ubuntu server. When I try to run it, I get this message: # ./ioquake3 ./ioquake3.x86_64: error while loading shared libraries: libSDL-1.2.so.0: cannot open ...
9
votes
2answers
12k views

How can I protect parentheses passed to a cd command?

I asked here how to make cd protect spaces. Tab completion is great, but sometimes you paste the path from the clipboard so this is useful. The solution breaks with parentheses however. No matter how ...
9
votes
4answers
4k views

How can I play a song in the background via my command line?

I have installed play : sudo apt-get install sox libsox-fmt-mp3 I can now play my audio files like this : play Desktop/SONGS/01\ -\ Oh\ Baby\ Girl.mp3 Since I'm learning shell, I wish I could ...
8
votes
3answers
333 views

How to run a script when a directory is changed by another user?

I know has been a bit of discussion about topics similar to this. But here is what I am basically trying to do. I have a watch directory called watched and whenever a file is added to that directory, ...
8
votes
2answers
1k views

What's the use of complete command?

While running the complete command on my gnome-terminal, it shows some commands.What are they? And what is the use of complete command? $ complete complete -F _minimal complete -F _filedir_xspec ...
8
votes
2answers
11k 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 ...
7
votes
5answers
8k views

How to have a path containing spaces in PATH?

I tried export TASK=$HOME/Ubuntu\ One and export TASK="$HOME/Ubuntu One" but neither works.
5
votes
3answers
1k views

Pipable command to print in color?

I'm a bit new to bash scripting, and I'm wondering if there is a program or built-in command to pipe to that will print in a specified color? Or is there an echo argument to do so? Like I could do: ...
3
votes
2answers
1k views

How to use -exec option in find command

I wanna solve some problems in compiz with my brain and hands. By the way I entered following command to build compiz from source in Ubuntu 12.04 find /opt/compiz-built/share/gconf/schemas -exec ...
3
votes
1answer
620 views

Doing something if connected to particular SSID in Ubuntu

I want to write a bash script that will put off dropbox automatic synchronization if i'm connected to particular wifi ssid. How can i catch this event: for example i'm working at home and sync is on, ...
3
votes
2answers
8k views

Creating a script to install software after a clean install?

I find myself moving between multiple new machines lately (new laptop, new computer at work, etc.). I want to create a bash script to install all the software I use. Ninite is not reach enough. I have ...
1
vote
1answer
84 views

Raise all windows with a specific title

I'm trying to find a way to raise all the windows that have one, specific title. For example, I have two windows named superconky (yes, you guessed it, I'm trying to get conky running in lubuntu). I ...
1
vote
2answers
243 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
3answers
5k 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 ...
1
vote
2answers
4k views

How do I determine the MIME type of a file?

I recently switched to GNOME 3 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 ...
0
votes
3answers
34k views

Where my linux password is stored on my system and how i can retrieve it? [duplicate]

I am currently logged in on my Linux system and i want to output my Linux password and username on my terminal, what commands i need to write and in which file it is stored and how i can retrieve it ? ...
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 ...
9
votes
3answers
13k views

Changing behavior of bash prompt when functioning as root

Before you click away, this isn't the typical "how do I make my bash prompt have color" question. I've already customized my bash prompt to look like this: [user @ host]----[$(pwd)] $ where ...