存档

2005年11月 的存档

Linux Shell : crontab, at, &

2005年11月24日 没有评论

Sometimes, we need to run the processes in the background.The following four command are useful : crontab, at, & and nohup.

crontab syntax:

# crontab [-u user] -e -l -r 

-u : user
-e : edit or modify the crontab file
-l : list the crontab file contents.
-r : delete the crontab file crontab is schedule periodic background work,and it maintain the crontab files for individual users.

Every user could has his own crontab file, but in most case, system administrator forbids this operation by modifying ‘cron.deny’ and ‘cron.allow’ file, and the sa will keep only one crontab file for all users.

In the crontab tables,the meaning of every column are showed here:

The 1st column : miniute (1-59)
The 2nd column: hour (1-23,and 0 indicates middle night )
The 3rd column: date (1-31)
The 4th column: month (1-12)
The 5th column: week (0-6, o is sunday)
The 6th column: command will be executed (Note,absolute directory must be added)
eg:

10 9 24 11 4 /sbin/init 6 

This string means the system will reboot at November(11) 24,9:10,Thursday.

A useful command:

# ps -x
# ps -fe

-x : processes w/o controlling ttys.
-e : all processes
-f : output format

when I issued ‘ps -x’ command, I found there was such a line showing in the screen:

...... 
5942 ? S 0:07 kmail -caption KMail -icon kmail -miniicon kmail 
...... 

So,I wanted to make the kmail processes startup automatic when the user logs in. I modified the crontab files by adding the following lines:

.... 
32 11 24 11 4 /opt/kde3/bin/kmail 
.... 

And waited for the action happening,but at the 11:10, SuSE told me that I had gotten a mail in the /var/spool/mail/root which said ‘ERROR:kUnique Application,Can’t determing DISPLAY Aborting’. Oh, what’s the matter?

I added an other line indicating the display parameter before the kmail command in crontab file:

10 11 24 11 4 export DISPLAY=0:0 ; /opt/kde3/bin/kmail 

But I still received an error report in /var/spool/mail/root:

----------/var/spool/mail/root--------------- 

From root@linux.site  Thu Nov 24 11:32:21 2005
Return-Path: <root@linux.site>
X-Original-To: root
Delivered-To: root@linux.site
Received: by linux.site (Postfix, from userid 0)
 id C017E101213; Thu, 24 Nov 2005 11:32:21 +0800 (CST)

From: root@linux.site (Cron Daemon)
To: root@linux.site
Subject: Cron <root@linux> export DISPLAY=0:0 ; /opt/kde3/bin/kmail 

X-Cron-Env: <SHELL=/bin/sh>
X-Cron-Env: <HOME=/root>
X-Cron-Env: <PATH=/usr/bin:/bin>
X-Cron-Env: <LOGNAME=root>

Message-Id: <20051124033221.C017E101213@linux.site>
Date: Thu, 24 Nov 2005 11:32:21 +0800 (CST)

_X11TransSocketINETConnect() can't get address for 0:6000: 
Name or service not known
kded: cannot connect to X server 0:0
DCOP aborting call from 'anonymous-5910' to 'kded'
kded: ERROR: Communication problem with kded, it probably crashed.

_X11TransSocketINETConnect() can't get address for 0:6000: 
Name or service not known
kdeinit: Can't connect to the X Server.
kdeinit: Might not terminate at end of session.

_X11TransSocketINETConnect() can't get address for 0:6000: 
Name or service not known
kmail: cannot connect to X server 0:0
DCOP aborting call from 'anonymous-5901' to 'kmail'

ERROR: Communication problem with kmail, it probably crashed.
Mutex destroy failure: Device or resource busy
sh: line 1: iceauth: command not found

The test failed. I’ll try to resolve this problem later.Maybe using pipe is a good idea.Waiting…

at syntax: at [-f script] [-m -l -r] [time] [date] 

-f script : Shell script or command
-m : mail the report to user
-l : list the quote contains waiting jobs
-r : cancel the job by using its job-ID
time : H,HH,HHMM,HH:MM,H:M
date : today,tomorrow

at has two mode: command line and prompt mode.
Command line mode,for example:

$ at 3.00 pm tomorrow -f /apps/bin/db-table.sh 
Prompt mode: 
$ at 14:08 
at> find / -name 'adobe' > report.txt 
at> [EOT] 

[EOT],NOT IS EOF,means “CTRL+D” to save and quit the at prompt mode. Note,once the job was submitted, at will store the running environment including path.but Using crontab command,we must identify the absolute directory.

& character : command &

& is used to make the job running in the background.These jobs may be find,print,soft,Shell Script and other high-costing issues.The interactive of user is forbidden,or it will confuse the system to make it waiting forever. eg:

 $ find -name 'adobe' & 
[1] 6531 linux 
$ ps -e 
PID      TTY       TIME          CMD 
... 
6510     tty2     00:00:00       bash 
6532     tty2     00:00:00       ps 
[1]+ Done ...... find -name 'adobe' 
分类: 科技 标签:

Linux Shell : find

2005年11月22日 没有评论

Find is a very important command, when it is issued, the system resource will be heavily costed,so we’d better put the instance in the background.

find syntax:

#find pathname -options [-print -exec -ok]

pathname: if find file in own HOME directory,the pathname could be instead of ‘~’;if in the current directory,’.’ is used.
-exec : issue the command on the finding result.-exec must be added ‘{} ;’.Please pay attention that there are space between ‘{}’ and ‘;’.
-ok : it works like ‘-exec’,but will require user’s answer before issung the command.
eg:

# find -name '1.txt' -exec rm {} ;
     # find -name '1.txt' -ok rm {} ;

How to find file which is bigger than 1M byte?

# find . -size +1000000c -print

1000000c means 1M byte.Character ‘c’ must be added.

# find . -size +10 -print
'+10' without character 'c' means 10 blocks. 1 block = 512 byte.

If many commands are listed after ‘-exec’, Linux will create instance for every command,it will decrease the Linux performance.We could use xargs,this useful command will create only one instance thourgh there are many commands in queue.xargs prevents overflower error.

# find ..... | xargs command-op
分类: 科技 标签:

Linux Shell : privilege and attribute

2005年11月22日 没有评论

There are total three mode to access file system:

-Read: is able to display the file’s content.
-Write: is able to be modified or deleted.
-Execute: if the file is shell script or executable,it’s able to be executed.

When a file is created, Linux keeps all its information including:

Location, File types, File length, Owners, Owner’s default group,Users who can access this file,
Last updated time, Privilege.

For example:

# ls -l
total 4132
-rwxr-xr-x    1    root    root    3756    Oct 14 04:44    dmesg

total: the directory’s capacity
-rwxr-xr-x : privilege
1 : the number of hard link
root: the owner
root: the owner’s default group
3576: the file length.(byte)
Oct 14 04:44 : last updated time
dmesg : file name

The file cuold have one of the following file types:
d : directory
l : link
s : socket file
b : block device
c : character device
p : pipe
– : general file

We could use ‘chmod’ command in the following two modes:

1.standard: # chmod ugo +/- rwx file
2.absolute mode: # chmod [mode] file eg: chmod 775 1
The standard mode is better than absolute mode for its clear operation.
Note,if we use multiple operator in the chmod command, a comma must be added.
for example: # chmod g+r,o-w filename

The directory privilege is prior than file lever,it has the main two accessing:

-Reading: list the directory’s content
-Write: is about create new file or folder.

suid/guid

Many operating systems disallow these parameter for security reason.Suid: if this key word is set in the privilege, it means that when other user even who are not root or belong to root group could execute the file as root. Of course,it could cause
many security problems what we must care.

How to find if the Linux distribute supports suid and guid:

# cd /bin
# ls -l | grep '^...s'

eg, in RHEL 3.0 update4, the following command files will be listed:
mount, umount, ping, ping6, su, traceroute, traceroute6.
if we use absolute mode to set suid,just take the position to number ‘4’;
if guid were used, the number is ‘2’;
if suid and guid were set together,the right number is ‘6’ which means 4+2.

A useful linux command to list all the users:

# cat /etc/passwd

To find the group which user are belong to:

# groups

To identify user’s id:

# id

umask command indicates the default mode when create a new file or directory.we could configure umask parameter at /etc/profile. Every user has his own umask which could be unique.The users can set the unique umask number, and take it active in the $HOME/.profile or $HOME/.bask_profile.To file,the maximum umask number is 6;To directory, the maximum umask numner is 7.

How to identify the setting umask number? Issue the command:

# umask

Q: The default umask number is 022.In the /root, I created file named ‘myfile’ by the following
command:

# touch myfile
# ls -l myfile
-rw-r--r--

Why?
A:000 0
001 1
010 2
011 3
100 4
101 5
110 6
111 7

Because ‘myfile’ is just file, not directory,so its maximum umask is 666. We could know the default
umask number is 022 from the question, 2 means ‘-w-‘,6 means ‘rw-‘,then the result should be ‘r–‘.
So,the privilege of ‘myfile’ is ‘-rw-r–r–‘.

Soft link:

# link -s source-path target-path
分类: 科技 标签:

Konqueror and Smb

2005年11月22日 没有评论

In the Linux,we could look windows sharing directories by using Konqueror. Open the Konqueror brower, and type the following text: smb://192.168.1.143, and then press enter,the windows directories will be displayed in the Konqueror.

