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

learn more… | top users | synonyms (1)

6
votes
2answers
9k views

How to protecting cd command to deal with parentheses?

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 ...
3
votes
1answer
527 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
7k 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 ...
2
votes
2answers
253 views

Autostart program whenever a file is added to a folder

I have Lubuntu 14.04 LTS on my laptop for a few weeks now. I have been working on customizing the OS and such quite a bit, as well as installing everything that I need for daily usage. One thing I did ...
2
votes
2answers
735 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 ...
1
vote
2answers
122 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
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 ...
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
26k 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 ? ...
-1
votes
3answers
10k 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 ...
5
votes
1answer
4k 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
3k 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
4answers
244 views

Bash create custom string

how could in bash a pattern like ROW1 n1 n2 n3 n4 up to 300 be done with some command in bash or also just perl...the delimiter would need to be \t as above
3
votes
2answers
275 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
183 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
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 ...
3
votes
1answer
980 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
456 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
374 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
241 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
72 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 ...
1
vote
1answer
347 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
142 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
194 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
449 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
225 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
197 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
374 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
5k 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
1answer
279 views

How do I use a shell command as a launcher shortcut? [duplicate]

The following command from terminal works perfectly: sh /home/flux/Downloads/TeamSpeak3-Client-linux_amd64/ts3client_runscript.sh How would I go about adding this as a shortcut, so I can open ...
114
votes
10answers
40k 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 ...
37
votes
3answers
127k 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 ...
38
votes
5answers
11k views

Shortcut to clear command line terminal [duplicate]

Is there a shortcut to clear the command line when typing in it instead of keeping backspace pressed for a few long seconds? I ask because I regularly use the Tab key to automatically fill in file ...
38
votes
1answer
9k 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 ...
26
votes
3answers
39k 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
9k 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
14k 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 ...
30
votes
3answers
21k 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 ...
20
votes
4answers
18k 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 ...
29
votes
6answers
21k 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 ...
11
votes
6answers
20k 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?
25
votes
3answers
22k 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 ...
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 ...