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

learn more… | top users | synonyms (1)

22
votes
9answers
161k views

How do I run .sh files in Terminal?

Whenever I open a .sh file, it opens it in gedit instead of the terminal. I can't find any option similar to Right Click → Open With → Other Application... → Terminal. How do I open this file in the ...
126
votes
5answers
91k views

What is the CVE-2014-6271 bash vulnerability (Shellshock) and how do I fix it?

Recently, there have been news going around regarding "CVE-2014-6271" (See USN-2362-1), which is a vulnerability in Bash. How do I know if I am affected by this, how can I fix it, and why should I ...
62
votes
6answers
111k views

How do I create a permanent Bash alias?

I would like to create an alias to rm command in order to have a confirmation message after executing this command. So I am creating an alias like this alias rm='rm -i'. But as far as I know this is a ...
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 ...
44
votes
4answers
65k views

Running programs in the background from terminal

How do I run a program in the background of a shell, with the ability to close the shell while leaving the program running? Lets say my UI is having problems or for some reason, I need to boot up a ...
8
votes
6answers
4k views

How can I run this sh script without typing the full path?

I'm still very new to Ubuntu. I'm using 12.04, and I'd like to know if there is a way to run this program/shell script without typing: /opt/idea/bin/idea.sh It's kinda tedious and I'm quite lazy. ...
14
votes
8answers
27k views

How do I rebuild a corrupt dpkg status file?

Whenever I type sudo apt-get remove and then press the Tab key for auto-completion I get the following message: grep-status: /var/lib/dpkg/status:15945: expected a colon. I don't see anything ...
72
votes
9answers
12k views

How can I tell what date Ubuntu was installed?

is there a command which will output the date that ubuntu (or any distribution) was installed?
51
votes
4answers
69k views

Why ~/.bash_profile is not getting sourced when opening a terminal?

Problem I have an Ubuntu 11.04 Virtual Machine and I wanted to set up my Java development environment. I did as follows sudo apt-get install openjdk-6-jdk Added the following entries to ...
26
votes
3answers
18k views

How can I shorten my command line (bash) prompt?

Currently it is: michael@Castle2012-Ubuntu-laptop01:~/Dropnot/webs/rails_v3/linker/spec/controllers$ Outside of renaming my machine and directory structure... How could I make it be something ...
48
votes
3answers
3k 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 ...
18
votes
6answers
9k views

Differences between doublequotes “ ”, singlequotes ' ' and backticks ´ ´ on commandline?

I often see tutorials on the web or posts on this site which make heavy use of the following characters at the command line. Often it seems that they are used for pretty similar purposes. What are the ...
1
vote
1answer
849 views

How can I capture text from a specific terminal and redirect it to a log file while simultaneously working? [duplicate]

I viewed this question to redirect text to file while displaying the output. My question is how can I redirect it while working AND without constant | tee command. My plan is to use this question to ...
56
votes
4answers
28k views

Hide current working directory in terminal

As a default, the terminal prompt shows something like: user@system:/folder1/folder2/folder3/folder4$ the deeper you go into the filesystem, the less space is left for typing in commands. Can I ...
37
votes
3answers
16k views

Bash history search, partial + up-arrow

I have searched, but not found anything on this. I am looking for a functionality in bash, using a terminal. Way back when, I had a user on a debian system, and a friend set me up with a convenient ...
9
votes
1answer
1k views

How to run a command or script at screen lock/unlock?

I am looking for a way to store lock/unlock screen times. A=$(date) echo $A >> $HOME/time_xprofile What did I try: $HOME/.bashrc $HOME/.bash_logout $HOME/.bash_prompt $HOME/.xprofile Then ...
13
votes
2answers
2k views

Can I enable bash-completion for the new apt command?

The new apt command in 14.04 seems to be a really useful intersection of functionality between apt-get and apt-cache but the current version of bash-completion doesn't know about it... Which makes it ...
11
votes
5answers
9k views

trim the terminal command prompt working directory

When using the terminal in a deep folder structure sometimes the prompt can take up most of the line. Is there any way in which I can trim the working directory? I know I can do PS1="\W >" to only ...
60
votes
8answers
131k views

How to clear bash history completely?

I want to clear all before command from history of my server. I use history -c it seems all things are cleared but when I ssh to the server,all commands are still there. How can I clear them ...
36
votes
5answers
52k views

How to list all variables names and their current values?

Including not only $HOME, $PWD etc but any other you have defined.
21
votes
3answers
21k views

How do I modify my PATH so that the changes are available in every Terminal session

I want to add a directory to search my search path. I know I have to modify the $PATH environment variable. However, I want the change to be permanent, so that it is always in effect, for every ...
7
votes
3answers
903 views

Where can I find a complete reference for the $PS1 variable?

