LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Need homework help! (https://www.linuxquestions.org/questions/linux-newbie-8/need-homework-help-33953/)

bumstickie 10-27-2002 09:07 PM

Need homework help!
 
Newbie! I started out OK, but now I'm getting confused! I think I'm thinking too hard on these, either that or my brain fried....I will happily take "hints", or a push in the right direction! I'm doing fine on other parts, but some questions just aren't clicking in my head. Here are my problems:

1. I am to deliberately write a command that generates an error, like "ls -l asfd". No problem. I am then to send this stderr to a file called "errfile". Again, no problem. Now here's the problem: "send stdout to tempfile and stderr to errfile" How do I do both at the same time?
More on the same question: "write a version of above, send both stdout and stderr to tempfile" ALSO: "write another version where you only need to specify the name 'tempfile' one time, but both stdout and stderr are redirected to 'tempfile' (hint - use "&").

2. "Find" command with reg exp....write a Find command to find all filenames in the /dev directory that begin with 'fd', but limit the list to files ending with '20' or '40'....I'm so close, but I just can't get it. I know the basic theory on using ? and *, but I just can't get it. I tried "find /dev -name fd[24] -print" with all versions of *'s, ?'s, ^'s...but just can't figure it out. I know this is a really stupid quesiton!!!

3. "grep" confuses me.... Just a hint here and I should be able to get the rest.... "Type 'ls -al > tempfile' to store a directory listing in tempfile".
a.) "Write a grep command which will show all lines of all files in your home directory that contain the string '.bash'"
b.) write another to show all lines with file permissions rw-r--r--
c.) write one command containing 2 commands connected by a pipe to accomplish "a.)"
d.) write one command containing 2 commands connected by a pipe to accomplish "b.)"

4. Aliases. I understand the concept. I am to edit the ".bashrc" script to add an alias using vi editor. I did that. It worked. I shut down and went about my day. Started Linux back up and continued on with this question - and it disappeared. I saved it originally, and tested it out. But when I logged in later, it wasn't there. I am supposed to figure out how to automate this for all new users that are created. I understand that this is done with /etc/skel, but I can't figure out how. (Like I said, I think I'm thinking too hard or not getting enough sleep or somethign, because I know I should be able to figure these simple things out, they're just not coming to me!)

5. Need basic help with mounting. "use 'cat' command to create a small text file in '/mnt/cdrom', use ls to verify. insert CD and mount it. Why I can't get this is beyond me....I'm an idiot!

6. Was to run the "ps" command as "ps -ef". Fine, no prob. Then wa asked to write "a ps command in the format 'ps -eo <option list> which gives exactly the same display as -ps -ef'" Tried everything. CHecked everywhere...just can't get it.

7. "Use the --sort option of ps to repeat #6 in reverse order by user"

Any help anyone can give me is greatly appreciated! I don't need exact answers (although they are welcome!), just a point in the right direction. I picked a bad time to start this particular class (life in general), and I'm struggling. Things should get better (now that I got laid off and will have plenty of time to study) - but as for now, I'm confused. Thanks in advance!

d

trickykid 10-27-2002 10:44 PM

Well, the one suggestion I'll give you is to search for you answers first.

Check out:

www.tldp.org - lots of howto's, guides, good information there.
www.google.com/linux - the best search engine around for Linux.

Not to sound rude or anything, but most members here and mods don't like people who ask to help with homework or the such and it often annoys us. Its just the whole principle of the thing. That's why its assignment, its for you to do, not anyone else.

sewer_monkey 10-27-2002 10:51 PM

Just curious... What school/course was this assignment given in?

Most schools nowadays only do Micro$oft junk.

Mik 10-28-2002 04:37 AM

1. Read the manual pages of bash. Particullary the sections Redirecting Output & Redirecting Standard Output and Standard Error

2. Your find command looks for all entries starting with fd and followed by a 2 or a 4. It should be starting with fd then any range of characters and then ending with either a 2 or a 4 and then a zero.

3. Read the manual pages of grep. Basically you just type 'grep string_to_search filename'. For the first two commands grep reads from the tempfile. In the c and d you should be able to let grep work on the output of the first ls command by using a pipe. They haven't specified the question very clearly though, making c and d sound a bit confusing.

4. Just adding the commands to /etc/skel/.bashrc should be enough to have it set for each newly created user. The command you added dissapeared from the .bashrc file? Is there some start up script which is overwriting the file on bootup?

5. What do they want you to do for this question? After mounting the cd the file you just created obviously won't be there.

6. If you look at the first line of ps -ef you should be able to see all the field names. You should be able to get the same options using an option list. To get the first two fields you could run the command: ps -eo "user pid"
You can find the rest by reading the man page of ps.

7. A normal ps command sorts by pid. You can specify a reverse sort by adding a - before the key.


All times are GMT -5. The time now is 02:55 PM.