Tuesday, May 15, 2007

fedora 5 using windows printers

用 system-config-printer 来安装windows 下面的共享打印机。但是在这之前一定要设置防火墙,允许samba服务访问网络。

Thursday, August 03, 2006

掌门网等自动弹出网页的解决办法

掌门网等自动弹出网页的解决办法

2006-04-19

今天真不爽,我也是在网上行走多时的老鸟啦,居然会中招!(虽然这个病毒广告编写者的水平还算可以吧)我正在上网中,突然发现我的防火墙blackice一直报警,我也没太在意,继续上网,可是防火墙报警报了都好几个小时啦,而且试探连接的IP一直的变换,多年的上网经验使我意识到我中招了。

首先检查我的注册表启动项HKEY_LOCAL_MACHINE\\Software\\Microsoft\\Windows\\CurrentVersion\\Run 发现完全正常,里面只有默认的输入法和诺顿防火墙。 接着用Tcpview.exe查看和网络连接的情况,没有发现有连接到我机器的IP。然后再用Regmon监视注册表,这时发现了可疑的进程调用的注册表位置

HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\policies\\Explorer\\Run 里面有个IPSec32.DLL,位置是C:\\PROGRA~\\COMMON~\\system\\msdc32.dll,_S1 首先删除这个键值,然后找到这个文件夹,在打开了"显示所有文件和文件夹"后还是看不到msdc32.dll ,于是又打开了"隐藏受系统保护的操作系统文件(推荐)",终于找到了这个msdc32.dll,直接删除当然是删除不了的,写保护了嘛,于是我就给它改了个名字11msdc32.dll,打算重启后删除,但是重启后发现这个文件夹下有了2个文件11msdc32.dllmsdc32.dll,而此时注册表

HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\policies\\Explorer\\Run 里删除的IPSec32.DLL键值又自动回来了,这使我意识到木马文件绝不仅仅是这一个dll文件。晕~好烦,又得分析,真是浪费我宝贵的学习时间!接下来通过大家的协助分析,终于彻底弄明白了这个木马的特征和机理,详细解释一下:这个病毒没有单独的进程,所以当你查看进程时会发现你的进程很正常,没有多余的进程。那是因为它捆绑在了explorer.exe上面,细心的用户会发现你explorer.exe 进程的大小会比以前大了点。这个木马一共有2dll动态链接库和一个exe文件,分别在这三个地方:

C:\\PROGRA~1\\COMMON~1\\system\\msdc32.dll

C:\\PROGRA~1\\COMMON~1\\system\\mod\\mstd.dll

C:\\WINDOWS\\ .exe (这个注意一下exe前面的是空格,这个设计也很巧妙,使你在命令提示符下无法删除)在重启后进入安全模式,把这三个文件删除,然后展开注册表,查找"msdc32.dll"(应该会查到3个吧,可能会因为机器不同而有所不同),然后都统统删除。此时还没完,把注册表展开到[HKEY_LOCAL_MACHINE\\Software\\Microsoft\\Windows

NT\\CurrentVersion\\Winlogon] 里面有一个userinit.exe 是系统的,而后面逗号后的c:\\windows\\.exe 这是病毒加的,意思就是启运userinit.exe 捆绑嘛,把逗号后的c:\\windows\\.exe 删除。这时再重启就一切正常了。----看到这以为问题解决的朋友继续看本文的最后几行下面谈谈这个病毒,用UltraEdit编辑了一下msdc32.dll,发现它是从这里下载

更新信息的:http://c1.cn/getinfo/updatelist.txt

下载http://c1.cn/dw/1.dll文件。

下载下来的就是mstd.dll

mstd.dll从这里下载广告信息:

http://c1.cn/getinfo/actionlist.txt

目前(也就是2006.3.171732)我下载它的广告信息,如下:

id0=995083D4ECE58166F3948CA4499A0693

userid0={*}

date0=7200000

count0=7

action0=pop

content0=www.byair.com

state0=0

version0=1

id1=5083D4ECE58A4499A0693166F3948C99

userid1={*}

date1=1800000

我们可以很清楚的看到www.byair.comwww.58.com这两个网站作了广告,一起鄙视这两个网站啊!!!

http://c1.cn/getinfo/updatelist.txt 中的信息我也下载了一份,如下:

[Files]

FileCount=2

FileName0=mstd.dll

FileVersion0=1.5

FileId0=AB79CDC10A1A9351478aB2E05CFCAD09

FilePath0=http://c1.cn/dw/1.dll

FileName0=mstd.dll

FileName1=msdw.dll

FileVersion1=1.0

FileId1=D2B6EAE6D7514F96B835400CD40451C0

FilePath1=http://c1.cn/dw/2.dll

FileName1=msdw.dll

这个发病毒广告的网站http://c1.cn的服务器在江苏省无锡市 电信,病毒作者在首页留下了一些很狂躁的话,其实也就是以前的黑客常用的改首页的方式,哎,看来咱们中国人还真是没有创意啊,只会抄袭,不会创造!PS:我还有一条补充,就是上面所有做完后,文件是被清除了,但是在重起后会有一个对话框说加载msdc32.dll失败这个还需要再更改一次注册表,当然,在钢材的安全模式里也一样可以改,方法如下:msdc32.dll可以在注册表的HKLM\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Polices\\ Explorer\\Run下被找到,他写在ip_Sec中:rundll32.exe C:\\Progra~1\\Common~1\\system\\msdc32.dll,_S1,正常情况下,根本不会再polices下有Explorer, 所以将整个Explorer删除掉,下次启动就再也没有烦人的弹出框了

为了大家方便,还是给出一个按步骤的解决办法吧:

1 进入安全模式,方法是重启机器,按F8直至安全模式选项出现,选择进入。

2 打开文件夹至:C:\Program Files\Common Files\system

3 点击“工具”——“文件夹选项”——“查看”,将“隐藏受保护的操作系统文件(推荐)”一项前面的方框点空。在下面的“隐藏文件和文件夹”的两项中,选择“显示所有文件和文件夹”。

4 应用后出现病毒文件msdc32.dll,删除之。

5 进入mod文件夹,删除里面的病毒文件mstd.dll

6 找到C:\WINDOWS,发现一个名为 .exe的可执行文件,删除。

7 找到C:\Documents and Settings\用户名\Local Settings\Temp\RarSFX0文件夹,删除。

8 打开注册表:点击“开始”——“运行”,输入regedit点确定。展开注册表至HKEY_LOCAL_MACHINE\Software\\Microsoft\WindowsNT\CurrentVersion\Winlogon,里面有一个userinit.exe的键值,将后面的逗号以及c:\windows\.exe统统删除。

9 展开注册表至HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Polices\Explorer\Run,将Explorer子项完全删除。

10 点击“编辑”——“查找”,依次查找msdc32.dllmstd.dllHNETPOLCY,将找到的子值全部删除干净。

11 重启机器,一切ok

Wednesday, August 02, 2006

With linux system, pdflatex cannot display the pictures

use
pdflatex file.tex
created the file.pdf file but the pictrues in .eps formate cannot be shown. This is becasue pdflatex doesn't support .eps file, it supports .jpg, .png, .pdf file.

There are some other ways to do it:

1: .tex--(latex)->.dvi--(dvipdfm,dvipdfmx)->.pdf
2: .tex--(latex)->.dvi--(dvips)->.ps--(ps2pdf)->.pdf
it is like this:

dvipdfm -o file.pdf file.dvi
or
dvips -o file.ps file.dvi
ps2pdf file.ps file.pdf

Then the curves in .eps format can be shown.

LaTeX Tutorial

pix
Go back to home page

This page provides a progression of examples of using LaTeX for scientific typesetting. Links are provided to both downloadable and online references about LaTeX.
last modified: 02:41 AM CDT, Sun 16 Jul 2006

This page is designed for Unix/Linux users. But I have assembled some tips for people needing LaTeX on windows.

On Unix/Linux, you will need latex, pdflatex, xdvi, dvips and gv. Mandrake Linux 9.0 (and greater) has the annoying feature of only installing latex, but not xdvi, dvips of gv. You will need to install the rpm's for these programs, if they are missing in your Linux distribution. Oddly, pdflatex will not work without dvips, and Mandrake sets no formal dependency of the pdflatex rpm on the dvips rpm.


A first experience with LaTeX

Here we go. Download into a suitable directory (playtex might be a suitable name):

then:

latex jfm2esam.tex
latex jfm2esam.tex That's right, you really should type it twice
xdvi jfm2esam.dvi
dvips -o jfm2esam.ps jfm2esam.dvi
lpr jfm2esam.ps or preview first with gv

After looking at jfm2esam.ps (preferably at the 600 dpi resolution of a good printer) and being suitably impressed and excited, crack open jfm2esam.tex with a text editor and be suitably horrified. Does it really have to be that complicated? Well not always.

Try this for a gentler introduction. Download first.tex. Then

 latex first.tex
latex first.tex
xdvi first.dvi
dvips -o first.ps first.dvi
gv first.ps
lpr first.ps
pdflatex first.tex
gv first.pdf

Note: On some Linux systems, you may have gpdf or xpdf available for viewing pdf files. But gv, which originated as a postscript viewer, seems to have adequate pdf capabilities. ghostview has yielded to gv in recent Linux distros, with ghostview merely providing a symbolic link to gv.

Below you will find a progression of further examples that introduce the finer points of LaTeX. But first, read the manual...


Learning more about LaTeX

  • Besides needing latex, I highly recommend that you have the utilities jpeg2ps, ps2eps and epstopdf, which have been introduced here.
  • I recommend that you use gvim to view and edit the .tex files. For these examples to be highlighted correctly you will need some amendments to tex.vim, provided in my gvim tuneup.

  • Some of the best things in life are free. Not only LaTeX, but the documentation:

    • A not so Short Introduction to LaTeX2e: lshort.pdf. This document might be the only paper reference manual that you will ever need. Here is the home page of one of the authors: Tobi Oetiker.

    • Using EPS Graphics in Latex2e Documents: epslatex.pdf (86 pages) Detailed information about including encapsulated postscript figures in your LaTeX documents.

    • A Sample LaTeX Document: DuplexRef.ps (3 pages) Print this out to see a side-by-side example of the .tex file shown next to the final printed page.

    • Cambridge University Engineering Department also has a lot of good on-line help, though some of the advice is specific to their system.

  • As of March, 2005, the best book about LaTeX is (IMO):
    Guide to LaTeX, Fourth Edition Helmut Kopka and Patrick W. Daly. ISBN 0-321-17385-6

  • Here are some other books worthy of mention. There are three books that constitute the definitive guide to LaTeX. If you have money to burn, you will want to get all three of them, at about $35 each. Owning only one of them would be a rather frustrating experience. But they are becoming out or date, for example there is no mention of pdflatex. You can probably do without these:

    • LaTeX: a document preparation system. Leslie Lamport. ISBN 0-201-52983-1

    • The LaTeX companion. Goosens et al. ISBN 0-201-54199-8

    • The LaTeX Graphics companion. Goosens et al. ISBN 0-201-85469-4

    A book that empasizes typing complicated equations is:

    • Math into LaTeX, 3rd Edition. George Gratzer. ISBN 0-8176-4131-9

  • Latex2e help may be useful to you as an online reference, after you are familiar with LaTeX.

Bundled LaTeX examples

Below are several examples of using LaTeX. After you download thefiles.tar.gz then:

gunzip thefiles.tar.gz
tar xvf thefiles.tar
cd thefiles
cat Readme
  • texample.tar.gz Demonstrates user-defined commands, how to include graphics, and how to ultimately make either a .pdf file or a .ps file. revised February 25, 2003.
    If you are doing this course for credit, your task is to write your own paper in LaTeX. Modifying this example into an original work of your own may be the most productive way to attempt the task. Your paper must include at least two figures, at least one raster image (e.g., photo) and at least one vector graphics image (e.g., a graph of y(x)). Your paper must include at least four equations, with a least two inline and two displayed. At least two of the displayed equations must have a label, and the text must reference the equations.

  • pdfprob.tar.gz New on August 5, 2001. Demonstrates how to overcome certain problems that arise when attempting to use epic graphics within pdflatex. A short description of the problem. Revised slightly on July 13, 2006.

  • amermeteorsoc.tar.gz Shows how to use a "style file" to make the output conform to a publications standard, in this case the preprint style of the American Meteorological Society. The use of BibTex to make bibliographies is also introduced. Revised March 1, 2006.

  • oudis2.tar.gz Shows how to use the style file OUdissertation.cls to make a thesis or dissertation conforming to the standards of the University of Oklahoma's Graduate College. Loaded with examples of graphics, tables, equations, "includes" and BibTex. Revised July 15, 2006 to avoid obsolete doublespace.sty, fix margins, and upgrade for pdflatex.

  • semex.tar.gz Shows how to use LaTeX to make big-print transparencies and how to use the "psfrag" system to annotate .eps graphics with LaTeX symbols. (Traditional transparencies offer much more resolution on the screen than does Powerpoint.) Note: this may be obsolete.

Some Tips

  • As you adapt some of these examples for your own work, you are advised to make a single directory in which to store all the .sty, .cls, .bst and .bib files that you will be reusing in various projects. I made one called mysty in my home directory and have the following line in my .bashrc on gentry.metr.ou.edu:
    TEXINPUTS=.:$HOME/mysty:/usr/share/texmf/tex//:/usr/share/texmf/tex//:
    export TEXINPUTS
    BSTINPUTS=.:$HOME/mysty:/usr/share/texmf/bibtex//
    export BSTINPUTS
    BIBINPUTS=.:$HOME/mysty:/usr/share/texmf/bibtex//
    export BIBINPUTS
    If your texmf directory is elsewhere (try locate texmf), you will need to alter the path accordingly.

  • One of the annoyances of LaTeX is getting the bugs out. When an error is encountered, latex will stop, showing a prompt of ? on the monitor. Note the message about the line number of the alleged error, enter X to abort latex, and then enter :linenumber in gvim (if that is the editor you are using) to lead you to the offending line. For some errors, just (continually) hitting return at the ? prompt will allow latex to complete, and then you may find where things went wrong by viewing the .dvi file.

  • I do my work with three windows open: gvim, xterm and xdvi. Use :w within gvim to write without quitting, use xterm to execute commands and see error messages, and use xdvi to view the .dvi file. Note that xdvi will automatically refresh when it is clicked to become the top window.

  • For spell checking, long ago I used:
    ispell myfile.tex
    ispell is smart enough to skip some, but not all, LaTeX tags and math. But now I use the spell checking features of gvim.

Links


pix
Go back to home page

pix
Move to top of page

Copy an Entire Directory in Linux

this is simple but I'm forgetful so heres how you copy an entire directory, its subdirectories, and files:

cp -R dirtocopy/ newdir/

Here's how to do the copy shown in the figure below. This copies the directory /home/jane, with all its files and subdirectories, and creates a subdirectory named jane in the current directory (.) :

cp -r /home/jane

Using WINE to Run Windows Programs

Using WINE to Run Windows Programs
If you've followed the very first step above and downloaded and installed WINE on your Linux machine, then you are ready to try running your Windows program!

  1. Check to see that the WINE program is truly installed by typing the command: locate wine You should see a list of files with WINE.
  2. Be sure you have properly mounted your Windows drive. If you don't know how then click here for brief help.
  3. Edit the file /etc/wine.conf by changing the line under [Drive C] to read exactly: Path=/mnt/win
  4. Save the edited wine.conf file and then make sure you also copy the file user.dat to your Windows directory c:/windows/profiles/
  5. If you plan on running a game or other program that uses your midi then Linux midi-sequencer needs to be installed
  6. Now type: cd "/mnt/win/Program Files/Accessories" then type: wine ./calc.exe
  7. This will run Windows Calculator on your Linux! You can load any other programs by using similar commands, adjusting for directory names and file names as needed.

how to mount a NTFS system

12 June 2005

Either recompile your kernel for NTFS read support. (Hard)
Or obtain the matching the proper kernel module. Again make sure
you have the correct version (example similar to: 2.6.11-1.1369_FC4).
Use the 'uname -rm' command for more information.

Go to http://www.linux-ntfs.org/content/view/129/65/
for the module/rpm.
Go to http://www.linux-ntfs.org/content/view/127/63/
for the instructions.

[root@charon fc4]# uname -rm
2.6.11-1.1369_FC4 i686

I selected '2.6.11-1.1369_FC4' 'i686' for my Athlon-XP computer. Both parts MUST match.

[root@charon fc4]# rpm -ivh kernel-module-ntfs-2.6.11-1.1369_FC4-2.1.22-0.rr.6.0.i686.rpm
Preparing... ########################################### [100%]
1:kernel-module-ntfs-2.6.########################################### [100%]

To allow access to NTFS partitions you must (1) check how many partitions
you have, (2) create mount points, (3) mount partitions, and (4) update fstab
to mount at next boot.

Check Partitions

Check how many NTFS partitions you have:

[root@charon fc4]# fdisk -lu /dev/hda | grep NTFS
/dev/hda1 * 63 16771859 8385898+ 7 HPFS/NTFS
/dev/hda2 16771860 33543719 8385930 7 HPFS/NTFS
/dev/hda3 33752628 67312349 16779861 7 HPFS/NTFS

Usually the first will be C drive, next D, etc.

Create Mount Points

Instead of /media/, you can also use /mnt/, both will work, but make
sure to make the correct edits in all places.

[root@charon fc4]# cd /media/
[root@charon media]# mkdir c_drive
[root@charon media]# mkdir d_drive
[root@charon media]# mkdir e_drive

You don't have to use these names, if you prefer to creat folders such as
movies, documents, or winxp, any name will work (without spaces).

Mount Partitions

Run 'man mount' to fully explain what "-r -o umask=0222" does.

[root@charon media]# mount /dev/hda1 /media/c_drive/ -t ntfs -r -o umask=0222
[root@charon media]# mount /dev/hda2 /media/d_drive/ -t ntfs -r -o umask=0222
[root@charon media]# mount /dev/hda3 /media/e_drive/ -t ntfs -r -o umask=0222

Update /etc/fstab

Open '/etc/fstab' in an editor and add these lines to the END of the file:

/dev/hda1 /media/c_drive ntfs ro,defaults,umask=0222 0 0
/dev/hda2 /media/d_drive ntfs ro,defaults,umask=0222 0 0
/dev/hda3 /media/e_drive ntfs ro,defaults,umask=0222 0 0

NOTE for FAT32 users

Insted of 'NTFS' above you can use 'VFAT' to mount your FAT32 partitions. No
extra modules or download are needed. Just replace 'vfat' for 'ntfs' when
mounting and when editting '/etc/fstab'.

FAT32 read and write is supported. If you wish to mount read/write,
then use: '-rw' when Mounting Partitions, and 'rw,defaults,umask=0000 0 0' when
editing '/etc/fstab'.

Tuesday, August 01, 2006

Accessing drives/partitions and Network administration tools

Accessing drives/partitions

mount
See here for details on mounting drives. Examples are shown in the next commands.

mount -t auto /dev/fd0 /mnt/floppy
(as root) Mount the floppy. The directory /mnt/floppy must exist, be empty and NOT be your current directory.

mount -t auto /dev/cdrom /mnt/cdrom
(as root) Mount the CD. You may need to create/modify the /dev/cdrom file depending where your CDROM is. The directory /mnt/cdrom must exist, be empty and NOT be your current directory.

mount /mnt/floppy
(as user or root) Mount a floppy as user. The file /etc/fstab must be set up to do this. The directory /mnt/floppy must not be your current directory.

mount /mnt/cdrom
(as user or root) Mount a CD as user. The file /etc/fstab must be set up to do this. The directory /mnt/cdrom must not be your current directory.

