LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
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 10-06-2014, 12:38 AM   #1
bbisdd
LQ Newbie
 
Registered: Oct 2014
Posts: 4

Rep: Reputation: Disabled
Can someone please give me a little exam assistance?


Hello all Linux users. I am new to the linux world and am having an issue with an exam. I wanted to see if I could possibly get some assistance. All of these questions are in relations to CentOS.

1. You have a big file called "friends", and want to find all the lines that do NOT have the word "california" in it, and you want to sort them alphabetically, and save that in a file called "newb". How would you do that in one line of commands?

2. You want the permissions on a file to look like -rwxr-x--- for the file "newb"
And you want the group set to "newguy" and the owner set to "root". Please use 2-3 commands to complete these tasks

3. How would you back up the directories /home/newguy/etc and /usr/local/lib to a file called important.tar ?

4. What does the rsync command do and please sync the directory ~/mystuff with ~/Desktop/backupofmystuff.

Also to whoever helps me out, I very much so appreciate you taking the time to reply. The due date for this exam is nearing and I've nearing 7 hours trying to finish the exam and these are the only questions I have not been able to figure out. Thanks
 
Old 10-06-2014, 12:50 AM   #2
jdkaye
LQ Guru
 
Registered: Dec 2008
Location: Westgate-on-Sea, Kent, UK
Distribution: Debian Testing Amd64
Posts: 5,465

Rep: Reputation: Disabled
Quote:
Do not post homework assignments verbatim. We're happy to assist if you have specific questions or have hit a stumbling point, however. Let us know what you've already tried and what references you have used (including class notes, books, and searches) and we'll do our best to help. Keep in mind that your instructor might also be an LQ member.
The above quote is taken from the LQ Rules section. So tell us what you have done to answer these questions and what your problems are in doing so.
jdk
 
Old 10-06-2014, 01:09 AM   #3
bbisdd
LQ Newbie
 
Registered: Oct 2014
Posts: 4

Original Poster
Rep: Reputation: Disabled
Sorry, I should've read the rules and specified that they're not written verbatim. I reworded them and changed around the directories. As for the questions I have tried to figure them out I just have not been able to. For example for number 1, I have not been able to figure out how to put to command together, I know that for the grep -v command will search exclude a single word, the sort command will filter alphabetically and using > will print the output elsewhere, I just can't see to be able to come up with the proper command.

