LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Help needed with my OS exam tomorrow. (https://www.linuxquestions.org/questions/linux-newbie-8/help-needed-with-my-os-exam-tomorrow-808681/)

Alican 05-18-2010 03:10 PM

Help needed with my OS exam tomorrow.
 
Edit: Could you guys verify the answers I come up with?

Here are the questions, thanks in advance.
1- Count how many users are logged in currently. One user counts only once.
2- Count how many users are not using bash as a login shell
3- List all of the users whose login names contain “all” in them.
4- List all the symbolic links’ names in the current directory.
5- Count how many users are celebrating his name day at 6th of December (Santa Claus in Hungarian is Miklos)
6- Remove all files named “Core” and “core” from your home directory.
7- Start the archiving process of your home directory. Suspend the process and put it into the background. How can you get it back to the foreground?
8- Remove the comment from the .bash_rc file and create a new version as .bash_rc.new
9- How can you create a symbolic link?
10- List the content of the actual directory using ctime as sorting key and show only the first four entries.

1) users | wc -l
2) cat /etc/passwd | grep -v \/bin\/bash | wc -l
3) cat /etc/passwd | cut -d ":" -f1 | grep all
4) ls --file-type | grep @ OR find . -xtype l
5) cat /etc/passwd | cut -d ":" -f1 | grep Miklos (I'm not sure)
6) cd ~ && rm [cC]ore OR find ~ -type f | grep -e "[C|c]ore"
7) cd
cd ..
tar -cf homearchive.tar home
ctrl+Z
fg
8) sed '/^\#/d' .bash_rc > .bash_rc.new
9) 9) ln -s [src_file] [link_name]
10) ls -al --sort=time | head -n5 | tail -n4

repo 05-18-2010 03:21 PM

Quote:

Google didn't help me very much.
Why don't I believe this?

Alican 05-18-2010 03:23 PM

When you have no idea about what you're searching, even google doesn't help you.

brucehinrichs 05-18-2010 03:44 PM

Quote:

When you have no idea about what you're searching, even google doesn't help you.
If you are truly this clueless, you should fail.

Alican 05-18-2010 03:47 PM

Look, if you don't want to help, then don't. I'm sure there are some non-judgmental people on this forum.

brianL 05-18-2010 03:52 PM

A little quotation, from the LQ rules:
Quote:

Do not expect LQ members to do your homework - you will learn much more by doing it yourself.

XavierP 05-18-2010 03:55 PM

The answer to your first question can be found by following this link. I simply plugged your question into Google and then read up on the answer. Test the answers on your Linux box.

You *do* know the questions to ask, they are the exact questions you asked us.

Alican 05-18-2010 04:14 PM

Thanks! :) I've found these so far.
1) users | wc -l
3) users | grep all
4) ls --file-type | grep @
6) cd ~ && rm [cC]ore .
9) ln -s [src_file] [link_name]
10) ls -al --sort=time | head -n5 | tail -n4

pixellany 05-18-2010 04:35 PM

Alican;

Normally, this would have been closed by now. Since you obviously just did some work, we'll keep going.

As XavierP said, you now need to test these commands on your system to see how they work. Also, look at the man page for each one---eg "man users"

Alican 05-18-2010 04:35 PM

OK, maybe I'm going with the wrong approach here. Can you guys verify the answers I come up with at least?

7) cd (this should go to home directory if no path is given right?)
cd ..
tar -cf homearchive.tar home

edit: I have Ubuntu running on Virtual PC 2007 but number 2 and 3 didn't work for me or maybe they did but returned nothing.

smeezekitty 05-18-2010 04:37 PM

#7:
Control Z puts it in the background, typing fg puts in the foreground!

jefro 05-18-2010 04:44 PM

When in doubt, Charlie out.

That means guess the C answer if you have no idea.

(I should control myself but sometimes)

Alican 05-18-2010 05:09 PM

8) sed '/^\#/d' .bash_rc > .bash_rc.new

impert 05-18-2010 05:20 PM

Alican, I thought I was the world's worst student, but I have to say you are very serious competition!
Quote:

Can you guys verify the answers I come up with at least
?
Try them yourself!

Quote:

7) cd (this should go to home directory if no path is given right?)
cd ..
tar -cf homearchive.tar home
cd (on my machine) goes to MY home directory: ie /home/<myusername> NOT /home
cd .. goes to the directory above the present working directory. So if I'm not mistaken:

Quote:

cd
cd ..
tar -cf homearchive.tar home
will only make an archive if you have a directory /home/home, otherwise it will spit out an error message.
But don't take my word for it, I'm at least the world's second worst student, try it out.

Good luck, and thanks for starting one of the funniest threads I've read in a long time.

Andrew Benton 05-18-2010 05:41 PM

Count how many users are not using bash as a login shell
Code:

awk -F ":" '!/bash/ { print $7 }' /etc/passwd | wc -l
This page talks about the second part of number 7

For number 9 you need to read man ln


All times are GMT -5. The time now is 07:09 PM.