A shell script is a script written for the shell, or command line interpreter, of an operating system.

learn more… | top users | synonyms (1)

45
votes
3answers
2k views

Is #!/bin/sh read by the interpreter?

In bash or sh, I guess anything which starts with # is a comment. But in bash scripts we write: #!/bin/bash And in Python scripts, there is: #!/bin/python Does this mean that # by itself is a ...
45
votes
1answer
4k views

Can I make the webcam take a picture when an incorrect password is entered?

I am using a laptop . I was thinking to have a support in my Ubuntu machine. When an incorrect password is entered, a picture is taken later revealing who has been trying to gain access. I have ...
41
votes
6answers
8k views

What is the difference between ./ and sh to run a script?

I have written a simple script. When I runsh <myscriptname.sh>, i got the correct output, but when I run ./<myscriptname.sh>, I got an error. What is difference between when I do sh and ...
39
votes
3answers
8k 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 ...
38
votes
3answers
39k views

How can I get a list of all repositories and PPAs from the command line?

I know how to list all packages installed on my system. But how could I get a list of all repositories and PPA's? I know I can look into /etc/apt/sources.list and /etc/apt/sources.list.d, but I'm ...
36
votes
5answers
6k views

How do I create a deb package for a single python script?

I have a single python script that I want to distribute as a deb package. It is a indicator which shows local date in Unity panel. I did follow create a .deb Package from scripts or binaries but I ...
33
votes
2answers
9k views

What is the difference between “source” and “.” in bash?

As the question says, what is the difference between executing a script with source command and with . , i.e.: source /some/script and . /some/script
31
votes
1answer
16k views

Differences between /bin, /sbin, /usr/bin, /usr/sbin, /usr/local/bin, /usr/local/sbin [duplicate]

I'm running an Ubuntu Server 13.04, but I see the same on a 12.04: I have six directories with command files. These are: /bin /sbin /usr/bin /usr/sbin /usr/local/bin /usr/local/sbin What are the ...
31
votes
2answers
5k views

bashrc or bash_profile?

I know the difference between the two bash login scripts: .bashrc is run only by "non-login" shells. .bash_profile (or .bash_login or .profile) is executed by "login" shells. Does anyone have some ...
28
votes
2answers
49k views

What is difference between /bin/sh and /bin/bash?

if I write, #!/bin/bash echo "foo" or #!/bin/sh echo "foo" both yields same. I have seen some scripts starting with #!/bin/sh or #!/bin/bash. Is there any difference between them?
28
votes
3answers
5k views

How to make Skype use notify-osd?

How do I make Skype use the default Ubuntu notify-osd to display notifications (incoming messages, users connecting, etc.) instead of the Skype's own "ugly" message box?
24
votes
8answers
2k views

How to keep “dot files” under version control?

Etckeeper is a great tool for keeping track of changes to your configuration files in /etc A few key things about it really stand out. It can be used with a wide variety of VCSs: git, mercurial, ...
23
votes
6answers
50k views

Bash remove first and last characters from a string

I have a string like that: |abcdefg| And i want to get a new string called in someway (like string2) with the original string without the two | at the start and at the end of it so that i will ...
22
votes
2answers
28k views

ssh: automatically accept keys

I've written this small utility script: for h in $SERVER_LIST; do ssh $h "uptime"; done When a new server is added to $SERVER_LIST, the script is stopped with: The authenticity of host ...
19
votes
3answers
61k 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 ...
19
votes
4answers
19k views

How to install an init.d script in ubuntu?

I am trying to install an init.d script, to run celery for scheduling tasks. Here is the steps I followed: copied the file celeryd and pasted it in folder /etc/init.d/ created a configuration file ...
18
votes
2answers
40k views

How to add a shell script to launcher as shortcut [duplicate]

Possible Duplicate: How can I edit/create new launcher items in Unity by hand? How can I create launchers on my desktop? I want to add some shell scripts in my launcher as shortcuts.. ...
17
votes
5answers
16k views

Beep in shell script not working?

I'd like to use a beep sound in a shell script. Unfortunately none of the methods I found via Google work for me. I tried echo -e '\a' echo -ne '\007' and the command beep after I installed it ...
17
votes
9answers
64k views

How can I create a select menu in a shell script? [closed]

I'm creating a simple bash script and I want to create a select menu in it, like this: ./script echo "Choose your option:" 1) Option 1 2) Option 2 3) Option 3 4) Quit And according to user's ...
17
votes
5answers
19k views

How to execute a script just by double clicking like .EXE files in Windows?

How can I make a bash script executable by double clicking just like .exe files in Windows? I tried creating a launcher and assigning the script to it, but there are two consequences: the terminal ...
17
votes
1answer
7k views

how to execute a command after resume from suspend?

I've got a script that is executed in order to have suspending/resuming working in my laptop. Then I have another series of xinput,xkbset and xmodmap commands that are executed when I initiate a ...
17
votes
3answers
882 views

How can I initiate Nautilus file operations from the command line?

How can I start Nautilus's "File Operations" GUI from the command line? My goal is to include this in a Nautilus script.
16
votes
5answers
9k views

Execute script before shutting down

When I shut down my computer I want to show some pending tasks that I have to do before leaving the office... I did a local application to manage those tasks, basically I just want to run a command, ...
15
votes
5answers
4k views

Command to convert an upper-case string to lower-case?

What is the Bash command I can use to convert an upper-case string to lower-case and vice-versa? Thank you.
15
votes
5answers
24k views

