
Terminal - Commands using tail - 209 results
ls -drt /var/log/* | tail -n5 | xargs sudo tail -n0 -f
This is sample output - yours may be different.
==> /var/log/cron <==
==> /var/log/messages <==
==> /var/log/lastlog <==
==> /var/log/wtmp <==
==> /var/log/secure <==
==> /var/log/lastlog <==
==> /var/log/wtmp <==
�1pts/4ts/4myusermyhost.example.com�fJ��?
==> /var/log/secure <==
Jul 21 18:36:19 thost sshd[12730]: Accepted password for myuser from 192.168.100.7 port 50066 ssh2
Jul 21 18:36:19 thost sshd[12730]: pam_unix(sshd:session): session opened for user myuser by (uid=0)
This command finds the 5 (-n5) most frequently updated logs in /var/log, and then does a multifile tail follow of those log files.
Alternately, you can do this to follow a specific list of log files:
sudo tail -n0 -f /var/log/{messages,secure,cron,cups/error_log}
cp `ls -x1tr *.jpg | tail -n 1` newest.jpg
This is sample output - yours may be different.
search the newest *.jpg in the directory an make a copy to newest.jpg. Just change the extension to search other files. This is usefull eg. if your webcam saves all pictures in a folder and you like the put the last one on your homepage. This works even in a directory with 10000 pictures.
find /var/log -type f -exec file {} \; | grep 'text' | cut -d' ' -f1 | sed -e's/:$//g' | grep -v '[0-9]$' | xargs tail -f
This is sample output - yours may be different.
Works in Ubuntu, I hope it will work on all Linux machines. For Unixes, tail should be capable of handling more than one file with '-f' option.
This command line simply take log files which are text files, and not ending with a number, and it will continuously monitor those files.
Putting one alias in .profile will be more useful.
tail -f FILE | perl -pe 's/KEYWORD/\e[1;31;43m$&\e[0m/g'
This is sample output - yours may be different.
lynx -source http://www.commandlinefu.com/commands/random | sed 's/<[^>]*>//g' | head -1037 | tail -10 | sed -e 's/^[ \t]*//' | sed '/^$/d' | head -2
This is sample output - yours may be different.
Terminal - runs a bash script in debugging mode
bash -x ./post_to_commandlinefu.sh
ok I'm sure it's not pretty
F="$HOME/.moz*/fire*/*/session*.js" ; grep -Go 'entries:\[[^]]*' $F | cut -d[ -f2 | while read A ; do echo $A | sed s/url:/\n/g | tail -1 | cut -d\" -f2; done
This is sample output - yours may be different.
Tuned for short command line - you can set the path to sessionstore.js more reliable instead of use asterixes etc.
Usable when you are not at home and really need to get your actual opened tabs on your home computer (via SSH). I am using it from my work if I forgot to bookmark some new interesting webpage, which I have visited at home. Also other way to list tabs when your firefox has crashed (restoring of tabs doesn't work always).
This script includes also tabs which has been closed short time before.
tail -f --retry /var/log/syslog /var/log/auth.log | ccze -A
This is sample output - yours may be different.
ps -eo user,pcpu,pmem | tail -n +2 | awk '{num[$1]++; cpu[$1] += $2; mem[$1] += $3} END{printf("NPROC\tUSER\tCPU\tMEM\n"); for (user in cpu) printf("%d\t%s\t%.2f%\t%.2f%\n",num[user], user, cpu[user], mem[user]) }'
This is sample output - yours may be different.
NPROC USER CPU MEM
16 web2 10.80% 0.00%
1 rpc 0.00% 0.00%
44 web 18.30% 1.70%
9 patrol 0.00% 0.00%
11 wikimoe 0.00% 1.50%
11 gipce 0.00% 0.40%
3 68 0.00% 0.00%
1 dbus 0.00% 0.00%
1 rpcuser 0.00% 0.00%
1 named 0.30% 0.00%
11 wikiprod 0.20%
2 appli 0.00% 0.00%
1 smmsp 0.00% 0.00%
2 avahi 0.00% 0.00%
10 webdba 0.00% 0.00%
1 xfs 0.00% 0.00%
1 ntp 0.00% 0.00%
281 root 2.30% 8.10%
It's like `prstat -t` under Solaris
function jumpTo { xmms2 jump `xmms2 list | grep -i '$1' | head -n 1 | tail -n 1 | sed -re 's@.+\[(.+)/.+\] (.+)@\1@'`; }
This is sample output - yours may be different.
Usage:
Declare this function in your Shell, then use it like this:
> jumpTo foo
The script will search for the 'foo' pattern in your current xmms2 playlist (artist or songname), and play the first occurence of it !
ps aux | sort +2n | tail -20
This is sample output - yours may be different.
This command will show the 20 processes using the most CPU time (hungriest at the bottom).
You can see the 20 most memory intensive processes (hungriest at the bottom) by running:
ps aux | sort +3n | tail -20
Or, run both:
echo "CPU:" && ps aux | sort +2n | tail -20 && echo "Memory:" && ps aux | sort +3n | tail -20
du -xk | sort -n | tail -20
This is sample output - yours may be different.
This command will tell you the 20 biggest directories starting from your working directory and skips directories on other filesystems. Useful for resolving disk space issues.
while [ 1 ]; do echo -n "`date +%F_%T`" ; vmstat 1 2 | tail -1 ; sleep 4; done
This is sample output - yours may be different.
2009-03-26_15:13:49 0 0 536 27724 4236 699064 0 0 0 0 1306 413 2 1 98 0
2009-03-26_15:13:54 0 0 536 27212 4244 699576 0 0 0 0 1182 266 1 0 99 0
2009-03-26_15:13:59 0 0 536 26764 4252 699828 0 0 0 0 1229 330 1 0 98 0
2009-03-26_15:14:04 0 0 536 26508 4260 700080 0 0 0 0 1307 465 2 1 98 0
See man vmstat for information about the statistics.
This does the same thing without the timestamp:
vmstat 5
tail -f logfile.log | cut -b 1-80
This is sample output - yours may be different.
This truncates any lines longer than 80 characters. Also useful for looking at different parts of the line, e.g. cut -b 50-100 shows columns 50 through 100.
history | perl -lane '$lsize{$_} = scalar(@F); if($longest<$lsize{$_}) { $longest = $lsize{$_}; print "$_"; };' | tail -n1
This is sample output - yours may be different.
INFILE=/path/to/your/backup.img; MOUNTPT=/mnt/foo; PARTITION=1; mount "$INFILE" "$MOUNTPT" -o loop,offset=$[ `/sbin/sfdisk -d "$INFILE" | grep "start=" | head -n $PARTITION | tail -n1 | sed 's/.*start=[ ]*//' | sed 's/,.*//'` * 512 ]
This is sample output - yours may be different.
alanceil@kvirasim:22:20:1:~> /sbin/sfdisk -d disk.img
# partition table of disk.img
unit: sectors
disk.img1 : start= 63, size= 128457, Id=83
disk.img2 : start= 0, size= 0, Id= 0
disk.img3 : start= 0, size= 0, Id= 0
disk.img4 : start= 0, size= 0, Id= 0
root@kvirasim:22:20:0:~> INFILE=/home/alanceil/disk.img; MOUNTPT=/mnt/gen; PARTITION=1; mount "$INFILE" "$MOUNTPT" -o loop,offset=$[ `/sbin/sfdisk -d "$INFILE" | grep "start=" | head -n $PARTITION | tail -n1 | sed 's/.*start=[ ]*//' | sed 's/,.*//'` * 512 ]
root@kvirasim:22:22:0:~> mount | grep gen
/dev/loop0 on /mnt/gen type ext2 (rw,offset=32256)
Suppose you made a backup of your hard disk with dd:
dd if=/dev/sda of=/mnt/disk/backup.img
This command enables you to mount a partition from inside this image, so you can access your files directly.
Substitute PARTITION=1 with the number of the partition you want to mount (returned from sfdisk -d yourfile.img).
cat $(ls -tr | tail -1) | awk '{ a[$1] += 1; } END { for(i in a) printf("%d, %s\n", a[i], i ); }' | sort -n | tail -25
This is sample output - yours may be different.
348, 192.22.16.56
358, 192.240.8.178
360, 192.107.248.220
394, 192.206.78.2
424, 192.242.141.25
426, 192.175.45.153
440, 192.51.107.202
493, 192.215.222.135
500, 192.20.53.245
688, 192.164.143.36
732, 192.139.1.20
This command is much quicker than the alternative of "sort | uniq -c | sort -n".
This is sample output - yours may be different.
root@llistes:/var/log/mailman# tail -f *[!.1][!.gz]
==> error <==
==> post <==
==> qrunner <==
Mar 06 06:31:51 2009 (30465) OutgoingRunner qrunner caught SIGHUP. Reopening logs.
Mar 06 06:31:51 2009 (30464) NewsRunner qrunner caught SIGHUP. Reopening logs.
Mar 06 06:31:51 2009 (30467) RetryRunner qrunner caught SIGHUP. Reopening logs.
Mar 06 06:31:51 2009 (30466) VirginRunner qrunner caught SIGHUP. Reopening logs.
Mar 06 06:31:51 2009 (30461) BounceRunner qrunner caught SIGHUP. Reopening logs.
Mar 06 06:31:51 2009 (30463) IncomingRunner qrunner caught SIGHUP. Reopening logs.
Mar 06 06:31:51 2009 (30462) CommandRunner qrunner caught SIGHUP. Reopening logs.
Mar 06 06:31:51 2009 (30460) ArchRunner qrunner caught SIGHUP. Reopening logs.
Mar 06 06:31:51 2009 (30455) Master watcher caught SIGHUP. Re-opening log files.
==> smtp <==
==> subscribe <==
Mar 05 13:49:58 2009 (32332) test: new dreg@dreg.com,
Mar 05 13:49:58 2009 (32332) test: new nice@renice.co.uk,
Mar 05 13:49:58 2009 (32332) test: new thisisanemail@somailed.it,
==> vette <==
with discard wilcards in bash you can "tail" newer logs files to see what happen, any error, info, warn...
du | sort -n | tail -11 | head
This is sample output - yours may be different.
The pipe to head removes the listing of . as the largest directory.
tail -n 0 -f /var/log/messages
This is sample output - yours may be different.
In this case, I'm keeping an eye on /var/log/messages, but of course any file will do. When I'm following a file, I generally don't want to see anything other than what has been added due to the command or service I've executed. This keeps everything clean and tidy for troubleshooting.
tail -f file1 (file2 .. fileN)
This is sample output - yours may be different.
~$ tail -f file1 file2
==> file1 <==
==> file2 <==
==> file1 <==
new line in file1
==> file2 <==
new line in file2
Useful to e.g. keep an eye on several logfiles.
tail -n 15 /var/log/yum.log | tac
This is sample output - yours may be different.
It displays, last 15 yum operations (in last operation as first row order) with its dates. Change 15 to any number of operations you need to display or remove "| tac" to see it in reverse order (last operation as last row)
tail -1000 /some/file | vim -
This is sample output - yours may be different.
The hyphen tells vim to open from STDOUT - saves having to create temporary files.
tail -n 20 ~/Library/Logs/FileSyncAgent.log
This is sample output - yours may be different.
[2009/02/18 23:48:00.697] Starting automatic sync of "HomeSync_Mirror".
[2009/02/18 23:48:20.743] EXCEPTION: Unable to mount remote home volume (Carbon error -2)
[2009/02/18 23:48:20.744] Peer "network" is unable to sync. Not enough peers will be available to continue syncing.
[2009/02/18 23:48:20.744] Aborting sync of "HomeSync_Mirror".
[2009/02/18 23:51:18.084] Sync of "HomeSync_Mirror" encountered errors. (Unable to mount remote home volume (Carbon error -2))
[2009/02/18 23:51:18.084] Last successful sync completed at 2009-02-17 19:38:19 -0500.
[2009/02/18 23:51:18.085] Finished sync of "HomeSync_Mirror".
tail would be considered dull, but pair this with being able to push out unix commands over ARD, and life gets easier. (Same can be said for my TimeMachine scrape command, http://xrl.us/begrzb)
syslog -F '$Time $Message' -k Sender /System/Library/CoreServices/backupd -k Time ge -72h | tail -n 30
This is sample output - yours may be different.
Tue Feb 17 19:38:13 No pre-backup thinning needed: 603.9 MB requested (including padding), 4.73 GB available
Tue Feb 17 19:39:47 Copied 23039 files (33.8 MB) from volume 200GBsOfPurePower.
Tue Feb 17 19:39:47 No pre-backup thinning needed: 563.3 MB requested (including padding), 4.69 GB available
Tue Feb 17 19:40:05 Copied 492 files (60 KB) from volume 200GBsOfPurePower.
Tue Feb 17 19:40:13 Starting post-backup thinning
Tue Feb 17 19:40:13 No post-back up thinning needed: no expired backups exist
Tue Feb 17 19:40:13 Backup completed successfully.
Tue Feb 17 19:40:19 Ejected Time Machine disk image.
Tue Feb 17 19:40:23 Ejected Time Machine network volume.
Wed Feb 18 08:58:36 Starting standard backup
While they are few config options and even fewer useful details regarding what actually is being sent by the time machine 'backupd' process, this can at least tell you its doing something, how much it's doing, and exactly how often. Via macosxhints, http://xrl.us/begrwa, which in turn was via comments
tail -f /path/to/timestamped/files/file-*(om[1])
This is sample output - yours may be different.
zsh only
If you have this command in your history, you can always re-run it and have it reference the latest file.
The glob matches all timestamped files and then the resulting array is sorted by modification time (m) and then the first element in the sorted array is chosen (the latest)