How to connect to the printer based on Windows?Choose the target machine’s IP or name, and input the default printer’s name. In the session, the username and password were required.

分类: 科技 标签:

Road to OCP

2005年11月21日 没有评论

Nov,21th 2004, I was in ZhongShan University.
It was very important step in my career. About 3.5 months’ home preparing, I won my Oracle Cerficated Profession.
Thank you,mum,you’re the greatest mum in my heart. I love you.

分类: 科技 标签:

SuSE configuration

2005年11月21日 没有评论

SuSE 9.1 professional was installed on my office computer insteading of Red Hat Enterprise Linux 3.0 with Update 4. I found SuSE had more beautiful graphic interface than Red Hat series, it looks like Windows XP with green toolbar and colorful button. In fact, I do not like KDE in the first time, maybe GNOME has been used since I know linux.

There are total 5 CD to install SuSE 9.1 professional. After the operating system was installed successful, I found it was very difficult to input Chinese with Ping Yin.Many packages were tested,but only a tools named fcitx-3.0.2.Imgc.i686.rpm could be useful. After installed this rpm packages, press ctrl + space, then Chinese inputing tools bar was displayed in the screen.It’s very easy for me to type Chinese. Resolving this issue makes me very happy, because I even wanted to study the input method applied by SuSE 9 Professional , and installed a fresh operating system. Insisting is the key.

How to connect remote desktop and control them?

In the RHEL period, I used rdesktop tool to connect remote desktop and control it. SuSE linux provides a very easy graphic tool to do this. In the manu of SuSE, System – Remote Connect – Access, and type the following text in the input box:

rdp:/192.168.1.143

Note,there’s only one back slash in the above string. 192.168.1.143 is my Windows IP address. This experience seems as Windows Remote desktop connection.

How to mount windows directory in the networking?

My windows IP address is 192.168.1.143, and computer name is “powerlea-v3afhe”.The windows machine has a shared directory named ‘1103’. In the first test, I tried to use the following command as in Red Hat:

# mount -t smbfs -o username=Phillip,password=aaa //192.168.1.143/1103 /document/test
The error messages was displayed:

5440: session request to 192.168.1.143 failed (Called name not present)
5440: session request to 192 failed (Called name not present)

Why? and how could this error happens? I readed the mount help information and executed this modified command:
# mount -t smbfs -o username=Phillip,password=aaa //powerlea-v3afhe/1103 /document/test

Yeah!!! The windows directory was mounted successfully!!!

SuSE has Kmail tools to receive and send mail. I configured the character encode as gb2312, and when the mail will be sent, in the Kmail toolbar, View-Set Encoding-gb2312, this step could make the mail sent displaying in human read mode.

There is no Snapshoot iron or tools in SuSE. I found in GIMP manu, Acquire – Screenshow, then a dialog box will be displayed, which ask user to confirm the snapshoot range(Fullscreen or defined windows) and time(When will the picture will be taken?).It is very useful.

分类: 科技 标签:

Some Linux problem’s resolution

2005年11月2日 没有评论

My computer in the office is installed Red Hat Enterprise Linux 3.0 Update4. I want to try MSN in this operating system. RHEL supplies gaim program which can be configured in MSN,ICQ and other instant message tools. First , in the user’s input box, I create my MSN account and set the proxy server that is tested ok in other Windows.And then, connect the MSN remote server. It seems everything goes well.But as the Gaim showes the sucessful connection message and group’s information, there is the following error breaking the Gaim program:

"unable to write to MSN server via http (error9)"

I’ve searched some document during the Internet, no useful resolution has been found. When I used gaim in FC3(with the latest kernal:2.6.12-1.1381), the MSN plus program works ok.

AMSN is other MSN tools in Linux operating system. I downloaded the latest amsn reversion 0.94 from its website. and then installed the “bin” by executing “# ./xxx.bin”. in the directory created,issue the following command:

# ./amsn

the graphic interface was displayed. New trouble happened.I could not type any character in the input-box and configuration list.
This problem was resolved later by issuing the following command:

# su -
#  cd /opt/amsn-0.94

where /opt/amsn was the amsn’s main directory.

# ./amsn

After all these steps, amsn would be input character and number,but this soft still could not support Chinese. I tried to download some pitch from a website of Taiwan,and the amsn was configured to traditional Chinese which I ‘m not able to type this in my office’s computer.

This moring, I opened evoluation and gaim at the same time,after some time,the graphic console has no responsibilty.I did not want to reboot the system,so I changed to console by pressing “alt+F2”, and then check the system’s status:

# top
# ps -e

I killed evoluation and gaim procession, but the graphic console was still halted.OK,I tried to kill the X procession,then the console returned to log graphic,yes,I’ve done it and resolven this trouble! How happly I am!

分类: 科技 标签: