Questions tagged [bash]

Bash is the Bourne Again SHell, the successor to the classic Unix sh (shell).

bash is the Bourne Again SHell, the successor to the classic Unix Bourne shell (sh). It's the default shell on many Linux distributions, including RedHat, CentOS, Debian, and Ubuntu.

The premier online guide is the BashGuide.

3527 questions
27
votes
3 answers

How to make system wide alias for "ls -l"?

I would like to have alias ll="ls -l" to be system wide. How is that done on Ubuntu?
Sandra
  • 10,303
  • 38
  • 112
  • 165
27
votes
2 answers

Can I call pushd/popd and prevent it printing the stack?

After calling pushd/popd in bash, it will print off the current directory stack. Is there any way to prevent this behaviour, so that it will act 'quitely'? This sort of noise in a command is uncommon in unix tools.
Amandasaurus
  • 31,471
  • 65
  • 192
  • 253
26
votes
1 answer

Where is $BASH_ENV usually set?

I have twin Linux servers that should be configured identically, however ssh commands to one of them are failing for commands that require a path that's specified in ~/.bashrc. For example, I can use a command like pwd both interactively and through…
Basil
  • 8,851
  • 3
  • 38
  • 73
26
votes
4 answers

Linux Bash Syntax: Meaning of &&, \, and -

What do the '&&', '\' and '-' mean at the end of bash commands? In particular, I came across the following combination of lines that are supposed to add public keys to Ubuntu's aptitude package manager, what are those characters used here for? …
Alex
  • 2,357
  • 5
  • 32
  • 41
26
votes
5 answers

Send bash -x output to logfile without interrupting standard output

Is there a way to send the information displayed by running a bash script with the -x option to a file, while not changing the standard output seen by a user running the script? This is a debugging feature I would like to implement in a bash script…
26
votes
6 answers

From a shell script, how can I check whether a MySQL database exists?

mysqladmin -uroot create foo returns an exit status of 1 if foo exists, and 0 otherwise, but of course it will also create the database if it doesn't already exist. Is there some easy way to simply check whether a database exists?
ithinkihaveacat
  • 1,624
  • 3
  • 14
  • 18
25
votes
3 answers

Start Unix screen, Run command, Detach

How can screen be used to start a new session and run a command within that session without killing that session? screen -S myScreenName runSomething I tried the above command and it says [screen is terminating] Did it run the command then kill…
Nyxynyx
  • 1,459
  • 11
  • 39
  • 49
25
votes
9 answers

Running ssh-agent from a shell script

I'm trying to create a shell script that, among other things, starts up ssh-agent and adds a private key to the agent. Example: #!/bin/bash # ... ssh-agent $SHELL ssh-add /path/to/key # ... The problem with this is ssh-agent apparently kicks off…
Dan
  • 657
  • 2
  • 9
  • 13
25
votes
4 answers

How can I retrieve the absolute filename in a shell script on Mac OS X?

I'd like to retrieve the absolute file name of the script file that's currently executed. Links should be resolved, too. On Linux, this seems to be done like this: $(readlink -mn "$0") but readlink seems to work very differently on Mac OS X. I've…
Huxi
  • 361
  • 1
  • 4
  • 6
25
votes
4 answers

Do background processes get a SIGHUP when logging off?

This is a followup to this question. I've run some more tests; looks like it really doesn't matter if this is done at the physical console or via SSH, neither does this happen only with SCP; I also tested it with cat /dev/zero > /dev/null. The…
Massimo
  • 70,200
  • 57
  • 200
  • 323
24
votes
2 answers

Making ssh truly quiet

I'm half way through writing a nagios script and I've hit an annoyance with SSH. According to the man page: -q Quiet mode. Causes all warning and diagnostic messages to be suppressed. Yet if I enable the quiet flag and then pass an…
SimonJGreen
  • 3,205
  • 5
  • 33
  • 55
23
votes
2 answers

Will Ansible prevent the execution of 'rm -rf /' in a shell script

This is based upon this hoax question here. The problem described is having a bash script which contains something to the effect of: rm -rf {pattern1}/{pattern2} ...which if both patterns include one or more empty elements will expand to at least…
aroth
  • 393
  • 3
  • 9
23
votes
6 answers

How to run script via SSH that doesn't end when I close connection?

I need to run script, that takes long time to execute, or I just want it to run forever. I can't just SSH to my machine, because when I disconnect it stops running. Is there any way to run script that isn't dependent on the shell that started…
Jakub Arnold
  • 1,744
  • 10
  • 26
  • 33
23
votes
5 answers

How to keep: daily backups for a week, weekly for a month, monthly for a year, and yearly after that

I need to backup data and config files on this server, daily. I need to keep: daily backups for a week weekly backups for a month monthly backups for a year yearly backups after that All of this accomplished via a shell script run daily from…
Florin Andrei
  • 1,208
  • 1
  • 12
  • 18
23
votes
5 answers

ulimit -n not changing - values limits.conf has no effect

I am trying to raise the open file descriptor maximum for all users on an ubuntu machine. This question is somewhat of a follow up to this question. open file descriptor limits.conf setting isn't read by ulimit even when pam_limits.so is…
Abbas Gadhia
  • 343
  • 1
  • 3
  • 10