18 February 2011

LinuxClick here to read Part 1!

I’m going to assume that you know how to do some basic stuff in Linux. In other words, if you don’t know what a command line is, or how to traverse directories, this might not help you much.

I should also note that my preferred flavor of Linux is Ubuntu. These commands will work on Ubuntu, but I can’t make any guarantees for other distributions. Best to just try them out and see what happens!

Without further ado, here are some more of the top linux tips and tricks that I have gathered over the years…

Show current Ubuntu version:

lsb_release -a

Count number of files in the current directory:

ls -1 | wc -l

Find files edited in last 1 day in the current directory:

find ./ -ctime -1 -print

Empty a file’s contents of all but the last 5 lines:

tail -5 file.nam > file.nam

Truncate a file to zero length:


Show version/dependency info for a given [package name]:

dpkg -s [package name]/mysql

See what installed packages still have stuff pointing to a location such as /etc/mysql:

dpkg -S etc/mysql

Set time, data, and timezone:

Set the time zone:

dpkg-reconfigure tzdata

Set time/date with 24-hour HH value:


Sync hardware clock to system clock:

hwclock --utc --systohc

Get drive info:

fdisk -l
hdparm -i /dev/sda

(substitute /dev/XXX for /dev/sda)

Show partition info (UUID, TYPE, etc.):


That’s it for this round. Have fun!

Linux Tips and Tricks, Part 2
Tagged on:     

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.