umount /mnt/floppy
Unmount the floppy. The directory /mnt/floppy must not be your (or anybody else's) current working directory. Depending on your setup, you might not be able to unmount a drive that you didn't mount.

7.6 Network administration tools

netconf
(as root) A very good menu-driven setup of your network.

pingmachine_name
Check if you can contact another machine (give the machine's name or IP), press C when done (it keeps going).

route -n
Show the kernel routing table.

nslookup host_to_find
Query your default domain name server (DNS) for an Internet name (or IP number) host_to_find. This way you can check if your DNS works. You can also find out the name of the host of which you only know the IP number.

traceroute host_to_trace
Have a look how you messages trave to host_to_trace (which is either a host name or IP number).

ipfwadm -F -p m
(for RH5.2, seen next command for RH6.0) Set up the firewall IP forwarding policy to masquerading. (Not very secure but simple.) Purpose: all computers from your home network will appear to the outside world as one very busy machine and, for example, you will be allowed to browse the Internet from all computers at once.

echo 1 > /proc/sys/net/ipv4/ip_forward
ipfwadm-wrapper -F -p deny
ipfwadm-wrapper -F -a m -S xxx.xxx.xxx.0/24 -D 0.0.0.0/0
(three commands, RH6.0). Does the same as the previous command. Substitute the "x"s with digits of your class "C" IP address that you assigned to your home network. See here for more details. In RH6.1, masquarading seems broken to me--I think I will install Mandrake Linux:).

ifconfig
(as root) Display info on the network interfaces currently active (ethernet, ppp, etc). Your first ethernet should show up as eth0, second as eth1, etc, first ppp over modem as ppp0, second as ppp1, etc. The "lo" is the "loopback only" interface which should be always active. Use the options (see ifconfig --help) to configure the interfaces.

ifup interface_name
(/sbin/ifup to it run as a user) Startup a network interface. E.g.:
ifup eth0
ifup ppp0
Users can start up or shutdown the ppp interface only when the right permission was checked during the ppp setup (using netconf ). To start a ppp interface (dial-up connection), I normally use kppp available under kde menu "internet".

ifdown interface_name
(/sbin/ifdown to run it as a user). Shut down the network interface. E.g.: ifdown ppp0 Also, see the previous command.

netstat | more
Displays a lot (too much?) information on the status of your network.

7.5 Basic administration commands

7.5 Basic administration commands

printtool
(as root in X-terminal) Configuration tool for your printer(s). Settings go to the file /etc/printcap.

setup
(as root) Configure mouse, soundcard, keyboard, X-windows, system services. There are many distibution-specific configuration utilities, setup is the default on RedHat. Mandrake 7.0 offers very nice DrakConf .

linuxconfig
(as root, either in text or graphical mode). You can access and change hundreds of setting from it. Very powerful--don't change too many things at the same time, and be careful with changing entries you don't understand.

xvidtune
(in X-terminal). Adjust the settings of the graphical display for all resolutions so as to eliminate black bands, shift the display right/left/up/down, etc. (First use the knobs on your monitor to fit your text mode correctly on the screen.) To make the changes permanent, display the frequencies on the screen and transfer them to the setup file /etc/X11/XF86Config.

alias ls="ls --color=tty"
Create an alias for the command "ls" to enhance its format with color. In this example, the alias is also called "ls" and the "color" option is only envoke when the output is done to a terminal (not to files). Put the alias into the file /etc/bashrc if you would like the alias to be always accessible to all users on the system. Type "alias" alone to see the list of aliases on your system.

adduser user_name
Create a new account (you must be root). E.g., adduser barbara Don't forget to set up the password for the new user in the next step. The user home directory is /home/user_name.

useradd user_name
The same as the command " adduser user_name ".

userdel user_name
Remove an account (you must be a root). The user's home directory and the undelivered mail must be dealt with separately (manually because you have to decide what to do with the files).

groupadd group_name
Create a new group on your system. Non-essential but can be handy even on a home machine with a small number of users.

passwd
Change the password on your current account. If you are root, you can change the password for any user using: passwd user_name

chmod perm filename
(=change mode) Change the file access permission for the files you own (unless you are root in which case you can change any file). You can make a file accessible in three modes: read (r), write (w), execute (x) to three classes of users: owner (u), members of the same group as the owner (g), others on the system (o). Check the current access permissions using:
ls -l filename
If the file is accessible to all users in all modes it will show:
rwxrwxrwx
The first triplet shows the file permission for the owner of the file, the second for his/her group, the third for others. A "no" permission is shown as "-".
E.g., this command will add the permission to read the file "junk" to all (=user+group+others):
chmod a+r junk
This command will remove the permission to execute the file junk from others:
chmod o-x junk
Also try here for more info.
You can set the default file permissions for the news files that you create using the command umask (see man umask).

chown new_ownername filename
chgrp new_groupname filename
Change the file owner and group. You should use these two commands after you copy a file for use by somebody else.

su
(=substitute user id) Assume the superuser (=root) identity (you will be prompted for the password). Type "exit" to return you to your previous login. Don't habitually work on your machine as root. The root account is for administration and the su command is to ease your access to the administration account when you require it. You can also use "su" to assume any other user identity, e.g. su barbara will make me "barbara" (password required unless I am a superuser).

kernelcfg
(as root in X terminal). GUI to to add/remove kernel modules. You can do the same from the command line using the command "insmod", but "insmode" is less "newbie-friendly".

lsmod
List currently loaded kernel modules. A module is like a device driver--it provides operating system kernel support for a particular piece of hardware or feature.

modprobe -l |more
List all the modules available for your kernel. The available modules are determined by how your Linux kernel was compliled. Every possible module/feature can be compiled on linux as either "hard wired" (fast, non-removable), "module" (maybe slower, but loaded/removable on demand), or "no" (no support for this feature at all).

insmod parport
insmod ppa
(as root) Insert modules into the kernel (a module is roughly an equivalent of a DOS device driver). This example shows how to insert the modules for support of the external parallel port zip drive (it appears to be a problem to get the external zip drive to work in any other way under RH6.0 ).

rmmod module_name
(as root, not essential). Remove the module module_name from the kernel.

setserial /dev/cua0 port 0x03f8 irq 4
(as root) Set a serial port to a non-standard setting. The example here shows the standard setting for the first serial port (cua0 or ttyS0). The standard PC settings for the second serial port (cua1or ttyS1) are: address of i/o port 0x02f8, irq 3. The third serial port (cua2 or ttyS2): 0x03e8, irq 4. The forth serial port (cua3 or ttyS3): 0x02e8, irq 3. Add your setting to /etc/rc.d/rc.local if you want it to be set at the boot time. See man setserial for good a overview.

fdisk
(as root) Linux hard drive partitioning utility (DOS has a utility with the same name).

cd /usr/src/linux-2.0.36
make xconfig
(as root in X terminal). Nice GUI front-end for configuration of the kernel options in preparation for compilation of your customized kernel. (The directory name contains the version of your Linux kernel so you may need to modify the directory name if your Linux kernel version is different than 2.0.36 used in this example. You also need the "Tk" interpreter and the kernel source code installed. ) The alternatives to "make xconfig" are: "make config" (runs a scripts that asks you questions in the text mode) and "make menuconfig" (runs a text-based menu-driven configuration utility). Try: less /usr/doc/HOWTO/Kernel-HOWTO for more information.
After the configuration, you may choose to proceed with kernel compilation of the new kernel by issuing the following commands:
make dep
make zImage
The last command will take some time to complete (maybe 0.5 h, depending on your hardware). It produces the file "zImage", which is your new Linux kernel. Next:
make modules
make modules_install
Read: /usr/doc/HOWTO/Kernel-HOWTO for information on how to install the new kernel. You will probably also find it useful to read "man depmode". Configuration, compilation and installation of a new kernel is not difficult but it CAN lead to problems if you don't know what you are doing.
Compilation of a kernel is a good way to test your hardware, because it involves a massive amount of computing. If your hardware is "flaky", you will most likely receive the "signal 11" error (read the beatiful /usr/doc/FAQ/txt/GCC-SIG11-FAQ). See this for details on kernel upgrade.

depmod -a
(as root) Build the module dependency table for the kernel. This can, for example, be useful after installing and booting a new kernel. Use "modprobe -a" to load the modules.

ldconfig
(as root) Re-create the bindings and the cache for the loader of dynamic libraries ("ld"). You may want to run ldconfig after an installation of new dynamically linked libraries on your system. (It is also re-run every time you boot the computer, so if you reboot you don't have to run it manually.)

mknod /dev/fd0 b 2 0
(=make node, as root) Create a device file. This example shows how to create a device file associated with your first floppy drive and could be useful if you happened to accidentally erase it. The options are: b=block mode device (c=character mode device, p=FIFO device, u=unbuffered character mode device). The two integers specify the major and the minor device number.

fdformat /dev/fd0H1440
mkfs -c -t ext2
(=floppy disk format, two commands, as root) Perform a low-level formatting of a floppy in the first floppy drive (/dev/fd0), high density (1440 kB). Then make a Linux filesystem (-t ext2), checking/marking bad blocks (-c ). Making the files system is an equivalent to the high-level format.

badblocks /dev/fd01440 1440
(as root) Check a high-density floppy for bad blocks and display the results on the screen. The parameter "1440" specifies that 1440 blocks are to be checked. This command does not modify the floppy.

fsck -t ext2 /dev/hda2
(=file system check, as root) Check and repair a filesystem. The example uses the partition hda2, filesystem type ext2.

dd if=/dev/fd0H1440 of=floppy_image
dd if=floppy_image of=/dev/fd0H1440
(two commands, dd="data duplicator") Create an image of a floppy to the file called "floppy_image" in the current directory. Then copy floppy_image (file) to another floppy disk. Works like DOS "DISKCOPY".


7.4 Process control

7.4 Process control

ps
(=print status) Display the list of currently running processes with their process IDs (PID) numbers. Use ps axu to see all processes currently running on your system (also those of other users or without a controlling terminal), each with the name of the owner. Use "top" to keep listing the processes currently running.

fg PID
Bring a background or stopped process to the foreground.

bg PID
Send the process to the background. Opposite to fg. The same can be accomplished with z. If you have stopped jobs, you have to type exit twice in row to log out.

any_command&
Run any command in the background (the symbol "&" means "run the proceeding command in the background").

batch any_command
Run any command (usually one that is going to take more time) when the system load is low. I can logout, and the process will keep running.

at 17:00
Execute a command at a specified time. You will be prompted for the command(s) to run, until you press d.

kill PID
Force a process shutdown. First determine the PID of the process to kill using ps.

killall program_name
Kill program(s) by name.

xkill
(in an xwindow terminal) Kill a GUI-based program with mouse. (Point with your mouse cursor at the window of the process you want to kill and click.)

lpc
(as root) Check and control the printer(s). Type "?" to see the list of available commands.

lpq
Show the content of the printer queue. Under KDE (X-Windows), you may use GUI-based "Printer Queue" available from "K"menu-Utilities.

lprm job_number
Remove a printing job "job_number" from the queue.

nice program_name
Run program_name adjusting its priority. Since the priority is not specified in this example, it will be adjusted by 10 (the process will run slower), from the default value (usually 0). The lower the number (of "niceness" to other users on the system), the higher the priority. The priority value may be in the range -20 to 19. Only root may specify negative values. Use "top" to display the priorities of the running processes.

renice -1 PID
(as root) Change the priority of a running process to -1. Normal users can only adjust processes they own, and only up from the current value (make them run slower).

c, z, s, and q also belong to this chapter but they were described previously. In short they mean: stop the current command, send the current command to the background, stop the data transfer, resume the data transfer.

Network apps

Network apps

netscape
(in X terminal) Run netscape (requires a separate Netscape installation). The current versions of Netscape (4.x) are known to be big and buggy. They occasionally crash by vanishing (no other harm done). Also, when not connected to the network , Netscape likes to refuse to do anything (looks like it hanged)-it revives when you connect.

netscape -display host:0.0
(in X terminal) Run netscape on the current machine and direct the output to machine named "host" display 0 screen 0. Your current machine must have a permission to display on the machine "host" (typically given by executing the command xhost current_machine_name in the xterminal of the machine host. Other X-windows program can be run remotely the same way.

lynx file.html
View an html file or browse the net from the text mode.

pine
A good text-mode mail reader. Another good and standard one is elm. Your Netscape mail will read the mail from your Internet account. pine will let you read the "local" mail, e.g. the mail your son or a cron process sends to you from a computer on your home network. The command mail could also be used for reading/composing mail, but it would be inconvenient--it is meant to be used in scripts for automation.

elm
A good tex-mode mail reader. See the previous command.

mutt
A really basic but extremally useful and fast mail reader.

mail
A basic operating system tool for e-mail. Look at the previous commands for a better e-mail reader. mail is good if you wanted to send an e-mail from a shell script.

licq
(in X term) An icq "instant messaging" client. Another good one is kxicq. Older distributions don't have an icq client installed, you have to do download one and install it.

talk username1
Talk to another user currently logged on your machine (or use "talk username1@machinename" to talk to a user on a different computer) . To accept the invitation to the conversation, type the command "talk username2". If somebody is trying to talk to you and it disrupts your work, your may use the command "mesg n" to refuse accepting messages. You may want to use "who" or "rwho" to determine the users who are currently logged-in.

mc
Launch the "Midnight Commander" file manager (looks like "Norton Commander" for Linux).

telnet server
Connect to another machine using the TELNET protocol. Use a remote machine name or IP address. You will be prompted for your login name and password--you must have an account on the remote machine to login. Telnet will connect you to another machine and let you operate on it as if you were sitting at its keyboard (almost). Telnet is not very secure--everything you type goes in open text, even your password!

rlogin server
(=remote login) Connect to another machine. The login name/password from your current session is used; if it fails you are prompted for a password.

rsh server
(=remote shell) Yet another way to connect to a remote machine. The login name/password from your current session is used; if it fails you are prompted for a password.

ftp server
Ftp another machine. (There is also ncftp which adds extra features and gftp for GUI .) Ftp is good for copying files to/from a remote machine. Try user "anonymous" if you don't have an account on the remote server. After connection, use "?" to see the list of available ftp commands. The essential ftp command are: ls (see the files on the remote system), ASCII, binary (set the file transfer mode to either text or binary, important that you select the proper one ), get (copy a file from the remote system to the local system), mget (get many files at once), put (copy a file from the local system to the remote system), mput (put many files at once), bye (disconnect). For automation in a script, you may want to use ncftpput and ncftpget, for example:
ncftpput -u my_user_name -p my_password -a remote.host.domain remote_dir *local.html

minicom
Minicom program (looks like "Procomm for Linux").


7.3 Basic operations

any_command --help |more
Display a brief help on a command (works with most commands). "--help" works similar to DOS "/h" switch. The "more" pipe is needed if the output is longer than one screen.

man topic
Display the contents of the system manual pages (help) on the topic. Try man man first. Press "q" to quit the viewer. The command info topic works similar and may contain more up-to-date information. Manual pages can be hard to read. Try any_command --help for short, easy to digest help on a command. If more info needed, have a look to the directory /usr/doc. To display manual page from a specific section, I may use something like in this example: man 3 exit (this displays an info on the command exit from section 3 of the manual pages).

apropos topic
Give me the list of the commands that have something to to do with my topic.

help command
Display brief info on a bash (shell) build-in command.

ls
List the content of the current directory. Under Linux, the command "dir" is an alias to ls. Many users have "ls" to be an alias to "ls --color".

ls -al |more
List the content of the current directory, all files (also those starting with a dot), and in a long form. Pipe the output through the "more" command, so that the display pauses after each screenful.

cd directory
Change directory. Using "cd" without the directory name will take you to your home directory. "cd -" will take you to your previous directory and is a convenient way to toggle between two directories. "cd .." will take you one directory up.

cp source destination
Copy files. E.g., cp /home/stan/existing_file_name . will copy a file to my current working directory. Use the "-r" option (for recursive) to copy the contents of whole directories, e.g. , cp -r my_existing/dir/ ~ will copy a subdirectory under my current working directory to my home directory.

mcopy source destination
Copy a file from/to a DOS filesystem (no mounting necessary). E.g., mcopy a:\autoexec.bat ~/junk . See man mtools for related commands: mdir, mcd, mren, mmove, mdel, mmd, mrd, mformat ....

mv source destination
Move or rename files. The same command is used for moving and renaming files and directories.

ln source destination
Create a hard link called destination to the file called source. The link appears as a copy of the original files, but in reality only one copy of the file is kept, just two (or more) directory entries point to it. Any changes the file are automatically visible throughout. When one directory entry is removed, the other(s) stay(s) intact. The limitation of the hard links are: the files have to be on the same filesystem, hard links to directories or special files are impossible.

ln -s source destination
Create a symbolic (soft) link called "destination" to the file called "source". The symbolic link just specifies a path where to look for the file. In contradistinction to hard links, the source and destination don't not have to tbe on the same filesystem. In comparison to hard links, the drawback of symbolic links are: if the original file is removed, the link is "broken", symbolic links can also create circular references (like circular references in spreadsheets or databases, e.g., "a" points to "b" and "b" points back to "a").

rm files
Remove (delete) files. You must own the file in order to be able to remove it. On many systems, you will be asked or confirmation of deleation, if you don't want this, use the "-f" (=force) option, e.g., rm -f * will remove all files in my current working directory, no questions asked.

mkdir directory
Make a new directory.

rmdir directory
Remove an empty directory.

rm -r files
(recursive remove) Remove files, directories, and their subdirectories. Careful with this command as root--you can easily remove all files on the system with such a command executed on the top of your directory tree, and there is no undelete in Linux (yet). But if you really wanted to do it (reconsider), here is how (as root): rm -rf /*

cat filename | more
View the content of a text file called "filename", one page a time. The "|" is the "pipe" symbol (on many American keyboards it shares the key with "\") The pipe makes the output stop after each screenful. For long files, it is sometimes convenient to use the commands head and tail that display just the beginning and the end of the file. If you happened to use "cat" a binary file and your terminal displays funny characters afterwards, you can restore it with the command "reset".

less filename
Scroll through a content of a text file. Press q when done. "Less" is roughly equivalent to "more" , the command you know from DOS, although very often "less" is more convenient than "more".

pico filename
Edit a text file using the simple and standard text editor called pico.

pico -w filename
Edit a text file, while disabling the long line wrap. Handy for editing configuration files, e.g. /etc/fstab.

find / -name "filename"
Find the file called "filename" on your filesystem starting the search from the root directory "/". The "filename" may contain wildcards (*,?).

locate filename
Find the file name of which contains the string "filename". Easier and faster than the previous command but depends on a database that normally rebuilds at night.

./program_name
Run an executable in the current directory, which is not on your PATH.

touch filename
Change the date/time stamp of the file filename to the current time. Create an empty file if the file does not exist.

xinit
Start a barebone X-windows server (without a windows manager).

startx
Start an X-windows server and the default windows manager. Works like typing "win" under DOS with Win3.1

startx -- :1
Start another X-windows session on the display 1 (the default is opened on display 0). You can have several GUI terminals running concurrently. Switch between them using , , etc.

xterm
(in X terminal) Run a simple X-windows terminal. Typing exit will close it. There are other, more advanced "virtual" terminals for X-windows. I like the popular ones: konsole and kvt (both come with kde) and gnome-terminal (comes with gnome). If you need something really fancy-looking, try Eterm.

xboing
(in X terminal). Very nice, old-fashioned game. Many small games/programs are probably installed on your system. I also like xboard (chess).

shutdown -h now
(as root) Shut down the system to a halt. Mostly used for a remote shutdown. Use for a shutdown at the console (which can be done by any user).

halt
reboot
(as root, two commands) Halt or reboot the machine. Used for remote shutdown, simpler to type than the previous command.

Linux Shortcuts and Commands:

http://man.chinaunix.net/linux/command/Linux_command.htm

7.2 Common Linux commands--system info

pwd
Print working directory, i.e., display the name of my current directory on the screen.

hostname
Print the name of the local host (the machine on which you are working). Use netconf (as root) to change the name of the machine.

whoami
Print my login name.

id username
Print user id (uid) and his/her group id (gid), effective id (if different than the real id) and the supplementary groups.

date
Print or change the operating system date and time. E.g., I could change the date and time to 2000-12-31 23:57 using this command:
date 123123572000
To set the hardware (BIOS) clock from the system (Linux) clock, use the command (as root) setclock

time
Determine the amount of time that it takes for a process to complete + other info. Don't confuse it with the date command. E.g. I can find out how long it takes to display a directory content using:
time ls

who
Determine the users logged on the machine.

rwho -a
(=remote who) Determine all users logged on your network. The rwho service must be enabled for this command to run. If it isn't, run setup as root to enable "rwho".

finger user_name
System info about a user. Try: finger root

last
Show listing of users last logged-in on your system.

history | more
Show the last (1000 or so) commands executed from the command line on the current account. The "| more" causes the display to stop after each screenful.

uptime
Show the amount of time since the last reboot.

ps
(=print status) List the processes currently run by the current user.

ps axu | more
List all the processes currently running, even those without the controlling terminal, together with the name of the user that owns each process.

top
Keep listing the currently running processes, sorted by cpu usage (top users first). In KDE, you can get GUI-based Ktop from "K"menu under "System"-"Task Manager" (or by executing "ktop" in an X-terminal).

uname -a
(= Unix name with option "all") Info on your (local) server. I can also use guname (in X-window terminal) to display the info more nicely.

free
Memory info (in kilobytes).

df -h
(=disk free) Print disk info about all the filesystems (in human-readable form)

du / -bh | more
(=disk usage) Print detailed disk usage for each subdirectory starting at the "/" (root) directory (in human legible form).

cat /proc/cpuinfo
Cpu info--it show the content of the file cpuinfo. Note that the files in the /proc directory are not real files--they are hooks to look at information available to the kernel.

cat /proc/interrupts
List the interrupts in use.

cat /proc/version
Linux version and other info

cat /proc/filesystems
Show the types of filesystems currently in use.

cat /etc/printcap
Show the setup of printers.

lsmod
(As root. Use /sbin/lsmod to execute this command when you are a non-root user.) Show the kernel modules currently loaded.

set|more
Show the current user environment.

echo $PATH
Show the content of the environment variable "PATH". This command can be used to show other environment variables as well. Use "set" to see the full environment.

dmesg | less
Print kernel messages (the content of the so-called kernel ring buffer). Press "q" to quit "less". Use less /var/log/dmesg to see what "dmesg" dumped into this file right after the last system bootup.

File Compression and Archiving with Gzip, Zip, and Tar

File Compression and Archiving with Gzip, Zip, and Tar

Compressing with Gzip and Zip

Compressed files use less disk space and download faster than large, uncompressed files. You can compress Linux files with the open-source compression tool Gzip or with Zip, which is recognized by most operating systems.

By convention, compressed files are given the extension .gz. The command Gzip creates a compressed file ending with .gz; Gunzip extracts the compressed files and removes the .gz file.

To compress a file, at a shell prompt, type the following command:

gzip filename.ext

The file will be compressed and saved as filename.ext.gz.

To expand a compressed file, type:

gunzip filename.ext.gz

The filename.ext.gz is deleted and replaced with filename.ext.

If you exchange files with non-Linux users, you may want to use zip to avoid compatibility problems. Red Hat Linux can easily open zip or gzip files, but non-Linux operating systems may have problems with gzip files.

To compress a file with zip, type the following:

zip -r filename.zip files

In this example, filename represents the file you are creating and files represents the files you want to put in the new file:

To extract the contents of a zip file, type:

unzip filename.zip

You can zip or gzip multiple files at the same time. List the files with a space between each one.

gzip filename.gz file1 file2 file3 /user/work/school 

The above command will compress file1, file2, file3, and the contents of the /user/work/school directory and put them in filename.gz.

Archiving with Tar

Tar files place several files or the contents of a directory or directories in one file. This is a good way to create backups and archives. Usually, tar files end with the .tar extension.

To create a tar file, type:

tar -cvf filename.tar files/directories

In this example, filename.tar represents the file you are creating and files/directories represents the files or directories you want to put in the new file.

You can use absolute or relative pathnames for these files and directories (for more on pathnames, see the section called Changing Directories with cd in Chapter 10). Separate the names of files and directories with a space.

The following input would create a tar file using absolute pathnames:

  tar -cvf foo.tar /home/mine/work /home/mine/school

The above command would place all the files in the /work subdirectory and the /school subdirectory in a new file called foo.tar in the current working directory.

The command tar -cvf foo.tar file1.txt file2.txt file3.txt would place file1.txt, file2.txt and file3.txt in a new file called foo.tar.

To list the contents of a tar file, type:

 tar -tvf foo.tar

To extract the contents of a tar file, type:

tar -xvf foo.tar

This command does not remove the .tar file, but it places copies of the .tar contents in the current working directory.

The tar command does not compress files automatically. You can compress tar files with:

tar -czvf foo.tar

Compressed tar files are conventionally given the extension .tgz and are compressed with gzip.

To expand a compressed tar file type:

tar -xzvf foo.tgz

Tuesday, June 27, 2006