Labels

Showing posts with label Linux. Show all posts
Showing posts with label Linux. Show all posts

03/05/2012

Display Current System IP Address

arguments << "-c" << "ifconfig wlan0 | grep 'inet ' | awk '{print $2}' | sed 's/addr://'";
// or arguments << "-c" << "ifconfig eth1 | grep 'inet ' | awk '{print $2}' | sed 's/addr://'";
QProcess* process = new QProcess(this);
process->start(prog , arguments);
process->waitForFinished();
QString tmp = process->readAll();
//qDebug() << tmp;
ui->label_ip->setText(tmp);

20/04/2012

Black screen after running an application

I put my application in /etc/rc5.d/S99rmnologin to let it automatically start.
The application is running well. But the screen turns black after 1 minute. When I touched the screen, a small area, where my finger pointed, of my application GUI show up. My application GUI gradually appears if I continuously moving my finger on the screen. It looks like using a mop to wipe the screen.

Solution:

Take a look in /etc/rcS.d/S01psplash file. At the end of line, there is a "sleep 120 ..." command which caused the problem. After comment out this line, everything goes fine.

# Timetrap against hanging with splash hiding console messages.
(sleep 120; psplash-write "QUIT") &

13/04/2012

Change Gumstix Overo Booting Screen (Logo image)


By default, overo boots up with its own image with progress bar. I want to display my own picture when it boots up.

I follow the below website, but it is for Angstrom. I did some modification to suit my overo COM.

https://support.bluetechnix.at/wiki/Changing_the_splash_screen_picture

1) bitbake psplash

$ cd /build/czhang/overo-oe
$ source build/profile
$ bitbake psplash
...

2) copy make-image-header.sh file to proper place.

$ cp /build/czhang/overo-oe/tmp/work/armv7a-angstrom-linux-gnueabi/psplash-angstrom-0.0+svnr422-r33/psplash/make-image-header.sh /build/czhang/overo-oe/org.openembedded.dev/recipes/psplash/files/overo

3) create your own image file, make sure it is in right dimensions.

$ cd /build/czhang/overo-oe/org.openembedded.dev/recipes/psplash/files/overo
$ ./make-image-header.sh [your-image].png HAND

    back up original image head file:
$ mv psplash-hand-img.h psplash-hand-img.h_orig
$ mv [your-imge]-img.h psplash-hand-img.h
$ cd /build/czhang/overo-oe
$ source build/profile
$ bitbake psplash

Error occurred:

