Most Popular

1500 questions
276
votes
5 answers

How to suspend and bring a background process to foreground

I have a process originally running in the foreground. I suspended by Ctrl+Z, and then resume its running in the background by bg . I wonder how to suspend a process running in the background? How can I bring a background process to…
Tim
  • 101,790
275
votes
19 answers

How can I grep in PDF files?

Is there a way to search PDF files using grep, without converting to text first in Ubuntu?
Dervin Thunk
  • 3,529
274
votes
3 answers

Get file created/creation time?

Possible Duplicate: How do I do a ls and then sort the results by date created? Is there a command in Linux which displays when the file was created ? I see that ls -l gives the last modified time, but can I get the created time/date?
linuxAddict
274
votes
4 answers

Security implications of forgetting to quote a variable in bash/POSIX shells

If you've been following unix.stackexchange.com for a while, you should hopefully know by now that leaving a variable unquoted in list context (as in echo $var) in Bourne/POSIX shells (zsh being the exception) has a very special meaning…
273
votes
3 answers

What is the purpose of .bashrc and how does it work?

I found the .bashrc file and I want to know the purpose/function of it. Also how and when is it used?
Pandya
  • 24,618
272
votes
12 answers

The "proper" way to test if a service is running in a script

My problem: I'm writing a bash script and in it I'd like to check if a given service is running. I know how to do this manually, with $ service [service_name] status. But (especially since the move to systemd) that prints a whole bunch of text…
Nick S
  • 2,865
272
votes
3 answers

Open `less` scrolled to the end

Is there a way to open less and have it scroll to the end of the file? I'm always doing less app.log and then pressing G to go to the bottom. I'm hoping there's something like less --end or less -exec 'G'.
Miles
  • 6,927
272
votes
15 answers

Passing named arguments to shell scripts

Is there any easy way to pass (receive) named parameters to a shell script? For example, my_script -p_out '/some/path' -arg_1 '5' And inside my_script.sh receive them as: # I believe this notation does not work, but is there anything close to…
271
votes
6 answers

What do the flags in /proc/cpuinfo mean?

How can I tell whether my processor has a particular feature? (64-bit instruction set, hardware-assisted virtualization, cryptographic accelerators, etc.) I know that the file /proc/cpuinfo contains this information, in the flags line, but what do…
271
votes
9 answers

Where did the "wheel" group get its name?

The wheel group on *nix computers typically refers to the group with some sort of root-like access. I've heard that on some *nixes it's the group of users with the right to run su, but on Linux that seems to be anyone (although you need the root…
Michael Mrozek
  • 93,103
  • 40
  • 240
  • 233
270
votes
13 answers

Delete the last character of a string using string manipulation in shell script

I would like to delete the last character of a string, I tried this little script : #! /bin/sh t="lkj" t=${t:-2} echo $t but it prints "lkj", what I am doing wrong?
user3581976
  • 3,155
267
votes
5 answers

How to enable diffie-hellman-group1-sha1 key exchange on Debian 8.0?

I am unable to ssh to a server that asks for a diffie-hellman-group1-sha1 key exchange method: ssh 123.123.123.123 Unable to negotiate with 123.123.123.123 port 22: no matching key exchange method found. Their offer: diffie-hellman-group1-sha1 How…
267
votes
10 answers

Why *not* parse `ls` (and what to do instead)?

I consistently see answers quoting this link stating definitively "Don't parse ls!" This bothers me for a couple of reasons: It seems the information in that link has been accepted wholesale with little question, though I can pick out at least a…
mikeserv
  • 58,310
267
votes
10 answers

Parallelize a Bash FOR Loop

I have been trying to parallelize the following script, specifically each of the three FOR loop instances, using GNU Parallel but haven't been able to. The 4 commands contained within the FOR loop run in series, each loop taking around 10 minutes.…
266
votes
9 answers

Can I create a user-specific hosts file to complement /etc/hosts?

Is it possible to add a list of hosts that are only specific to a certain user? Perhaps a user-specific hosts file? This mechanism should also complement the entries in the /etc/hosts file.
redspike
  • 2,763