For number two I know chmod will change the group (or at least I believe it will chown will change the owner but I do not quite understand how to set the permissions like requested.

For the third one I know you can use the tar command, so I could do tar -vc important.tar (I believe this is correct but this is where I get stuck because I do not know how to back up two directories at once and send them to the same place)

For the last one, other than know that rsync is just used for copying, I'm not even sure at all how you would formulate that command. I've been at this for hours trying to figure these out (an of course the rest of the test) but I'm sincerely stuck.

Last edited by bbisdd; 10-06-2014 at 01:17 AM.
 
Old 10-06-2014, 01:43 AM   #4
astrogeek
Moderator
 
Registered: Oct 2008
Distribution: Slackware [64]-X.{0|1|2|37|-current} ::12<=X<=15, FreeBSD_12{.0|.1}
Posts: 6,263
Blog Entries: 24

Rep: Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194
OK, you have at least thought about it, so let's give a little nudge in the right direction...

Quote:
Originally Posted by bbisdd View Post
I know that for the grep -v command will search exclude a single word, the sort command will filter alphabetically and using > will print the output elsewhere, I just can't see to be able to come up with the proper command.
The thing that you are looking for is called a "pipe", looks like this |, it is used to pipe the output of one command into another.

So using what you already know, try something like this...

Code:
grep -v 'california' friends | sort > newb
You might need to add a case sensitivity flag in there, and there are a few sort options to look at, but note how the pipe is used - this is a cornerstone of Unix power.

See man grep and man sort for more.

Quote:
Originally Posted by bbisdd View Post
For number two I know chmod will change the group (or at least I believe it will chown will change the owner but I do not quite understand how to set the permissions like requested.
This always seems obscure to new users, and is so much taken for granted by long time users that it seems difficult to give a quick explanation.

So first let's ask if you know whow to read those permissions -rwxr-x---? That is pretty fundamental to understanding how to set them. If not read your study material for "file permissions" and see the chmod man page as well.

Hint: It is a simple binary representation of three octal values in bit order r (read), w (write) and x (execute), and group order user, group and others. A letter in a given position means that it is enabled, a '-' means it is disabled.

So rwxr-x--- means the user (owner) has read, write and execute permission, the group has read and execute, others have no rights: "rwx" "r-x" "---".

Again, see the chmod man page and come back if you need help over the hump - at least then we will be speaking the same language.

Quote:
Originally Posted by bbisdd View Post
For the third one I know you can use the tar command, so I could do tar -vc important.tar (I believe this is correct but this is where I get stuck because I do not know how to back up two directories at once and send them to the same place)
You already seem to know what is needed. See man tar and try it out. (I hope that you have a system to try it on...)

Quote:
Originally Posted by bbisdd View Post
For the last one, other than know that rsync is just used for copying, I'm not even sure at all how you would formulate that command. I've been at this for hours trying to figure these out (an of course the rest of the test) but I'm sincerely stuck.
See man rsync - think 'source' and 'destination'. Admittedly rsync has quite a few options, but just look at -a, -l and -v for now, pretty good hint.

Good luck and welcome to LQ!

Last edited by astrogeek; 10-06-2014 at 01:49 AM.
 
1 members found this post helpful.
Old 10-06-2014, 02:22 AM   #5
bbisdd
LQ Newbie
 
Registered: Oct 2014
Posts: 4

Original Poster
Rep: Reputation: Disabled
Thanks a lot for the help astro, I really do appreciate you taking the time to reply and help me out. I was actually able to figure out the first three questions with your assistance, I'm just trying to figure out the rsync command question. My brains about to explode from spending 10 hours trying to read though and learn these commands by myself. Unfortunately I have a teacher who doesn't exactly, "Explain" commands, rather just spits them all out and expects us to learn ourselves. I'll try to revisit this when I get a chance tomorrow and see if I'm able to figure it out, I've got till tomorrow night as 12 to finish my exam so I have a little bit of time - I also have class so I may be able to get assistance from my professor. Have a good night guys and thanks again for the help
 
Old 10-06-2014, 02:43 AM   #6
astrogeek
Moderator
 
Registered: Oct 2008
Distribution: Slackware [64]-X.{0|1|2|37|-current} ::12<=X<=15, FreeBSD_12{.0|.1}
Posts: 6,263
Blog Entries: 24

Rep: Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194
You are welcome!

Glad to hear that you got the first three figured out - the rsync is easy too.

Good luck on the test!
 
Old 10-06-2014, 11:40 PM   #7
jdkaye
LQ Guru
 
Registered: Dec 2008
Location: Westgate-on-Sea, Kent, UK
Distribution: Debian Testing Amd64
Posts: 5,465

Rep: Reputation: Disabled
If you're having trouble with rsync then this link may help you out. Give a shout if something isn't clear.
jdk
 
Old 10-07-2014, 09:30 AM   #8
onebuck
Moderator
 
Registered: Jan 2005
Location: Central Florida 20 minutes from Disney World
Distribution: Slackware®
Posts: 13,923
Blog Entries: 44

Rep: Reputation: 3158Reputation: 3158Reputation: 3158Reputation: 3158Reputation: 3158Reputation: 3158Reputation: 3158Reputation: 3158Reputation: 3158Reputation: 3158Reputation: 3158
Member Response

Hi,

Welcome to LQ!
Quote:
Originally Posted by bbisdd View Post
Thanks a lot for the help astro, I really do appreciate you taking the time to reply and help me out. I was actually able to figure out the first three questions with your assistance, I'm just trying to figure out the rsync command question. My brains about to explode from spending 10 hours trying to read though and learn these commands by myself. Unfortunately I have a teacher who doesn't exactly, "Explain" commands, rather just spits them all out and expects us to learn ourselves. I'll try to revisit this when I get a chance tomorrow and see if I'm able to figure it out, I've got till tomorrow night as 12 to finish my exam so I have a little bit of time - I also have class so I may be able to get assistance from my professor. Have a good night guys and thanks again for the help
Glad to see some initiative. Your instructor would be the first place to get detailed help.

I like to give new users these links;
Quote:
Just a few links to aid you to gaining some understanding;



1
Linux Documentation Project
2
Rute Tutorial & Exposition
3
Linux Command Guide
4
Bash Beginners Guide
5
Bash Reference Manual
6
Advanced Bash-Scripting Guide
7
Linux Newbie Admin Guide
8
LinuxSelfHelp
9
Ultimate Linux Newbie Guide
10
Linux Home Networking
11
Virtualization- Top 10

The above links and others can be found at '
Slackware-Links'. More than just Slackware® links!
Along with your text for the class the above links will help you to learn. Sure a lot of information but each reference material above will enhance your abilities.
Quote:
"Knowledge is of two kinds. We Know a subject ourselves, or we know where we can find information upon it."- Samuel Johnson

"It is one of the most beautiful compensations in life…that no man can sincerely try to help another without helping himself." - Ralph Waldo Emerson
Hope this helps.
Have fun & enjoy!
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
I am about to give RHCE 6 exam, Please guide me. tbibhuti Linux - Certification 12 12-19-2011 12:46 AM
planning to give RHEL exam in Aug adityasharma Linux - Newbie 4 07-19-2009 06:45 AM
LPI - exam emulation, asking for your assistance krajac Linux - Newbie 3 05-26-2009 03:21 PM

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

All times are GMT -5. The time now is 02:26 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