Saturday, February 4, 2012

Linux Tips and Tricks, Part 2

Hello there! If you are new here, you might want to subscribe to the RSS feed to receive updates.
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:
:>filename
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:
date MMDDHHMMYYYY.SS
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.):
blkid
That’s it for this round. Have fun!

0 comments:

Post a Comment