Friday, March 04, 2011

64-bit: How do I determine whether I am already running a 64-bit Linux OS?

If you are trying to figure out whether you can run 64-bit Linux on your computer, see this post.

Whether you are running a 64-bit OS is easy to find. Just open a terminal window on your computer running Linux, and run the following command:
uname -m

If the output you get is i686, then you are running a 32-bit OS.
However, if the output is x86_64 or amd64, then you are running 64-bit Linux.

(This post assumes that you are running Linux on a x86-based machine. Never, ever, have I seen a general purpose computer running Linux on a non-x86 processor, though I know it works.)

Labels: , , , , ,

64-bit: How do I find out whether I can run a 64-bit Linux OS?

I am surprised how often I get into this discussion:

Someone: How do I determine whether I can run a 64-bit build of my favorite Linux distribution?
Me: Only if you have a 64-bit processor.
Someone: Great, but how do I determine that I have a 64-bit processor?
Me: Well, if you are already running a Linux distribution, you just need to run this:
grep 'flags.*lm' /proc/cpuinfo
If you get any output, then, my friend, you are ready to jump into the 64-bit world.

Update: Just because you are running a 64-bit OS doesn't mean you have to. You are free to run a 32-bit OS, if you wish.

Labels: , , , ,

Thursday, May 01, 2008

Find out the current OS's version

cat /etc/issue
lsb_release -a

I tried on Ubuntu 8.0.4, FC8. One of those commands should work on most systems.

Labels: , , , , ,

Monday, April 07, 2008

Securing Apache 2 using SSL

Here is an absolutely simple and to-the-point guide to setup SSL service on your Apache2 HTTP server.
This should work with most Linux distributions. The author tried SuSE 9.1 Linux and I had it working on Ubuntu 7.10.

Labels: , , , , , ,

Wednesday, August 22, 2007

Find any information about any package (Ubuntu 7.04)

To find out any information about any package installed on your Ubuntu machine, use the pkg-config command.
I had to find out the version installed on my machine so I did this:
pkg-config <NAME> --modversion

Here's what --help on pkg-config throws up:
$ pkg-config --help
Usage: pkg-config [OPTION...]
--version output version of pkg-config
--modversion output version for package
--atleast-pkgconfig-version=VERSION require given version of
pkg-config
--libs output all linker flags
--static output linker flags for
static linking
--short-errors print short errors
--libs-only-l output -l flags
--libs-only-other output other libs (e.g.
-pthread)
--libs-only-L output -L flags
--cflags output all pre-processor and
compiler flags
--cflags-only-I output -I flags
--cflags-only-other output cflags not covered by
the cflags-only-I option
--variable=VARIABLENAME get the value of a variable
--define-variable=VARIABLENAME=VARIABLEVALUE set the value of a variable
--exists return 0 if the module(s)
exist
--uninstalled return 0 if the uninstalled
version of one or more
module(s) or their
dependencies will be used
--atleast-version=VERSION return 0 if the module is at
least version VERSION
--exact-version=VERSION return 0 if the module is at
exactly version VERSION
--max-version=VERSION return 0 if the module is at
no newer than version VERSION
--list-all list all known packages
--debug show verbose debug information
--print-errors show verbose information
about missing or conflicting
packages
--silence-errors show verbose information
about missing or conflicting
packages
--errors-to-stdout print errors from
--print-errors to stdout not
stderr

Help options
-?, --help Show this help message
--usage Display brief usage message

Labels: , , , , , ,

Thursday, August 09, 2007

screen: The power of windowing, in an xterm!

Here is an amazing piece of software, called screen, that will get you on a high if you spend just 5 minutes at it, exploring it with the help of a nicely prepared tutorial (here). It came pre-installed with my Ubuntu 7.04 (Feisty), but can be easily downloaded and installed.

Some of the things it can do for you:
  1. Allow you to open 'virtual' terminal windows inside a single xterm: not gnome-terminal, not konsole, just plain and simple xterm!
    So you can open various screen-based applications without opening so many independent terminals. That helps avoid clutter in the taskbar as well as saves you the hassle of searching for a particular terminal window. Switching between each of those virtual terminals is extremely easy, by the way.

  2. It also lets you run applications and then close (not always, it is all as you wish) the window that spawned the application, without disrupting the progress of the spawned process. As good as, if not better than, nohup.
    This is the main reason that led me to discover this highly useful piece of software, that remains to be highly under-used and is in fact unknown to linux users at large. Sad, I say!

  3. Has it ever happened with you that you opened a set of terminals, started doing some work in each of them but you had to leave the place in the middle of your job and then login from another machine? How do you get back those terminals? VNC? But why waste so much bandwidth when the same can be done safely and easily using screen. It lets you start a session of 'virtual' terminals, each of them running any application (totally independent of other applications). Then, if you have to leave the current place, just inform screen about the same and all will be taken care of!

