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.
Hi, I am having a hard time writing a shell script to a text file in vi.
I open a file via:
vi WK3-IA
I write my script, and then switch to command :!wq [enter]
I get a E212 cannot write to file. Obviously I know that there is a permission issue here, but how can I change the permission of a file I cannot save to??? The next obvious question is how to change the permission to a file that cannot be save to?
I tried:
chmod 700 WK3-IA
and it says the stupid file does not exist, which seems pretty obvious since I cannot save to the file after I opened it. Did I miss something here? I realize I am a newbie to Linux, but the logic seems to be missing somewhere here.
If you are trying to change the permissions on the file make sure you are in correct directory before you execute the chmod command. Else it will end up giving errors.
From readin the thread I'd say its a permission problem on the directory your trying to write the file to. And if you can't write the file it just does not exists. So you can't change permission on it.
In this case write the file your lacking permissions on to /tmp and fix permission issues later. Or use the shell escape sequence to change permissions
Can you list the contents of the directory and paste it here and make sure you are changing the permissions from inside the directory where the file is.
Ok, that worked. However, it does not answer the question on how to change permissions on a vi file.
Just for the record: It doesn't matter what kind of file you want to change permission on. Files are files under linux. (symlinks are some kind of exepction with permission...)
Quote:
Originally Posted by smturner1
Could anyone give me instructions on how to change permissions on an existing file, and a new file so that I can handle it in the future?
Your doing the right thing to change the permission of an allready existing file but a new file first has to be created to have it permissions change.
Just to quickly sum it up: If you can't write to a directory you can't create the file. so it does not matter what kind of permissions you want to set on a new file.
Like linuxlover.chaitanya said give us a directory listing with
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.