How can I make a script that opens terminal windows and executes commands in them?

I have three scripts I need to run when I start up my Ubuntu machine, they start services I use in my development environment. To do that, I manually open three terminals and type in the commands. ...
15
votes
3answers
6k views

How can a script check if it's being run as root?

I'm writing a simple bash script, but I need it to check whether it's being run as root or not. I know there's probably a very simple way to do that, but I have no idea how. Just to be clear: What's ...
15
votes
1answer
36k views

Command to append line to a text file without opening an editor

Assuming i have a line that i want to add to a file without opening an editor. How could i append this line alias list='ls -cl --group-directories-first' to this file config.fish
15
votes
2answers
3k views

How can I find the location (on the desktop) of a window on the command line?

I'm trying to write a little script to help manage my windows via keyboard shortcuts. In order to do what I want, I need to be able to find the current location and size of the "active" (focused) ...
15
votes
4answers
20k views

How to run an alias in a shell script?

I have an executable file mpiexec, whose full path is ~/petsc-3.2-p6/petsc-arch/bin/mpiexec. Since I want to execute this command in different directories (without having to retype the entire path), ...
15
votes
5answers
14k views

How to determine if a string is a substring of another in bash?

I want to see if a string is inside a portion of another string. e.g.: 'ab' in 'abc' -> true 'ab' in 'bcd' -> false How can I do this in a conditional of a bash script?
15
votes
5answers
22k views

How do I tell a start up program to start minimized?

Here is a quesion that has been bugging me. You know how you can set up a program to run on start up right? Well, how can i tell it to start minimized, like you would do in windows? TeamViewer ...
15
votes
1answer
609 views

How To Get Plymouth To Display Boot Messages When Booting?

I would like to know how to create a splash for Ubuntu Maverick with boot messages being displayed when I boot as well as a progress bar and a spinning logo. Or, if possible, how to edit a splash ...
14
votes
2answers
5k views

Record a programs output with PulseAudio

I would like to record an output of a program with PulseAudio using command line/bash script. It is important not to record every output of the sound card, but only the one of one specific program. I ...
14
votes
2answers
2k views

How can I write Nautilus scripts in Python?

I want to write a Nautilus script in Python. Is that possible? If it is possible, how can I do that?
13
votes
2answers
17k views

At what time does cron execute daily scripts?

If I place a shell script in /etc/cron.daily/, at what time of the day will it be executed?
13
votes
5answers
12k 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 ...
13
votes
1answer
2k views

How to run a shell script when a new USB storage device is detected?

I want a script that dumps the log and starts logging on it as soon as a usb mass storage is plugged (with the file 'OKdump' on it).And if anything abnormal(Like a error that is visually present) is ...
12
votes
3answers
2k 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?
12
votes
1answer
1k views

What is apt-fast and should I use it?

Several times over the past couple years, I've heard of people using apt-fast for updating and installing packages, but I'm not really sure what it does. I think I've traced its origin to this forum ...
12
votes
3answers
65k views

How can I make “rc.local” run on startup?

I have a script that I would like to run when my system starts. I have put it on "rc.local", but it doesn't work. How can I enable it to run on startup? Thanks!
11
votes
6answers
40k views

How to run scripts every 5 seconds using cron?

I would like to know how to run a script every 5 second. I know that cron can do every minute. How do you get intervals below that?
11
votes
7answers
6k views

How to remove Change Desktop Background from right click?

I want to restrict users on changing wallpapers and themes. So can anyone say me how to remove Change Desktop Background option from right click? Note: I just totally want to remove that option ...
11
votes
4answers
6k views

Script to display all terminal colors

Throughout the internet I have seen many people with scripts that prints out a bunch of stuff in all the colors defined in ~/.Xdefaults. However when I try to use these, I always get error: Bad ...
11
votes
5answers
14k views

Upstart script doesn't start

Ubuntu 10.04 I have created this upstart script (/etc/init/pure-ftpd.conf): # pure-ftpd - FTP server description "Pure-FTPd server" start on filesystem stop on runlevel S respawn respawn limit ...
11
votes
2answers
33k views

How do I run a script after OpenVPN has connected successfully?

How can I associate a script to OpenVPN so that it runs when the VPN is connected successfully?
11
votes
2answers
729 views

How can I programmatically change a file's icon?

If I select an icon in Nautilus and select Properties, I can click on the icon presented there. This gives me a file-chooser dialog to select a new icon image. I would like to do this via a script of ...
11
votes
1answer
6k views

What language(s) can I use in LibreOffice for macro scripting?

Not finding any info online; I hope somebody here knows. It was Python in OpenOffice; is it still Python? Or are they moving to gasp VBA?
10
votes
2answers
276 views

How can I preserve the executable bit on a file that is synchronized by Ubuntu One?

A script I am working on is in a folder that is synchronized by Ubuntu One. Every time I edit it from another computer, it looses its executable bit and I must manually reapply chmod +x. How can I ...
9
votes
6answers
15k views

Not able to execute a .sh file: /bin/bash^M: bad interpreter

I wanted to execute a shell script: -rwxr-x--x 1 root root 17234 Jun 6 18:31 create_mgw_3shelf_6xIPNI1P.sh I tried to do a standard procedure, but I am got this error: ...
9
votes
2answers
1k views

What is the least insecure way to store a password that is used by a script?

I have a Bash script that automatically authenticates with a service using my username and password. The credentials are currently stored as plain text within the script. What precautions should I ...