NOTE: Please be aware that the recent board software upgrade has corrupted the formatting on many threads/posts here on the board. This thread happens to be one of those that was affected. Please be patient with us here at Scot's while we manually repair each of these posts. You can always visit Bruno's Tips for Linux Explorers directly to read this same info that you see here in this thread. Thank you for your understanding.

~Eric, for the entire Staff at Scot's.

____________________________________________________________

General Linux tips can be a bit difficult to locate. In order to simplify where to look for the tips, I started this thread. I will add a new tip on a regular basis. Please keep in mind these tips are posted in random order, based upon questions posted on any given day. These do not provide full information, but just enough to make you hungry for more.

NOTE: This site has exactly the same info but additionally an accurate search function through the Tips

A full system crash is very rare in Linux, most of the times it is only one program that acts up. There are several ways to recover from a crashed program.

1). If a program blocks, crashes or runs-away ( does not want to close or stop running ), change desktop and press the Ctrl+Esc keys. You will get the Process Table with all processes running on your system ( some processes may appear several times, that is normal ) the first four columns are the most important, if you know the name of the process things are simple, if you don't: in the 3rd and 4th you can see what is consuming all that cpu. Now remember or note down the PID number ( Process IDentifier ) you will need this. ( for multiple processes with the same name only the last one is the one you're after ).
Now go to yet another desktop open a terminal/console type < su > ( without the <> ) and give your root password, then type < kill 4246 >; ( if 4246 was the pid number ).
That's all, job done ! ( rebooting like in Windows is NOT needed in Linux !)

(There are other ways with names instead of numbers, terminal instead of gui process table, but this is the most general way to save your butt )

2). If all your desktops are blocked ( when X crashes): Press Ctrl+Alt+F1, you will go out of X, and get an empty terminal screen, fully black with a login prompt. ( there are 6 terminals available F1 to F6 ) Then log in as "root" ( not "su" this time ) and type <top>, you will get the same process-table with the PID numbers, find the number that's hurting, close top with the"Q" key, press Alt+F2, you will get a second black screen ( terminal ) to log in to, log in as root and < kill 4246 >.
For returning to X, press Alt+F7 !

3). Also you can try Ctrl+Alt+Backspace . . . it will log you out of X and bring you back to the graphical login screen where you can start KDE or Gnome again.

4). If even this does not help or you can not find the process and PID number just type "reboot" at the root-prompt ( of a Ctrl+Alt+F1 terminal ) and you will get a clean reboot.

In addition to the PID story in Runaway Processes If all is blocked and even Ctrl+Alt+backspace ( what should be a last resort ) does not react, if your system does not react on any action ( like I said before, very rare in Linux ) remember the next line:

Raising Skinny Elephants Is Utterly Boring

Here is how you "raise the elephant":

Alt+SysRq+r ( SysRq is on the same button as print screen ) ( The LEFT Alt key )
Alt+SysRq+s
Alt+SysRq+e
Alt+SysRq+i
Alt+SysRq+u
Alt+SysRq+b

Give a little time between keystrokes.

The r stands for put keyboard in raw mode
The s for sync the disk
The e for terminate all processes
The i for kill all processes
The u for remount all filesystems read only
The b for reboot the system

THIS IS THE VERY LAST SAVE YOUR BUTT PROCEDURE ! ONLY IF ALL ELSE FAILS !

Bruno

PS: If your filesystem is Ext3 or ReiserFS and on reboot it wants you to do a filesystem check, don't touch any key as it asks you to press "Y" and let it recover the journal automatically.

NOTE: For the skinny elephants to work you need to have the sysrq-key enabled in the kernel. (CONFIG_MAGIC_SYSRQ)
You can check if it is enabled by typing 'ls /proc/sys/kernel/sysrq' if it's there, it's enabled.

Here is a simple one: Copy and paste from one program to another program, ( your browser to a text editor, from one desktop to another, from a text editor to the console/terminal etc.etc. )
Just select the text with your mouse ( this copies it automatically to the clipboard ) go to the other screen and push the wheel ( or middle button ) that pastes it.
So only two movements . . no context menu . . just select and paste.

The only exception is OpenOffice, there you will have to do in like you do it in Windows: select, rightclick, choose copy from the contextmenu, rightclick and paste it from the context menu.

Sure the keyboard shortcuts Ctrl+c and Ctrl+v work in Linux too

In most distro's you will find a clipboard next to the clock ( an orange icon with a K ) . . . it remembers the last 5 entries ( or more if you configure it that way ) . . . simply tick the entry you want to paste and pushing the wheel will paste that entry where you want it.

If you want to copy a full config file to a textfile that you can send as a mail-attachment, one command will do: ( example the lilo.conf file )

# cat /etc/lilo.conf >lilo.txt

This will put a text file in your /home directory by the name of lilo.txt

If you run Mandrake, SUSE or many other distro's ( RedHat has anacron installed as default ) and your computer is not ON 24 hrs a day, there are several cron-jobs ( maintenance ) that might be forgotten because they are planned for 3 - 4 o'clock at night.Installing anacron will set this straight, anacron picks up forgotten cron-jobs and executes them 5 minutes after you boot your computer. You will notice extra activity of your CPU and harddisk for about 5 to 7 minutes !

Typical cron-jobs are updatedb updating the locate database and various other databases.

Logrotate that zips up old logfiles, var/log/syslog and var/log/messages might grow so big that in extreme cases you could run out of diskspace : resulting in having to reinstall the OS !

When I first tried to join a local Linux User Group I was told to "read all the books and howtos and don't ask stupid questions and waste everybody's time". Needless to say I took their advice but didn't join their group.Joy

A little note on the site:
it's not my aim to turn you into full blown Linux geeks, but only to hand you the basics, the bare minimum in order to give you the appetite to learn more about Linux.Moderators, please make adjustments and corrections without hesitation, English is not my native language and I'm far from being a Linux guru.

I would never have started this thread without the backup of knowledgeable moderators as you are.

All the tasks we do on the commandline are done in a "dos-window", in Linux we call it a "Shell", "Console" or "Terminal" ( the name depends on the distro you use, Terminal is used in RedHat, Console in Mandrake ).
As you start up a Console ( look in your menu ) you will be presented with a “prompt“, this prompt will end with a $, this means that you are logged in as a normal user.

Once you type < su > and give your root password the $ will change in a #, indicating that you are root.
Ctrl+d will log you out as root and bring you back to $, if you do a Ctrl+d again the console will close.

