Click Technology

Linux, Windows, Mac it's all good

Display a .conf file without the comments

August8

Sometimes, when you get long .conf files wit long commentaries, it’s handy just to see the actual meat in the file. Here’S how, suing grep with a simple regular expression.

grep ^[^#] /etc/thefile.conf

You can also use…

cat /etc/thefile.conf | egrep -v "^\s*(#|$)") 
posted under Linux Tips | No Comments »

What CPU do I have?

June15

In Ubuntu, just open a terminal window and type

cat /proc/cpuinfo

Compare it here.

Simples!

posted under Linux Tips | No Comments »

How do I tell what version of Linux I’m running?

May5

Good question, and an annoying one as I can never remember the command. It is..

lsb_release -a

Sweet!

posted under Linux Tips | No Comments »

What hardware do I have?

April23

You need to know what hardware you’ve got in your Linux box?

Easy..

sudo lshw

Job done.

posted under Linux Tips | No Comments »

Mail Ports

April6

Network ports used in conjunction with IP addresses are used to define the TCPIP socket for network connections between hosts on an (inter)network so they can communicate with each other. Some port numbers are classics and here are those used for electronic mail.

POP3 – port 110

IMAP – port 143

SMTP – port 25

HTTP – port 80

Secure SMTP (SSMTP) – port 465

Secure IMAP (IMAP4-SSL) – port 585

IMAP4 over SSL (IMAPS) – port 993

Secure POP3 (SSL-POP) – port 995

posted under Linux Tips | No Comments »

Flushing IPTABLES

April4

IPTABLES is the Linux firewall and it is, in short, great. The one only niggle is that sometimes you want to be able to just clear all the rules and have a nice clean firewall to fiddle with.

I found this script on the interweb and it works like a dream. To use it just do this..

1. Open a terminal window by opening the run command line with Alt + F2. Of course, if you’re using a GUI-less terminal, this doesn’t apply, just skip to step 2.

Once open, type

gnome-terminal

and click OK. There’s your terminal window.

2. Now, let’s install vim, one of the common editors in Linux. Issue the command

sudo apt-get install vim

Enter your normal login password and away you go, installing VIM in a second, job done.

3. Now let’s create the file with these commands..

cd
sudo vim fwflush

to create and edit the file. Once in VIM, just cut and paste the script below into the terminal window / command line.

#!/bin/sh
#
# rc.flush-iptables - Resets iptables to default values.
#
# Copyright (C) 2001  Oskar Andreasson <bluefluxATkoffeinDOTnet>
#
#
# Configurations
#
IPTABLES="/sbin/iptables"

#
# reset the default policies in the filter table.
#
$IPTABLES -P INPUT ACCEPT
$IPTABLES -P FORWARD ACCEPT
$IPTABLES -P OUTPUT ACCEPT

#
# reset the default policies in the nat table.
#
$IPTABLES -t nat -P PREROUTING ACCEPT
$IPTABLES -t nat -P POSTROUTING ACCEPT
$IPTABLES -t nat -P OUTPUT ACCEPT

#
# reset the default policies in the mangle table.
#
$IPTABLES -t mangle -P PREROUTING ACCEPT
$IPTABLES -t mangle -P POSTROUTING ACCEPT
$IPTABLES -t mangle -P INPUT ACCEPT
$IPTABLES -t mangle -P OUTPUT ACCEPT
$IPTABLES -t mangle -P FORWARD ACCEPT

#
# flush all the rules in the filter and nat tables.
#
$IPTABLES -F
$IPTABLES -t nat -F
$IPTABLES -t mangle -F
#
# erase all chains that's not default in filter and nat table.
#
$IPTABLES -X
$IPTABLES -t nat -X
$IPTABLES -t mangle -X

Job done, now save it using the following key sequence in order

:wq

OK, that’s the file created and ready for use – we just need to make it excecutable. Do that by issuing the chmod command thus…

chmod u+x fwflush

4. Now run the script thus..

./fwflush

Now, if you issue the iptables command to show all the chains/rules, there are none but the defaults. Sweeeet!

sudo iptables -L
posted under Linux Tips | No Comments »
« Older EntriesNewer Entries »

This is my website for short blog posts and interesting materials that are noteworthy or have some handy-tip value.