Tech stuff and info dump

(Ubuntu) linux: how to find out what processor/CPU

June 06th, 2010

Open a terminal (Applications -> Accessories -> Terminal in Ubuntu 10.04) and type:

less /proc/cpuinfo

This gives a lot of information. Look for the ‘model name’ entry the top of the list.

For example, here are the first several lines of my /proc/cpuinfo:

processor : 0
vendor_id : GenuineIntel
cpu family : 6
model : 28
model name : Intel(R) Atom(TM) CPU N270 @ 1.60GHz
stepping : 2
cpu MHz : 800.000
cache size : 512 KB

Press the spacebar to go down a ‘page’ and ‘q’ to quit.


Filed under: Command line,linux
June 06th, 2010 10:47:39

How to find recently modified files (linux)

June 06th, 2010

Open a terminal (Applications -> Accessories -> Terminal in Ubuntu 10.04, for example). Typing:

find . -mtime -1 -print

will find files in the current directory that have been modified in the past 24 hours. The ‘.’ can be replaced with another directory.

Thanks to My Digital Life for the information – this site gives more information and other options.


Filed under: Command line,linux
June 06th, 2010 10:40:57

grep: how to use grep to search history (linux)

May 31st, 2010

I often remember only part of something I did before and want to remember how I’ve done something. To easily search through the history, the glorious grep can be invoked like this:

history | grep phrase_to_search_for

If the phrase to search for involves spaces or special characters, then quotes can be used around the phrase:

history | grep ‘phrase to search for’

To search for something with quotes, you can surround your phrase-to-search-for with the ‘other’ kind of quote.

For example,

history | grep ‘phrase to “search” for’

will match

phrase to “search” for

and

history | grep “phrase to ‘search’ for”

will match

phrase to ‘search’ for


Filed under: Command line,linux
May 31st, 2010 11:43:58

linux: find out what you’ve recently typed at the command line

May 31st, 2010

If you open a terminal window (in Ubuntu 10.04, go to Applications->Accessories->Terminal) and type

history

this will print out a list of things that have been recently typed at the command line.

If you’re curious, the history is stored in a file called .bash_history which you can view as a file. In Ubuntu, for example, you can open it with gedit by opening a terminal window and typing

gedit .bash_history

at the command line.

Note: if you have two (or more) terminal windows open and are typing commands in all of them, the history of one terminal window won’t know about what you’ve typed in the other window. If you close, say terminal window A, leave terminal window B open. and then open terminal window C, typing history in terminal window C will display what you’ve typed in A but not in B.

Examples of using grep to search through the history are here.


Filed under: Command line,linux
May 31st, 2010 11:43:53

How to list partitions and basic partition information: linux

May 31st, 2010

To find out basic information about partitions, open a terminal window (Applications -> Accessories -> Terminal in Ubuntu 10.04 and others) and type

fdisk -l

at the command line.

(If nothing happens, try typing

sudo fdisk -l

at the command line and entering your password when prompted.)

Something like this should be displayed:

Disk /dev/sda: 160.0 GB, 160041885696 bytes
255 heads, 63 sectors/track, 19457 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x66666666

Device Boot Start End Blocks Id System
/dev/sda1 * 1 2613 20988891 c W95 FAT32 (LBA)
/dev/sda2 2614 17532 119830471+ f W95 Ext’d (LBA)
/dev/sda3 17532 19458 15471448 12 Compaq diagnostics
/dev/sda5 13566 17532 31856640 7 HPFS/NTFS
/dev/sda6 2614 13194 84991819+ 83 Linux
/dev/sda7 13195 13565 2980026 82 Linux swap / Solaris

Here, /dev/sda6 is my linux partition.

In Ubuntu 10.04, you can navigate to System -> Administration -> Disk Utility to get a big graphical display of this information (and more).


Filed under: Command line,linux
May 31st, 2010 11:09:40

How to tell how much disk space is left: linux

May 31st, 2010

Open a terminal (Applications -> Accessories -> Terminal in Ubuntu 10.04 and others) and type

df

at the command line.

Something like this will be displayed:

Filesystem 1K-blocks Used Available Use% Mounted on
/dev/sda6 83657080 25098664 54308828 32% /
none 504088 296 503792 1% /dev
none 508500 372 508128 1% /dev/shm
none 508500 96 508404 1% /var/run
none 508500 0 508500 0% /var/lock
none 508500 0 508500 0% /lib/init/rw

The number listed on the top line (/dev/sda6) under ‘Available’ is the amount of space left on my linux partition.

For more human-readable numbers, try:

df -h

which will display something like this:

Filesystem Size Used Avail Use% Mounted on
/dev/sda6 80G 24G 52G 32% /
none 493M 296K 492M 1% /dev
none 497M 372K 497M 1% /dev/shm
none 497M 96K 497M 1% /var/run
none 497M 0 497M 0% /var/lock
none 497M 0 497M 0% /lib/init/rw

The df command won’t show space available on unmounted drives.

If you want to see basic information about the partitions on a machine, see this post.


Filed under: Command line,linux
May 31st, 2010 10:58:03

Ubuntu linux: using dmesg to find bootup messages

May 12th, 2010

To view your bootup messages, open a terminal (Applications -> Accessories -> Terminal in Ubuntu 10.04 etc.) and type:

dmesg

There can be a lot of information, so I like to use less to navigate through the message:

dmesg | less

(Use the spacebar to advance the text and ‘q’ to quit.)

If you want to save all the information to a file so that you can send it to someone or post it online, you can type:

dmesg > whatever_you_want_to_call_the_file

If you’ve just opened a terminal, you’re probably in your home directory; that’s where the file will appear.

(Make sure you don’t use the name of an existing file. If you want to check what other files are in your current directory, type ls on the command line.)


Filed under: Command line,Logs
Tags:
May 12th, 2010 12:33:11

Ubuntu linux: where to find error logs, messages, bootup messages, etc. and how to read them

May 12th, 2010

Various logs can be found here:

/var/log

They can be read by opening a terminal (Applications -> Accessories -> Terminal in Ubuntu 10.04, etc.) and typing:

cd /var/log
less name_of_logfile

(Use the space bar to go to the next page; type ‘q’ to quit.)

Most of the files in /var/log can also be viewed using Ubuntu’s Log File Viewer. In 10.04, this is found by navigating to System -> Administration -> Log File Viewer from the taskbar. There is a menu listing the available logs on the left-hand side of the Log File Viewer; click on the name of a file to view it.


Filed under: Command line,Logs
Tags:
May 12th, 2010 12:21:16

How to tell which version of java is running in linux (Ubuntu)

May 10th, 2010

Command line

To find out which version of java is installed, type

java -version

in a terminal window. This will give something like this:

java version “1.5.0”
gij (GNU libgcj) version 4.2.4 (Ubuntu 4.2.4-1ubuntu3)

Browser

You can also visit www.java.com’s Verify Java Version page. On this page, there is a pleasingly big red button that you can click which will tell you what version of java is installed.

Pressing the pleasingly big red button will tell you something like this:

Your Java version is 1.5.0_22

Of course, if one isn’t running the latest and greatest version, this page tells you to install the most up-to-date version, but I usually prefer to wait until there is an official Ubuntu update.


Filed under: Command line,General,java
May 10th, 2010 12:12:07