LinuxI’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 of the top linux tips and tricks that I have gathered over the years…

Avoid typing “sudo” in front of every command you want to run as root:

sudo -i

Add a new user account named “Bert”:

adduser Bert

Add group www-data as Bert’s secondary user group:

usermod -a -G www-data Bert

Make Bert’s primary user group www-data:

usermod -g www-data Bert

Delete Bert:

deluser Bert

Delete Bert and his home directory:

deluser --remove-home Bert

Delete Bert and all files owned by him:

deluser --remove-all-files Bert

Show size of all files and subdirectories of the current working directory:

du -sh

Show drive/partition space usage:

df -T -h

Empty a log file except for the last 5 lines:

tail -5 error.log > error.log

gzip the current directory with all subdirectories and files:

tar czvf /abc/123/backup.tar.gz .

Extract gzipped file into current directory:

tar xzvf file.tar.gz

Extract a tar file into the current directory:

tar xvf backup.tar

Generate a self-signed 1-year SSL certificate for HTTPS:

openssl req -new -newkey rsa:1024 -keyout hostkey.pem -nodes -out hostcsr.pem
(for "Common Name", use the web site's URI)

openssl req -x509 -days 365 -in hostcsr.pem -key hostkey.pem -out hostcert.pem

Dump a MySQL database to a file “sql.dump”:

mysqldump –-user USERNAME –-password=PASSWORD --opt DBNAME > sql.dump

Set your ethernet port to have a static IP address of

Edit /etc/network/interfaces (NOTE: your ethernet may not be "eth0"!!):

auto eth0
iface eth0 inet static
gateway [GATEWAY_IP]
dns-nameservers [DNS1_IP] [DNS2_IP]

Then run: /etc/init.d/networking restart

Eliminate the long lag between the “login:” and “password:” prompts when you SSH in to your server:

Add "UseDNS no" to the end of /etc/ssh/sshd_config

And, last but not least…

List all PCI devices present in your system:


List all USB devices connected to your system:


Get your computer’s detailed hardware specs:


lshw -html > your-file-name.html

That’s it for this part. Stay tuned for more!

Need help? Hire me!
Get Scottie Stuff!