Most Popular

1500 questions
86
votes
3 answers

What does an idle CPU process do?

Looking at the source of strace I found the use of the clone flag CLONE_IDLETASK which is described there as: #define CLONE_IDLETASK 0x00001000 /* kernel-only flag */ After looking deeper into it I found that, although that flag is not covered in…
grochmal
  • 8,657
86
votes
7 answers

How are the GPG usage flags defined in the key details listing?

When I list the details of a key I get output like this: $ gpg --edit-key SOMEID pub [..] created: [..] expires: [..] usage:SC [..] sub [..] created: [..] expires: [..] usage: E Or even usage: SCA on another key (the master-key part). What does…
maxschlepzig
  • 57,532
86
votes
3 answers

What is the 6th character of the password hash on Linux, and why is it often a slash?

On Linux, what is the sixth character of the password hash stored in /etc/shadow? On my puppy style linux box, if I try to generate 100 random passwords using shuf and /dev/urandom, then the sixth character is / about half the time. My question is…
insecure
  • 761
86
votes
9 answers

Does compression option -z with rsync speed up backup

In rsync, --compress or -z will compress file data during the transfer. If I understand correctly, it compresses files before transfer and then decompress them after transfer. Does the time reduced during transfer due to compression outweight the…
Tim
  • 101,790
86
votes
8 answers

get first X characters from the cat command?

I have a text file I'm outputting to a variable in my shell script. I only need the first 50 characters however. I've tried using cat ${filename} cut -c1-50 but I'm getting far more than the first 50 characters? That may be due to cut looking for…
jkj2000
  • 1,149
86
votes
7 answers

Determining if a file is a hard link or symbolic link?

I'm creating a shell script that would take a filename/path to a file and determine if the file is a symbolic link or a hard link. The only thing is, I don't know how to see if they are a hard link. I created 2 files, one a hard link and one a…
k-Rocker
  • 1,415
86
votes
3 answers

Why is my find not recursive?

I am running the following command, but it is not performed recursively: find . -name *.java I know there are java files further down in the current directory but it is performing the find on the current directory only. I am using OS X, 10.9.
user11498
  • 2,441
86
votes
4 answers

How can I get the tac command on OS X?

I like to use tac to reverse the output of cat. However, it's not available in the Mavericks terminal. I tried to find it on MacPorts and again it's not available. Can anyone please show me how to get tac? It's very helpful for reading log files.
polarise
  • 1,051
86
votes
3 answers

Why I can't escape spaces on a bash script?

I'm trying to escape the space char for a path in Bash, but neither using a backslash or quotes works. .sh script: ROOT="/home/hogar/Documents/files/" FILE=${ROOT}"bdd.encrypted" DESTINATION="/home/hogar/Ubuntu\ One/folder" mv ${FILE}…
Lucio
  • 1,307
85
votes
4 answers

How to pass a string to a command that expects a file?

Suppose a program cook takes one argument: the pathname of a text file containing the recipe of the food to cook. Suppose I wish to call this program from within a bash script, also suppose I already have the recipe in a string…
Flux
  • 2,938
85
votes
1 answer

Which Fedora package does a specific file belong to?

In the Debian family of OSes, dpkg --search /bin/ls gives: coreutils: /bin/ls That is, the file /bin/ls belongs to the Debian package named coreutils. (see this post if you are interested in a package containing a file that isn't installed) What is…
tshepang
  • 65,642
85
votes
1 answer

vi - How go to line N?

In vi editor how do I go to a particular line? For example if I open a file named file.py is there an option for open the file at a particular line, or can I open my file and then go to line with keyboard shortcut?
85
votes
9 answers

Can a script be executable but not readable?

Is it possible to execute a script if there is no permission to read it? In root mode, I made a script and I want the other user to execute this script but not read it. I did chmod to forbid read and write but allow execute, however in user mode, I…
ashim
  • 1,017
85
votes
4 answers

What is the purpose of -e in sed command?

I can't find any documentation about the sed -e switch, for simple replace, do I need it? e.g. sed 's/foo/bar/' VS sed -e 's/foo/bar/'
Howard
  • 997
85
votes
1 answer

What is the purpose of the "do" keyword in Bash for loops?

What is the purpose of the do keyword in Bash for loop syntax? To me, it feels redundant. for i in `seq 1 2`; do echo "hi"; done Why isn't the syntax like this? for i in `seq 1 2`; echo "hi"; done I'm sure that it does fill a purpose. I just want…