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

learn more… | top users | synonyms (1)

2
votes
1answer
2k views

Applying chgrp “apache” to entire directory failed

I've been tried to change group of the whole directory with code example below [bash terminal on ubuntu 11.10]: chgrp apache -R ./test1 but failed and said : chgrp: invalid group: `apache' user ...
2
votes
1answer
2k views

Typing commands into a terminal always returns “-bash: /usr/bin/python: is a directory”

I think I messed something up on my Ubuntu server while trying to upgrade to Python 2.7.2. Every time I type in a command that doesn't have a response, the default from bash is this: -bash: ...
1
vote
1answer
409 views

My terminal prompt PS1 mixed up

By the way I'm on a Mac OS X but I'm connected to an Ubuntu Server. Yesterday I installed a module for node.js(after a hour I deleted it) which asked me to add something to the .bashrc file and now ...
2
votes
7answers
5k views

How to enter every directory in current path and execute script

I want to enter every directory retuned by ls command and execute script. I tried this (and many other things), but it just does not work ls | awk '{print $1" && pwd"}' | xargs cd How to ...
5
votes
3answers
2k views

Need help with bash checking if computer uptime is greater than 5 minutes

I have an bash script that runs on a every minute cron. It checks to see if a necessary program is running and starts it if it is not. Occasionally it will run before the user has actually autologged ...
1
vote
1answer
9k views

How to get line number from grep?

the fallowing grep grep -r -e -n coll * will display fullpath/filename: <tag-name>coll</tag-name> I would like to know what line has the fallowing text, I tried adding -n, but it ...
3
votes
3answers
4k views

How to find text and replace that line if exists with terminal otherwise just append line to end

I want to put in sudo gedit /etc/sysctl.conf the one line vm.swappiness=10 which I sometimes change. By default this line doesnt exist so I use echo "vm.swappiness=10" | sudo tee -a /etc/sysctl.conf. ...
3
votes
2answers
1k views

How to create daily job without write access to /etc?

I don't have write permissions to /etc and its sub folders, but even do I would like to have bash script that is executed every morning. How to set it up? also when i type cron in command line I get ...
1
vote
0answers
75 views

How to disconnect modem when postfix queue gets empty? [closed]

in /etc/ppp/ip-up.d/script I have the following that runs fetchmail when the ppp0 interface is up (connected) and when it finish the modem ends internet conection automatically. #!/bin/sh ...
24
votes
2answers
97k views

How to use variables in 'sed' command?

I try the fallowing code and it does nothing var1=QQ sed -i 's/$var1/ZZ/g' $file However this code replaces QQ with ZZ sed -i 's/QQ/ZZ/g' $file How to use variables in sed?
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
2
votes
1answer
278 views

How to make tail -f show time when line was appended?

I'd like to know the time when line was appended when file is being tail -f'ed. Is it possible to configure tail to do something like that?
0
votes
2answers
640 views

Redirection Doesn't Work

I want to put my program's output into a file. I keyed in the following : ./prog > log 2>&1 But there is nothing in the file "log". I am using the Ubuntu 11.10 and the default shell is ...
0
votes
2answers
1k views

How to append text to file every morning?

I would like to append current date to text file every morning at 7am. if the computer is turned off I would like it to be executed after its turned on.
2
votes
3answers
16k views

How to execute script in different directory?

I tried this ./home/user/scripts/someScript but it doesn't work No such file or directory any ideas?
4
votes
4answers
600 views

How to make script support file:/// notation?

When I copy any file and paste it in console or text editos it is passed as file:///home/user/path/file when I pass it to script it is not found What is the easiest way to convert that to ...
0
votes
3answers
826 views

Help me to add line to file password /etc/shadow

when I try to add line inside /etc/shadow: echo -e "admin234:!!:0:0:99999:7:::" >> /etc/shadow 1 2 3 The console show this message: -bash: 0: unrecognized history modifier or ...
0
votes
1answer
127 views

