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 [email protected] #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

[Linux File Permissions Task

I’ve completed the task, but the end result failed; below is the information.

Hi @dino.farinha ,
Please share the “Review” link here. So we can take a look at it.

Regards,

You’ve added the permissions just for group and not for other users - as was requested.

Tried again and failed

[root@stapp01 tmp]# ls -l
total 8
-rwx------ 1 root root 836 Aug 1 2019 ks-script-rnBCJB
---------x 1 root root 40 Aug 2 11:03 xfusioncorp.sh
-rw------- 1 root root 0 Aug 1 2019 yum.log
[root@stapp01 tmp]# ./xfusioncorp.sh
Welcome To KodeKloud
[root@stapp01 tmp]#

Seems that permission (and even creating or copying the missing script file) needs to be on the 3 app servers.

Even if the description says that you must apply permissions to file on server 3, at the beginning explains that the script must be deployed on all the app servers.

I thought it after giving permissions on server 3 and receiving this failure message:

- 'script' is not executable on App Server 1

To make a file executable, it must also be readable.
The easiest way to do this (for all users) is

sudo chmod +rx xfusioncorp.sh

Do this on whichever app server the task is asking. The server can change each time you are assigned it.

1 Like

step 4 : exit
step 5 : sh filename.sh
step 6 :beers:

I’m able to execute the file without the read permission. Chat GPT says:

“In Linux, execute permissions are required to run a file. If a file does not have execute permissions, you won’t be able to execute it directly. However, you can still execute a file without read permissions if the parent directory has execute permissions.”

/tmp/ has 777 permissions, so I can execute it without the read being set on the file directly. I think the question needs to be worded more specifically to what you’re after here. Technically speaking adding chmod +x would satisfy the requirements so long as it’s moved into. directory that doesn’t have such open permissions. Am I off here? Still learning about this world so I get tripped up by details like this.