By default, grep command prints the matching lines You can pass -H option to print the filename for each match.
$ grep -H -r “irfan” /etc/passwd
$ grep -H -r “irfan” /etc/passwd
dconf reset -f /org/gnome/gnome-panel/
killall gnome-panel
# find . -name tecmint.txt ./tecmint.txt
# find /home -name tecmint.txt /home/tecmint.txt
# find /home -iname tecmint.txt ./tecmint.txt ./Tecmint.txt
# find / -type d -name Tecmint /Tecmint
# find . -type f -name tecmint.php ./tecmint.php
# find . -type f -name "*.php" ./tecmint.php ./login.php ./index.php
# find . -type f -perm 0777 -print
# find / -type f ! -perm 777
# find / -perm 2644
# find / -perm 1551
# find / -perm /u=s
# find / -perm /g+s
# find / -perm /u=r
# find / -perm /a=x
# find / -type f -perm 0777 -print -exec chmod 644 {} \;
# find / -type d -perm 777 -print -exec chmod 755 {} \;
# find . -type f -name "tecmint.txt" -exec rm -f {} \;
# find . -type f -name "*.txt" -exec rm -f {} \; OR # find . -type f -name "*.mp3" -exec rm -f {} \;
# find /tmp -type f -empty
# find /tmp -type d -empty
# find /tmp -type f -name ".*"
# find / -user root -name tecmint.txt
# find /home -user tecmint
# find /home -group developer
# find /home -user tecmint -iname "*.txt"
# find / -mtime 50
# find / -atime 50
# find / -mtime +50 –mtime -100
# find / -cmin -60
# find / -mmin -60
# find / -amin -60
# find / -size 50M
# find / -size +50M -size -100M
# find / -size +100M -exec rm -rf {} \;
# find / -type f -name *.mp3 -size +10M -exec ls -l {} \;
$ crontab -e
1 2 3 4 5 /path/to/command arg1 arg2OR
1 2 3 4 5 /root/backup.shWhere,
* * * * * command to be executed - - - - - | | | | | | | | | ----- Day of week (0 - 7) (Sunday=0 or 7) | | | ------- Month (1 - 12) | | --------- Day of month (1 - 31) | ----------- Hour (0 - 23) ------------- Minute (0 - 59)Your cron job looks as follows for system jobs:
1 2 3 4 5 USERNAME /path/to/command arg1 arg2
OR1 2 3 4 5 USERNAME /path/to/script.sh
# crontab -e
0 3 * * * /root/backup.sh
5 0 * * * /path/to/command
15 14 1 * * /path/to/script.sh
0 22 * * 1-5 /scripts/phpscript.php
23 0-23/2 * * * /root/scripts/perl/perlscript.pl
5 4 * * sun /path/to/unixcommand
0 3 * * * /root/backup.sh >/dev/null 2>&1
MAILTO="vivek@nixcraft.in"
0 3 * * * /root/backup.sh >/dev/null 2>&1
# crontab -l
# crontab -u username -l
# crontab -r
crontab -r -u username
Special string | Meaning | |||||
@reboot | Run once, at startup. | |||||
@yearly | Run once a year, "0 0 1 1 *". | |||||
@annually | (same as @yearly) | |||||
@monthly | Run once a month, "0 0 1 * *". | |||||
@weekly | Run once a week, "0 0 * * 0". | |||||
@daily | Run once a day, "0 0 * * *". | |||||
@midnight | (same as @daily) | |||||
@hourly | Run once an hour, "0 * * * *". |
sudo apt-get install gnome-schedule
You can create a cron.log file to contain just the CRON entries that show up in syslog. Note that CRON jobs will still show up in syslog if you follow the following directions.
/etc/rsyslog.d/50-default.conf
Find the line that starts with: #cron.*
uncomment that line, save the file, and restart rsyslog: sudo service rsyslog restart
You should now see a cron log file here: /var/log/cron.log
Cron activity will now be logged to this file (in addition to syslog).
# tcptrack -i eth0
[shredder12]$ netstat -n -A inet-n is used to display numeric addresses instead of trying to determine symbolic hostnames
[shredder12]$ lsof -i
[shredder12]$ netstat -n -A inet
[shredder12]$ lsof -i
[shredder12]$ netstat --listen -A inet
[shredder12]$ netstat -n -A inet -tsimilarly, -u for UDP connections.
[shredder12]$ lsof -i4TCPPlease note no space between i4 and TCP. This means TCP connections on IPv4 network. Similary one can use i6 for IPv6 and UDP for udp connections.
[shredder12]$ netstat -A inet -n -p | grep 1413You can find out the PID of a process using ps or pgrep.
[shredder12]$ ps -e | grep firefox
[shredder12]$ pgrep firefox
[shredder12]$ lsof -i4TCP -a -p 1413The -a flag is used to tell lsof to AND the result of all the options used.