Bash /var/log/apache2/error.log Permission Denied
Contents |
communities company blog Stack Exchange Inbox Reputation and Badges sign up log in tour help Tour Start here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business var log apache2 permission denied Learn more about hiring developers or posting ads with us Ask Ubuntu Questions Tags Users apache error log permissions Badges Unanswered Ask Question _ Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes apache error log permission denied a minute: Sign up Here's how it works: Anybody can ask a question Anybody can answer The best answers are voted up and rise to the top Ubuntu clear Apache2 error log [duplicate] up vote 0 down vote apache 403 forbidden favorite 1 This question already has an answer here: When using sudo with redirection, I get 'permission denied' 5 answers I am new to Ubuntu. I can find my error log here in var/log/apache2/error.log. but i couldn't clear it. i tried to change the permission to edit the content. But couldn't achieve it. Please help me to remove it. I have read some question previously asked. but it does-not help me . this one I read http://askubuntu.com/questions/574725/how-to-clear-system-logs-in-ubuntu.
Add User To Group
Here is my terminal screen-shot: permissions apache2 error-handling share|improve this question edited May 18 at 9:52 Pierre.Vriens 6671615 asked Dec 5 '15 at 5:33 Kvvaradha 1299 marked as duplicate by David Foerster, Eric Carvalho, Videonauth, RPi Awesomeness, muru May 19 at 20:15 This question was marked as an exact duplicate of an existing question. Please post text files and program output listings as text, not as images (see How do I save terminal output to a file?). –David Foerster May 18 at 8:42 add a comment| 2 Answers 2 active oldest votes up vote 0 down vote accepted Most files in /var/log are owned by root. So, if you want to modify them, you will have to use sudo. To clear the error file, give command: sudo bash -c 'echo > /var/log/apache2/error.log' If that doesn't work, then very likely the apache process keeps the file locked and you have to stop apache before you can clear the file. This goes as follows: sudo service apache2 stop sudo bash -c 'echo > /var/log/apache2/error.log' sudo service apache2 start Note: You can't use sudo echo > /var/log/apache2/error.log here, because sudo executes the echo command but the redirect to error.log is done under the process of the user, which doesn't have elevated privileges. That's why I pass the whole command to bash, which is then executed by sudo. share|improve this answer
Support Search GitHub This repository Watch 99 Star 1,761 Fork 481 fideloper/Vaprobash Code Issues 30 Pull requests 34 Projects 0 Wiki Pulse Graphs New issue Permission denied on apache2 logs #436 Closed damianlewis opened this Issue Jan 26, 2015 · 1 comment Projects None yet Labels None yet Milestone No milestone Assignees No one assigned 2 participants damianlewis commented Jan 26, 2015 I can't access the apache2 http://askubuntu.com/questions/706128/ubuntu-clear-apache2-error-log log directory? I can view the log file is by using: $ sudo cat /var/log/apache2/192.168.22.10.xip.io-error.log but I can't access the /var/log/apache2 directory. I just get -bash: cd: /var/log/apache2: Permission denied fideloper closed this Jan 26, 2015 Owner fideloper commented Jan 26, 2015 Try using "sudo su" to login as root, then "cd" into https://github.com/fideloper/Vaprobash/issues/436 them. This is normal behavior, as using "sudo" with cat will work fine, but some operations like CD are "weird" in their behavior. so: sudo su cd /var/log/apache2 … On Mon Jan 26 2015 at 12:10:42 PM Damian Lewis ***@***.***> wrote: I can't access the apache2 log directory? I can view the log file is by using: $ sudo cat /var/log/apache2/192.168.22.10.xip.io-error.log but I can't access the /var/log/apache2 directory. I just get -bash: cd: /var/log/apache2: Permission denied — Reply to this email directly or view it on GitHub <#436>. Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment Contact GitHub API Training Shop Blog About © 2016 GitHub, Inc. Terms Privacy Security Status Help You can't perform that action at this time. You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings http://superuser.com/questions/558464/permision-denied-on-log-file and policies of this site About Us Learn more about Stack Overflow http://serverfault.com/questions/582758/can-not-truncate-clear-error-log-on-apache-but-can-do-it-manually-with-nano the company Business Learn more about hiring developers or posting ads with us Super User Questions Tags Users Badges Unanswered Ask Question _ Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute: Sign up Here's how permission denied it works: Anybody can ask a question Anybody can answer The best answers are voted up and rise to the top Permision denied on log file up vote 1 down vote favorite I want to be able to view log files from apache as regular user. I have set this files to 777 as root but still cannot view them as apache error log regular user, why is that? #I have set permissions for everyone root@senior:/var/log/apache2# ls -l total 200 -rwxrwxrwx 1 root root 1951 Feb 27 23:07 access.log -rwxrwxrwx 1 root root 89508 Feb 27 23:07 error.log -rwxrwxrwx 1 root root 101601 Feb 27 23:06 other_vhosts_access.log #I have also set directory permission root@senior:/var/log# ls -l drw-rw-r-- 2 root adm 4096 Feb 27 23:08 apache2 But still cannot view the files kubi@senior:$ ls -l /var/log/apache2/ ls: cannot access /var/log/apache2/other_vhosts_access.log: Permission denied ls: cannot access /var/log/apache2/error.log: Permission denied ls: cannot access /var/log/apache2/access.log: Permission denied total 0 -????????? ? ? ? ? ? access.log -????????? ? ? ? ? ? error.log -????????? ? ? ? ? ? other_vhosts_access.log kubi@senior:/$ ls /var/log/apache2/error.log ls: cannot access /var/log/apache2/error.log: Permission denied Im running debian file-permissions share|improve this question asked Feb 27 '13 at 22:15 Buksy 11327 add a comment| 2 Answers 2 active oldest votes up vote 3 down vote accepted The directory should be 750, not 664. Also, you should add the user to the adm group. That's actually largely the point of the adm group: reading logs. Permissions o
Start here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Server Fault Questions Tags Users Badges Unanswered Ask Question _ Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute: Sign up Here's how it works: Anybody can ask a question Anybody can answer The best answers are voted up and rise to the top Can not truncate / clear error.log on apache, but can do it manually with nano up vote 4 down vote favorite 3 I tried to clear the content of error.log file on my apache server with commands sudo >error.log sudo truncate -s0 error.log But in both cases I got -bash: error.log: Permission denied. I tried the same thing while stopping apache, but still got the same message. After that I tried to clear it with sudo nano error.log and was able to remove everything. So why was not I able to clear the log properly? log-files apache-2.4 share|improve this question asked Mar 18 '14 at 0:39 Salvador Dali 32021126 add a comment| 1 Answer 1 active oldest votes up vote 11 down vote accepted You should try this : sudo sh -c ">/var/log/apache2/error.log" share|improve this answer answered Mar 18 '14 at 0:47 krisFR 7,35821025 Can you please explain what does this command do? –Salvador Dali Mar 18 '14 at 0:47 It runs an inline sh (shell) command under sudo context. Actually this inline sh command clears Apache error log (as you know) –krisFR Mar 18 '14 at 0:50 1 My guess is that > is not a command without an interpreter like sh or bash –krisFR Mar 18 '14 at 0:59 1 However your sudo truncate... command should work...That is the real thing i cannot explain by now –krisFR Mar 18 '14 at 1:07 4 Redirection operators are evaluated by your local shell before the sudo command even runs. sudo > foo opens the file foo for writing, then runs the command sudo . If you put it inside quotes or escape the redirection operator, then it is evaluated within the context of the sub-shell. –Zoredache Mar 18 '14 at 1:16 | show 1 more comment Your Answer draft saved draft discarded Sign up or log in Sign up using Google Sign up using Facebook Sign up using Email and Password Post as a gues