How to Clear syslog Log Files in Linux

Many Linux distributions are preconfigured to automatically and periodically rotate syslog log files by means of cron jobs that call logrotate or a similar log rotation script. However, if you want to clear a log file manually, you can simply use the greater than sign followed by the log file name. For example, to manually clear the file kern.log, you can run this command:

me@mycomputer:> /var/log/kern.log

The beauty of this is that the cleared out file still retains its original permissions and ownership.

Displaying Masqueraded Connections

I often use Linux’s netstat command to do things like figuring out which ports are listening on a computer and what are the active connections on a computer. It’s very handy for troubleshooting networking problems.

Today I wanted to figure out what sites a certain user on my network was connecting to and how much traffic the user was using. I connected to the router with SSH and ran netstat with no options. I was surprised to see only my SSH connection. Then I remembered that the user in question gets onto the internet with a masqueraded address. Well, duh! Continue reading » Displaying Masqueraded Connections

Linux traceroute vs Windows tracert

Anyone who has used Linux traceroute and Windows tracert knows that the two programs have very different command line options. But did you know that there is a fundamental difference in the way that these two programs work? Continue reading » Linux traceroute vs Windows tracert

How to Sort Files By Modification Time in ls

To sort files by modification time when using ls, use the -t option. For example, to sort in descending order:

[me@mycomputer usr]$ ls -lt
total 224
drwxr-xr-x   88 root root 65536 Sep  1 17:39 lib
drwxr-xr-x   14 root root  4096 Sep  1 16:00 local
drwxr-xr-x    2 root root 12288 Jul 26 04:04 sbin
drwxr-xr-x  174 root root  4096 Jul 25 19:01 share
drwxr-xr-x    2 root root 40960 Jan 25  2006 bin
drwxr-xr-x    7 root root  4096 Jan 16  2006 libexec
drwxr-xr-x    3 root root  4096 Oct 16  2005 java
drwxr-xr-x   61 root root 12288 Mar 13  2005 include
drwxr-xr-x    4 root root  4096 Mar 13  2005 src
lrwxrwxrwx    1 root root    10 Mar 13  2005 tmp -> ../var/tmp
drwxr-xr-x    6 root root  4096 Feb 27  2005 kerberos
drwxr-xr-x    2 root root  4096 Feb 22  2005 etc
drwxr-xr-x    2 root root  4096 Feb 22  2005 games
drwxr-xr-x    7 root root  4096 Feb 21  2005 X11R6

To sort in descending order, add the -r option:

[me@mycomputer usr]$ ls -ltr
total 224
drwxr-xr-x    7 root root  4096 Feb 21  2005 X11R6
drwxr-xr-x    2 root root  4096 Feb 22  2005 games
drwxr-xr-x    2 root root  4096 Feb 22  2005 etc
drwxr-xr-x    6 root root  4096 Feb 27  2005 kerberos
lrwxrwxrwx    1 root root    10 Mar 13  2005 tmp -> ../var/tmp
drwxr-xr-x    4 root root  4096 Mar 13  2005 src
drwxr-xr-x   61 root root 12288 Mar 13  2005 include
drwxr-xr-x    3 root root  4096 Oct 16  2005 java
drwxr-xr-x    7 root root  4096 Jan 16  2006 libexec
drwxr-xr-x    2 root root 40960 Jan 25  2006 bin
drwxr-xr-x  174 root root  4096 Jul 25 19:01 share
drwxr-xr-x    2 root root 12288 Jul 26 04:04 sbin
drwxr-xr-x   14 root root  4096 Sep  1 16:00 local
drwxr-xr-x   88 root root 65536 Sep  1 17:39 lib
Page 5 of 6« First...«23456»