[SOLVED] some obstacles in executing commands and having limited permission to some files
Linux - NewbieThis 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
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
some obstacles in executing commands and having limited permission to some files
I am learning the commands and it is going great. This is an obstacle which I could not figure it out from other forums and online. trying to learn chmod command by doing the following
problem number 1:
1-I can't execute test.sh after doing the following.
echo "shit happens" > test
chmod +x test.sh
./test.sh
I am getting
./test.sh: line 1: shit: command not found
Any ideas?
2- on the other files, it says permission denied. I watched some Youtube tutorials and applied them, still won't work. (to be specific, I changed the ownership of the file to root)
and if I enter # ls -ld , I get this:
drwxr-xr-x 22 root root 4096 Feb 20 2005 /
which seems fine to me but will still get permission denied
Thnx in advance
N.B: using Kali Linux
Last edited by Abdulmalek97; 07-14-2017 at 04:12 PM.
An executable file is not the same thing as a file that is executable. Changing the permissions on a file that contains random text does not create an executable program. A bash script is taking all those commands you have been learning and putting them into a file to have some sort of automated process. There are many guides and tutorials on bash scripting.
An executable file is not the same thing as a file that is executable. Changing the permissions on a file that contains random text does not create an executable program. A bash script is taking all those commands you have been learning and putting them into a file to have some sort of automated process. There are many guides and tutorials on bash scripting.
An actual program contains commands that follow a particular language syntax. Your file does not which is why you see the error code despite the fact that it is executable.
Put the following lines in a text file and change its permissions so that it is executable. See what happens when you execute the file.
An actual program contains commands that follow a particular language syntax. Your file does not which is why you see the error code despite the fact that it is executable.
Put the following lines in a text file and change its permissions so that it is executable. See what happens when you execute the file.
Use a text editor and copy/paste the provided code.
The echo command as posted creates a text file that contains hello world which is not the same as the above code.
but you asked me to put hello world in a txt file, right? cause if I only have echo hello world, it will print it on the terminal and that is not what i was trying to achieve.
but you asked me to put hello world in a txt file, right? cause if I only have echo hello world, it will print it on the terminal and that is not what i was trying to achieve.
Not in the context of creating a script that you can execute.
Not in the context of creating a script that you can execute.
This is the tutorial that I am trying to achieve but I get the error and he obviously doesn't. I am wondering what did I do differently because i am literally following his words and in all the other commands, it went well.
edit: video is uploading.....
Last edited by Abdulmalek97; 07-14-2017 at 05:03 PM.
i am sorry. I don't seem to understand. there must be a miscommunication. I will record a video of what I am trying to do> give me 5 minutes please.
I would discourage your from using video as a primary means of communicating your tasks, code and data as it is more difficult for others to understand your questions and problems and creates a huge obstacle to your learning experience in my opinion. Particularly in something as simple and basic as shell scripting, it is simply not an appropriate medium.
It is clear that you have not yet grasped the most basic concept of shell scripting and programming, that of passing arguments to some function for processing. In this case, passing a string to the echo function for writing to the screen. This has nothing to do with permissions on the file itself.
Michaelk has posted a link to one of the best resources available for learning those concepts, please try to work your way through the examples it contains. Until you do, you will not be able to learn any other concepts.
I would also urge you to try another distro for your learning experience. Kali Linux is specifically designed for Linux and networking experts and is really unsuitable for learning the basics - even dangerous to yourself and others in unknowledgable hands.
Thanks. It worked. What is the trick and what is the story with all these echos and double writing it? in the video, he didn't do it like that and still worked. there was no bin bash and stuff. but there was indeed two echos
I would discourage your from using video as a primary means of communicating your tasks, code and data as it is more difficult for others to understand your questions and problems and creates a huge obstacle to your learning experience in my opinion. Particularly in something as simple and basic as shell scripting, it is simply not an appropriate medium.
It is clear that you have not yet grasped the most basic concept of shell scripting and programming, that of passing arguments to some function for processing. In this case, passing a string to the echo function for writing to the screen. This has nothing to do with permissions on the file itself.
Michaelk has posted a link to one of the best resources available for learning those concepts, please try to work your way through the examples it contains. Until you do, you will not be able to learn any other concepts.
I would also urge you to try another distro for your learning experience. Kali Linux is specifically designed for Linux and networking experts and is really unsuitable for learning the basics - even dangerous to yourself and others in unknowledgable hands.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.