ls: cannot access '/var/log/auth.log*': No such file or directory (Linux shell scripting basic-Redirection)
-
Hi Don,
when i run this command
./filelog.shthe result
ls: cannot access '/var/log/auth.log*': No such file or directoryi'm running on Ubuntu
stenlymo@DESKTOP-EIMSBDB:~/shellscript$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 20.04 LTS
Release: 20.04
Codename: focal
stenlymo@DESKTOP-EIMSBDB:~/shellscript$Script filelog.sh
#!/bin/bash
#make the log of the auth logs everytime script runtoday=$(date +%y%m%d)
ls /var/log/auth.log* -al > log.$todayresult ls -l
stenlymo@DESKTOP-EIMSBDB:/var$ ls -l
total 44
drwxrwxr-x 7 root syslog 4096 Apr 23 14:17 logstenlymo@DESKTOP-EIMSBDB:/var$ cd log
stenlymo@DESKTOP-EIMSBDB:/var/log$ ls -l
total 380
-rw-r--r-- 1 root root 3568 Jul 18 19:19 alternatives.log
drwxr-xr-x 2 root root 4096 Jul 18 19:19 apt
-rw-rw---- 1 root utmp 0 Apr 23 13:43 btmp
drwxr-xr-x 2 root root 4096 Apr 8 22:59 dist-upgrade
-rw-r--r-- 1 root root 68296 Jul 18 19:19 dpkg.log
drwxr-sr-x 2 root systemd-journal 4096 Apr 23 13:40 journal
drwxr-xr-x 2 landscape landscape 4096 Apr 14 22:07 landscape
-rw-rw-r-- 1 root utmp 292292 Jul 18 19:00 lastlog
drwxr-x--- 2 root adm 4096 Apr 14 05:37 unattended-upgrades
-rw-rw-r-- 1 root utmp 0 Apr 23 13:43 wtmp -
sudo vim /var/log/auto.log could belong to root.