Linux File Permissions Task

Hi,

I tried my first task which was to make the xfusioncorp.sh script executable on app server 3. Attached is a screenshot of when i executed the script, but i failed the task. Just wanted to be sure. Thanks.

1 Like

You have to change the permissions of the file. Go to app server 3 and check the file permission of the xfusioncorp file using the command ls -la <file name> . Then based on what the current permissions are, change file access rights using chmod <binary> <file name>.

1 Like

Thank you, I will give it a try.

Guys, few of you might get froze in this task, follow the below steps

currently you will be jumpserver

step1; ssh banner@172.16.238.12 #pressenter
comments :(username) (ip address)

step2 : sudo su -

step 3 : chmod +rx filename.sh

1 Like

I also completed the task, but it is showing failed. Below are the output:

[banner@stapp03 tmp]$ ls -l
total 8
-rwx------ 1 root root 836 Aug 1 2019 ks-script-rnBCJB
---------- 1 root root 40 Mar 2 17:36 xfusioncorp.sh
-rw------- 1 root root 0 Aug 1 2019 yum.log
[banner@stapp03 tmp]$ chmod +x xfusioncorp.sh
chmod: changing permissions of ‘xfusioncorp.sh’: Operation not permitted
[banner@stapp03 tmp]$ sudo chmod +x xfusioncorp.sh

We trust you have received the usual lecture from the local System
Administrator. It usually boils down to these three things:

#1) Respect the privacy of others.
#2) Think before you type.
#3) With great power comes great responsibility.

[sudo] password for banner:
[banner@stapp03 tmp]$ ls -l
total 8
-rwx------ 1 root root 836 Aug 1 2019 ks-script-rnBCJB
—x–x–x 1 root root 40 Mar 2 17:36 xfusioncorp.sh
-rw------- 1 root root 0 Aug 1 2019 yum.log
[banner@stapp03 tmp]$ thor@jump_host ~$

2 Likes

Hello, @Anurag-Yadav
Please share your work in our “Review” section.

I also ran into the same issue as Anurag. The question asked for execute permissions to be granted to everyone and that is what I did and confirmed below. The only thing I can think of is maybe we were supposed to also include read access? But would be a bit confused if that’s the case due to how the question was worded. Please let me know what I did incorrectly. Thank you!

Hi @zachary8495 try with chmod 777 <file>.

Thanks,
KodeKloud Support

Thanks Vitor.

I’m still a bit confused as to why we would need to use chmod 777. Wouldn’t that provide all permissions (r,w,x) and not just execute? Can you please help me understand why only providing execute permissions is not appropriate in this situation? Thank you!

Maybe the text must be reviewed, but my first tough would be: if I’m giving execution privileges, maybe the user would have to read the content or even change it. Again, it depends on the context of the question. But I think if you use 777, it will be ok. Try it when you have a chance and let me know. :slight_smile:

Thanks,
KodeKloud Support

Ahh I see what you mean - how can a file be executed if the shell trying to execute cannot read the file? I looked around for additional clarification and found this post : linux - how to grant execute permission without read permission? - Super User

It makes sense that in order for a shell to execute a script it needs to be able to read the file to understand what it is executing. As an additional question, does this mean that in order to have execute permissions you must have read permissions, or do you also need write permissions to? I can see why someone would want to have write permissions, but not necessarily why they would need them, unless I am not thinking of something critical.

So, to execute, you’ll need at least chmod a+x,u+r teste-permissions. Don’t permitting to write to it can be a good security practice. This is very common, especially with stick bit where hackers can benefit from it :slight_smile:

Thanks,
KodeKloud Support

1 Like