LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 08-15-2020, 06:23 PM   #16
sgosnell
Senior Member
 
Registered: Jan 2008
Location: Baja Oklahoma
Distribution: Debian Stable and Unstable
Posts: 1,943

Rep: Reputation: 542Reputation: 542Reputation: 542Reputation: 542Reputation: 542Reputation: 542

The reason the clamscan -r /home >> /home/user/clamscanresults.log didn't work is that >> redirects to an existing file, it doesn't create one if it doesn't exist. To get an empty file, use
Code:
touch /home/user/clamscanresults.log
But that won't work on your system either, because you have to replace 'user' with your username.
Code:
/home/alex/clamscanresults.log
There should be no user named user on the system. Anytime you see that in an example, you're expected to substitute your own username.
 
Old 08-15-2020, 07:12 PM   #17
alex4buba
Member
 
Registered: Jul 2020
Posts: 624

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by sgosnell View Post
The reason the clamscan -r /home >> /home/user/clamscanresults.log didn't work is that >> redirects to an existing file, it doesn't create one if it doesn't exist. To get an empty file, use
Code:
touch /home/user/clamscanresults.log
But that won't work on your system either, because you have to replace 'user' with your username.
Code:
/home/alex/clamscanresults.log
There should be no user named user on the system. Anytime you see that in an example, you're expected to substitute your own username.
So, you mean - I have to create an empty file xxx.log and place it into that folder?

Many thanks
Alex
 
Old 08-15-2020, 07:25 PM   #18
John VV
LQ Muse
 
Registered: Aug 2005
Location: A2 area Mi.
Posts: 17,627

Rep: Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651
your almost getting it

sogsnell posted one way
run this BEFORE YOU GO TO BED AT NIGHT
-- run it AS ROOT
Code:
su -
---type in your root password when asked for ---
clamscan -r /
this will take some time so - GO TO BED
in the morning you will have the output


99.99999% of the time it is clean , with the exception of Microsoft Windows malware in email attachments

you really need to be more afraid of Rootkits
to scan for those install " chkrootkit"
it is in the ubuntu repos , and is a comandline tool ( no gui)
 
Old 08-15-2020, 08:11 PM   #19
alex4buba
Member
 
Registered: Jul 2020
Posts: 624

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by sgosnell View Post
A couple of things:

clamav must be run as root, so either log in as root or use sudo.

If you want to scan the entire drive, use
Code:
clamscan -r /
Scanning the entire disk will take a looooooonnnggg time, so set the cronjob to run while you're in bed sleeping, not while you're trying to do work on the computer.

You don't run !bin/bash in a terminal, you put it into a text file as the first line. Linux runs almost entirely on text files. Open your favorite text editor, put the suggested lines into it, and save the file. From a terminal I like nano, but there are others. I can't remember what Gnome uses for a text editor, but it should be easy enough to find.
OK, It took over two hours... I didn't realize that it will also scan my external devices (two hard disks and one SD 512GB.... I was doing other things while this was running... A big part of the time was spent on checking the Evolution database...

Anyway, below is a screen shot of the end message. How can I find out what are the 70 infected files?
I can see now - why NOT to ever run this again, but then the question is - what Folders should I run?

Cheers
Alex

----------- SCAN SUMMARY -----------
Known viruses: 8468537
Engine version: 0.102.4
Scanned directories: 78046
Scanned files: 563668
Infected files: 70
Total errors: 90793
Data scanned: 56575.53 MB
Data read: 90301.40 MB (ratio 0.63:1)
Time: 7454.258 sec (124 m 14 s)
 
Old 08-16-2020, 12:43 AM   #20
John VV
LQ Muse
 
Registered: Aug 2005
Location: A2 area Mi.
Posts: 17,627

Rep: Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651
are you running a email server ?

or are you sharing this linux install with a windows install ?

there will be a log file in
/var/log/clamav ( or something like that )


the only hits i get are from attachments in emails
and then 99.9% of the time it is a SPAM mail


as above viruses are not a issue
rootkits are


there are about 3.5 million micrsoft viruses
and about 12 to 36 linux viruses

and about 24 rootkits
 
Old 08-16-2020, 01:53 AM   #21
alex4buba
Member
 
Registered: Jul 2020
Posts: 624

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by John VV View Post
are you running a email server ?

or are you sharing this linux install with a windows install ?

there will be a log file in
/var/log/clamav ( or something like that )


the only hits i get are from attachments in emails
and then 99.9% of the time it is a SPAM mail


as above viruses are not a issue
rootkits are


there are about 3.5 million micrsoft viruses
and about 12 to 36 linux viruses

and about 24 rootkits
In that folder, I found two log files
clamav.log and freshclam.log
I have no idea what to look for?

Not sure, should I load those files back to this message?

Cheers
Alex
 
Old 08-16-2020, 01:59 AM   #22
alex4buba
Member
 
Registered: Jul 2020
Posts: 624

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by alex4buba View Post
In that folder, I found two log files
clamav.log and freshclam.log
I have no idea what to look for?

Not sure, should I load those files back to this message?

Cheers
Alex
I ran chkrootkit, the only thing it found is the following. SHould I do anything about this?

Searching for suspicious files and dirs, it may take a while... The following suspicious files and directories were found:
/usr/lib/debug/.build-id /usr/lib/modules/5.4.0-26-generic/vdso/.build-id /usr/lib/modules/5.4.0-42-generic/vdso/.build-id
/usr/lib/debug/.build-id /usr/lib/modules/5.4.0-26-generic/vdso/.build-id /usr/lib/modules/5.4.0-42-generic/vdso/.build-id
 
Old 08-16-2020, 03:08 AM   #23
alex4buba
Member
 
Registered: Jul 2020
Posts: 624

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by Hermani View Post
Hi Alex4Buba,

You're on the right track, because you (already) installed ClamAV.

If you need something to be done in Linux on a regular basis, it is done by a so-called crontab command. This is a list in which you can tell the system what things to do every x amount of time. There are some desktop tools that can do the same however they mostly rely on crontab. And because crontab is found on every Linux installation and always works well, it is nice to use and rely on.

There is a system crontab list you can edit that works with superuser privileges, and every user on the system has its own crontab list to perform tasks with the privileges of that user.

For a tutorial on how to use crontab, take a look at one of the following (there are many more):
You can run commands in the crontab. However for me the best thing to do is to
  1. Make a shell script (this is like a Windows / MS-DOS batch file)
  2. Make an entry in the crontab pointing to the shell script
This way you can easily change, modify or extend the command. There are a lot of tutorials about how to write a shell script. The most simple script to run clamav would be something like this:

Code:
!/bin/sh
clamscan -r /home >> /home/user/clamscanresults.log
The first line of code is necessary (I don't know why) and can also be !/bin/bash, if your system runs BASH as well.

The second line of code is the clamscan command you want to issue. The output that normally would be sent to the terminal is now routed to a file called "clamscanresults.log" (you can pick any name). Because I used >> any existing log file is appended, not replaced.

If you save this text file as eg "scancommand.sh" you have a shell script. PLEASE do not forget to enable execution for the shell script - you can do it through the file manager or by issuing a command like

Code:
chmod +x scancommand.sh
Next, you can modify the crontab. If you want to have all users in /home scanned, you might use the systemwide crontab. So you fire up the crontab editor using the following command

Code:
sudo crontab -e
Then you just have to put in the code for the timing of your shellscript and of course, the name and path of your script. If you wanted to edit your user's crontab you could use the following command

Code:
crontab -e
Hope I got you started!
OK, I am back... Fantastic tutorial, thanks again. Still fails on executing !/bin/sh or !/bin/bash but it seems I can continue without it. The tutorial I looked at is : https://www.cyberciti.biz/faq/how-do...-or-unix-oses/

I generally speaking, opt for written tutorials, not YT video clips, but that's just me. From that tutorial, I gather that cron is a batch file executor of a script, kind of what I used to do with .bat files in the DOS days.

I hope that I will be able to create a .sh (I assume this is a shell script) from the examples on the above tutorial to execute my automated clamav daily scan.

Many thanks again
Alex
 
Old 08-16-2020, 05:52 AM   #24
hazel
LQ Guru
 
Registered: Mar 2016
Location: Harrow, UK
Distribution: LFS, AntiX, Slackware
Posts: 7,637
Blog Entries: 19

Rep: Reputation: 4469Reputation: 4469Reputation: 4469Reputation: 4469Reputation: 4469Reputation: 4469Reputation: 4469Reputation: 4469Reputation: 4469Reputation: 4469Reputation: 4469
Quote:
Originally Posted by alex4buba View Post
alex@alex-NUC8i7HNK:~$ !/bin/sh
bash: !/bin/sh: event not found
alex@alex-NUC8i7HNK:~$ !/bin/bash
bash: !/bin/bash: event not found
alex@alex-NUC8i7HNK:~$
That was a misprint on hermani's part. They meant to say #!/bin/sh. This is called a hashbang and indicates to the script what program is required to run it (in this case the system shell).

But ! by itself has a special meaning in Linux shells. It means "Go back to when I last used this command and repeat it exactly, with the same arguments". That can be a useful and quick way of repeating an operation, but obviously it doesn't work if you haven't used the command before. Hence the message "event not found".
 
1 members found this post helpful.
Old 08-16-2020, 07:25 AM   #25
alex4buba
Member
 
Registered: Jul 2020
Posts: 624

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by hazel View Post
That was a misprint on hermani's part. They meant to say #!/bin/sh. This is called a hashbang and indicates to the script what program is required to run it (in this case the system shell).

But ! by itself has a special meaning in Linux shells. It means "Go back to when I last used this command and repeat it exactly, with the same arguments". That can be a useful and quick way of repeating an operation, but obviously it doesn't work if you haven't used the command before. Hence the message "event not found".
OK, I am learning... a lot each day

What is this command anyway? #!/bin/sh

Cheers
Alex
 
Old 08-16-2020, 07:48 AM   #26
hazel
LQ Guru
 
Registered: Mar 2016
Location: Harrow, UK
Distribution: LFS, AntiX, Slackware
Posts: 7,637
Blog Entries: 19

Rep: Reputation: 4469Reputation: 4469Reputation: 4469Reputation: 4469Reputation: 4469Reputation: 4469Reputation: 4469Reputation: 4469Reputation: 4469Reputation: 4469Reputation: 4469
Quote:
Originally Posted by alex4buba View Post
OK, I am learning... a lot each day

What is this command anyway? #!/bin/sh

Cheers
Alex
A script can't be run directly on the cpu because it's text, not machine code. So a program that can interpret the script must be loaded first and the script passed to it for interpretation and execution. That is why the first non-comment line of a script is always the hashbang (or shebang). This tells the kernel what program to load. /bin/sh is a symbolic link to the system shell (usually either /bin/bash or /bin/dash). They are very similar, so it doesn't usually matter which one is run. If it does matter, for example if your script contains a bit of syntax that only bash supports, you can use the hashbang #!/bin/bash.

Perl and Python scripts work in exactly the same way.

Last edited by hazel; 08-16-2020 at 07:59 AM.
 
Old 08-16-2020, 03:19 PM   #27
Hermani
Member
 
Registered: Apr 2018
Location: Delden, NL
Distribution: Ubuntu
Posts: 261
Blog Entries: 3

Rep: Reputation: 113Reputation: 113
Quote:
Originally Posted by hazel View Post
That was a misprint on hermani's part.
Have corrected my previous post, and I am sorry I did not tell about the touch part.

I am sorry, Hazel and Alex I am still a bit of a n00b too, but I recently have had to figure this all out as well.
 
Old 08-16-2020, 03:45 PM   #28
alex4buba
Member
 
Registered: Jul 2020
Posts: 624

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by Hermani View Post
Have corrected my previous post, and I am sorry I did not tell about the touch part.

I am sorry, Hazel and Alex I am still a bit of a n00b too, but I recently have had to figure this all out as well.
Hi Hermani,

I am a 75 years "Young" retired guy, continue building websites. I have learned a lot in my journey, by making mistakes, you only make them if you do things....

Cheers
Alex
 
Old 08-16-2020, 03:51 PM   #29
Hermani
Member
 
Registered: Apr 2018
Location: Delden, NL
Distribution: Ubuntu
Posts: 261
Blog Entries: 3

Rep: Reputation: 113Reputation: 113
Quote:
Originally Posted by alex4buba View Post
From that tutorial, I gather that cron is a batch file executor of a script, kind of what I used to do with .bat files in the DOS days.
You could say
  1. a shell script (.sh file) is about the same as a MS-DOS batch file (.bat)
  2. the crontab is a special file that executes programs / commands / shell scripts on a regular basis.
The reason I recommended using a shell script is because I find it is more easy to modify, and I can put extra commands in that can add extra information in a log file, for instance the date and time of an event.

When you get the hang of it, it is quite easy if you have programmed MS-DOS batch files before.

For instance, I use a backup server that I programmed to make a backup copy of my main server on a daily basis. It works fully autonomous and I have zero interaction with it (next to the infrequent check-up and update/upgrade). Also I programmed a small SBC (single board computer) as a secondary backup-server that also makes a daily backup of the most important data, also with zero interaction. Next to that, I have programmed my main server to make a backup of an online Nextcloud server. It all works flawlessly, and I can tell because I have the shell scripts make log files I can read.
 
Old 08-16-2020, 05:56 PM   #30
alex4buba
Member
 
Registered: Jul 2020
Posts: 624

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by Hermani View Post
You could say
  1. a shell script (.sh file) is about the same as a MS-DOS batch file (.bat)
  2. the crontab is a special file that executes programs / commands / shell scripts on a regular basis.
The reason I recommended using a shell script is because I find it is more easy to modify, and I can put extra commands in that can add extra information in a log file, for instance the date and time of an event.

When you get the hang of it, it is quite easy if you have programmed MS-DOS batch files before.

For instance, I use a backup server that I programmed to make a backup copy of my main server on a daily basis. It works fully autonomous and I have zero interaction with it (next to the infrequent check-up and update/upgrade). Also I programmed a small SBC (single board computer) as a secondary backup-server that also makes a daily backup of the most important data, also with zero interaction. Next to that, I have programmed my main server to make a backup of an online Nextcloud server. It all works flawlessly, and I can tell because I have the shell scripts make log files I can read.
Hello again,

I am a retired guy, working at home on building websites as a voluntary occupation, not for money. Since you mentioned backup, I will use that.

1) I have only ONE single computer
2) I only want to backup a list of selected folders to a single exteranal stotrage device (SSD). Each source folder to be copied into a target folder with the same name.
3) I do NOT want to backup to the cloud or anything else
4) I want to do it say, once a day - at 2:00 pm every day
5) I want the backup to be simple copy, not compressed

Is there a way to specify how many "Versions" to keep so that the external storage device doen't fill up?

I want to backup the following folders, for example - folder1, folder2, folder 3

So, what will the script.sh look like?

All of the above again, for virus check using clamav - How do I "know" which folders I need to check? How will an .sh script look for this?

Thaks again
Alex
 
  


Reply

Tags
20.04, ubuntu 18.04, virus antivirus



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Do I need a firewall and virus protection for Ubuntu? adhinsley Linux - Newbie 31 10-13-2009 10:56 AM
LXer: Virus Protection With F-PROT Antivirus On Ubuntu Feisty Fawn LXer Syndicated Linux News 0 09-24-2007 02:10 PM
LXer: Virus Protection With AVG Antivirus On Ubuntu Feisty Fawn LXer Syndicated Linux News 0 09-12-2007 06:21 PM
Boot virus or Anti-Virus? AVG Free Anti-Virus Software problems SparceMatrix Linux - Security 9 08-02-2004 02:35 PM
virus protection p_murugappan Linux - General 1 07-11-2001 08:40 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 11:04 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration