How to apply chmod 777 command to gain permissions to be able read the content of auth.log which is located under the /var/log directory [duplicate]
student@Ubuntu:/$ ls -l
total 80
drwxr-xr-x 1 root root 4096 May 9 2021 bin
drwxr-xr-x 2 root root 4096 Apr 24 2018 boot
drwxr-xr-x 5 root root 360 Nov 23 19:50 dev
drwxr-xr-x 1 root root 4096 Nov 23 19:50 etc
drwxr-xr-x 1 root root 4096 May 9 2021 home
drwxr-xr-x 1 root root 4096 May 9 2021 lib
drwxr-xr-x 2 root root 4096 Apr 16 2021 lib64
drwxr-xr-x 2 root root 4096 Apr 16 2021 media
drwxr-xr-x 2 root root 4096 Apr 16 2021 mnt
drwxr-xr-x 1 root root 4096 May 9 2021 opt
dr-xr-xr-x 167 root root 0 Nov 23 19:50 proc
drwx------ 1 root root 4096 May 9 2021 root
drwxr-xr-x 1 root root 4096 May 9 2021 run
drwxr-xr-x 1 root root 4096 May 9 2021 sbin
drwxr-xr-x 2 root root 4096 Apr 16 2021 srv
dr-xr-xr-x 13 root root 0 Nov 23 19:50 sys
drwxrwxrwt 1 root root 4096 Nov 23 19:52 tmp
drwxr-xr-x 1 root root 4096 Apr 16 2021 usr
drwxr-xr-x 1 root root 4096 Apr 16 2021 var
student@Ubuntu:/$ cd tmp
student@Ubuntu:/tmp$ cat /var/log/auth.log
cat: /var/log/auth.log: Permission denied
student@Ubuntu:/tmp$ cd ..
student@Ubuntu:/$ cd sys
student@Ubuntu:/sys$ cat /var/log/auth.log
cat: /var/log/auth.log: Permission denied
student@Ubuntu:/sys$ chmod 777 sys
chmod: cannot access 'sys': No such file or directory
student@Ubuntu:/sys$ cd ..
student@Ubuntu:/$ chmod 777 sys
chmod: changing permissions of 'sys': Read-only file system
student@Ubuntu:/$ chmod 777 var
chmod: changing permissions of 'var': Operation not permitted
If you want to see the content of /var/log/auth.log
you just need to make use of the sudo
-command:
sudo cat /var/log/auth.log
will prompt you for your password and then display the content of the file.
Don't change permissions of system files, you'd easily end up with a reinstall of your operating system.
Alternatively you could add the user to the adm
-group with
sudo adduser $USER adm
Followed by logout/login, groups are applied at login
time.
This will make the use of the sudo
-command unnecessary.