It can do a lot more things, like the ability to let you work collaboratively with someone else, the ability to name (and rename) terminals, the ability to monitor terminals for activity, and so on and so forth.

Here are some of my settings.
  1. ${HOME}/.screenrc:
    #change the hardstatus settings to give an window list at the bottom of the                                              
    #screen, with the time and date and with the current window highlighted
    startup_message off
    defscrollback 2048
    vbell off
    altscreen on
    hardstatus alwayslastline
    backtick 1 60 60 /home/varunk/.screen_ip
    hardstatus string '%{gk}[%{G}%H: %1`%{g}][%= %{wk}%?%-Lw%?%{=b kR}(%{W}%n*%f %t%?(%u)%?%{=b kR})%{= kw}%?%+Lw%?%?%= %{g}][%{Y}
    shelltitle "$\ |term"
  2. ${HOME}/.screen_ip:
    #!/bin/bash
    # Script to get run by hardstatus in screen.
    # Prints customized single-line system stats
    IP=`ifconfig eth0 | grep Mask | cut -d: -f2 | cut -d " " -f1`
    UP=`uptime | awk -F' |,' '{print $4" "$5", "$8}'`
    echo -n "$IP | UP: $UP"
  3. Screenshot of my screen:
Give it a try and let me know if you do not like a thing about it.

Labels: , , , , , , ,

Saturday, December 16, 2006

Unix command in 'awk'

uname -a: Linux MyMachine01 2.4.21-37.ELsmp #1 SMP Wed Sep 7 13:32:18 EDT 2005 x86_64 unknown unknown GNU/Linux
i.e. Red Hat Enterprise Linux 3 running on AMD64. Shell: tcsh

Today's tip is about how to make awk run Unix commands on its input.

As it happened to me today, sometimes we want 'awk' to perform some UNIX command on some field in the input. I performed a Google search without much trouble but putting it here, nevertheless, would be a good idea.

So what I wanted to do was, look for a pattern in all the files in all the subdirectories in the current working directory (CWD) and if the pattern is present in the files, present the name of the directory which contains this file.

Let's say the pattern was: PaTtErN; and the directory structure:
Top/:
Top/Dir_1: Top/Dir_2: Top/Dir_3: Top/Dir_4 ...
Top/Dir_1/a.out Top/Dir_2/a.out Top/Dir_3/a.out ...
Top/Dir_1/b.out Top/Dir_2/b.out Top/Dir_3/b.out ...
Top/Dir_1/c.out Top/Dir_2/c.out Top/Dir_3/c.out ...


This is how I proceeded:
  1. Let's start with a simple grep command:
    grep PaTtErN Top/Dir_*/*
    The output of this command, for every line that matches in any of the files, is of the format:
    <FILENAME>:<MATCHING-LINE>
  2. Now let's extract the filenames from that list. Here comes the use of awk, to get a particular column:
    grep PaTtErN Top/Dir_*/* | awk -F':' '{print $1}'
    Print the 1st ($1) column of grep command's output, where each column is assumed to be separated by a ':'
    That's how we separate out the name of files containing the pattern we are searching for.

  3. The problem with this output is that in each directory, there could be multiple files which could possibly contain this pattern multiple times. However, what we really care about is the parent directory name, for example, Top/Dir_2.Here, I would introduce a lesser known but nevertheless, very useful command: dirname. I would also encourage you to look at the man page of another similar command: basename. These two come in really handy sometimes, as we'll see shortly.
    grep PaTtErN Top/Dir_*/* | awk -F':' '{print "dirname " $1 }' | sh
    That says, on the shell (sh), execute the command 'dirname <First-Column-Of-grep-Output>', which will give us the directory name of the file that contains the pattern.
    The problem is that it produces the directory name for each match in each file but we want it only once.

  4. No problem, that is taken care of by this:
    grep PaTtErN Top/Dir_*/* | awk -F':' '{print "dirname " $1 }' | sh | sort | uniq | less
  5. And lo, and behold, we have what we wanted.

Tip: It is always a good idea to less the output of a command, specially when you are not sure how big the output is going to be!

Labels: , ,

Monday, August 28, 2006

Kerala will soon be a FOSS state

Thanks to all those who made this decision :)
In the current year, class VIII students have shifted to Linux. By 2007, class XI students and by 2008 class X students will follow suit.

BTW, FOSS stands for "Free and Open Software Systems"

Labels: ,