Noobie help required.

Good evening all,

This is my first post so I apologies if I am asking something which has being asked numerous times.

Basically I have applied for a new job role which requires networking (cisco security) and linux skills. I have the required Cisco skills but I am a total noobie regarding Linux (something I am soon to remedy,). All that being said I have being given a technical challenge regarding Linux to complete, the Operation Director has stated that even though I don’t know Linux he would like me to research the answers and complete.

Given the above would anyone have a few moments to give some advise/assistance with some basic Linux commands? I have essentially googled a few of the simpler ones, which I was advised to do but I am running into a bit of trouble with the more “complex” commands.

Kind Regards

Hi ArdenUK, and welcome to the forum :slight_smile:

Why not post the questions and see if anyone will explain them … I would think that’s more likely to elicit responses than asking for help without saying what you want help with :wink:

I for example don’t know whether to respond, as I don’t yet know if I’m able to help.

Thank you for the warm welcome, Here is a sample! I’ll drop it on you all slowly lol.

1.) Using one command, change the mode bits of the text file to look like this: -rwxrw–w-.

2.) Explain the permissions on the file shown below:

[james@HaPPi Linux]$ ls -l LinuxChallenge 
-rwsrwsrwx. 1 james james 65 Apr  2 12:49 LinuxChallenge

3.) What are the risks of having a file with these permissions?

4.) Using bash commands, replace the contents of the file “LinuxChallenge” with the text below:

one four seven two five eight three six nine

For the first 3 questions this might help you get your head around “linux/unix file permissions”:
http://www.onlineconversion.com/html_chmod_calculator.htm

Answers:-

chmod 762 /path/to/file

(see the link above, and I’m sure you’ll work it out)
-rwxrw–w-
rwx = read/write/execute = 7 ← OWNER permissions
rw- = read/write = 6 ← GROUP permissions
-w- = write = 2 ← EVERYONE ELSE permissions


  1. I don’t know where the 2 “s” are coming from, but assuming that’s supposed to read -rwxrwxrwx

the first “-” digit (-rwxrwxrwx) means it’s a file, other options would be “d” for a directory, or “l” for a link (aka. symlnk/shortcut)

the next 3 digits (-rwxrwxrwx) are the permissions for the file “owner” (owner = james) … rwx = 7 = he has permission to read/write/execute the file.

the next 3 digits (-rwxrwxrwx) are the permissions for the file “group” (group = james) … rwx = 7 = anyone that belongs to the group assigned to the file has permission to read/write/execute the file.

the next 3 digits (-rwxrwxrwx) are the permissions for “everyone else” … rwx = 7 = everyone has permission to read/write/execute the file


  1. Because EVERYONE has permission the read/write/execute the file, it could (depending on what it is) be considered a security risk … particularly if it’s executable (but also if you just want to keep it private, or make it public but not editable by anyone else).

echo -e "one    four    seven\n""two    five    eight\n""three    six    nine" > LinuxChallenge

you can see the echo options at the bottom of this page:
http://www.tecmint.com/echo-command-in-linux/
where you can see \n = new line

BTW,

means write it to the file (overwriting what’s already there)
but

means append it to the end of the file (without overwriting what’s already there).

Thank you again!

5.) Make a directory called “CHALLENGE”

I believe this is just mkdir Challenge

6.) Within that directory, create a text file with the name “LinuxChallenge”

7.) Copy the text below into that file: (preferably using bash commands)

<3 Archer Quotes

Do you want ants? because that’s how you get ants!

Nope nope nope nope nope nope nope… you don’t want to do that.

Do you think this is a game?
No, I think Jenga is a game.

Lana. Lana? Lana! LANAAAAAA!
What?
…Danger zone

8.) Using bash commands, remove all ‘.’ characters from the above text

9.) Using bash commands, replace all ‘!’ characters with ‘.’ characters

10.) Using bash commands, search for all lines in the text file which have the ‘?’ character in them.

The output should look like:
	
	Do you want ants? because that's how you get ants!
	Do you think this is a game?
	Lana. Lana? Lana! LANAAAAAA!
	What?

5.) to create a folder called “CHALLENGE” in your home folder

mkdir ~/CHALLENGE

6.)

touch ~/CHALLENGE/LinuxChallenge

7.) dunno if this is what they expect, but it would work:

echo -e "<3 Archer Quotes""\n\n""Do you want ants? because that's how you get ants!""\n\n""Nope nope nope nope nope nope nope... you don't want to do that.""\n\n""Do you think this is a game?""\n""No, I think Jenga is a game.""\n\n""Lana. Lana? Lana! LANAAAAAA!""\n""What?""\n""....Danger zone" > ~/CHALLENGE/LinuxChallenge

8.)

sed -i -e 's/\.//g' ~/CHALLENGE/LinuxChallenge

9.)

sed -i -e 's/!/./g' ~/CHALLENGE/LinuxChallenge

10.)

cat ~/CHALLENGE/LinuxChallenge | grep ?

Hi Mark,
I see in item

6.)
Code: [Select]
touch ~/CHALLANGE/LinuxChallenge

If copied and pasted (as usual) it may provide a CHALLANGE too far :smiley:

typo fixed in (6) above.

Forgive my impertinence but for Qu2 & 3 …
I believe the file attributes are the SETUID bit and SETGID bit.

http://i.imgur.com/OSrt6pN.png

I will let you Google for why setting the SETUID bit and SETGID bit can be a security risk, it is a bit of a lengthy explanation.

Cheers Finlay, not something I’d come across before … but something I know now :wink:
(actually I knew about setuid and setgid … I just never realised they showed up in the permissions as “s” and didn’t make the connection)

.

Hi guys,

Thank you for all your assistance in this matter. Given all your help as well as me epically falling over numerous times on my ubuntu install testing the commands you have supplied I was offered the role at the company. Goes without saying I could not do this without your support. Many many thanks!

Regards

Paul!

PS. Given this company works purely with Linux, watch this space for further questions hahaha :slight_smile:

Great stuff … I guess you now have some homework ahead of you :slight_smile:

More than “some” lol, Have to become competent on CentOS which should be a fun ride ! :slight_smile:

Or talk them into switching to Debian :wink:

I’ve never understood why companies like CentOS so much … all the downsides of Redhat, without the single upside (support) :o