| psplash.c: In function 'main':
| psplash.c:271: error: 'POKY_IMG_WIDTH' undeclared (first use in this function)
| psplash.c:271: error: (Each undeclared identifier is reported only once
| psplash.c:271: error: for each function it appears in.)
| psplash.c:272: error: 'POKY_IMG_HEIGHT' undeclared (first use in this function)
| psplash.c:275: error: 'POKY_IMG_BYTES_PER_PIXEL' undeclared (first use in this function)
| psplash.c:276: error: 'POKY_IMG_RLE_PIXEL_DATA' undeclared (first use in this function)
| make[1]: *** [psplash.o] Error 1
| make[1]: *** Waiting for unfinished jobs....
| mv -f .deps/psplash-write.Tpo .deps/psplash-write.Po
| mv -f .deps/psplash-console.Tpo .deps/psplash-console.Po
| mv -f .deps/psplash-fb.Tpo .deps/psplash-fb.Po
| make[1]: Leaving directory `/build/czhang/overo-oe/tmp/work/armv7a-angstrom-linux-gnueabi/psplash-0.0+svnr422-r33/psplash'
| make: *** [all] Error 2
| FATAL: oe_runmake failed

it took me a long time to figure it out. In

/build/czhang/overo-oe/tmp/work/armv7a-angstrom-linux-gnueabi/psplash-0.0+svnr422-r33/psplash

there are three files:
psplash-hand-img.h
psplash-poky-img.h
psplash-bar-img.h

take a look psplash-poky-img.h content where the error occurred:
$ less psplash-poky-img.h

/* GdkPixbuf RGB C-Source image dump 1-byte-run-length-encoded */

#define HAND_IMG_ROWSTRIDE (816)
#define HAND_IMG_WIDTH (272)
#define HAND_IMG_HEIGHT (363)
#define HAND_IMG_BYTES_PER_PIXEL (3) /* 3:RGB, 4:RGBA */
#define HAND_IMG_RLE_PIXEL_DATA ((uint8*) \

After I replaced the HAND with POKY, and bitbake again, error disappeared.

4) bitbake console image

$ bitbake omap3-console-image

5) remember to install psplash_0.0+svnr422-r33.6_armv7a.ipk (maybe psplash-support_0.0+svnr422-r33.6_armv7a.ipk too), this is a software which can load booting image.

Done! you will see the pretty image in the booting procedure.

Modify booting scrip for Gumstix Overo Tide COM

The Tide COM has no NAND built in. When I try to change environment parameter, such as rotate screen or change default display, it just won't work.

The solution is to create a boot command file, e.g. ubootenvcmd, and add it into a boot.scr.

Here is how I do it:

1) create a ubootenvcmd file by using gedit. The content is something like:

setenv ethaddr 00:00:00:FF:FF:FF
setenv mpurate 720
setenv vram 4M
setenv linuxmem 176M
setenv defaultdisplay lcd43
setenv dvimode 480x272MR-16@60
setenv mmcargs ${mmcargs} omapfb.rotate=1
setenv bootcmd 'mmc init; run loaduimage; run mmcboot'
boot

2) install mkimage:
$ sudo apt-get install uboot-mkimage

3) create boot.scr file:
$ mkimage -A arm -O linux -T script -C none -a 0 -e 0 -n "Overo boot script" -d ubootenvcmd boot.scr

ps. remember to put the ubootenvcmd file in current directory.

4) copy boot.scr to your FAT partition of your SD card.

Done :)

10/04/2012

Cross compile for i386 on 86_64 system

Down load  qt-everywhere-opensource-src-4.7.0

"configure -help" will tell you how to do the cross compile for different OS.

1) tell machine to compile program to 32bit OS
$  ./configure -platform linux-g++-32

Error:
/usr/include/gnu/stubs.h:7:27: error: gnu/stubs-32.h: No such file or directory
make: *** [project.o] Error 1

Solution:
$ sudo apt-get install libc6-dev-i386

Error:
/usr/bin/ld: cannot find -lstdc++
collect2: ld returned 1 exit status

Solution:
$ sudo apt-get install g++-multilib

2) make all libraries
$ make

3) create a "projects" folder under  "qt-everywhere-opensource-src-4.7.0". put your project folder, i.e. m4works, in "projects". and also copy relative folders, qextserialport, qwt-5.2.1, into "projects".

4) compile project relative libraries first to get 32bit libraries.
$ qmake qextserialport.pro
$ make
...

5) modify project .pro file to point libraries in right directory.

6) compile project.
$ qmake m4.pro
$ make




23/03/2012

Rotate Screen in Ubuntu


The screen rotation function in Nvidia graphics driver is normally disabled. But We can enable it by modifying xorg.conf file.

To do this, we need to back up xorg.conf file first.

$ sudo cp /etc/X11/xorg.conf /etc/X11/xorg.conf.bak

Now edit the file:
$ sudo gedit /etc/X11/xorg.conf

In the Device section that includes the line:

         Driver    "nvidia"

Add:
         Option "RandRRotation"   "on"

It will looks like:

Section "Device"
    Identifier            "Device0"
    Driver                "nvidia"
    VendorName     "NVIDIA Corporation"
    Option                "RandRRotation" "on"
EndSection


Then, we need to log out and log back in to restart X server.

To rotate screen to left, use:
$ xrandr -o left

To rotate screen to right, use:
$ xrandr -o right

To flip screen upside down, use:
$ xrandr -o inverted

To go back to normal, use:
$ xrandr -o normal

12/10/2011

Load Gumstix Libraries


1) Install rsync pakage:
$ scp /build/czhang/overo-oe/tmp/deploy/glibc/ipk/armv7a/rsync_3.0.6-r0.6_armv7a.ipk root@10.0.0.146://home/root/

$ opkg install rsync_3.0.6-r0.6_armv7a.ipk

2) Install Qt lib:
$ rsync -av czhang@10.0.1.202://build/czhang/qt-everywhere-opensource-src-4.7.0/lib/* /usr/lib

3) Install serial port lib:
$ rsync -av czhang@10.0.1.202://build/czhang/qt-everywhere-opensource-src-4.7.0/projects/qextserialport/build/libqextserialport* /usr/lib

4) Install qwt lib:
$ rsync -av czhang@10.0.1.202:///build/czhang/qt-everywhere-opensource-src-4.7.0/projects/qwt-5.2.1/lib/* /usr/lib

4) Install sqlit3 lib:
$ scp czhang@x.x.x.x:/build/czhang/qt-everywhere-opensource-src-4.7.0/plugins/sqldrivers/libqsqlite.so /home/m4/sqldrivers

5) Install qzip lib:
$ rsync -av czhang@10.0.1.202://build/czhang/qt-everywhere-opensource-src-4.7.0/projects/quazip-0.3/quazip/libquazip.so* /usr/lib

6) Install Analogwidget lib:
$ scp /build/czhang/qt-everywhere-opensource-src-4.7.0/projects/AnalogWidgets/analogwidgets/libanalogwidgets_plugin.so root@10.0.0.146://usr/lib

 

01/10/2011

Create an Application Shortcut to Open Nautilus as Root in Ubuntu


$ sudo nano /usr/share/applications/Nautilus-root.desktop

Paste the following text in the editor that comes up in Terminal:

 [Desktop Entry]
Name=File Browser (Root)
Comment=Browse the filesystem with the file manager
Exec=gksudo nautilus
Icon=file-manager
Terminal=false
Type=Application
Categories=Application;System;

 Hit Ctrl+X  then Y

Done!

29/09/2011

User Management


Create a user:
$  useradd tech

Add password:
$ passwd tech
Enter new UNIX password:
Retype new UNIX password:

Direct user to a preferred directory when the user log on:
usermod -d /home/tempdir/ tech


08/08/2011

Install AnalogWidget in Ubuntu / Gumstix

Install in Ubuntu:

System spec:

Ubuntu 10.04 (lucid)
2.30.2 (Ubuntu 2010-06-25)
2.6.32-33-generic (#70-Ubuntu SMP Thu Jul 7 21:13:52 UTC 2011)
4.4.3 (x86_64-linux-gnu)
AnalogWidgets_234.zip

Download from here:
http://qt-apps.org/content/show.php?content=87780&forumpage=0

unzip it.

$ cd /home/czhang/Downloads/AnalogWidgets
$ qmake AnalogWidgets.pro
$ make
$ sudo make install
$ cp  /home/czhang/Downloads/AnalogWidgets/analogwidgets/libanalogwidgets_plugin.so /home/czhang/QtSDK/QtCreator/lib/qtcreator/plugins/designer/libanalogwidgets_plugin.so

In .pro file, added:
LIBS += /home/czhang/Downloads/AnalogWidgets/analogwidgets/libanalogwidgets_plugin.so
INCLUDEPATH += /home/czhang/Downloads/AnalogWidgets/analogwidgets/analogwidgets


Install in Gumstix:

unzip Analogwidget.zip under:
/build/czhang/qt-everywhere-opensource-src-4.7.0/projects

$ qmake AnalogWidgets.pro
$ make

got some error messages according to file:
/build/czhang/AnalogWidgets/analogwidgets/code/chart/channel.cpp
/build/czhang/AnalogWidgets/analogwidgets/code/scriptwidget.cpp

I edited these two files:
in channel.cpp
void Channel::setType(unsigned int i)
{
//if (i!=Line && i!=Dots)
// throw "Bledny typ";

m_type = i;

}

in scriptwidget.cpp:
void ScriptWidget::setScript(const QString & s)
{
m_script = s;
qDebug("ScriptWidget::setScript() %s",qPrintable(m_script));
try
{
QFile file(m_script);
if (file.open( QIODevice::ReadOnly ))
{
QString src = QString(file.readAll());
QScriptValue widget = m_engine->newQObject(this);
m_engine->globalObject().setProperty(objectName(),widget);
m_engine->evaluate(src);
QScriptValue v = m_engine->uncaughtException();

if (v.isValid())
qDebug("Error %s",qPrintable(v.toString()));
}
}
//catch (std::exception & e)
//{
// qDebug("Wyjatek %s",e.what());
//}
}// setScript


$ scp /build/czhang/qt-everywhere-opensource-src-4.7.0/projects/AnalogWidgets/analogwidgets/libanalogwidgets_plugin.so root@10.0.0.146://usr/lib

31/05/2011

Disable gumstix overo console login message on ttyS2

In my design, I need to use second serial port (ttyS2) on overo.
I connected SDA3 (pin 24 on chestnut43 board) to WinXP hyperterminal, and booted up Overo.
I saw all booting messages are showing in hyperterminal.

----------------------------------------------------------- 
Login timed out after 60 seconds.                                               
                                                                                
.-------.                                                                       
|       |                  .-.                                                   
|   |   |-----.-----.-----.| |   .----..-----.-----.                             
|       |     | __  |  ---'| '--.|  .-'|     |     |                             
|   |   |  |  |     |---  ||  --'|  |  |  '  | | | |                             
'---'---'--'--'--.  |-----''----''--'  '-----'-'-'-'                             
                -'  |                                                           
                '---'                                                           
                                                                                
The Angstrom Distribution overo ttyS2                                           
                                                                                
Angstrom 2010.7-test-20101005 overo ttyS2                                       
                                                                                
overo login: root                                                               
 |  '  | | | |                                                                   
'---'---'--'--'--.  |-----''----''--'  '-----'-'-'-'                             
                -'  |                                                           
                '---'                                                           
                                                                                
The Angstrom Distribution overo ttyS2                                           
                                                                                
Angstrom 2010.7-test-20101005 overo ttyS2                                       
... 
... 

-------------------------------------------------------------------- 

Then, I run my program (written by Qt), the hyperterminal shows as follow: 

-------------------------------------------------------------------------- 
QIODevice::read: Called with maxSize < 0 
QIODevice::read: Called with maxSize < 0 
QIODevice::read: Called with maxSize < 0 
QIODevice::read: Called with maxSize < 0 
QIODevice::read: Called with maxSize < 0 
QIODevice::read: Called with maxSize < 0 
QIODevice::read: Called with maxSize < 0 
QIODevice::read: Called with maxSize < 0 
QIODevice::read: Called with maxSize < 0 
QIODevice::read: Called with maxSize < 0 
QIODevice::read: Called with maxSize < 0 
QIODevice::read: Called with maxSize < 0 
QIODevice::read: Called with maxSize < 0 
QIODevice::read: Called with maxSize < 0 
... 
... 
------------------------------------------------------------------------- 

in the meantime, the string which sent from Qt program also shows in the screen. 
I only want ttyS2 send the information from my program, not other messages.

With help from Nabble forum, the following is my solution:

Those messages are from the kernel.  U need to change the "console" uboot environment variable, otherwise the kernel will print messages on that serial port.

Take a look at uboot environment variable. to do this ,  boot gumsix, pushed any key to stop it booting from MMC. Then use "printenv" list all u-boot variables. 
------------------------------------------ 
Overo # printenv 
bootcmd=if mmc init; then if run loadbootscript; then run bootscript; else if run loaduimagei 
baudrate=115200 
loadaddr=0x82000000 
console=ttyS2,115200n8 
vram=12M 
dvimode=1024x768MR-16@60 
nandargs=setenv bootargs console=${console} vram=${vram} omapfb.mode=dvi:${dvimode} omapfb.d2 
loadbootscript=fatload mmc 0 ${loadaddr} boot.scr 
bootscript=echo Running bootscript from mmc ...; source ${loadaddr} 
loaduimage=fatload mmc 0 ${loadaddr} uImage 
mmcboot=echo Booting from mmc ...; run mmcargs; bootm ${loadaddr} 
nandboot=echo Booting from nand ...; run nandargs; nand read ${loadaddr} 280000 400000; boot} 
dieid#=0ef000040000000004035c140d002011 
ethact=smc911x-0 
bootdelay=2 
defaultdisplay=lcd43 
i2cspeed=3,100 
bootargs=console=ttyS2,115200n8 i2c_bus=${i2cspeed} vram=12M omapfb.mode=dvi:1024x768MR-16@6t 
mmcargs=setenv bootargs console=${console} i2c_bus=${i2cspeed} vram=12M omapfb.mode=dvi:1024t 
stdin=serial 
stdout=serial 
stderr=serial 

Environment size: 1279/131068 bytes 
--------------------------------------------- 

the "console=ttyS2,115200n8" means send console login messages to ttyS2.

After that, take a look at /etc/inittab in mmc system on 2G SD card.
-------------------------------------------------
# /etc/inittab: init(8) configuration.
# $Id: inittab,v 1.91 2002/01/25 13:35:21 miquels Exp $

# The default runlevel.
id:5:initdefault:

# Boot-time system configuration/initialization script.
# This is run first except when booting in emergency (-b) mode.
si::sysinit:/etc/init.d/rcS

# What to do in single-user mode.
~~:S:wait:/sbin/sulogin

# /etc/init.d executes the S and K scripts upon change
# of runlevel.
#
# Runlevel 0 is halt.
# Runlevel 1 is single-user.
# Runlevels 2-5 are multi-user.
# Runlevel 6 is reboot.

l0:0:wait:/etc/init.d/rc 0
l1:1:wait:/etc/init.d/rc 1
l2:2:wait:/etc/init.d/rc 2
l3:3:wait:/etc/init.d/rc 3
l4:4:wait:/etc/init.d/rc 4
l5:5:wait:/etc/init.d/rc 5
l6:6:wait:/etc/init.d/rc 6
# Normally not reached, but fallthrough in case of emergency.
z6:6:respawn:/sbin/sulogin
S:2345:respawn:/sbin/getty 115200 ttyS2
# /sbin/getty invocations for the runlevels.
#
# The "id" field MUST be the same as the last
# characters of the device (after "tty").
#
# Format:
#  :::
#

1:2345:respawn:/sbin/getty 38400 tty1
-------------------------------------------------------

The last line sets up a login on tty1.  If you have a keyboard (eg. USB keyboard via a powered HUB)  and display connected, then you'd be able to login using those.  I am using a chestnut43 board with LCD, and i can use tty1 on a couple of occasions when I messed up the networking.

the command to change console environment variable are follows:

# setenv console tty1 
# saveenv 
The console setting is passed to the kernel at boot time.  It Only tells the kernel where to send messages;  It does not have anything to do with login terminals as that is handled by inittab and getty.  I can use tty1 because it allows me to see the kernel messages on the LCD during boot. 

20/05/2011

Linux hints

After reinstalled Ubuntu in my laptop, I tried to ssh laptop from Fedora computer. I got following error message:

[czhang@F13-64-VM projects]$ ssh czhang@10.0.0.124

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

@    WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!     @

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!

Someone could be eavesdropping on you right now (man-in-the-middle attack)!

It is also possible that the RSA host key has just been changed.

The fingerprint for the RSA key sent by the remote host is

4e:b4:d9:05:e3:b3:81:3c:1a:f6:79:64:c1:23:b7:83.

Please contact your system administrator.

Add correct host key in /home/czhang/.ssh/known_hosts to get rid of this message.

Offending key in /home/czhang/.ssh/known_hosts:3

RSA host key for 10.0.0.124 has changed and you have requested strict checking.

Host key verification failed.

This is because the RSA host key has changed since reinstalled the system.
Just remove the RSA key will solve the problem.

$ rm /home/czhang/.ssh/known_hosts

17/05/2011

Ubuntu 10.04 Install No Machine NX

Download DEB package from here:
http://www.nomachine.com/download-package.php?Prod_Id=2573

$ sudo chmod 755 /usr/lib/cups/backend/ipp
$ sudo dpkg -i nxclient_3.4.0-7_x86_64.deb

11/05/2011

Install QWT in Fedora 14

yum install libQtGTL
yum install libQtGTL-devel
yum install gcc-c++
yum install qt-devel

1. Install Qt programm (Will be installed in /home/czhang/QtDSK)
2. Download qwt-6.0.0.tar.bz2
3. cp qwt-6.0.0.tar.bz2 /home/czhang/
4. tar -xjvf qwt-6.0.0.tar.bz2
5. qmake-qt4
6. make
7. sudo make install
8. sudo cp /home/czhang/qwt-6.0.0/designer/plugins/designer/libqwt_designer_plugin.so /home/czhang/QtSDK/QtCreator/lib/qtcreator/plugins/designer
9 cp -a /home/czhang/qwt-6.0.0/lib/* /usr/lib64  // copy all libqwt.so libqwt.so.6 etc.
10 Add following codes in the end of .pro file in Qt, before build
LIBS += -L/usr/local/lib -lQtSvg
INCLUDEPATH += /usr/local/qwt-6.0.0/include
LIBS += -L/usr/local/qwt-6.0.0-rc5/lib -lqwt

10/05/2011

13/04/2011

Beginners: Learn Linux


From (http://linuxreviews.org/beginner/#toc18)


1. What is Linux?

Linux is a free Unix-type operating system for computer devices. The operating system is what makes the hardware work together with the software. The OS is the interface that allows you to do the things you want with your computer. Linux is freely available to everyone. OS X and Windows are other widely used OS.

Linux gives you a graphical interface that makes it easy to use your computer, yet it still allows those with know-how to change settings by adjusting 0 to 1.
It is only the kernel that is named Linux, the rest of the OS are GNU tools. A package with the kernel and the needed tools make up a Linux distributionMandrake , SUSE Linux,Gentoo and Redhat are some of the many variants. GNU/Linux OS can be used on a large number of boxes, including i386+ , Alpha, PowerPC and Sparc.

2. Understanding files and folders

Linux is made with one thought in mind: Everything is a file.
A blank piece of paper is called a file in the world of computers. You can use this piece of paper to write a text or make a drawing. Your text or drawing is called information. A computer file is another way of storing your information.
If you make many drawings then you will eventually want to sort them in different piles or make some other system that allows you to easily locate a given drawing. Computers use folders to sort your files in a hieratic system.
A file is an element of data storage in a file system (file systems manual page). Files are usually stored on harddrives, cdroms and other media, but may also be information stored in RAM or links to devices.
To organize our files into a system we use folders. The lowest possible folder is root / where you will find the user homes called /home/.
/
/home/
/home/mom/
/home/dad/
Behind every configurable option there is a simple human-readable text file you can hand-edit to suit your needs. These days most programs come with nice GUI (graphical user interface) like Mandrakes Control Center and Suses YAST that can smoothly guide you through most configuration. Those who choose can gain full control of their system by manually adjusting the configuration files from foo=yes to foo=no in an editor.
Almost everything you do on a computer involves one or more files stored locally or on a network.
Your filesystems lowest folder root / contains the following folders:
/binEssential user command binaries (for use by all users)
/bootStatic files of the boot loader, only used at system startup
/devDevice files, links to your hardware devices like /dev/sound, /dev/input/js0 (joystick)
/etcHost-specific system configuration
/homeUser home directories. This is where you save your personal files
/libEssential shared libraries and kernel modules
/mntMount point for a temporarily mounted filesystem like /mnt/cdrom
/optAdd-on application software packages
/usr/usr is the second major section of the filesystem. /usr is shareable, read-only data. That means that /usr should be shareable between various FHS-compliant hosts and must not be written to. Any information that is host-specific or varies with time is stored elsewhere.
/var/var contains variable data files. This includes spool directories and files, administrative and logging data, and transient and temporary files.
/procSystem information stored in memory mirrored as files.
The only folder a normal user needs to use is /home/you/ - this is where you will be keeping all your documents.
/home/elvis/Documents
/home/elvis/Music
/home/elvis/Music/60s
Files are case sensitive, "myfile" and "MyFile" are two different files.
For more details, check out:

3. Understanding users and permissions

Linux is based on the idea that everyone using a system has their own username and password.
Every file belongs to a user and a group, and has a set of given attributes (read, write and executable) for users, groups and all (everybody).
A file or folder can have permissions that only allows the user it belongs to to read and write to it, allowing the group it belongs to to read it and at the same time all other users can't even read the file.

4. Who and what is root

Linux has one special user called root (this is the user name). Root is the "system administrator" and has access to all files and folders. This special user has the right to do anything.
You should never log on as this user unless you actually need to do something that requires it!
Use su - to temporary become root and do the things you need, again: never log into your sytem as root!
Root is only for system maintenance, this is not a regular user (LindowsOS don't have any user management at all and uses root for everything, this is a very bad idea!).
You can execute a command as root with:
su -c 'command done as root'
Gentoo Linux: Note that on Gentoo Linux only users that are member of the wheel group are allowed to su to root.

5. Opening a command shell / terminal

To learn Linux, you need to learn the shell command line in a terminal emulator.
In KDE: K -> System -> Konsoll to get a command shell)
Pressing CTRL-ALT-F1 to CTRL-ALT-F6 gives you the console command shell windows, while CTRL-ALT-F7 gives you XFree86 (the graphical interface).
xterm (manual page) is the standard XFree console installed on all boxes, run it withxterm (press ALT F2 in KDE and Gnome to run commands).
Terminals you probably have installed:
Non-standard terminals should install:

6. Your first Linux commands

Now you should have managed to open a terminal shell and are ready to try your first Linux commands. Simply ask the computer to do the tasks you want it to using it's language and press the enter key (the big one with an arrow). You can add a & after the command to make it run in the background (your terminal will be available while the job is done). It can be practical to do things like moving big divx movies as a background process: cp movie.avi /pub &Jobs - the basics of job control

6.1. ls - short for list

ls lists the files in the current working folder. This is probably the first command to try out. It as a number of options described on the ls manpage.
Examples:
ls
ls -al --color=yes

6.2. pwd - print name of current/working directory

pwd prints the fully resolved name of the current (working) directory. pwd manpage.

6.3. cd - Change directory

cd stands for change (working) directory and that's what it does. The folder below you (unless you are in /, where there is no lower directory) is called "..".
To go one folder down:
cd ..
Change into the folder Documents in your current working directory:
cd Documents
Change into a folder somewhere else:
cd /pub/video
The / in front of pub means that the folder pub is located in the / (lowest folder).

7. The basic commands


7.1. chmod - Make a file executable

To make a file executable and runnable by any user:
chmod a+x myfile
Refer to the chmod manual page for more information.

7.2. df - view filesystem disk space usage

df -h
Filesystem Size  Used Avail Use% Mounted on
/dev/hda3 73G 67G 2.2G 97% /
tmpfs 2.0M 24K 2.0M 2% /mnt/.init.d
tmpfs 252M 0 252M 0% /dev/shm
The flags: -h, --human-readable Appends a size letter such as M for megabytes to each size.

7.3. du - View the space used by files and folders

Use du (Disk Usage) to view how much space files and folders occupy. Read the du manual page for flags and usage.
du is a part of fileutils.
Example du usage:
du -sh Documents/
409M Documents

7.4. mkdir - makes folders

Folders are created with the command mkdir:
mkdir folder
To make a long path, use mkdir -p :
mkdir -p /use/one/command/to/make/a/long/path/
Like most programs mkdir supports -v (verbose). Practical when used in scripts.
You can make multiple folders in bash and other shells with {folder1,folder2} :
mkdir /usr/local/src/bash/{old,new,dist,bugs}
The command rmdir removes folders.

7.5. passwd - changes your login password

To change your password in Linux, type:
passwd
The root user can change the password of any user by running passwd with the user name as argument:
passwd jonny
will change jonnys password. Running passwd without arguments as root changes the root password.
If you need to add several new users and give them password you can use a handy program like Another Password Generator to generate a large set of "random" passwords.

7.5.1. KDE

From KDE you can change your password by going:
  • K -> Settings -> Change Password
  • K -> Settings -> Control Center -> System Administration -> User Account

7.6. rm - delete files and folders, short for remove

Files are deleted with the command rm:
rm /home/you/youfile.txt
To delete folders, use rm together with -f (Do not prompt for confirmation) and -r(Recursively remove directory trees):
rm -rf /home/you/foo/
Like most programs rm supports -v (verbose).

7.7. ln - make symbolic links

A symbolic link is a "file" pointing to another file.
To make a symbolic link :
ln /original/file /new/link
This makes /original/file and /new/link the same file - edit one and the other will change. The file will not be gone until both /original/file and /new/link are deleted.
You can only do this with files. For folders, you must make a "soft" link.
To make a soft symbolic link :
ln -s /original/file /new/link
Example:
ln -s /usr/src/linux-2.4.20 /usr/src/linux
Note that -s makes an "empty" file pointing to the original file/folder. So if you delete the folder a symlink points to, you will be stuck with a dead symlink (just rm it).

7.8. tar archiving utility - tar.bz2 and tar.gz

tar (manual page) is a very handle little program to store files and folders in archives, originally made for tapestreamer backups. Tar is usually used together with gzip (manual page) or bzip2 (manual page), comprepssion programs that make your .tar archive a much smaller .tar.gz or .tar.bz2 archive.
kde
You can use the program ark (K -> Utilities -> Ark) to handle archives in KDE. Konquerortreats file archives like normal folders, simply click on the archive to open it. The archive becomes a virtual folder that can be used to open, add or remove files just as if you were working with a normal folder.

7.8.1. tar files (.tar.gz)

To untar files:
tar xvzf file.tar.gz
To tar files:
tar cvzf file.tar.gz filedir1 filedir2 filedir2...
Note: A .tgz file is the same as a .tar.gz file. Both are also often refered to as tarballs.
The flags: z is for gzip, v is for verbose, c is for create, x is for extract, f is for file (default is to use a tape device).

7.8.2. bzip2 files (.tar.bz2)

To unpack files:
tar xjvf file.tar.bz2
To pack files:
tar cvjf file.tar.bz2 filedir1 filedir2 filedir2...
The flags: Same as above, but with j for for bzip2
You can also use bunzip2 file.tar.bz2 , will turn it into a tar.
For older versions of tar, try tar -xjvf or -xYvf or -xkvf to unpack.There's a few other options it could be, they couldn't decide which switch to use for bzip2 for a while.
How to untar an entire directory full or archives?
.tar:
for i in `ls *.tar`; do tar xvf $i; done
.tar.gz: for i in `ls *.tar.gz`; do tar xvfz $i; done
.tar.bz2: for i in `ls *.tar.bz2`; do tar xvfj $i; done