My Linux FAQ

Introduction

Ok, I am not a Linux expert by no means. But I did have a lot of questions when I started with Linux (coming from Windows). This page is an attempt to collect the most frequently asked questions to myself by myself, as a Linux newbie. Maybe this will be helpful to someone else. Or, it may help me if I loose my memory...
Oh, by the way... the initial distro was Mandrake, these days I do Debian.

Disclaimer: Use this info on your own risk. I take no responsibility if your system screws up. The tips here worked for me, they may not work for you. Check the man-pages, HOWTOs, and other resources. Be a responsible root.

The questions

The shell vi The file system Compiling the kernel KDE

The shell

Q: Isn't there anything better than the shell?
A: Define better... A lot of the stuff can be done using the GUI tools in KDE, GNOME, etc. However, it may often be faster to do it in the shell. Besides, it will make feel like a hacker. And it will impress your Windows and MAC friends...

Q: What are some useful commands?
A: Commands that I find useful are...


Q: How do I move or rename a file?
A: To move it...
mv filename /to/wherever/
This can also be used to rename a file, simply type...
mv filename new_filename

Q: How do I delete a directory?
A: Same as deleting a file, but we'll force the deletion, and make it recursive... Be careful!
rm -fr directory

Q: How do I change a symbolic link to a file?
A: A symbolic link allows you to use another name for a file, while keeping the original file name. Quite handy...
ln -fs original_name link_name

Q: How do I find a file?
A: There are a couple of different ways, I often use...
find /starting_directory -name 'filena*'
To search everywhere, specify /, you may want to be root...

Q: This command takes forever. How do I abort?
A: ctrl+c

Q: I'm tired of typing the same commands over and over. Can I speed it up?
A: Yes. Here's where the shell excel...
Q: How do I extract .tar.gz and .tar.bz2 files?
A: These tar-balls can be extracted using...
tar xvzf file_name.tar.gz
for .tar.gz, and...
tar xvjf file_name.tar.bz2
for .tar.bz2

vi

Q: vi sucks!
A: Though this is not a frequently asked question, it is a frequently expressed opinion. vi can be very frustrating at first, but just like a crappy song played over and over again on the radio - after a while you grow to accept it... So, you'd better learn to live with vi (or actually vim, as this is the program mostly used these day). It is in virtually every Linux and UNIX distribution, and if you learn the basics you will never be without a file-editor.
Some people claim that vi can be a very powerful editor. Frankly, I have never had the desire, energy, or time to learn anything but the bare essentials of vi... For more "advanced" editing, I use a GUI editor. By the way, vim sucks a little bit less than pure vi...

Q: How do I perform basic editing?
A: Well, vi filename starts the editor with the (existing or non-existing) file. When you first start vi you won't be able to enter text (just delete), this is called command mode. dd deletes a line. To enter text press i (as in input mode). Escape brings you back to the "initial" command mode.

Q: How do I exit vi?
A: Easier said than done... The quick way is Escape (if you're in the input mode), and then ZZ (that is, two capital Z's). This will save the current file, and exit vi.

Q: How do I exit without saving?
A: By the extremely logical command (in non-insert mode) :q!

The file system

Q: I can't find anything. Where is it?
A: If you're looking for a specific file, you could try to find it... But it helps to have a basic understanding of the file system in Linux (Mandrake). Here's the "big picture"...
Note: The information comes mostly from the Mandrake Reference Guide, and the "graphic" is shamelessly inspired by Garrik's Little Mandrake FAQ.

/--,       :the root directory, the start of it all...
   |-/bin  :essential binary files, necessary for system operation
   |-/boot :stuff for your bootloader, the kernel can be here
   |-/dev  :system device files
   |-/etc  :system configuration files
   |    |-/rc.d      :system init scripts
   |    '-/sysconfig :various configuration files
   |
   |-/lib  :libraries essential to the system
   |    '-modules :kernel modules
   |
   |-/home :personal directories for the user(s)
   |-/mnt  :mounting points for devices (CD-rom, Windows, etc.)
   |-/proc :kernel parameters, good for hardware info
   |    '- /sys :allows you to change some kernel parameters
   |
   |-/root :the directory for root
   |-/sbin :system binaries essential for start-up
   |-/tmp  :temporary files
   |-/usr  :main application-storage, not needed for start-up
   |    |-/bin     :majority of system binaries
   |    |-/lib     :libraries for /usr/bin and /usr/sbin
   |    |-/local   :non-mdk installed applications
   |    |
   |    |-/include :headers needed for compilation
   |    |-/sbin    :system applications
   |    |-/share   :architecture-independent data
   |    |      |-/doc :documentation for a lot of stuff
   |	|      '-/man :pages for man...
   |    |-/src     :source-files, including kernel sources
   |    '-/X11R6   :stuff needed to run the X Window System
   |
   '-/var  :various data files used by some programs
        '-/log :log files, including dmesg and syslog

Q: Where do I find the messages I see when booting?
A: Check out dmesg and syslog in /var/log.

Compiling the kernel

Q: Isn't it hard to compile the kernel?
A: You'd probably be surprised how easy it is (if you follow instructions). I was. The only instructions I had were the ones found in the Mandrake Reference Guide. You probably don't want to compile a kernel until you have read that document...

Q: Why do I need to compile the kernel?
A: Well, you want to increase your cred as a Linux-geek, don't you? Besides, when you're picking up someone at the bar, and mention that you compile your own kernel, they will look tenderly into your eyes and say: "you had me at compile". Why do you think so many Linux-geeks get laid?
Anyway, I see two reasons why you need to compile your own kernel:
  1. Because you can.
  2. You need to add some functionality to the kernel in order to make your computer run the way you want to.

Q: What do I need in order to compile the kernel?
A: Erhm, a couple of things are needed...

Q: How do I configure the kernel?
A: If you have compiled the kernel previously...
make mrproper
...will clean up any left-overs from that compilation. Then...
make xconfig
...will start the configuration program. Specify the settings you need. The defaults may be good enough. Be careful, read the help for each setting. Save. This will create a file called .config containing all the settings.
It may be a good idea to customize the name of the kernel by changing the EXTRAVERSION line at the beginning of the Makefile file.
Note: if you're compiling a kernel with the exact same version as one of the kernels already existing on your system, you really should remove the modules for that (existing) kernel version. The modules are located under the kernel version in /lib/modules/. Life will be easier if you have booted to another kernel version...

Q: How do I compile the kernel?
A: Once the kernel is configured, the following commands should be run:
make dep
make clean bzImage modules
make modules_install install
Note: For a 2.4.x kernel  make dep  is required. For a 2.6.x kernel it is not used.
Debian is doing things differently...
make-kpkg clean
make-kpkg --initrd --revision=something-0.1 kernel_image modules_image
dpkg -i /usr/src/kernel-image-some_version_something-0.1_i386.deb

Q: Is the kernel installed after compilation?
A: It should be; though, I've noticed in the Mandrake system that the installation is not as installed as I would prefer it to be; therefore, some additional fixin' is needed...
  1. In /boot/ make sure that the following symbolic links exists:
initrd.img -> initrd-your_kernel_version.img
System.map -> System.map-your_kernel_version
vmlinuz -> vmlinuz-your_kernel_version
  1. The installation adds a new entry in /etc/lilo.conf (if LILO is your boot-loader of choice). The entry is for the new kernel. Since the symbolic links points to the new kernel, change the new LILO entry to reflect the previous kernel instead.
  2. Don't forget to run LILO (lilo) after lilo.conf is changed. I have forgotten that numerous times...
  3. Reboot and enjoy. Should any problems emerge, reboot to the older kernel and fix the problems. In the worst case, reboot to a Knoppix CD.

Q: How do I know what kernel version I'm running?
A: In the shell, type...
uname -r
Q: When I do make xconfig I get "Xlib: connection to :0.0 refused by server". What's wrong?
A: Hmm, root is for some reason not allowed to make things happen in X. I put the following line in ~/.bashrc (for root):
cp ~normal_user/Xauthority


KDE

Q: How do I get those kool translucent menus?
A: Start the KDE Control Center ("Configure your desktop"), choose LookNFeel, Style. Click on Effect, and check "Enable GUI effects", then you can select the translucency effect...

Q: How do I get that kool translucent shell window?
A: In a shell window, click Settings, Configure Konsole. Click on Schema, select transparent, and enjoy...

1