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

learn more… | top users | synonyms (1)

96
votes
10answers
34k views

Moving from bash to zsh

I'm considering moving from bash to zsh as I often come across posts praising zsh. I'm an experienced command line user and I'm assuming the basics are pretty much the same, so I'm looking for advice ...
70
votes
9answers
11k 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?
52
votes
4answers
23k 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 ...
51
votes
6answers
87k 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 ...
48
votes
8answers
99k 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 ...
46
votes
5answers
67k views

How can I decode a base64 string from the command line?

I would like to write a bash script to decode a base64 string. For example I type decode QWxhZGRpbjpvcGVuIHNlc2FtZQ== and it prints Aladdin:open sesame and returns to the prompt. So far I have tried ...
46
votes
6answers
10k views

What to do when Ctrl-C won't kill running job?

Sometimes, processes ignore the SIGINT signal sent by Ctrl-C in Bash. For instance, man and vi. Assuming you don't want to google or read the manual on how to exit the running process, is there any ...
46
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 ...
45
votes
4answers
57k 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 ...
39
votes
3answers
9k 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 ...
39
votes
4answers
51k 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 ...
38
votes
4answers
5k views

How can I undo the last cd command?

Is there any way to jump back to the previous working directory after doing a cd to a different directory? My use-case is that I'm traversing a directory structure for a Java project, and I'm ...
37
votes
2answers
12k 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
34
votes
6answers
6k views

Is there a difference between the '&&' and ';' symbols in a standard BASH terminal?

They seem to both signal BASH to commence with another command following the symbols but is there a distinct difference?
34
votes
3answers
14k 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 ...
33
votes
4answers
17k 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: &, &&, || ...
32
votes
4answers
26k 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 ...
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 ...
31
votes
1answer
15k 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 ...
30
votes
6answers
2k views

Shortcut to clear command line terminal [duplicate]

Is there a shortcut to clear the command line when typing in it instead of keeping backspace pressed for a few long seconds? I ask because I regularly use the Tab key to automatically fill in file ...
30
votes
5answers
33k views

How to list all variables names and their current values?

Including not only $HOME, $PWD etc but any other you have defined.
30
votes
7answers
22k views

How do I make my terminal display graphical pictures?

This is a quick mockup I copy and pasted together. I imagine this being super cool and useful. Does something like this exist already?
29
votes
4answers
8k views

Removing files with a certain extension except one file from terminal

I need to remove all files with .gif extension except one file with name say "filename.gif". What is the optimal way to go about doing this in terminal? The command rm *.gif removes all gif files ...
29
votes
6answers
61k 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 ...
29
votes
9answers
23k 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 ...
28
votes
4answers
8k views

How to see the command attached to a bash alias?

Suppose I have an alias in the bash shell. Is there a simple command to print out what command the alias will run?
28
votes
3answers
27k views

How to grep for tabs without using literal tabs and why does \t not work?

When I search for tabs in a file with (e)grep I use the litteral tab (^v + <tab>). I can not utilize \t as a replacement for tabs in regular expressions. With e.g. sed this expression works very ...
27
votes
3answers
4k views

Conveniently schedule a command to run later?

What's a simple way to run a command, say, 8 hours from now? I can think of this way: nohup bash -c "sleep 28800 ; ./mycommand.sh" & Is there a more "proper" way?
27
votes
4answers
8k 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?
26
votes
1answer
4k views

What's the difference between set, export and env and when should I use each?

Every so often I'll bash out a bash script and it strikes me there are a few ways of setting a variable: key=value env key=value export key=value When you're inside a script or a single command ...
25
votes
5answers
3k views

Removing folder named ~

This is the output of ls -l ls -l total 53484 drwxr-xr-x 3 root root 4096 2011-02-10 05:59 ~ -rw-r--r-- 1 root root 54313810 2011-02-13 05:09 jobs.jar -rw-r--r-- 1 root root 384035 2011-02-15 ...
25
votes
5answers
33k views

How do I get long command lines to wrap to the next line?

Something I have noticed in Ubuntu for a long time that has been frustrating to me is when I am typing a command at the command line that gets longer (wider) than the terminal width, instead of ...
25
votes
4answers
6k views

What is the purpose of the -9 option in the kill command?

Is there a difference between kill -9 212121 and kill 212121
25
votes
2answers
13k 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?
24
votes
9answers
79k 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 ...
24
votes
3answers
24k 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?
24
votes
3answers
77k 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 ...
23
votes
4answers
2k views

What is the meaning of $$1 in bash?

I am actually playing with arguments and its happened. I just thought like to see what will happen if I type $$1 and I did it and got something below. raja@raja-BONEFISH:~$ $$1 19301: command not ...
23
votes
3answers
4k views

Find directories that DON'T contain a file

Yes, I'm sorting out my music. I've got everything arranged beautifully in the following mantra: /Artist/Album/Track - Artist - Title.ext and if one exists, the cover sits in ...
23
votes
3answers
5k views

Bash auto-completion with added spaces – why, and how to fix?

I use tab completion more than typing letters. I used to type rm ~/De<TAB> and it would be completed to rm ~/Desktop/ so that I could continue on the next level. Recently, that behaviour ...
23
votes
2answers
7k 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 ...
22
votes
2answers
4k views

Bash: delete from cursor till end of line with a keyboard shortcut

Consider the following bash prompt, where ^ denotes the prompt location: # git commit -am "[bug 123456] Do this and that with the bug" ^ Suppose that I want to commit ...
22
votes
1answer
49k 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
22
votes
2answers
20k 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 ...
21
votes
3answers
966 views

Why `time` command doesn't work with any option?

I tried to use time command with -f option to format the output of time, but I get the following error: -f: command not found Then I tried to use other options -a, -o, etc and I get the same error. ...
21
votes
4answers
7k views

How to navigate long commands faster?

Is there a way speed up Linux CLI navigation when I must enter long commands? I simply use arrows right now, and - if I have a long command it takes some time to get from start of the command to the ...
21
votes
3answers
38k views

How do I find the version of bash I am running?

(learning bash) I was trying to check the bash version so I typed /bin/bash -v. That outputted a whole lot of text to the screen (contents of .bashrc, and other files sourced from it). Could I have ...
21
votes
7answers
33k 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 ...
20
votes
9answers
131k 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 ...
20
votes
4answers
3k views

Why does “A=10 echo $A” not print 10?

This command: A=10 echo $A prints an empty line. Why not 10? Why doesn't the in-place temporary environment setting work? I want to know the reason and explanation rather than solution. I used ...