linux

linux os tutorials, hacks, tips & tricks

dmidecode

i found the command below here. what it does is grab your service tag number using dmidecode.

dmidecode | grep 'Serial Number' | head -1

after seeing how that worked i decided to look at the dmidecode output. a lot of it wasnt anything i could actually use, however, i did find this one particularly useful when recompiling the kernel.

processor info from the BIOS with flags:
dmidecode |grep 'Processor Information' -40

it gives a good look at the processor flags, more detailed than cat /proc/cpuinfo, however, cat /proc/cpuinfo listed off more flags. it also states on the dmidecode homepage they say

Beware that DMI data have proven to be too unreliable to be blindly trusted. Dmidecode does not scan your hardware, it only reports what the BIOS told it to.

run the last command as root

run the last command as root:

sudo !!

 

when you put in sudo !! the !! translates to !-1. you can also write it as sudo !-n to refer to the n-th previous command.

save a file in vi as root

way to often i start editing a file without using sudo. here is a fix for that. when you go to save the file, do the following:

:w !sudo tee %

 

smbmount example

to mount a windows share via the command line:

smbmount //machine/share /where-you-want-it

 

handy one liners for awk

an awesome compilation of one liners for awk. check it out here

steves bourne/bash shell scripting tutorial

here is an awesome tutorial on bash scripting. it is possibly the most informative and thorough tutorial i have ever read. it is a definite must read for anyone who is trying to get into bash scripting or learn more about it.

this tutorial is written to help people understand some of the basics of shell script programming, and hopefully to introduce some of the possibilities of simple but powerful programming available under the bourne shell. as such, it has been written as a basis for one-on-one or group tutorials and exercises, and as a reference for subsequent use.

steves bourne/bash shell scripting tutorial

    

benchmarking with phoronix

i wanted to find a decent benchmarking tool for linux that was open source and found the phoronix test suite. i downloaded the source here. i wanted to benchmark my nvidia geforce gt 220, and a variety of other tests, including cpu load and kernel recompile time.

you can see all the available tests by using phoronix-test-suite list-tests. to run a test, use phoronix-test-suite benchmark testname. it will then download the necessary files and run the test.

there is also a gui, which is accessed using phoronix-test-suite gui. (when i went to run the gui, i was missing php-gtk, so i installed it

i will post my test results after i have run a few. i am curious to see how my system performance is.

alternative to the ‘miracle 200 line patch’

i have yet to try this, i plan to either on my ubuntu install on my desktop or i will install ubuntu netbook remix on my netbook just so i can try this out.

Use it in Ubuntu

To use Lennart’s solution in Ubuntu (not tested – thanks to Lsh for this), you have to replace “/sys/fs” with “/dev”. So you would have to add the following commands in your /etc/rc.local (open it with: sudo gedit /etc/rc.local) file, above the “exit 0″ line:

mkdir -p /dev/cgroup/cpu
mount -t cgroup cgroup /dev/cgroup/cpu -o cpu
mkdir -m 0777 /dev/cgroup/cpu/user
echo "1" > /dev/cgroup/cpu/user/notify_on_release
echo "/usr/local/sbin/cgroup_clean" > /dev/cgroup/cpu/release_agent

and make it executable:

sudo chmod +x /etc/rc.local

And then add the following to your ~/.bashrc file (to open it: gedit ~/.bashrc):

if [ "$PS1" ] ; then
mkdir -m 0700 /dev/cgroup/cpu/user/$$
echo $$ > /dev/cgroup/cpu/user/$$/tasks
fi

Run the following command:

sudo gedit /usr/local/sbin/cgroup_clean

And paste this:

#!/bin/sh
rmdir /dev/cgroup/cpu/$1

then save the file and make it executable:

sudo chmod +x /usr/local/sbin/cgroup_clean

And finally, restart the computer.

Update: The above instructions have been updated automatically remove empty cgroups (thank to Ricardo Ferreira – see his comment below).

here is the source for the above quote.

php-gtk

“PHP-GTK is an extension for the PHP programming language that implements language bindings for GTK+. It provides an object-oriented interface to GTK+ classes and functions and greatly simplifies writing client-side cross-platform GUI applications.” source

installing

download the source here

./buildconf
./configure
make
make install

edit the php.ini and add extension=php_gtk2.so below all the extension settings

to test if it is installed, run php -m | grep php-gtk. you should get a single php-gtk back.

200+ line kernel patch

there is a new kernel patch out. it is a total of 233 line of code added to the kernel. this new patch, written by mike galbraith, is intended to streamline the desktop system inside of a linux system under a heavy cpu load. by writing either 0 or 1 to /proc/sys/kernel/sched_autogroup_enabled or passing “noautogroup” as a parameter when booting the kernel will allow the automated per tty task to be done dynamically on the kernel in real time.

linus torvalds had great things to say in an e-mail about the new patch:

Yeah. And I have to say that I’m (very happily) surprised by just how
small that patch really ends up being, and how it’s not intrusive or
ugly either.

I’m also very happy with just what it does to interactive performance.
Admittedly, my “testcase” is really trivial (reading email in a
web-browser, scrolling around a bit, while doing a “make -j64″ on the
kernel at the same time), but it’s a test-case that is very relevant
for me. And it is a _huge_ improvement.

It’s an improvement for things like smooth scrolling around, but what
I found more interesting was how it seems to really make web pages
load a lot faster. Maybe it shouldn’t have been surprising, but I
always associated that with network performance. But there’s clearly
enough of a CPU load when loading a new web page that if you have a
load average of 50+ at the same time, you _will_ be starved for CPU in
the loading process, and probably won’t get all the http requests out
quickly enough.

So I think this is firmly one of those “real improvement” patches.
Good job. Group scheduling goes from “useful for some specific server
loads” to “that’s a killer feature”.

Linus

i am curious to see the system performance changes and i will be applying this patch to my test kernel later on this week.