help me problem in my shell script

I need back from 2 or 3 to 1 after print error ?? 1 echo -e "program set defulte home dirctory /home/admin/$un" echo -e "DO you want use defulte home dirctory? Yes=1 & NO=2" ...
6
votes
4answers
8k views

How to add an extension to all files via terminal

I would like to add the .zip extension to all files. I tried this, however it does not work: ls | awk '{print $1 " " $1".zip"}' | xargs mv -f
1
vote
1answer
232 views

bash text processing and error message

for example I have this script that kills firefox ps x | grep firefox | grep -v grep | awk '{print $1}'| xargs kill -9 but when there is no firefox running it spits out: Usage: kill pid ... ...
0
votes
1answer
16k views

why syntax error near unexpected token ' fi '

#!/bin/bash # # # # echo -e "please insert user name :" read un echo "$un" len=${#un} echo "$len" ze=0 te=10 if [ "$len" -eq "$ze" ] than echo "no argument" exit fi if [ "$len" -ge ...
1
vote
1answer
418 views

shell script to insert line into /etc/passwd , /etc/shadow ,/etc/group and save it

Can anyone help me to add one line to any file from this: /etc/passwd , /etc/shadow ,/etc/group exp; username:!!: …. add to /etc/shadow by shell script without vi program
19
votes
5answers
1k views

How do I teach bash in Ubuntu some curse words?

When bash encounters an unknown command(word?) it does this : The program 'hello' can be found in the following packages: * hello * hello-debhelper Try: sudo apt-get install <selected ...
4
votes
1answer
611 views

How to compare zip files' contents?

Is there any tool to compare zips by content? maybe some krusader addon or command-line magic?
2
votes
5answers
16k views

How to modify “/etc/bash.bashrc”? It is read only?

Trying to modify /etc/bash.bashrc I get an error: $ echo "my edit" >> /etc/bash.bashrc bash: /etc/bash.bashrc: Permission denied ls -ll /etc/bash.bashrc shows: -rw-r--r-- 1 root root 1975 ...
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 ...
19
votes
8answers
48k views

How to remove all files and subdirectories in a directory WITHOUT deleting the directory in bash?

Is there a command to remove all files and subdirectories in a directory WITHOUT deleting the directory? For example if I have directory "dontDeleteMe" with subdirectories "1", "2", "3" and each ...
4
votes
1answer
5k views

When you run `update-rc.d myscript default` - what is called on startup/shutdown?