( A normal prompt will look like: [localhost@localdomain:~]$ Not very spectacular, but in a few days we will start tweaking your prompt into something fancy, but the $ and # will always stay the same )

For nearly every program or command there are “man”-ual pages stored on your computer. You can read them by typing < man man >, this will give you the man pages for the command man. < man cp > will give you the man pages for the command cp. The spacebar lets you scroll the page. With < q > you close the man pages !

More info than the man pages can often be found by typing < --help > after the command. See < cp --help > gives a different result then < man cp >.

All configuration files in Linux are written in plain English, easy to read and to adapt. We use a text-editor to write or make changes to those files.
The two most popular, powerful and "difficult" editors that you will find in every distro are Vi and Emacs. They both have "syntax-highlighting" to make writing code easy.

There are hundreds of commands for Vi, we will only touch the absolute minimum.

$ vi tessst

Will open the file tessst in located in your /home, if the file does not exist it will create one.
Vi has 3 modes: a command mode, an insert mode and an ex mode.
When you start Vi it starts in command mode. So we first have to type an < i > to put it in insert mode. Now you can type "the quick brown fox etc."
After inserting the text we go back to command mode < Esc > and save the file with ZZ. Thats all we have to know for the beginning.: < i > for insert < Esc > for command, ZZ for saving the file.

Some more commands for Vi: ( less important )
i = insert text before the cursor
a = insert text after the cursor
: = switch to ex mode
$ = go to last place on the line
^ = go to first place on the line
w = next word
b = previous word
G = last line of the file
20G = go to line no 20
y = copy ( y3w = copy 3 words ) ( y3j = copy 4 lines )
p = paste
d = cut
x = delete character under the cursor

Emacs

Emacs is made easy because these days it has a GUI in modern distro's, but we will use the keyboard because it has more speed.

$ emacs ssset

Will open or create the file ssset in your /home
OK type away: " the quick brown etc".
Now to save the file do: Ctrl+x, Ctrl+c, y
Well i said we were going to keep it simple !

Leave the tessst and ssst files in your /home, in the next section we can do some exercises with them.

Open an console on desktop 1, open the home directory by clicking on it on desktop 2 ( there you can see and verify the commands executed on desktop 1 )

$ mkdir One ( without the $ ) ( makes a dir One in your home dir )
$ mkdir one ( Linux is case sensitive so One and one are not the same ! ) ( makes a dir one in your home dir)
$ cp tessst One ( copies the file tessst, that we made in previous Tip, to dir One )
$ mv ssset one ( moves the file ssset, that we made in previous Tip, to dir one )
$ mv one One ( moves dir one in dir One )
$ cd One ( see how the promt puts the current dir in in the prompt ) ( puts you in dir One )
$ ls ( shows you what is inside One )
$ cat tessst ( shows contents file tessst )
$ rm tessst ( removes file tessst from One dir )
$ cd .. ( puts you back in your home dir
$ rm tessst ( removes tessst from home dir )
$ rm -rf One ( now all files and directories we played with are removed )

How about some basic stuff for real beginners? When I first started I couldn't work out how to get the CD to work, find out where to configure the sound, how to install stuff, where did it go when it was installed etc. That's the sort of thing that puts a lot of people off Linux, they're not all like us, willing to learn, they want it to work straight away.Joy

This is what I had in mind for the next week or so:Text editors Vi and EmacsNavigating the filesystem and basic commandsHidden files(Auto)Start programs at startupLocate, search filesInstall software with urpmi, rpm and tarballConfiguring Multi Media keysTweaking the promptIso burning and checksumFile permissions

I will add configuring sound to the list !More items can be added for the following week too Bruno

back to runaway X Windows (KDE, etc.) program(works particularly well for Mandrake and RedHat RPM based systems):In KDE, click the K Button, select Run command, type "xkill" (sans quotes), your cursor turns into a funny square, click the program that is in runaway mode and bye bye program.If that fails, do "ALT, CTRL, F1" and then CTRL C to break out of XWindows (KDE, etc.). Then you can go back into X (KDE, etc.) ... problem has usually solved itself by exiting X. No need to reboot.

How about some basic stuff for real beginners? When I first started I couldn't work out how to get the CD to work, find out where to configure the sound, how to install stuff, where did it go when it was installed etc. That's the sort of thing that puts a lot of people off Linux, they're not all like us, willing to learn, they want it to work straight away.Joy

Joy,With the newer distributions (2.4.x kernel) a lot of this has become very automatic, almost plug'n'play. For instance, Red Hat and Mandrake now automounts your CDs if put it in while you're in X Windows. (If you are in the console uses this command: mount /dev/cdrom /mnt/cdrom and the contents of the CD are accessible from the filesystem directory /mnt/cdrom.)If you aren't familiar with the way Linux handles storage devices here's a concise explanation: You know that in DOS and Windows you access storage devices by drive letters such as a: for the floppy drive, c: for your active primary partition and letters for all other partitions, optical drives, USB keys, etc. In Linux you access storage devices by mounting the device so that it appears as if it's part of the directory structure, or as it is technically called, the filesystem. The Linux directory /dev is a special type of directory known as a block device. The /dev naming convention is used to identify the storage device and it is this device that you mount to a directory. Most Linux users stick with the default convention of mounting storage devices under the /mnt directory.

'freedom...is actually the reason that men live together in political organisations at all. Without it, political life as such would be meaningless. The raison d'Être of politics is freedom, and its field of experience is action'.
My Flickr Photo Blogdel.icio.us bookmarks

Thanks Peachy, but I'm quite comfortable with the Penguin, I was thinking more of the absolute beginner who would probably have a minor heart attack if a Linux distro suddenly dropped him back at the command line.Joy

Quint:Well, eh, kind of ! However very rare, ( extremely seldom compared to windows ) there are system freezes. Program crashes are more common du of bugs ( bugfixes ). Processes that run wild in a loop and keep consuming cpu, mostly because you made a mistake yourself. All those I call "runaway". The first bue screen o.d. has not been seen up till now on a Linux system. ( if you would see one, make a screenshot !! ) Bruno

( Will list all files in the /etc dir that end with conf including conf )

$ ls /etc/[!g-z]*

( Will list all files in /etc/ that do not start with the letters g to z )

$ locate *doc

( Will produce a long list of the files ending on doc on your computer )

Because this list is very long, and we might want to keep it:

$ locate *doc >alldocs

( Will create a textfile called alldocs in your /home listing all the doc files crowding your computer. ( Notice the speed of you lovely Linux system ) )

$ ls /mnt/win_c/My\ Documents/*txt

( Will make a list of all your txt files it finds in your C:\windows\My Documents. )
Note: Linux does not like spaces in names ! So in My\ Documents, the \ tells it to ignore the next character. An other way to do it is "My Documents".

Another, but somewhat complicated command for searching is "find". See for instructions how to use it: The Find Command

More Magic:

The Tab key autocompletes:

Try this, < cd /u > and press tab now add an "s" and press tab, give an "h" and press tab, now we have got < cd /usr/share/ >

Software comes in many different kind of packages deb, rpm and tarball are the most popular, but there are a bunch of other ones too, just take the Firefox browser; just unpacking it and creating a shortcut from the firefox script to the desktop is all there is to it !
Tarballs can be a real problem because of lib dependencies ( The nightmare of every Linux starter ! )

Today we'll introduce you to urpmi, a kind of rpm with gold-plating, because all dependencies are taken care of automatically.
You have to be on-line to download and install the packages though !
Urpmi does not only download the rpm you want but also all packages needed to make the install successful , easy as cake !

In Mandriva you can use the graphical software manager in the Mandriva Control Center, it uses urpmi by clicking on a few buttons.
But there is a much faster way of installing software using urpmi on the commandline and you will be surprised how easy it actually is

An example, installing the gkrellm package ( system monitors ) would type the command:

# urpmi gkrellm

. . . and if you want to install both the program with the plugins and the themes in one go you do

# urpmi gkrellm gkrellm-plugins gkrellm-themes

Then, if you want to remove/uninstall gkrellm you do

# urpme gkrellm

Well, that was easy enough wasn't it ? And like I said: urpmi resolves dependencies but does need an working net connection.