Most Popular

1500 questions
253
votes
6 answers

How can I delete a word backward at the command line (bash and zsh)?

How can I delete a word backward at the command line? I'm truly used to some editors deleting the last 'word' using Ctrl+Backspace, and I'd like that functionality at the command line too. I am using Bash at the moment and although I could jump…
lucidquiet
  • 2,779
  • 2
  • 15
  • 8
253
votes
3 answers

Difference between 2>&-, 2>/dev/null, |&, &>/dev/null and >/dev/null 2>&1

Just looking for the difference between 2>&- 2>/dev/null |& &>/dev/null >/dev/null 2>&1 and their portability with non-Bourne shells like tcsh, mksh, etc.
Det
  • 2,652
  • 3
  • 13
  • 7
252
votes
4 answers

Why is FreeBSD deprecating GCC in favor of Clang/LLVM?

So I was surfing the net and stumbled upon this article. It basically states that FreeBSD, starting from Version 10 and above will deprecate GCC in favor of Clang/LLVM. From what I have seen around the net so far, Clang/LLVM is a fairly ambitious…
NlightNFotis
  • 7,525
  • 7
  • 32
  • 38
252
votes
12 answers

How can I calculate the size of a directory?

How to know the size of a directory? Including subdirectories and files.
Juanjo Conti
  • 2,683
  • 2
  • 15
  • 7
251
votes
12 answers

How do I make my pc speaker beep

Using bash, how can I make the pc speaker beep? Something like echo 'beepsound' > /dev/pcspkr would be nice.
Stefan
  • 24,830
  • 40
  • 98
  • 126
249
votes
6 answers

Can grep return true/false or are there alternative methods

As a part of this script, I need to be able to check if the first argument given matches the first word of file. If it does, exit with an error message; if it doesn't, append the arguments to the file. I understand how to write the if statement, but…
Lauren
  • 2,555
  • 2
  • 15
  • 9
249
votes
5 answers

What does env x='() { :;}; command' bash do and why is it insecure?

There is apparently a vulnerability (CVE-2014-6271) in bash: Bash specially crafted environment variables code injection attack I am trying to figure out what is happening, but I'm not entirely sure I understand it. How can the echo be executed as…
jippie
  • 13,756
  • 10
  • 44
  • 64
248
votes
12 answers

linux: How can I view all UUIDs for all available disks on my system?

My /etc/fstab contains this: # / was on /dev/sda1 during installation UUID=77d8da74-a690-481a-86d5-9beab5a8e842 / ext4 errors=remount-ro 0 1 There are several other disks on this system, and not all disks are being mounted to…
Stefan Lasiewski
  • 19,264
  • 24
  • 70
  • 85
248
votes
20 answers

How can I get distribution name and version number in a simple shell script?

I'm working on a simple bash script that should be able to run on Ubuntu and CentOS distributions (support for Debian and Fedora/RHEL would be a plus) and I need to know the name and version of the distribution the script is running (in order to…
Alix Axel
  • 2,879
  • 4
  • 17
  • 13
248
votes
2 answers

Unzipping a .gz file without removing the gzipped file

I have a file file.gz, when I try to unzip this file by using gunzip file.gz, it unzipped the file but only contains extracted and removes the file.gz file. How can I unzip by keeping both unzipped file and zipped file?
jack
  • 3,853
  • 11
  • 28
  • 33
246
votes
16 answers

Merging folders with mv?

If I use mv to move a folder called "folder" to a directory that already contains "folder" will they merge or will it be replaced?
Dominique
  • 5,155
  • 8
  • 26
  • 29
245
votes
14 answers

How to recursively find the amount stored in directory?

I know you are able to see the byte size of a file when you do a long listing with ll or ls -l. But I want to know how much storage is in a directory including the files within that directory and the subdirectories within there, etc. I don't want…
Rob Avery IV
  • 3,075
  • 3
  • 17
  • 14
245
votes
11 answers

Limit memory usage for a single Linux process

I'm running pdftoppm to convert a user-provided PDF into a 300DPI image. This works great, except if the user provides an PDF with a very large page size. pdftoppm will allocate enough memory to hold a 300DPI image of that size in memory, which…
Ben Dilts
  • 2,553
  • 3
  • 13
  • 5
245
votes
14 answers

Find the total size of certain files within a directory branch

Assume there's an image storage directory, say, ./photos/john_doe, within which there are multiple subdirectories, where many certain files reside (say, *.jpg). How can I calculate a summary size of those files below the john_doe branch? I tried du…
mbaitoff
  • 4,911
  • 8
  • 28
  • 32
245
votes
5 answers

What is the 'working directory' when cron executes a job?

I have a script that works when I run it from the command line, but when I schedule it with cron I get errors that it cannot find files or commands. My question is twofold: When I schedule a cron job using crontab -e, does it use my user ID as the…
ProfessionalAmateur
  • 3,115
  • 3
  • 18
  • 17