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
20
votes
3 answers

Bash prompt on Ubuntu - FQDN (\H) same as hostname (\h)

We've got seperate environments at my workplace for development, testing, integration, and staging. Within those envs, we've overloaded the hostnames in DNS - e.g. in the dev environment, the primary web machine is called web1.dev.example.com, and…
Ben Williams
  • 787
  • 1
  • 8
  • 17
20
votes
9 answers

script to automatically test if a web site is available

I'm a lone web developer with my own Centos VPS hosting a few small web sites for my clients. Today I discovered my httpd service had stopped (for no apparent reason - but that's another thread). I restarted it but now I need to find a way that I…
Xoundboy
  • 603
  • 1
  • 10
  • 21
20
votes
4 answers

How can I use sudo to check if a file exists?

I want to check if a file exists like so [ -f /path/to/file/ ] However I am running this command as a regular user and the file is owned by root. How can I use sudo to accomplish this. sudo [ -f /path/to/file/ ] does not work.
ckliborn
  • 2,778
  • 4
  • 25
  • 37
20
votes
5 answers

What could make `>` silently fail in Linux?

I ran this command: python ./manage.py dumpdata partyapp.InvitationTemplate > partyapp_dump.json To dump data into the partyapp_dump.json file. But all the data just gets printed on the screen and an empty partyapp_dump.json file is created. Why…
Ram Rachum
  • 5,231
  • 7
  • 34
  • 46
20
votes
3 answers

How do I reclaim a disown'd process?

Similar to many previous questions, I found myself running a job that I wish I had run in screen. I was forced to disown the process because I needed to disconnect. Now that I have reconnected, I see that the process is still running. How can I…
Sparr
  • 770
  • 1
  • 5
  • 14
20
votes
7 answers

Kill all processes that are running for more than 5 minutes by a given user in linux bash script

I need the command to kill processes that have been running since at least 5 minutes for a given process. I will have to run that command every five minutes or so. Thanks a million ! (system is Centos5)
Pierre
20
votes
2 answers

Implementing dry-run in bash scripts

How would one implement a dry-run option in a bash script? I can think of either wrapping every single command in an if and echoing out the command instead of running it if the script is running with dry-run. Another way would be to define a…
Andrei Serdeliuc
  • 905
  • 5
  • 14
  • 26
20
votes
2 answers

Display \n characters as newlines when using tail?

I have a file that I am trying to read by using tail -f. I was wondering if there was a way to have the terminal output an actual line break instead of the \n character.
GSto
  • 391
  • 1
  • 3
  • 8
19
votes
3 answers

Linux gzip multiple subdirectories into separate archives?

How would I be able to compress subdirectories into separate archives? Example: directory subdir1 subdir2 Should create subdir1(.tar).gz and subdir2(.tar).gz
aardbol
  • 1,473
  • 4
  • 17
  • 26
19
votes
2 answers

Compress command output by piping to bzip2

Is it possible to pipe a command output to bzip2 for compression to an output file? Something along the lines of: cat somefile.txt | bzip2 --output somefile.txt.bz2
Dom
  • 458
  • 1
  • 5
  • 15
19
votes
5 answers

chsh: PAM authentication failed

i want to change default shell env and run chsh -s /bin/zsh as root user, but a error message appeared: chsh: PAM authentication failed. i find this thread http://ubuntuforums.org/showthread.php?t=1702833 but the answer did not solve my problem any…
txworking
  • 479
  • 2
  • 6
  • 15
19
votes
2 answers

Is there a utility like cron, that schedules a job for later (but only once)?

I'm trying to design a program that sends a text when a certain (non-periodic) event occurs. Right now, I'd like a script that finds when this event occurs, and then schedules a (cron-like) job that will send a text just before that even occurs. A…
user1209326
  • 301
  • 1
  • 4
19
votes
2 answers

What is the difference between sudo -i and sudo su -

What is the difference between commands sudo -i and sudo su -? Are they the same?
Howard
  • 2,135
  • 13
  • 48
  • 72
19
votes
3 answers

Using rsync to only delete extraneous files

What's the best way of comparing two directory structures and deleting extraneous files and directories in the target location? I have a small web photo gallery app that I'm developing. Users add & remove images using FTP. The web gallery software…
Bryan
  • 7,628
  • 15
  • 69
  • 94
19
votes
5 answers

Using bash, how can i find out the average, max and min from a list of numbers?

I have a series piped greps, awks and seds which produce a list of numbers, one on each line. Something like this: 1.13 3.59 1.23 How can i pipe this to something which will output the average, max, and min?
JavaRocky
  • 481
  • 2
  • 4
  • 15