Tagged Questions

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

learn more… | top users | synonyms (1)

6
votes
1answer
2k views

What's the difference between mkfs and mkdosfs?

I'm trying to put a linux distro .iso on my usb and the instructions suggests using the following command to make a fat32 filesystem: mkdosfs -F 32 /dev/sdc1 Is there a reason this command is to be ...
1
vote
1answer
4k views

how to completely reformat a usb using fdisk?

I have a usb drive which I would like to put a linux distribution on but it already has some files on it on /dev/sdc1. Using fdisk, I deleted the first partition and wrote the changes. When I ...
1
vote
1answer
2k views

Moving files to different directories

I'm trying to move media and other files which are in a specified directory to another directory, which will be created if it does not exist. And, I'm trying to create a directory where the remaining ...
26
votes
3answers
27k views

apt-get autocomplete package name is broken

At some moment apt-get install autocomplete was broken It was very useful to me to see packages name with Tab press How to repair this autocomplete?
2
votes
1answer
2k views

How can I set HISTSIZE for all users?

How can I set HISTSIZE for all users on Ubuntu 10.04? I've tried adding the following lines to both /etc/profile and /etc/bash.bashrc. I'm not sure I understand the difference between the two files ...
4
votes
4answers
7k views

Does executing sudo su and su root do the same thing?

What are the technical differences between the two? The only thing I noticed is that sudo su requires you to enter your own password (assuming you're not root) While su root requires you to ...
1
vote
1answer
4k views

Where is the default bash profile file kept?

Under Ubuntu 11.10, where is the default bash profile file for new users kept? I want to edit the default file so that new users get a preconfigured .bash_profile file.
3
votes
3answers
3k views

Is it preferred to avoid use of “exit” in bash scripts as much as possible?

I've been told in php it's preferred to avoid the use of the exit command as much as possible. Is the same true for bash? For example is the following #!/bin/bash if [ -z $1 ]; then echo ...
7
votes
4answers
432 views

What do the paranthesis and $ sign mean in echo $(ls)

The output of # ls and # echo $(ls) are the same. What exactly does the $ sign and the parenthesis mean? Also, what is going on a technical level that causes the output of these two commands ...
7
votes
2answers
11k views

How-to make file have different color when doing ls?

When I execute command ls it displays files and folders. folders are typed in light blue. I would like to have xml files types in pink color. How to do it?
5
votes
2answers
12k 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 ...
8
votes
2answers
31k views

Compress in .tgz

I want to compress files in .tgz. I know how to make tar.gz(with tar and gzip) and some people say it is almost the same, but I need to make a .tgz, how??
3
votes
2answers
789 views

Check connection and reconnect wifi [duplicate]

I'm building a wireless photoframe. The one thing I haven't been able to figure out is how to get my wifi connection back up using a recommended method. Right now I edited /etc/network/interfaces so ...
6
votes
1answer
5k 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?
2
votes
2answers
2k views

gnome-terminal and logging

Is there any way to log every that was displayed in gnome-terminal? for example I have a complex command doSomethingThatPrintoutsAlot ; doSomethingThatPrintoutsAlot2 ; doSomethingThatPrintoutsAlot3 ...
6
votes
1answer
15k 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.
3
votes
2answers
7k views

How can I install a specific older version of Firefox and keep it from automatically updating?

I wrote a bash script to configure a suite of tools for continuous integration on top of Ubuntu 10.04.2. The script recently stopped working and I tracked the problem down to the newer version of ...
1
vote
1answer
146 views

How to make error message?

When I execute bash script in eclipse the error output is written in red text. I have some behaviour in my code that is letting "user" know that error has occurred, how to make in error look like ...
11
votes
3answers
22k views

How to execute command every 10 seconds (without cron)?

When I execute cron I get this fault cron: can't open or create /var/run/crond.pid: Permission denied So, how to do it without cron? P.S. I want to check if file in svn has changed and I have a ...
1
vote
1answer
795 views

How to stop executing bash script when there are errors? (if problem)

I build my application using Maven. In my script after I build the app I startup application server. The problem is that if build is not succesfull the application server is started any way. If I ...
2
votes
1answer
301 views

How to prevent terminal from killing process with ctrl+z

I know that you can restore the process by hitting fg and enter after you stop a job with ctrl+z, but I don't think I've ever intended to stop a job.. ever. e.g. I always bump it when typing ctrl+x in ...
2
votes
1answer
553 views

How to escape spaces in pwd path when creating a Boost build script?

I want to compile Boost with some specific options (eg: using zlib from its latest source) So I try next bash code like: WD=`pwd` #//... cd $BOOST_ROOT_DIR echo_run ./bootstrap.sh #// problem with ...
1
vote
2answers
175 views

How to download code with weird interface

Here is a code for Eclipse Drag and Drop http://www.vogella.de/code/de.vogella.dnd.jface/codestartpage.html I would like to download it, how to do it using wget?
9
votes
3answers
8k views

How do I combine multiple grep commands?

I have a command like this: | grep -v @param | grep -v @return | grep -v @Test | grep -v @throws and its getting bigger, is there any way to make this neater?
1
vote
1answer
93 views

Get disk utilization by file-type?

Is there a way to get a break down of a disk (or directory) utilization based upon file-type from the command line? I guess I could write a bash script to find+du based upon a few known file-types, ...
0
votes
1answer
251 views

Line gets overwritten instead of continuing on same line

I have a problem with the bash prompt. When I type a command that exceeds the length of the width of the screen it continues on the same line and overwrites what I have written, and then continues on ...
2
votes
2answers
528 views

Why “cd ..” doesn't work in this if

pwd | grep 'database$' if [ "$?" = 0 ]; then echo "has db" cd .. cd .. echo "after has db" fi after I execute it I see has db after has db and I'm still in the same dir, how to fix it?
2
votes
4answers
3k views

Recursively rename files - oneliner preferably

I found this answer how do i... but it simply doesn't work - it did not rename any file for unknown to me reason Before I started to search around I thought that it should be easy task even for ...
20
votes
3answers
14k 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 ...
9
votes
6answers
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 ...
2
votes
5answers
692 views

How to grep whole manual?

I can do for example man cp | grep verbose to findout if cp man has word "verbose", how can I do something like (pseudo-code) man * | grep copy to find out what command to use for coping?
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
405 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
8k 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
74 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 ...
20
votes
2answers
91k views

how to use variables in SED?

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?
7
votes
3answers
13k 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
267 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
583 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
15k 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
570 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
795 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
125 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
7k 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