List files not owned by root at the / directory












-3















The actual homework question is




  1. List all files/directories NOT owned by root and not created in July.


I can't find a way to use




ls




and




grep




to output a file ~/NotOwnedByRoot.txt



find / ! -user root -d -maxdepth 1 -exec ls > ~/NotOwnedByRoot.txt  {} +


I also tried



find / ! -user root -type d -maxdepth 1 > ~/NotOwnedByRoot.txt


I get the error




find: warning: you have specified the -maxdepth option after a
non-option argument !, but options are not positional (-maxdepth
affects tests specified before it as well as those specified after
it). Please specify options before other arguments.











share|improve this question

























  • does "-d" want to be "-type d"? and by "list users not owned by root" did you mean "list directories not owned by root"? (guessing at the typo-corrections)

    – Jeff Schaller
    Mar 6 at 16:51











  • $ find / ! -user root -type d -maxdepth 1 > ~/NotOwnedByRoot.txt find: warning: you have specified the -maxdepth option after a non-option argument !, but options are not positional (-maxdepth affects tests specified before it as well as those specified after it). Please specify options before other arguments.

    – software is fun
    Mar 6 at 17:05











  • Your title does not make sense, and does not match the 2nd line of you question. Read up on what a user, file, directory and a process is.

    – ctrl-alt-delor
    Mar 6 at 17:36











  • The error is a warning, but do what it says anyway. It will help you understand the command.

    – ctrl-alt-delor
    Mar 6 at 17:38











  • Which July? any July, or just this past one?

    – Jeff Schaller
    Mar 6 at 17:39
















-3















The actual homework question is




  1. List all files/directories NOT owned by root and not created in July.


I can't find a way to use




ls




and




grep




to output a file ~/NotOwnedByRoot.txt



find / ! -user root -d -maxdepth 1 -exec ls > ~/NotOwnedByRoot.txt  {} +


I also tried



find / ! -user root -type d -maxdepth 1 > ~/NotOwnedByRoot.txt


I get the error




find: warning: you have specified the -maxdepth option after a
non-option argument !, but options are not positional (-maxdepth
affects tests specified before it as well as those specified after
it). Please specify options before other arguments.











share|improve this question

























  • does "-d" want to be "-type d"? and by "list users not owned by root" did you mean "list directories not owned by root"? (guessing at the typo-corrections)

    – Jeff Schaller
    Mar 6 at 16:51











  • $ find / ! -user root -type d -maxdepth 1 > ~/NotOwnedByRoot.txt find: warning: you have specified the -maxdepth option after a non-option argument !, but options are not positional (-maxdepth affects tests specified before it as well as those specified after it). Please specify options before other arguments.

    – software is fun
    Mar 6 at 17:05











  • Your title does not make sense, and does not match the 2nd line of you question. Read up on what a user, file, directory and a process is.

    – ctrl-alt-delor
    Mar 6 at 17:36











  • The error is a warning, but do what it says anyway. It will help you understand the command.

    – ctrl-alt-delor
    Mar 6 at 17:38











  • Which July? any July, or just this past one?

    – Jeff Schaller
    Mar 6 at 17:39














-3












-3








-3








The actual homework question is




  1. List all files/directories NOT owned by root and not created in July.


I can't find a way to use




ls




and




grep




to output a file ~/NotOwnedByRoot.txt



find / ! -user root -d -maxdepth 1 -exec ls > ~/NotOwnedByRoot.txt  {} +


I also tried



find / ! -user root -type d -maxdepth 1 > ~/NotOwnedByRoot.txt


I get the error




find: warning: you have specified the -maxdepth option after a
non-option argument !, but options are not positional (-maxdepth
affects tests specified before it as well as those specified after
it). Please specify options before other arguments.











share|improve this question
















The actual homework question is




  1. List all files/directories NOT owned by root and not created in July.


I can't find a way to use




ls




and




grep




to output a file ~/NotOwnedByRoot.txt



find / ! -user root -d -maxdepth 1 -exec ls > ~/NotOwnedByRoot.txt  {} +


I also tried



find / ! -user root -type d -maxdepth 1 > ~/NotOwnedByRoot.txt


I get the error




find: warning: you have specified the -maxdepth option after a
non-option argument !, but options are not positional (-maxdepth
affects tests specified before it as well as those specified after
it). Please specify options before other arguments.








linux grep find ls






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 6 at 18:20









roaima

45.9k758124




45.9k758124










asked Mar 6 at 16:47









software is funsoftware is fun

952




952













  • does "-d" want to be "-type d"? and by "list users not owned by root" did you mean "list directories not owned by root"? (guessing at the typo-corrections)

    – Jeff Schaller
    Mar 6 at 16:51











  • $ find / ! -user root -type d -maxdepth 1 > ~/NotOwnedByRoot.txt find: warning: you have specified the -maxdepth option after a non-option argument !, but options are not positional (-maxdepth affects tests specified before it as well as those specified after it). Please specify options before other arguments.

    – software is fun
    Mar 6 at 17:05











  • Your title does not make sense, and does not match the 2nd line of you question. Read up on what a user, file, directory and a process is.

    – ctrl-alt-delor
    Mar 6 at 17:36











  • The error is a warning, but do what it says anyway. It will help you understand the command.

    – ctrl-alt-delor
    Mar 6 at 17:38











  • Which July? any July, or just this past one?

    – Jeff Schaller
    Mar 6 at 17:39



















  • does "-d" want to be "-type d"? and by "list users not owned by root" did you mean "list directories not owned by root"? (guessing at the typo-corrections)

    – Jeff Schaller
    Mar 6 at 16:51











  • $ find / ! -user root -type d -maxdepth 1 > ~/NotOwnedByRoot.txt find: warning: you have specified the -maxdepth option after a non-option argument !, but options are not positional (-maxdepth affects tests specified before it as well as those specified after it). Please specify options before other arguments.

    – software is fun
    Mar 6 at 17:05











  • Your title does not make sense, and does not match the 2nd line of you question. Read up on what a user, file, directory and a process is.

    – ctrl-alt-delor
    Mar 6 at 17:36











  • The error is a warning, but do what it says anyway. It will help you understand the command.

    – ctrl-alt-delor
    Mar 6 at 17:38











  • Which July? any July, or just this past one?

    – Jeff Schaller
    Mar 6 at 17:39

















does "-d" want to be "-type d"? and by "list users not owned by root" did you mean "list directories not owned by root"? (guessing at the typo-corrections)

– Jeff Schaller
Mar 6 at 16:51





does "-d" want to be "-type d"? and by "list users not owned by root" did you mean "list directories not owned by root"? (guessing at the typo-corrections)

– Jeff Schaller
Mar 6 at 16:51













$ find / ! -user root -type d -maxdepth 1 > ~/NotOwnedByRoot.txt find: warning: you have specified the -maxdepth option after a non-option argument !, but options are not positional (-maxdepth affects tests specified before it as well as those specified after it). Please specify options before other arguments.

– software is fun
Mar 6 at 17:05





$ find / ! -user root -type d -maxdepth 1 > ~/NotOwnedByRoot.txt find: warning: you have specified the -maxdepth option after a non-option argument !, but options are not positional (-maxdepth affects tests specified before it as well as those specified after it). Please specify options before other arguments.

– software is fun
Mar 6 at 17:05













Your title does not make sense, and does not match the 2nd line of you question. Read up on what a user, file, directory and a process is.

– ctrl-alt-delor
Mar 6 at 17:36





Your title does not make sense, and does not match the 2nd line of you question. Read up on what a user, file, directory and a process is.

– ctrl-alt-delor
Mar 6 at 17:36













The error is a warning, but do what it says anyway. It will help you understand the command.

– ctrl-alt-delor
Mar 6 at 17:38





The error is a warning, but do what it says anyway. It will help you understand the command.

– ctrl-alt-delor
Mar 6 at 17:38













Which July? any July, or just this past one?

– Jeff Schaller
Mar 6 at 17:39





Which July? any July, or just this past one?

– Jeff Schaller
Mar 6 at 17:39










1 Answer
1






active

oldest

votes


















-2














you can use ls and grep together its very easy and with the -v in grep option you can search for words or phrases that are NOT there, so it will output everything which is not in conjunction with your search.



While in the directory you want to do this in try: ls -l | grep -v root || July



The first part ls -l lists all the files in a long listing order



The | symbol is called a pipe and it takes the input of the previous command and uses it as an input in the next command, in this case ls -l would be used as an input into 'grep'.



The second part grep -v root uses grep with the -v option which, with the search term root, the -v option is used to look for all contents that do not have what you searched for, so it will look for everything that does not have 'root'.



Finally the last part || July , the || basically means 'and' in grep so your specifiying two or more search terms, the 'July' is the second search term.***



PS: I DO NOT THINK THE QUESTION IS ASKING YOU TO MAKE A FILE CALLED 'NOTOWNEDBYROOT' INSTEAD ITS ASKING YOU TO SEARCH A DIRETCORY FOR ALL FILES/SUB DIRECTORYS THAT ARE NOT OWNED BY ROOT OR MADE IN JULY






share|improve this answer


























  • Will straight-up fail to work as intended; if grep -v root throws a non-zero exit code, it will attempt to run the command July which is very likely not to be an internal or a binary in the PATH.

    – DopeGhoti
    Mar 6 at 18:21











  • If you fix your code, and explanation of | then I will change my -1 to +1

    – ctrl-alt-delor
    Mar 7 at 9:15











  • but thats what a pipe is, it takes the output of a command as an input of a next command..........

    – Qasim
    Mar 7 at 11:07











  • And July is not a command. Things that are not the same, partial list: ||, |. Either way, it's wrong here.

    – DopeGhoti
    Mar 8 at 16:18











  • okay, what does | | and | mean then?

    – Qasim
    Mar 8 at 20:39












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
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f504766%2flist-files-not-owned-by-root-at-the-directory%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









-2














you can use ls and grep together its very easy and with the -v in grep option you can search for words or phrases that are NOT there, so it will output everything which is not in conjunction with your search.



While in the directory you want to do this in try: ls -l | grep -v root || July



The first part ls -l lists all the files in a long listing order



The | symbol is called a pipe and it takes the input of the previous command and uses it as an input in the next command, in this case ls -l would be used as an input into 'grep'.



The second part grep -v root uses grep with the -v option which, with the search term root, the -v option is used to look for all contents that do not have what you searched for, so it will look for everything that does not have 'root'.



Finally the last part || July , the || basically means 'and' in grep so your specifiying two or more search terms, the 'July' is the second search term.***



PS: I DO NOT THINK THE QUESTION IS ASKING YOU TO MAKE A FILE CALLED 'NOTOWNEDBYROOT' INSTEAD ITS ASKING YOU TO SEARCH A DIRETCORY FOR ALL FILES/SUB DIRECTORYS THAT ARE NOT OWNED BY ROOT OR MADE IN JULY






share|improve this answer


























  • Will straight-up fail to work as intended; if grep -v root throws a non-zero exit code, it will attempt to run the command July which is very likely not to be an internal or a binary in the PATH.

    – DopeGhoti
    Mar 6 at 18:21











  • If you fix your code, and explanation of | then I will change my -1 to +1

    – ctrl-alt-delor
    Mar 7 at 9:15











  • but thats what a pipe is, it takes the output of a command as an input of a next command..........

    – Qasim
    Mar 7 at 11:07











  • And July is not a command. Things that are not the same, partial list: ||, |. Either way, it's wrong here.

    – DopeGhoti
    Mar 8 at 16:18











  • okay, what does | | and | mean then?

    – Qasim
    Mar 8 at 20:39
















-2














you can use ls and grep together its very easy and with the -v in grep option you can search for words or phrases that are NOT there, so it will output everything which is not in conjunction with your search.



While in the directory you want to do this in try: ls -l | grep -v root || July



The first part ls -l lists all the files in a long listing order



The | symbol is called a pipe and it takes the input of the previous command and uses it as an input in the next command, in this case ls -l would be used as an input into 'grep'.



The second part grep -v root uses grep with the -v option which, with the search term root, the -v option is used to look for all contents that do not have what you searched for, so it will look for everything that does not have 'root'.



Finally the last part || July , the || basically means 'and' in grep so your specifiying two or more search terms, the 'July' is the second search term.***



PS: I DO NOT THINK THE QUESTION IS ASKING YOU TO MAKE A FILE CALLED 'NOTOWNEDBYROOT' INSTEAD ITS ASKING YOU TO SEARCH A DIRETCORY FOR ALL FILES/SUB DIRECTORYS THAT ARE NOT OWNED BY ROOT OR MADE IN JULY






share|improve this answer


























  • Will straight-up fail to work as intended; if grep -v root throws a non-zero exit code, it will attempt to run the command July which is very likely not to be an internal or a binary in the PATH.

    – DopeGhoti
    Mar 6 at 18:21











  • If you fix your code, and explanation of | then I will change my -1 to +1

    – ctrl-alt-delor
    Mar 7 at 9:15











  • but thats what a pipe is, it takes the output of a command as an input of a next command..........

    – Qasim
    Mar 7 at 11:07











  • And July is not a command. Things that are not the same, partial list: ||, |. Either way, it's wrong here.

    – DopeGhoti
    Mar 8 at 16:18











  • okay, what does | | and | mean then?

    – Qasim
    Mar 8 at 20:39














-2












-2








-2







you can use ls and grep together its very easy and with the -v in grep option you can search for words or phrases that are NOT there, so it will output everything which is not in conjunction with your search.



While in the directory you want to do this in try: ls -l | grep -v root || July



The first part ls -l lists all the files in a long listing order



The | symbol is called a pipe and it takes the input of the previous command and uses it as an input in the next command, in this case ls -l would be used as an input into 'grep'.



The second part grep -v root uses grep with the -v option which, with the search term root, the -v option is used to look for all contents that do not have what you searched for, so it will look for everything that does not have 'root'.



Finally the last part || July , the || basically means 'and' in grep so your specifiying two or more search terms, the 'July' is the second search term.***



PS: I DO NOT THINK THE QUESTION IS ASKING YOU TO MAKE A FILE CALLED 'NOTOWNEDBYROOT' INSTEAD ITS ASKING YOU TO SEARCH A DIRETCORY FOR ALL FILES/SUB DIRECTORYS THAT ARE NOT OWNED BY ROOT OR MADE IN JULY






share|improve this answer















you can use ls and grep together its very easy and with the -v in grep option you can search for words or phrases that are NOT there, so it will output everything which is not in conjunction with your search.



While in the directory you want to do this in try: ls -l | grep -v root || July



The first part ls -l lists all the files in a long listing order



The | symbol is called a pipe and it takes the input of the previous command and uses it as an input in the next command, in this case ls -l would be used as an input into 'grep'.



The second part grep -v root uses grep with the -v option which, with the search term root, the -v option is used to look for all contents that do not have what you searched for, so it will look for everything that does not have 'root'.



Finally the last part || July , the || basically means 'and' in grep so your specifiying two or more search terms, the 'July' is the second search term.***



PS: I DO NOT THINK THE QUESTION IS ASKING YOU TO MAKE A FILE CALLED 'NOTOWNEDBYROOT' INSTEAD ITS ASKING YOU TO SEARCH A DIRETCORY FOR ALL FILES/SUB DIRECTORYS THAT ARE NOT OWNED BY ROOT OR MADE IN JULY







share|improve this answer














share|improve this answer



share|improve this answer








edited Mar 6 at 18:12

























answered Mar 6 at 18:06









QasimQasim

19




19













  • Will straight-up fail to work as intended; if grep -v root throws a non-zero exit code, it will attempt to run the command July which is very likely not to be an internal or a binary in the PATH.

    – DopeGhoti
    Mar 6 at 18:21











  • If you fix your code, and explanation of | then I will change my -1 to +1

    – ctrl-alt-delor
    Mar 7 at 9:15











  • but thats what a pipe is, it takes the output of a command as an input of a next command..........

    – Qasim
    Mar 7 at 11:07











  • And July is not a command. Things that are not the same, partial list: ||, |. Either way, it's wrong here.

    – DopeGhoti
    Mar 8 at 16:18











  • okay, what does | | and | mean then?

    – Qasim
    Mar 8 at 20:39



















  • Will straight-up fail to work as intended; if grep -v root throws a non-zero exit code, it will attempt to run the command July which is very likely not to be an internal or a binary in the PATH.

    – DopeGhoti
    Mar 6 at 18:21











  • If you fix your code, and explanation of | then I will change my -1 to +1

    – ctrl-alt-delor
    Mar 7 at 9:15











  • but thats what a pipe is, it takes the output of a command as an input of a next command..........

    – Qasim
    Mar 7 at 11:07











  • And July is not a command. Things that are not the same, partial list: ||, |. Either way, it's wrong here.

    – DopeGhoti
    Mar 8 at 16:18











  • okay, what does | | and | mean then?

    – Qasim
    Mar 8 at 20:39

















Will straight-up fail to work as intended; if grep -v root throws a non-zero exit code, it will attempt to run the command July which is very likely not to be an internal or a binary in the PATH.

– DopeGhoti
Mar 6 at 18:21





Will straight-up fail to work as intended; if grep -v root throws a non-zero exit code, it will attempt to run the command July which is very likely not to be an internal or a binary in the PATH.

– DopeGhoti
Mar 6 at 18:21













If you fix your code, and explanation of | then I will change my -1 to +1

– ctrl-alt-delor
Mar 7 at 9:15





If you fix your code, and explanation of | then I will change my -1 to +1

– ctrl-alt-delor
Mar 7 at 9:15













but thats what a pipe is, it takes the output of a command as an input of a next command..........

– Qasim
Mar 7 at 11:07





but thats what a pipe is, it takes the output of a command as an input of a next command..........

– Qasim
Mar 7 at 11:07













And July is not a command. Things that are not the same, partial list: ||, |. Either way, it's wrong here.

– DopeGhoti
Mar 8 at 16:18





And July is not a command. Things that are not the same, partial list: ||, |. Either way, it's wrong here.

– DopeGhoti
Mar 8 at 16:18













okay, what does | | and | mean then?

– Qasim
Mar 8 at 20:39





okay, what does | | and | mean then?

– Qasim
Mar 8 at 20:39


















draft saved

draft discarded




















































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.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f504766%2flist-files-not-owned-by-root-at-the-directory%23new-answer', 'question_page');
}
);

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







Popular posts from this blog

How to reconfigure Docker Trusted Registry 2.x.x to use CEPH FS mount instead of NFS and other traditional...

is 'sed' thread safe

How to make a Squid Proxy server?