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

learn more… | top users | synonyms (1)

12
votes
2answers
7k views

How do I select a field/column from the output of `ls -l`?

My goal is deceptively simple (at least to me). I wish to take the output of ls -l or ls -lh and select just one field. I am looking for this to be as bulletproof as possible, by which I mean, assume ...
17
votes
5answers
22k views

How do I use wget/curl to download from a site I am logged into?

Some parts of wikipedia appear differently when you're logged in. I would like to wget user pages so they would appear as if I was logged in. Is there a way I can wget user pages like this ...
3
votes
4answers
8k views

Command to delete all files from folders matching name recursivly?

I have my base folder (let's call it base). I have a bunch of folders inside, scattered at various depths within these folders are cache folders. I want to delete all files from within the cache ...
0
votes
1answer
436 views

How do I solve this “unexpected '}' syntax error” in my bash script?

I have a piece of code that has some serious issues and I was hoping to get it solved soon but no one has offered any help. I thought I'd try some Ubuntu users since this is the OS running the script. ...
9
votes
4answers
21k views

How to find history of shell commands since machine was created?

I created an Ubuntu virtualbox machine a couple weeks ago and have been working on projects off and on in it since then. Now I would like to find the syntax of some commands I typed in the terminal ...
2
votes
2answers
894 views

Bash script not working as required with xbindkeys

I made a simple bash script to display a notification whenever my capslock key is pressed. It works fine when I call it like bash capsnotify.sh. The problem now is when I bind my above script to ...
0
votes
1answer
344 views

create a Pseudo command for lampp xampp

How do I create a psuedo command for the terminal? The basic command for lampp is: sudo /opt/lampp/lampp start But I don't want to type this every time so can I create a psuedo for this so I can ...
2
votes
4answers
225 views

Where does 'clear' command come from?

I'm from windows background. I wish to know where do all commands like exit,clear comes from in my terminal? And are they scripts? In what language they have been written?
4
votes
2answers
479 views

Script to find executable based on extension of a file?

I need to create a script that returns the default app to be used for a given file extension (including the path). I had a look at the file command which can return the mime type and xdg-open which ...
3
votes
1answer
396 views

Script for filing call recordings into date folders

We have an IP PBX that is running Asterisk and is set by the manufacturer to delete call recordings after a certain time period. I am backing these up to an Ubuntu server using rsync so that we are ...
0
votes
1answer
541 views

Why won't this bash script to drop caches work?

I am trying to make a bash script to clear my RAM caches. Here's what I have so far: #! /bin/bash free -m sync sudo -s echo 3 > /proc/sys/vm/drop_caches But it doesn't fully work. The first ...
19
votes
6answers
51k views

How to determine whether a process is running or not and make use it to make a conditional shell script?

How can I determine if a process is running or not and then have a bash script execute some stuff based on that condition... For example: if process 'abc' is running, do this if it is not running , ...
14
votes
2answers
6k views

What has 'rm -r ~' done to my home directory?

gedit creates hidden backup files ending with '~'. I wanted to do a recursive cleanup of my directory tree. The command rm *~ will delete all local files ending with '~' I thought rm -r *~ . would ...
1
vote
2answers
2k views

Ubuntu 12.04 Can't Login-Tty Console said: -bash: /usr/bin/byobu/-launch: no such file or directory

I face problem in login to Ubuntu 12.04. I think it's caused by accessing super user (if not wrong). I type sudo nautilus to put a background to burg, but i fail x_x. After reboot, i can't login to ...
3
votes
2answers
233 views

How do I cancel a time-delayed screenshot?

I'm using the default screenshot application that comes with Ubuntu gnome-screenshot When I was using it earlier to take screenshots of the lock screen I had set a long time delay, but forgot to ...
2
votes
4answers
1k views

Cannot execute shell /bin/zsh when execute a shell command in vi

I use bash. But it cannot find zsh. How to change this? ps:I don't want to install zsh.
-3
votes
2answers
703 views

Help with bash script with text

I'm new in bash scripting and need help with the following please: The purpose of this homework is to let students write programs in bash scripting language that enable them to manipulate data in a ...
26
votes
3answers
34k views

Why does “ps aux | grep x” give better results than “pgrep x”?

I've just tried the following command on my Ubuntu, it doesn't show a thing: pgrep php5 shouldn't it return the process id of php5(which the following command just does)?: ps aux | grep php5 So, ...
6
votes
2answers
2k views

How do I get the bash debugger to work with ddd?

ddd script.bsh does not open the script. It shows an our glass and if I want to close ddd, it says "bash is busy"... I found an old message, but it didn't help. ...
2
votes
5answers
423 views

Help with Bash script

#!/bin/bash if [ "$(Which gimp)" != ""] then { if [ "$(gimp -version)" != 2.8 ] then { sudo apt-get remove gimp sudo add-apt-repository ppa:otto-kesselgulasch/gimp sudo apt-get update sudo apt-get ...
1
vote
2answers
445 views

How do I set and use shell variables?

IRSTLM=$HOME/irstlm I need help setting this variable up. Was wondering if this is correct syntax IRSTLM=/home/user/irstlm Is that possible to run from root? I need it to be done in root in order ...
4
votes
2answers
977 views

How do I cut and paste terminal I/O without using the mouse?

I want to search and cut text from command output in a terminal so I can use it in subsequent command line invocations or just in an editor session. Is there any way to easily run a regular ...
7
votes
5answers
6k views

How to get current gnome keyboard layout from terminal?

For usage in a bash script, I need to get the gnome keyboard layout the user is currently using. For example if the user sets its keyboard layout to en-us , I need a bash command that prints me this. ...
1
vote
1answer
4k views

How can I backup and encrypt with tar, split and openssl, all in one command?

I often use tar to backup my stuff in 4 gigabyte chunks to a directory on a FAT32-formatted disk, as documented here. To get that done, I use the following command: tar -cvpj /path/to/directory/ | ...
37
votes
2answers
21k views

What are login and non-login shells?

It is said that settings for non login shell to go into .bashrc file and login shell settings to go into .profile file. What is really meant by login and non-login shells? Please explain without ...
0
votes
1answer
153 views

How do I grep audio/video frame time indexes from an XML file?

I have a xml file like this: <field name="frame.time_delta_displayed" showname="Time delta from previous displayed frame: 0.000000000 seconds" size="0" pos="0" show="0.000000000"/> <field ...
14
votes
4answers
35k views

How do I clean or disable the memory cache?

After the system starts, in a few minutes my memory cache fills up and it starts using the swap. Here's a screenshot of /proc/meminfo. However, if I can disable this process / clean the cache once ...
2
votes
2answers
500 views

How to Tab-complete directories when in symlinked directory?

I have a symlink: /path/to/foo -> /path/to/bar/foo When in /path/to/foo I might want to cd to /path/to/bar/foo: $ cd ../ Tab Then nothing autocompletes. I can still cd just fine by typing in ...
3
votes
1answer
530 views

How would you unsuspend a computer using a bash script?

How I can unsuspend my computer with a bash script like: #!/bin/bash pm-suspend sleep 10m {unsuspend command}
2
votes
0answers
729 views

Why doesn't duply work when set as a cron job?

I have a problem with a cron job which starts but doesn't complete. Running the command manually works fine. I already read the page about cron issues and solutions here on AskUbuntu, tried the ...
3
votes
0answers
875 views

Run a script from Django view as root without asking for password [closed]

I need to run a script (text.sh) that needs sudo, without inputting password, for example: sudo apt-get update >> /home/derp/test.txt I have modified my sudoers file like this: # This file ...
7
votes
1answer
19k views

How do I get the parent process ID of a given child process?

How to get parent pid from a given children pid? I know I can mannully check it under /proc, I am wonder if there is a smart/better way to achieve this in Ubuntu. Note the parent may or may not be ...
0
votes
1answer
492 views

Attempting to GREP details of a Java error

I'm running Ubuntu 11 and I'm having some issues with grep. I have a shell script (see below) which essentially checks if a certain Java program of mine is running, if not it runs it. That part works ...
21
votes
2answers
5k views

How does this [t]ricky bracket expression in grep work?

I saw this one-liner recently: $ ps -ef | grep [f]irefox thorsen 16730 1 1 Jun19 ? 00:27:27 /usr/lib/firefox/firefox ... So it seems to return the list of processes with "firefox" ...
3
votes
2answers
4k views

Run Bash Script as Root

Is there some way I can run a Bash script as root without being prompted for a password every time? I'm attempting to automate the process of starting my LAMPP install, which requires me running a ...
1
vote
2answers
5k views

Passwordless su in a Bash script?

I've run into a dilemma while migrating a Hadoop installation from Oracle Enterprise Linux to Ubuntu. The prior developer put the following command into rc.local within OEL: su reporter -c "cd ...
0
votes
1answer
4k views

Bash script throws “syntax error near unexpected token `}'” when run

I am trying to write a script to monitor some battery statuses on a laptop running as a server. To accomplish this, I have already started to write this code: #! /bin/bash # A script to monitor ...
3
votes
3answers
5k views

Why does `cd downloads` fail with “No such file or directory”?

Running Ubuntu 12.04, while in a terminal, I type ls and see list of folders, including the downloads folder. I then type cd downloads, press enter. I get bash: cd: downloads: No such file or ...
3
votes
1answer
305 views

lower-case 'c' key not working in bash

This is a bit of a strange one. I'm running Ubuntu 12.04. It's been working well but today, I ran into a hell of strange phenomenon. I can no longer type a lower-case 'c' in bash. At first I thought ...
13
votes
5answers
18k views

How do I insert a line at the top of a text file using the command line?

I want to insert text at the top of an already existing file. How can I achieve this. I tried echo and tee but was not successful. I was trying to insert repo line at the top of sources.list file ...
5
votes
3answers
833 views

How do I list the public files in my home directory? (mode 777)

I want to get the list of all the files in my home folder, having rwx (read-write-execute) or 777 permissions for everyone. Also, what is the command to know the permissions of a file?
0
votes
1answer
198 views

How to programatically fetch the download status of Google Chrome?

How would I go about determining if Google Chrome is downloading something, and getting the "percent-done" value of that download, from the terminal using a Python, Perl, or Bash script?
0
votes
2answers
1k views

How to install old version of ffmpeg?

I'm having trouble with the current release of ffmpeg, it transcodes .mp3 to .wavs in a format that is unsupported by my client. How can install this version? ffmpeg version ...
12
votes
5answers
15k views

difference between bash.bashrc and /etc/environment file

Till data I was used to set my environment variables in the bash.bashrc file. Recently I told to use the /etc/environment file. Well, both work fine. So, what is the difference between them? I ...
4
votes
1answer
534 views

Difference between launching an application from a keyboard shortcut vs the terminal?

What I have observed: When I type emacs in gnome-terminal, it launches in the same environment, with variables set in .bashrc. If I use a keyboard shortcut to the command emacs, it opens in an ...
3
votes
0answers
495 views

Problem with using wmctrl to arrange windows in compiz [closed]

I'm trying to write a bash script to control the arrangement of open windows on a particular viewport and have run up against a problem which is basically I can't find a way to reposition the windows ...
0
votes
1answer
37 views

Bash error suppresion

I'm using PHP script from cli, the script calls exec() few times. There are some minor errors sometimes, which are handled by php script. I'm suppressing the errors by appending 2>/dev/null to the end ...
4
votes
1answer
22k views

useradd: cannot lock /etc/passwd; try again later

Trying to add a user: useradd -c "test" -d /home/bbbbbbbb -e "01-jan-2013" -f 10 -g admin -p secretfgjdhdgd -s /bin/bash -u 123456 blobblob but getting: useradd: cannot lock /etc/passwd; try ...
3
votes
1answer
410 views

launching a program from bash causes bash to go to new prompt

When I run a program from the console, e.g. me@box:~$ firefox I expect the console to log error messages (I think this is std out or std err?) and other items from the program, firefox in this ...
3
votes
2answers
55 views

find everything besides directories

How can I use find command to find every type of the file (not just -type f but also specials such as sockets, device files etc.) but ommiting dirs?