The default PS1 variable on my machine (Kubuntu 13.10) is this: \[\e]0;\u@\h: \w\a\]${debian_chroot:+($debian_chroot)}\u@\h:\w\$ I'm looking for a reference for how the $PS1 variable works that, at ...
7
votes
1answer
412 views

Sequence of scripts sourced upon login

I would like to concentrate all my login config in my ~/.bash_profile. There was a ~/.bashrc there by default but I replaced it with a ~/.bash_profile. However, when I log in, something before my ...
9
votes
5answers
12k views

Home directory not being created

I am trying to understand system administration on Ubuntu. So, as an example, I create a dummy user using sudo useradd -d /home/linda linda and the passwd to create a the password. I check that an ...
0
votes
2answers
146 views

UEFI machine doesn't boot Ubuntu through NVRAM bootcatalog. How to fix?

An answer posted here should: Avoid to require the user to download and install additional packages or PPAs. Be as quick and simple as possbile. (I tried boot-repair and it didn't ...
42
votes
2answers
86k 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?
36
votes
1answer
18k 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 ...
21
votes
6answers
7k views

How can I create an alias for cd and ls?

I frequently run the ls command after running the cd command. How can I create an alias (like cs) for this operation?
28
votes
2answers
16k views

How can I tell if my system was booted as EFI/UEFI or BIOS?

How do I determine whether a particular running Ubuntu system was booted using EFI/UEFI, or BIOS?
11
votes
3answers
27k 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 ...
11
votes
5answers
9k views

Search for duplicate file names within folder hierarchy?

I have a folder called img, this folder has many levels of sub-folders, all of which containing images. I am going to import them into an image server. Normally images (or any files) can have the ...
21
votes
5answers
9k views

How to avoid duplicate entries in .bash_history

The same command is listed in my history again and again. How can I avoid this? I know it's possible via HISTCONTROL but I haven't found the right way.
14
votes
3answers
34k views

What is the difference between 'su -' , 'sudo bash' and 'sudo sh'?

I would like to know what is the difference between su - sudo bash sudo sh I cannot login as root while doing su - because I do not have the root password - I mean I have my user password with ...
2
votes
1answer
6k views

Run simple bash script to start applications at login

I want to run a simple bash script automatically when I log in. For example #!/bin/bash echo "start spotify" gnome-terminal -e spotify --title spotify When I run this command, one gnome-terminal ...
1
vote
4answers
1k views

Can't run a shell script [duplicate]

So I have this script: #!/bin/bash # Flips the screen (hopefully) syntax_error=0 orientation=0 current_orientation="$(xrandr -q --verbose | grep 'connected' | egrep -o '\) ...
26
votes
3answers
29k 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?
45
votes
5answers
29k views

Which one is better: using ; or && to execute multiple commands in one line?

In tutorials and how-to's I often see commands combined. For instance, sudo apt-get update && sudo apt-get install pyrenamer There seem to be four possible connectors: &, &&, || ...
22
votes
4answers
35k views

How to change extension of multiple files from command line?

I have many files with .abc extension and want to change them to .edefg How to do this from command line ? EDIT: I have a root folder with many sub-folders, so the solution should work -r ...
21
votes
1answer
232k views

How to copy files via terminal?

I have read about copying files with terminal but these examples will help me a lot. So here is what I want to do: Examples: I have a file in /home/levan/kdenlive untitelds.mpg and I want to copy ...
45
votes
2answers
14k 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
32
votes
2answers
6k 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 ...
33
votes
6answers
29k views

/etc/profile not being sourced

For 11.04, I did a fresh install of my system. Part of that install was to install rvm, which sticks a rvm.sh in /etc/profile.d/. This doesn't work as /etc/profile (which loads each +r in ...
22
votes
7answers
41k views

Can you set passwords in .ssh/config to allow automatic login?

I'm using ubuntu 11.10. I'm using ssh for connecting to many servers daily, so i put their parameters in .ssh/config file; like this : Host Home User netmoon Port 22 HostName test.com Is there a ...
28
votes
9answers
93k views

How can I create a select menu in a shell script?

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 ...
25
votes
1answer
62k 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
13
votes
5answers
16k 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 ...
11
votes
2answers
7k views

How do I use 'notify-send' to immediately replace an existing notification?

When I use notify-send to show a notification on the desktop, and then use it again to show a different notification, I have noticed that the second one only shows after the first one has disappeared. ...
24
votes
3answers
22k views

How do I add environment variables?

I'm running Ubuntu 11.04. I use the terminal to start a bash session, and I want to add an environment variable: $r@hajt:~$ env THEVAR=/example But it's not working. It shows all the variables with ...
5
votes
2answers
901 views

How does one open the HUD from the command line.

Alt is used to open the HUD in 12.04. I'd like to use alt to execute a second action as well as open the HUD by having alt execute an executable script. So Alt = script, that does HUD and other ...
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 ...