Variations of the Same Command Return Same/Similar Result Announcing the arrival of Valued...
When a candle burns, why does the top of wick glow if bottom of flame is hottest?
What does the "x" in "x86" represent?
Using audio cues to encourage good posture
How do pianists reach extremely loud dynamics?
What font is "z" in "z-score"?
How would a mousetrap for use in space work?
What is the meaning of the simile “quick as silk”?
Can you use the Shield Master feat to shove someone before you make an attack by using a Readied action?
Do jazz musicians improvise on the parent scale in addition to the chord-scales?
Is "Reachable Object" really an NP-complete problem?
How to compare two different files line by line in unix?
What causes the direction of lightning flashes?
Does classifying an integer as a discrete log require it be part of a multiplicative group?
What is the meaning of the new sigil in Game of Thrones Season 8 intro?
Do wooden building fires get hotter than 600°C?
How to deal with a team lead who never gives me credit?
How do I find out the mythology and history of my Fortress?
How to find all the available tools in mac terminal?
Circuit to "zoom in" on mV fluctuations of a DC signal?
Chinese Seal on silk painting - what does it mean?
Do I really need to have a message in a novel to appeal to readers?
Withdrew £2800, but only £2000 shows as withdrawn on online banking; what are my obligations?
What does this Jacques Hadamard quote mean?
How can I use the Python library networkx from Mathematica?
Variations of the Same Command Return Same/Similar Result
Announcing the arrival of Valued Associate #679: Cesar Manara
Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern)
2019 Community Moderator Election Results
Why I closed the “Why is Kali so hard” questionUNIX commands - findFind human-readable filesUNIX commands - findHow to send AT commands to a modem in Linux?Why does find -exec du sum up differently?Getting the size of parent folders when using find to search for criteria?Find human-readable filesFailing to expand disc space running Kali Linux on vmwarePass 'file' command results to find commandparted command line not get the same resultHow do I return the first matched result in each folder with find command in tcsh?How do commands like fdisk -l find the sector size?
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ margin-bottom:0;
}
I'm working on a public server, which offers games designed to help teach people Linux and ethical hacking skills. The goal of each level (so far) has been to find the ssh password to the following level w/ various commands suggested as possibly being useful in accomplishing this task. I'm currently working on a level, which listed the following as the goal:
The password for the next level is stored in a file somewhere under the
inhere directory and has all of the following properties:
human-readable
1033 bytes in size
not executable
The suggested commands are: ls, cd, cat, file, du, find
I read the man pages for each command, and I also searched online for help. I found two separate questions/answers on Unix & Linux StackExchange pertaining to this exact exercise. These can be found here and here. Both sets of commands output essentially the same information. For instance, from the first link, the accepted answer and output was:
bandit5@bandit:~/inhere$ find . -type f -size 1033c ! -executable -exec file {} + | grep ASCII
./maybehere07/.file2: ASCII text, with very long lines
I decided to play w/ this command a bit, so first, I removed grep from the command, then ran it again. I then removed the non-executable switch and the file command and ran it again.
bandit5@bandit:~/inhere$ find . -type f -size 1033c ! -executable -exec file {} +
./maybehere07/.file2: ASCII text, with very long lines
bandit5@bandit:~/inhere$ find . -type f -size 1033c
./maybehere07/.file2
As is plain to see, the shortest version of this command returns the exact information I was searching for. The second link above from Unix & Linux StackExchange is an even longer and more exacting command returning the same information as the shortest version of the command above.
I realize that I shouldn't be creating more work for myself, so the shortest command would probably be the best in this case. I also realize that this server is most likely designed in a way to not confuse issues. Therefore, my question is, is there a time when these longer commands might prove useful to retrieve output in a similar situation? Would these longer commands help to narrow down the sought after answer, while parsing out output that the shorter command might not? An example would be greatly appreciated. Thank you very much!
linux grep find
New contributor
add a comment |
I'm working on a public server, which offers games designed to help teach people Linux and ethical hacking skills. The goal of each level (so far) has been to find the ssh password to the following level w/ various commands suggested as possibly being useful in accomplishing this task. I'm currently working on a level, which listed the following as the goal:
The password for the next level is stored in a file somewhere under the
inhere directory and has all of the following properties:
human-readable
1033 bytes in size
not executable
The suggested commands are: ls, cd, cat, file, du, find
I read the man pages for each command, and I also searched online for help. I found two separate questions/answers on Unix & Linux StackExchange pertaining to this exact exercise. These can be found here and here. Both sets of commands output essentially the same information. For instance, from the first link, the accepted answer and output was:
bandit5@bandit:~/inhere$ find . -type f -size 1033c ! -executable -exec file {} + | grep ASCII
./maybehere07/.file2: ASCII text, with very long lines
I decided to play w/ this command a bit, so first, I removed grep from the command, then ran it again. I then removed the non-executable switch and the file command and ran it again.
bandit5@bandit:~/inhere$ find . -type f -size 1033c ! -executable -exec file {} +
./maybehere07/.file2: ASCII text, with very long lines
bandit5@bandit:~/inhere$ find . -type f -size 1033c
./maybehere07/.file2
As is plain to see, the shortest version of this command returns the exact information I was searching for. The second link above from Unix & Linux StackExchange is an even longer and more exacting command returning the same information as the shortest version of the command above.
I realize that I shouldn't be creating more work for myself, so the shortest command would probably be the best in this case. I also realize that this server is most likely designed in a way to not confuse issues. Therefore, my question is, is there a time when these longer commands might prove useful to retrieve output in a similar situation? Would these longer commands help to narrow down the sought after answer, while parsing out output that the shorter command might not? An example would be greatly appreciated. Thank you very much!
linux grep find
New contributor
add a comment |
I'm working on a public server, which offers games designed to help teach people Linux and ethical hacking skills. The goal of each level (so far) has been to find the ssh password to the following level w/ various commands suggested as possibly being useful in accomplishing this task. I'm currently working on a level, which listed the following as the goal:
The password for the next level is stored in a file somewhere under the
inhere directory and has all of the following properties:
human-readable
1033 bytes in size
not executable
The suggested commands are: ls, cd, cat, file, du, find
I read the man pages for each command, and I also searched online for help. I found two separate questions/answers on Unix & Linux StackExchange pertaining to this exact exercise. These can be found here and here. Both sets of commands output essentially the same information. For instance, from the first link, the accepted answer and output was:
bandit5@bandit:~/inhere$ find . -type f -size 1033c ! -executable -exec file {} + | grep ASCII
./maybehere07/.file2: ASCII text, with very long lines
I decided to play w/ this command a bit, so first, I removed grep from the command, then ran it again. I then removed the non-executable switch and the file command and ran it again.
bandit5@bandit:~/inhere$ find . -type f -size 1033c ! -executable -exec file {} +
./maybehere07/.file2: ASCII text, with very long lines
bandit5@bandit:~/inhere$ find . -type f -size 1033c
./maybehere07/.file2
As is plain to see, the shortest version of this command returns the exact information I was searching for. The second link above from Unix & Linux StackExchange is an even longer and more exacting command returning the same information as the shortest version of the command above.
I realize that I shouldn't be creating more work for myself, so the shortest command would probably be the best in this case. I also realize that this server is most likely designed in a way to not confuse issues. Therefore, my question is, is there a time when these longer commands might prove useful to retrieve output in a similar situation? Would these longer commands help to narrow down the sought after answer, while parsing out output that the shorter command might not? An example would be greatly appreciated. Thank you very much!
linux grep find
New contributor
I'm working on a public server, which offers games designed to help teach people Linux and ethical hacking skills. The goal of each level (so far) has been to find the ssh password to the following level w/ various commands suggested as possibly being useful in accomplishing this task. I'm currently working on a level, which listed the following as the goal:
The password for the next level is stored in a file somewhere under the
inhere directory and has all of the following properties:
human-readable
1033 bytes in size
not executable
The suggested commands are: ls, cd, cat, file, du, find
I read the man pages for each command, and I also searched online for help. I found two separate questions/answers on Unix & Linux StackExchange pertaining to this exact exercise. These can be found here and here. Both sets of commands output essentially the same information. For instance, from the first link, the accepted answer and output was:
bandit5@bandit:~/inhere$ find . -type f -size 1033c ! -executable -exec file {} + | grep ASCII
./maybehere07/.file2: ASCII text, with very long lines
I decided to play w/ this command a bit, so first, I removed grep from the command, then ran it again. I then removed the non-executable switch and the file command and ran it again.
bandit5@bandit:~/inhere$ find . -type f -size 1033c ! -executable -exec file {} +
./maybehere07/.file2: ASCII text, with very long lines
bandit5@bandit:~/inhere$ find . -type f -size 1033c
./maybehere07/.file2
As is plain to see, the shortest version of this command returns the exact information I was searching for. The second link above from Unix & Linux StackExchange is an even longer and more exacting command returning the same information as the shortest version of the command above.
I realize that I shouldn't be creating more work for myself, so the shortest command would probably be the best in this case. I also realize that this server is most likely designed in a way to not confuse issues. Therefore, my question is, is there a time when these longer commands might prove useful to retrieve output in a similar situation? Would these longer commands help to narrow down the sought after answer, while parsing out output that the shorter command might not? An example would be greatly appreciated. Thank you very much!
linux grep find
linux grep find
New contributor
New contributor
New contributor
asked 7 hours ago
jmg999jmg999
62
62
New contributor
New contributor
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
To answer your question (despite the downvote) yes this is just because the person who first wrote that command was trying to use all the information available to them. The question states that the file is human-readable
, 1033 bytes in size
, and not executable
. The original command was:
find . -type f -size 1033c ! -executable -exec file {} + | grep ASCII
So lets break this down into parts:
-type f
means you're looking for a file (as opposed to a directory).
-size 1033c
means you're looking for a file that is 1033 bytes.
! -executable
means you are looking for a file that is not executable.
-exec file {} +
means you want to execute the file command on each file found by find.
| grep ASCII
here you're piping the output of the previous command into grep to search for only lines containing ASCII.
I've created 3 files that are each 1033 bytes, file1
is binary data, file2
is the file you're looking for and file3
is a copy of file1
but is marked as executable. In this directory here's the output of your suggested commands:
jon@jon-HP-Pavilion-15-Notebook-PC:~/temp$ find . -type f -size 1033c ! -executable -exec file {} + | grep ASCII
./file2: ASCII text, with very long lines
jon@jon-HP-Pavilion-15-Notebook-PC:~/temp$ find . -type f -size 1033c ! -executable -exec file {} +
./file2: ASCII text, with very long lines
./file1: data
jon@jon-HP-Pavilion-15-Notebook-PC:~/temp$ find . -type f -size 1033c
./file2
./file1
./file3
As you can see with multiple files these commands behave very differently, the reason they seem the same in your test environment is because there is only one file that is 1033bytes (which to be fair is probably also the case in reality, but then again in reality you often don't know the exact size of a file).
New contributor
I'm not certain why you received a downvote. It wasn't from me. I found your answer to be quite helpful and spot on. It reinforced the idea that in certain instances, you might end up w/ similar filetypes, thus the need to use more tools at your disposal. As I mentioned in my OP, I think that in this instance, the environment was set up to teach the basics in a way so as not to create the need for more complex commands. After all, this was level five of 34, so it's still the early-going. Thanks very much for your answer!
– jmg999
3 hours ago
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "106"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
jmg999 is a new contributor. Be nice, and check out our Code of Conduct.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f513098%2fvariations-of-the-same-command-return-same-similar-result%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
To answer your question (despite the downvote) yes this is just because the person who first wrote that command was trying to use all the information available to them. The question states that the file is human-readable
, 1033 bytes in size
, and not executable
. The original command was:
find . -type f -size 1033c ! -executable -exec file {} + | grep ASCII
So lets break this down into parts:
-type f
means you're looking for a file (as opposed to a directory).
-size 1033c
means you're looking for a file that is 1033 bytes.
! -executable
means you are looking for a file that is not executable.
-exec file {} +
means you want to execute the file command on each file found by find.
| grep ASCII
here you're piping the output of the previous command into grep to search for only lines containing ASCII.
I've created 3 files that are each 1033 bytes, file1
is binary data, file2
is the file you're looking for and file3
is a copy of file1
but is marked as executable. In this directory here's the output of your suggested commands:
jon@jon-HP-Pavilion-15-Notebook-PC:~/temp$ find . -type f -size 1033c ! -executable -exec file {} + | grep ASCII
./file2: ASCII text, with very long lines
jon@jon-HP-Pavilion-15-Notebook-PC:~/temp$ find . -type f -size 1033c ! -executable -exec file {} +
./file2: ASCII text, with very long lines
./file1: data
jon@jon-HP-Pavilion-15-Notebook-PC:~/temp$ find . -type f -size 1033c
./file2
./file1
./file3
As you can see with multiple files these commands behave very differently, the reason they seem the same in your test environment is because there is only one file that is 1033bytes (which to be fair is probably also the case in reality, but then again in reality you often don't know the exact size of a file).
New contributor
I'm not certain why you received a downvote. It wasn't from me. I found your answer to be quite helpful and spot on. It reinforced the idea that in certain instances, you might end up w/ similar filetypes, thus the need to use more tools at your disposal. As I mentioned in my OP, I think that in this instance, the environment was set up to teach the basics in a way so as not to create the need for more complex commands. After all, this was level five of 34, so it's still the early-going. Thanks very much for your answer!
– jmg999
3 hours ago
add a comment |
To answer your question (despite the downvote) yes this is just because the person who first wrote that command was trying to use all the information available to them. The question states that the file is human-readable
, 1033 bytes in size
, and not executable
. The original command was:
find . -type f -size 1033c ! -executable -exec file {} + | grep ASCII
So lets break this down into parts:
-type f
means you're looking for a file (as opposed to a directory).
-size 1033c
means you're looking for a file that is 1033 bytes.
! -executable
means you are looking for a file that is not executable.
-exec file {} +
means you want to execute the file command on each file found by find.
| grep ASCII
here you're piping the output of the previous command into grep to search for only lines containing ASCII.
I've created 3 files that are each 1033 bytes, file1
is binary data, file2
is the file you're looking for and file3
is a copy of file1
but is marked as executable. In this directory here's the output of your suggested commands:
jon@jon-HP-Pavilion-15-Notebook-PC:~/temp$ find . -type f -size 1033c ! -executable -exec file {} + | grep ASCII
./file2: ASCII text, with very long lines
jon@jon-HP-Pavilion-15-Notebook-PC:~/temp$ find . -type f -size 1033c ! -executable -exec file {} +
./file2: ASCII text, with very long lines
./file1: data
jon@jon-HP-Pavilion-15-Notebook-PC:~/temp$ find . -type f -size 1033c
./file2
./file1
./file3
As you can see with multiple files these commands behave very differently, the reason they seem the same in your test environment is because there is only one file that is 1033bytes (which to be fair is probably also the case in reality, but then again in reality you often don't know the exact size of a file).
New contributor
I'm not certain why you received a downvote. It wasn't from me. I found your answer to be quite helpful and spot on. It reinforced the idea that in certain instances, you might end up w/ similar filetypes, thus the need to use more tools at your disposal. As I mentioned in my OP, I think that in this instance, the environment was set up to teach the basics in a way so as not to create the need for more complex commands. After all, this was level five of 34, so it's still the early-going. Thanks very much for your answer!
– jmg999
3 hours ago
add a comment |
To answer your question (despite the downvote) yes this is just because the person who first wrote that command was trying to use all the information available to them. The question states that the file is human-readable
, 1033 bytes in size
, and not executable
. The original command was:
find . -type f -size 1033c ! -executable -exec file {} + | grep ASCII
So lets break this down into parts:
-type f
means you're looking for a file (as opposed to a directory).
-size 1033c
means you're looking for a file that is 1033 bytes.
! -executable
means you are looking for a file that is not executable.
-exec file {} +
means you want to execute the file command on each file found by find.
| grep ASCII
here you're piping the output of the previous command into grep to search for only lines containing ASCII.
I've created 3 files that are each 1033 bytes, file1
is binary data, file2
is the file you're looking for and file3
is a copy of file1
but is marked as executable. In this directory here's the output of your suggested commands:
jon@jon-HP-Pavilion-15-Notebook-PC:~/temp$ find . -type f -size 1033c ! -executable -exec file {} + | grep ASCII
./file2: ASCII text, with very long lines
jon@jon-HP-Pavilion-15-Notebook-PC:~/temp$ find . -type f -size 1033c ! -executable -exec file {} +
./file2: ASCII text, with very long lines
./file1: data
jon@jon-HP-Pavilion-15-Notebook-PC:~/temp$ find . -type f -size 1033c
./file2
./file1
./file3
As you can see with multiple files these commands behave very differently, the reason they seem the same in your test environment is because there is only one file that is 1033bytes (which to be fair is probably also the case in reality, but then again in reality you often don't know the exact size of a file).
New contributor
To answer your question (despite the downvote) yes this is just because the person who first wrote that command was trying to use all the information available to them. The question states that the file is human-readable
, 1033 bytes in size
, and not executable
. The original command was:
find . -type f -size 1033c ! -executable -exec file {} + | grep ASCII
So lets break this down into parts:
-type f
means you're looking for a file (as opposed to a directory).
-size 1033c
means you're looking for a file that is 1033 bytes.
! -executable
means you are looking for a file that is not executable.
-exec file {} +
means you want to execute the file command on each file found by find.
| grep ASCII
here you're piping the output of the previous command into grep to search for only lines containing ASCII.
I've created 3 files that are each 1033 bytes, file1
is binary data, file2
is the file you're looking for and file3
is a copy of file1
but is marked as executable. In this directory here's the output of your suggested commands:
jon@jon-HP-Pavilion-15-Notebook-PC:~/temp$ find . -type f -size 1033c ! -executable -exec file {} + | grep ASCII
./file2: ASCII text, with very long lines
jon@jon-HP-Pavilion-15-Notebook-PC:~/temp$ find . -type f -size 1033c ! -executable -exec file {} +
./file2: ASCII text, with very long lines
./file1: data
jon@jon-HP-Pavilion-15-Notebook-PC:~/temp$ find . -type f -size 1033c
./file2
./file1
./file3
As you can see with multiple files these commands behave very differently, the reason they seem the same in your test environment is because there is only one file that is 1033bytes (which to be fair is probably also the case in reality, but then again in reality you often don't know the exact size of a file).
New contributor
New contributor
answered 7 hours ago
Dude Random21Dude Random21
1
1
New contributor
New contributor
I'm not certain why you received a downvote. It wasn't from me. I found your answer to be quite helpful and spot on. It reinforced the idea that in certain instances, you might end up w/ similar filetypes, thus the need to use more tools at your disposal. As I mentioned in my OP, I think that in this instance, the environment was set up to teach the basics in a way so as not to create the need for more complex commands. After all, this was level five of 34, so it's still the early-going. Thanks very much for your answer!
– jmg999
3 hours ago
add a comment |
I'm not certain why you received a downvote. It wasn't from me. I found your answer to be quite helpful and spot on. It reinforced the idea that in certain instances, you might end up w/ similar filetypes, thus the need to use more tools at your disposal. As I mentioned in my OP, I think that in this instance, the environment was set up to teach the basics in a way so as not to create the need for more complex commands. After all, this was level five of 34, so it's still the early-going. Thanks very much for your answer!
– jmg999
3 hours ago
I'm not certain why you received a downvote. It wasn't from me. I found your answer to be quite helpful and spot on. It reinforced the idea that in certain instances, you might end up w/ similar filetypes, thus the need to use more tools at your disposal. As I mentioned in my OP, I think that in this instance, the environment was set up to teach the basics in a way so as not to create the need for more complex commands. After all, this was level five of 34, so it's still the early-going. Thanks very much for your answer!
– jmg999
3 hours ago
I'm not certain why you received a downvote. It wasn't from me. I found your answer to be quite helpful and spot on. It reinforced the idea that in certain instances, you might end up w/ similar filetypes, thus the need to use more tools at your disposal. As I mentioned in my OP, I think that in this instance, the environment was set up to teach the basics in a way so as not to create the need for more complex commands. After all, this was level five of 34, so it's still the early-going. Thanks very much for your answer!
– jmg999
3 hours ago
add a comment |
jmg999 is a new contributor. Be nice, and check out our Code of Conduct.
jmg999 is a new contributor. Be nice, and check out our Code of Conduct.
jmg999 is a new contributor. Be nice, and check out our Code of Conduct.
jmg999 is a new contributor. Be nice, and check out our Code of Conduct.
Thanks for contributing an answer to Unix & Linux Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f513098%2fvariations-of-the-same-command-return-same-similar-result%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown