LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 02-18-2019, 09:02 AM   #1
ash997
LQ Newbie
 
Registered: Jun 2018
Posts: 23

Rep: Reputation: Disabled
Files and directories


If I have a user and I want to add it to /home and pass the output with the errors to a text file to the /tmp directory would this be the right command?
User1 -a &> /home/tmp/text
 
Old 02-18-2019, 09:45 AM   #2
rtmistler
Moderator
 
Registered: Mar 2011
Location: USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu, Debian
Posts: 9,883
Blog Entries: 13

Rep: Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931
Quote:
Originally Posted by ash997 View Post
If I have a user and I want to add it to /home and pass the output with the errors to a text file to the /tmp directory would this be the right command?
User1 -a &> /home/tmp/text
Not that I can see. I really can't tell what exact information you wish to gather, and what you want result to be.

How about: "When you run that command you wrote, what happened?"
 
Old 02-18-2019, 09:45 AM   #3
berndbausch
LQ Addict
 
Registered: Nov 2013
Location: Tokyo
Distribution: Mostly Ubuntu and Centos
Posts: 6,316

Rep: Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002
To send output of a command to a text file in /tmp:
Code:
SOME-COMMAND >/tmp/text
To send both regular output and error output to that file:
Code:
SOME-COMMAND >/tmp/text 2>&1
since error output normally goes to file descriptor 2.

User1 -a is not a command I know. Are you sure it does what you want to achieve?
 
1 members found this post helpful.
Old 02-18-2019, 10:13 AM   #4
ash997
LQ Newbie
 
Registered: Jun 2018
Posts: 23

Original Poster
Rep: Reputation: Disabled
user1 is the user
aslo what is the command I put in the beginning?
would it look like this Mkdir /home/user1 >/tmp/text 2>&1

Last edited by ash997; 02-18-2019 at 10:33 AM.
 
Old 02-18-2019, 10:35 AM   #5
rtmistler
Moderator
 
Registered: Mar 2011
Location: USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu, Debian
Posts: 9,883
Blog Entries: 13

Rep: Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931
Quote:
Originally Posted by ash997 View Post
user1 is the user
aslo what is the command I put in the beginning?
What information do you want? You've never said this. Your original question was:
Quote:
Originally Posted by ash997 View Post
If I have a user and I want to add it to /home and pass the output with the errors to a text file to the /tmp directory would this be the right command?
User1 -a &> /home/tmp/text
Are you asking how to add a user to your system, or are you asking about doing something with an existing user? You've been told that your question is unclear.
 
Old 02-18-2019, 10:44 AM   #6
ash997
LQ Newbie
 
Registered: Jun 2018
Posts: 23

Original Poster
Rep: Reputation: Disabled
Please provide the correct unix command(s) to user1 to their traditional place (/home) with a bash shell and pass the output - including errors - of the command into a text file on it into the /tmp directory.
 
Old 02-18-2019, 10:46 AM   #7
rtmistler
Moderator
 
Registered: Mar 2011
Location: USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu, Debian
Posts: 9,883
Blog Entries: 13

Rep: Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931
Quote:
Originally Posted by ash997 View Post
user1 is the user
aslo what is the command I put in the beginning?
would it look like this Mkdir /home/user1 >/tmp/text 2>&1
You've edited your post and now it shows a mkdir command. Have you tried that? What resulted other than nothing into the /tmp/text file? Because the successful return from a mkdir command is a return code to your bash return variable, but otherwise no text output details. It seems as if you want a log of the result of a mkdir command. Unless there was an error, there is no text based return from that system call.


Perhaps besides putting out a series of varied command attempts without indicating any outcome you've experienced, you should instead write clearly what you intend to do. Sorry, not trying to be difficult, but your question is as confusing now as it was in the first post.

EDIT: See my next, because I see that you finally wrote a brief paragraph describing what you're trying to do. I still have a question about it.

Last edited by rtmistler; 02-18-2019 at 10:52 AM.
 
Old 02-18-2019, 10:48 AM   #8
rtmistler
Moderator
 
Registered: Mar 2011
Location: USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu, Debian
Posts: 9,883
Blog Entries: 13

Rep: Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931
Quote:
Originally Posted by ash997 View Post
Please provide the correct unix command(s) to user1 to their traditional place (/home) with a bash shell and pass the output - including errors - of the command into a text file on it into the /tmp directory.
Are you saying you want to log every command made by a user?
 
Old 02-18-2019, 10:56 AM   #9
ash997
LQ Newbie
 
Registered: Jun 2018
Posts: 23

Original Poster
Rep: Reputation: Disabled
No I forgot to say add. Please provide the correct unix command(s) to add user1 to their traditional place (/home) with a bash shell and pass the output - including errors - of the command into a text file on it into the /tmp directory. That's what the question should look like..
 
Old 02-18-2019, 11:00 AM   #10
rtmistler
Moderator
 
Registered: Mar 2011
Location: USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu, Debian
Posts: 9,883
Blog Entries: 13

Rep: Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931
Quote:
Originally Posted by ash997 View Post
No I forgot to say add. Please provide the correct unix command(s) to add user1 to their traditional place (/home) with a bash shell and pass the output - including errors - of the command into a text file on it into the /tmp directory. That's what the question should look like..
Please look up the useradd(8) command and refer to berndbausch's reply in post #3 regarding how to log the outcome of your command.
 
Old 02-18-2019, 12:13 PM   #11
l0f4r0
Member
 
Registered: Jul 2018
Location: Paris
Distribution: Debian
Posts: 900

Rep: Reputation: 290Reputation: 290Reputation: 290
Quote:
Originally Posted by berndbausch View Post
To send both regular output and error output to that file:
Code:
SOME-COMMAND >/tmp/text 2>&1
Since OP has mentioned bash, there is a nice & quicker way to do that:
Code:
SOME-COMMAND &>/tmp/text
 
Old 02-18-2019, 01:53 PM   #12
ash997
LQ Newbie
 
Registered: Jun 2018
Posts: 23

Original Poster
Rep: Reputation: Disabled
what goes in place of SOME-COMMAND?
 
Old 02-18-2019, 02:05 PM   #13
rtmistler
Moderator
 
Registered: Mar 2011
Location: USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu, Debian
Posts: 9,883
Blog Entries: 13

Rep: Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931Reputation: 4931
Quote:
Originally Posted by ash997 View Post
what goes in place of SOME-COMMAND?
Your fellow members are all volunteers. Same as you.

Your recent question asked how to add a user, and you were directed to look up the useradd command, as well as given a link to the manual page.

Two different users have given valid ways to re-direct stdout and stderr to a file, where both ways will work.

It seems clear that you have not tried any command at all and you seem to be repeatedly asking your fellow members to "give" you a command.

You've been a member of LinuxQuestions long enough to know that this is not how the site works.

Please take the time to review links on the LQ site, here to aid you with how best to formulate your technical questions.

Please understand that it is very difficult for anyone to help you when you ask incomplete, unclear questions and also do not follow up on advice already given.
 
Old 02-18-2019, 04:13 PM   #14
berndbausch
LQ Addict
 
Registered: Nov 2013
Location: Tokyo
Distribution: Mostly Ubuntu and Centos
Posts: 6,316

Rep: Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002
Quote:
Originally Posted by ash997 View Post
what goes in place of SOME-COMMAND?
Some command, such as useradd user1.
 
1 members found this post helpful.
Old 02-19-2019, 06:56 PM   #15
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,368

Rep: Reputation: 2753Reputation: 2753Reputation: 2753Reputation: 2753Reputation: 2753Reputation: 2753Reputation: 2753Reputation: 2753Reputation: 2753Reputation: 2753Reputation: 2753
Is it just me, or does that phraseology sound awfully like a homework qn?
 
1 members found this post helpful.
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Sub-Directories not picking up correct group permissions for new files/directories JockVSJock Linux - Newbie 4 05-07-2017 10:52 AM
[SOLVED] How to remove all hidden directories and folders, and only hidden directories and folders rm_-rf_windows Linux - General 5 04-12-2016 07:28 AM
How to store files/directories in different different directories!! anishkumarv Linux - Newbie 7 03-23-2011 05:26 PM
Copying files and sub-directories of a directory except the directories named ".abc" sri1025 Linux - General 2 08-24-2010 08:53 AM
CHMOD directories.sub-directories.files zerojosh Linux - Software 2 11-19-2005 03:22 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 06:14 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration