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
答案1
如果你想查看内容,/var/log/auth.log
你只需要使用sudo
命令:
sudo cat /var/log/auth.log
将提示您输入密码,然后显示文件的内容。
不要更改系统文件的权限,否则您很容易导致重新安装操作系统。
或者,你可以使用以下命令将用户添加到adm
-group
sudo adduser $USER adm
随后注销/登录,并按login
时间应用组。
这将使得 -command 的使用变得sudo
没有必要。