[英]root directory IOError: [Errno 13] Permission denied:
我在Ubuntu上工作,並用python編寫代碼。 我想在放置在根目錄中的文件中添加一行:
ins = open( "/usr/local/etc/conf.d/test.txt", "r" )
array = []
for line in ins:
array.append( line )
array.append('add this new line')
f = open("/usr/local/etc/gnuradio/test.txt",'w')
for line in array:
f.write(line)
我收到此錯誤:
Traceback (most recent call last):
File "overwrite.py", line 6, in <module>
f = open("/usr/local/etc/gnuradio/test.txt",'w')
IOError: [Errno 13] Permission denied: '/usr/local/etc/gnuradio/test.txt'
我知道如果沒有使用sudo,我們沒有權限更改根目錄中的任何內容。 但是無論如何,我可以從python模塊中更新此文件嗎?
您已經回答了自己的問題:您無權這樣做。
無論您使用sh,bash,python,C,erlang還是橡皮軟管攻擊。
與擁有必要權限的用戶一起運行腳本,或者授予您自己對該文件的訪問權限。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.