What gets called on startup/shutdown when you run update-rc.d myscript default? Docs seem fuzzy, I want concrete. I am guessing that this happens: At startup (specifically at entry to runlevel 2, ...
2
votes
2answers
10k views

How to write an init script that will execute an existing start script?

I'm trying to understand the init process. I have a script which launches 3 background processes (2 shell scripts and a java app). It works just fine from the command line. I'd like to execute that ...
2
votes
1answer
798 views

How to run script at shutdown? [duplicate]

How can I make a bash script run only at shutdown? I have searched for it and keep coming up empty handed. I would be fine with either a link or an explanation to how to do it.
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?
1
vote
1answer
348 views

How to interpolate a variable immediately after a `$` or `\$` in the bash prompt?

I am using this function: function test(){ local var="hello" PS1="\u\$$var" } The output I am trying to get from the function is john$hello. But what I get is just john. If I add a space ...
0
votes
2answers
697 views

Problem using `sed` to colorize `ls` output (Tenth back-reference `\10` not working)

I had asked this question a while back: Is it possible to colorize permissions-part of the output of ls? While the accepted answer in that question is OK, I now want to do the same thing without ...
17
votes
3answers
2k views

how to get bash to stop escaping $ during tab-completion?

I have this on the command line: ln -sf $PWD/wine- and then I hit tab to complete the filename. In earlier versions of Ubuntu, this worked just fine to complete the wine- filename (and as a ...
2
votes
1answer
121 views

What happens when I run ln -s pear /tmp/pear-build-`whoami`

I have read this interesting post regarding the installation of php-mongo driver not writeable by the current user mkdir pear ln -s pear /tmp/pear-build-`whoami` /usr/bin/pear config-set cache_dir ...
2
votes
2answers
3k views

How to run an executable bash script on Kubuntu?

I have recently changed my OS from Ubuntu 11.04 to Kubuntu 10.04 but don't know how to get my executable bash scripts to run on Kubuntu. On Ubuntu all I did was click on the text file and I was given ...
1
vote
1answer
407 views

gdialog cannot output variable

copied='cp -v *SNAPSHOT.jar /home/user/folder' $copied prints information about copied files however gdialog --title "done" --clear --yesno "done $copied" 15 60 shows command that was executed, ...
2
votes
1answer
940 views

Upstart scripting: Start service and immediately run another command

Here is my current Upstart script I've placed at /etc/init/redis.conf: description "redis server" start on runlevel [2345] stop on shutdown exec sudo /opt/redis/redis-server /opt/redis/redis.conf ...
32
votes
9answers
26k views

How do I restrict my kids' computing time?

Access to our computer (not only to the internet) needs to be restricted for the accounts of my kids (7, 8) until they are old enough to manage this by themselves. Until then we need to be able to ...
1
vote
1answer
672 views

Running program on startup

I wrote a program in Bash, and now I want to run it on startup for all users so that nobody can cancel it, except for root. How can I do it?
29
votes
4answers
10k views

How to create script with auto-complete?

When I use program like svn and I type in Gnome Terminal: svn upd and hit Tab it's autocompleted to: svn update Is it possible to do something like that in my custom bash script?
1
vote
1answer
3k views

output terminal redirect to zenity

Let's explain you my doubt. We all know that >& is shell syntax for "fold a file descriptor into another". So 2>&1 means that i want to redirect stderr to the stdin, this is simple and ...
2
votes
1answer
949 views

Problem to write long lines in terminal

I have defined a PS1 prompt multi-line in my server with Ubuntu 11.04. The problem occurs when I write a long command, the line cuts before the end of terminal and it continues at beginning the same ...
31
votes
2answers
8k views

Is it possible to make writing to .bash_history immediate?

I often open lots and lots of Terminals [Right now I have 7 open on this workspace] and I often search history with grep to find a command I've just written recently, but I don't want to hunt down the ...
0
votes
0answers
72 views

How do I make nautilus reload emblems when changed by a script? [duplicate]

Possible Duplicate: Is there any tweak to bring back emblems in Nautilus? I am writing a script to manage my downloads folder. It will automatically delete items older than a month (or any ...
0
votes
1answer
1k views

bash script and zenity progress

I have this cmds: (youtube-dl http://www.youtube.com/watch?v=HhoewflkQu0) | zenity --progress --width=400 --height=100 --title="Scaricamento" --text "Scaricamento in corso..." --auto-close --pulsate ...
3
votes
2answers
2k views

Where to put custom .bashrc stuff, in .bash_local?

Just upgraded to 11.10, and prompted me to wondering where is now the preferred way to put customised .bashrc bits? I have some aliases, some env variables, and a python virtualenvwrapper script, for ...
5
votes
2answers
1k views

How to set env with a dot?

I tried doing that with export and set env, but it did not work. how to do it? for example ~/directory$ export a.home=1 bash: export: `a.home=1': not a valid identifier
1
vote
2answers
284 views

Opening program from nautilus through custom script

Would like to open all avi and mpeg files from folders in nautilus into a script that opens the file and moves the window using wmctrl. Basically, I need to open all media files with a script that ...
15
votes
4answers
1k views

How (and where) can one change 'user@host $:' pattern in gnome-terminal?

When I start terminal in Ubuntu, I see: ilya@HOST:~$ I need to add a timestamp to this, something like: 2011-10-09T09:32:00 ilya@HOST:~$ How can I configure this?