实训资料

来源:互联网 发布:淘宝批量删除宝贝软件 编辑:程序博客网 时间:2024/05/02 02:26


我们的课程开始了,大家都要准备好环境

我们的服务器在:210.44.123.90 

我们的文档: http://210.44.123.90/doc/doc.txt

登陆oracle数据库:sqlplus briup/briup

第一: 打开浏览器 http://210.44.123.90
第二:下载putty,然后登陆
  login:  boss
  passwd: boss   (密码不显示)
 
  $who
第三: 登陆oracle数据库  sqlplus briup/briup

在unix或者linux中,有且只有一个超级用户root


第一天上班,sa会给你开设email账号和unix系统账号和cvs账号

top  查看当前系统进程状态
who  查看谁在线
pwd  查看当前处在什么目录
sh   切换到bourne shell
bash 切换到bash  (默认)


$ Command [option(s)] [argument[s]]

A space must be used as a delimiter between each part of the command line
Up to 256 characters can be entered on a single command line
Different from DOS
Case sensitive
Different command prompt

boss@boss:~$ ls -F /bin
arch*          df*              mknod*       sleep*
bash*          dir*             mktemp*      stty*
bsd-csh*       dmesg*           more*        su*
bunzip2*       dnsdomainname*   mount*       sync*
busybox*       echo*            mountpoint*  tar*
bzcat*         ed*              mt@          tempfile*
bzcmp*         egrep*           mt-gnu*      touch*
bzdiff*        false*           mv*          true*
bzegrep*       fgconsole*       nano*        umount*
bzexe*         fgrep*           nc*          uname*
bzfgrep*       grep*            netcat@      uncompress*
bzgrep*        gunzip*          netstat*     vdir*
bzip2*         gzexe*           pidof@       which*
bzip2recover*  gzip*            ping*        zcat*
bzless*        hostname*        ping6*       zcmp*
bzmore*        kill*            ps*          zdiff*
cat*           ksh@             pwd*         zegrep*
chgrp*         ksh93*           rbash@       zfgrep*
chmod*         ln*              readlink*    zforce*
chown*         loadkeys*        rm*          zgrep*
cp*            login*           rmdir*       zless*
cpio*          ls*              rnano@       zmore*
csh@           lsmod*           run-parts*   znew*
date*          lsmod.modutils@  sed*
dd*            mkdir*           sh@


 login :   zhangsan   (张三)
           zhangsf    (张三丰)
           zhangsf    (张山峰)
 passwd :  boss 
 每个账户都有一个home和一个id
 
 chengxing@boss:/usr/local/boss/apache$ echo $HOME
/home/chengxing //每个账户都有自己的目录,别人无权修改
chengxing@boss:/usr/local/boss/apache$ id
//每个账户都有一个id号
uid=1002(chengxing) gid=105(development) groups=105(development)
chengxing@boss:/usr/local/boss/apache$

 
命令:
clear
pwd 打印当前工作目录
cd   进入某个目录
   .   当前目录
   ..  上一级目录

 cd /usr/local/boss/apache
 pwd  
 /usr/local/boss/apache
 cd ..
 pwd
 /usr/local/boss
 cd ../../././../.
 pwd
 /
 cd       #立刻回家
 pwd
 /home/boss
chengxing@boss:~$ pwd
/home/chengxing
chengxing@boss:~$ cd /usr/local/boss/apache
chengxing@boss:/usr/local/boss/apache$ pwd
/usr/local/boss/apache
chengxing@boss:/usr/local/boss/apache$ cd ..
chengxing@boss:/usr/local/boss$ pwd
/usr/local/boss
chengxing@boss:/usr/local/boss$ cd ../.././././././..
chengxing@boss:/$ pwd
/
chengxing@boss:/$ cd
chengxing@boss:~$ pwd
/home/chengxing
chengxing@boss:~$
Displaying a Listing of Files and Directories
ls –a Displaying hidden files
 Hidden file: a file started with a “.”
ls –R Displaying a recursive listing
ls –t Sorts by time stamp instead of by name
ls –l Displaying a long list
  d rwx r-x r-x  4 user nobody 1024 Feb 22 09:20 a.txt
 文 拥  同 其   链   拥     拥       大     最后一次      文
 件 有  组 它   接   有     有       小     修改时间      件
 类 者  人 人   号   者     组                                  名
 型 权  权 权
     限  限 限
boss@boss:~$ touch apple
boss@boss:~$ ls -l apple
-rw-r--r-- 1 boss development 0 2009-07-13 18:06 apple
boss@boss:~$ ls -F  /
bin/    etc/         lib/         opt/   srv/  var/
boot/   home/        lost+found/  proc/  sys/  vmlinuz@
cdrom@  initrd/      media/       root/  tmp/
dev/    initrd.img@  mnt/         sbin/  usr/
boss@boss:~$


boss@boss:~$ ls -l apple
-rw-r--r-- 1 boss development 0 2009-07-13 18:22 apple
boss@boss:~$
boss@boss:~$ chmod u-w apple
boss@boss:~$ ls -l apple
-r--r--r-- 1 boss development 0 2009-07-13 18:22 apple
boss@boss:~$ chmod o-r apple
boss@boss:~$ ls -l apple
-r--r----- 1 boss development 0 2009-07-13 18:22 apple
boss@boss:~$ chmod u-r,g+wx,o+rx apple
boss@boss:~$ ls -l apple
----rwxr-x 1 boss development 0 2009-07-13 18:22 apple
boss@boss:~$
chengxing@boss:~/zhangsan$ mkdir zhangsan
chengxing@boss:~/zhangsan$ cd zhangsan
chengxing@boss:~/zhangsan$ touch apple
chengxing@boss:~/zhangsan$ ls -l apple
--w--wxr-x 1 chengxing development 0 2009-07-13 18:40 apple
chengxing@boss:~/zhangsan$ chmod 710 apple
chengxing@boss:~/zhangsan$ ls -l apple
-rwx--x--- 1 chengxing development 0 2009-07-13 18:40 apple
chengxing@boss:~/zhangsan$

浙江移动验证授权系统:
 r   4   00000100
 w   2   00000010
 x   1   00000001

 

 如果给大家一个权限p,如何判断p具有写权限?
 if(p&w==w)具有写权限
 一个int在32机上有几个字节?4个字节
 一个字节几位?8位
 一个int几位?32位
 一个long几位?64位
 
 浙江移动有n个角色,n 个权限,而且角色权限可以交叉,
 是否可以设计一个统一验证授权系统?
 不能操作的功能都看不到,即使看到也不能操作
 
 角色: vip主任,大客户部主任,客服,客服经理,大堂副理
 index   0     1     2      3         4       5
 权限: 开户,授权,转账,人工停复机,换卡,换品牌,
     
 vip主任:p= 开户+授权+换品牌=1|2|32=35(权重)
 大客户部主任 开户,授权,转账,换卡,换品牌
 客服: 开户+授权+换品牌。。。。。
 
 
 代码如下:
 if(p&1==1) 可以开户
 if(p&2==2)可以授权
 IF(P&4==4) 可以转账

 
 
 
 chengxing@boss:~$ mkdir hello
chengxing@boss:~$
chengxing@boss:~$ cd hello
chengxing@boss:~/hello$ pwd
/home/chengxing/hello
chengxing@boss:~/hello$ ls
chengxing@boss:~/hello$ touch abc
chengxing@boss:~/hello$ ls -l abc
-rw-r--r-- 1 chengxing development 0 2009-07-13 22:41 abc
chengxing@boss:~/hello$ clear
chengxing@boss:~/hello$ mkdir dir1 dir2 dir3
chengxing@boss:~/hello$ pwd
/home/chengxing/hello
chengxing@boss:~/hello$ ls
abc  dir1  dir2  dir3
chengxing@boss:~/hello$ mkdir  dir4/dir5/dir6
mkdir: cannot create directory `dir4/dir5/dir6': No such file or directory
chengxing@boss:~/hello$ mkdir -p  dir4/dir5/dir6
chengxing@boss:~/hello$ ls
abc  dir1  dir2  dir3  dir4
chengxing@boss:~/hello$ cd dir4
chengxing@boss:~/hello/dir4$ ls
dir5
chengxing@boss:~/hello/dir4$ cd dir5
chengxing@boss:~/hello/dir4/dir5$ ls
dir6
chengxing@boss:~/hello/dir4/dir5$ cd ../../
chengxing@boss:~/hello$ ls
abc  dir1  dir2  dir3  dir4
chengxing@boss:~/hello$

在unix/linux中,系统假设你是一个工程师
cp,rm,mv 如果文件存在,都不会提示你,如果你想获得提示
cp rm mv    -i    要求提示

chengxing@boss:~/hello$ ls
abc  dir1  dir2  dir3  dir4
chengxing@boss:~/hello$ clear
chengxing@boss:~/hello$ ls
abc  dir1  dir2  dir3  dir4
chengxing@boss:~/hello$ cp abc apple
chengxing@boss:~/hello$ ls
abc  apple  dir1  dir2  dir3  dir4
chengxing@boss:~/hello$ cp abc apple
chengxing@boss:~/hello$ ls
abc  apple  dir1  dir2  dir3  dir4
chengxing@boss:~/hello$ cp -i abc apple
cp: overwrite `apple'? y
chengxing@boss:~/hello$ cp abc apple dir4
chengxing@boss:~/hello$ ls dir4
abc  apple  dir5
chengxing@boss:~/hello$ cp -r dir5 mydir
cp: cannot stat `dir5': No such file or directory
chengxing@boss:~/hello$ ls
abc  apple  dir1  dir2  dir3  dir4
chengxing@boss:~/hello$ cp -r dir4 mydir
chengxing@boss:~/hello$ ls
abc  apple  dir1  dir2  dir3  dir4  mydir
chengxing@boss:~/hello$


chengxing@boss:~/hello$ ls
abc  apple  dir1  dir2  dir3  dir4  mydir
chengxing@boss:~/hello$ mv abc cde
chengxing@boss:~/hello$ ls
apple  cde  dir1  dir2  dir3  dir4  mydir
chengxing@boss:~/hello$ mv mydir dirs
chengxing@boss:~/hello$ ls
apple  cde  dir1  dir2  dir3  dir4  dirs
chengxing@boss:~/hello$ rm apple
chengxing@boss:~/hello$ ls
cde  dir1  dir2  dir3  dir4  dirs
chengxing@boss:~/hello$ rm -i cde
rm: remove regular empty file `cde'? y
chengxing@boss:~/hello$ ls
dir1  dir2  dir3  dir4  dirs
chengxing@boss:~/hello$ clear
chengxing@boss:~/hello$ ls
dir1  dir2  dir3  dir4  dirs
chengxing@boss:~/hello$ rmdir dir1
chengxing@boss:~/hello$ rmdir dir2
chengxing@boss:~/hello$ rmdir dirs
rmdir: dirs: Directory not empty
chengxing@boss:~/hello$ rm -r dirs
chengxing@boss:~/hello$


login  :   zhangsan   (张三)
      zhangsf     (张三丰)
      zhangsf     (张山峰)
      zhangsf1  

passwd :   boss

修改操作系统密码: 

chengxing@boss:~/hello$ passwd

 
修改邮箱密码: 


 
 
chengxing@boss:/$ ls ~liushuan
chengxing@boss:/$ touch ~liushuan/apple
touch: cannot touch `/home/liushuan/apple': Permission denied
chengxing@boss:/$
chengxing@boss:/$
chengxing@boss:/$ pwd
/
chengxing@boss:/$
chengxing@boss:/$
chengxing@boss:/$ cd ~liushuan
chengxing@boss:/home/liushuan$ ls
chengxing@boss:/home/liushuan$ ls -a
.  ..  .bash_logout  .bash_profile  .bashrc
chengxing@boss:/home/liushuan$ cd
chengxing@boss:~$ pwd
/home/chengxing
chengxing@boss:~$

 

chengxing@boss:~$ touch a b ac ad bc gf ef sfe app nba cba fba
chengxing@boss:~$ ls
a   A.cc  app    b   cba  fba  hello  sfe
ac  ad    apple  bc  ef   gf   nba    zhangsan
chengxing@boss:~$ ls a*
a  ac  ad  app  apple
chengxing@boss:~$ ls b*
b  bc
chengxing@boss:~$ ls b?
bc
chengxing@boss:~$ ls [a-f]*
a  ac  A.cc  ad  app  apple  b  bc  cba  ef  fba
chengxing@boss:~$ ls [af]*
a  ac  ad  app  apple  fba
chengxing@boss:~$


==================


chengxing@boss:~$ cal
     July 2009
Su Mo Tu We Th Fr Sa
          1  2  3  4
 5  6  7  8  9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31

chengxing@boss:~$ cal > a.txt
chengxing@boss:~$ cat a.txt
     July 2009
Su Mo Tu We Th Fr Sa
          1  2  3  4
 5  6  7  8  9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31

chengxing@boss:~$ date
Mon Jul 13 23:44:28 CST 2009
chengxing@boss:~$ date > a.txt
chengxing@boss:~$ cat a.txt
Mon Jul 13 23:44:34 CST 2009
chengxing@boss:~$ cal >> a.txt
chengxing@boss:~$ cat a.txt
Mon Jul 13 23:44:34 CST 2009
     July 2009
Su Mo Tu We Th Fr Sa
          1  2  3  4
 5  6  7  8  9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31

chengxing@boss:~$
chengxing@boss:~$
chengxing@boss:~$ clear
chengxing@boss:~$ wall
ni hao ma ? chi le mei?
asdfsdf

ds
fs
                                                              
Broadcast Message from chengxing@boss                         
        (/dev/pts/23) at 23:45 ...                            
                                                              
ni hao ma ? chi le mei?                                       

asdfsdf                 
                                                              
chengxing@boss:~$
chengxing@boss:~$
chengxing@boss:~$ clear
chengxing@boss:~$ wall
ni hao ,nice to see u
                                                              
Broadcast Message from chengxing@boss                         
        (/dev/pts/23) at 23:46 ...                            
                                                              
ni hao ,nice to see u                                         

CTRL +D 发送 CTRL+C 取消                                                              
chengxing@boss:~$ wall < a.txt
                                                              
Broadcast Message from chengxing@boss                         
        (/dev/pts/23) at 23:46 ...                            
Mon Jul 13 23:44:34 CST 2009                                  
     July 2009                                                
Su Mo Tu We Th Fr Sa                                          
          1  2  3  4                                          
 5  6  7  8  9 10 11                                          
12 13 14 15 16 17 18                                          
19 20 21 22 23 24 25                                          
26 27 28 29 30 31                                             

                                                              


 
 
 
 
 
//拒绝接受别人消息    mesg y  允许别人发消息给我
chengxing@boss:~$ mesg n
在面试过程中经常会问:进程间通讯有哪些方式?

socket
rpc
fifo
pipe :管道   (父子进程间通讯的方式)
memory share

chengxing@boss:~$ cal | wall
                                                              
Broadcast Message from chengxing@boss                         
        (/dev/pts/23) at 23:59 ...                            
                                                              
     July 2009                                                

Su Mo Tu We Th Fr Sa                                          

          1  2  3  4                                          

 5  6  7  8  9 10 11                                          

12 13 14 15 16 17 18                                          

19 20 21 22 23 24 25                                          

26 27 28 29 30 31                                             

                                                              

                                                              
chengxing@boss:~$

 

chengxing@boss:~$ cal > a.txt
chengxing@boss:~$
chengxing@boss:~$ cat a.txt
     July 2009
Su Mo Tu We Th Fr Sa
          1  2  3  4
 5  6  7  8  9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31

chengxing@boss:~$ cat /dev/null > a.txt
chengxing@boss:~$ cat a.txt
chengxing@boss:~$


chengxing@boss:~$ cat /etc/passwd|awk -F:      '{print $1 "/t" $6}' | sort > userinfo.txt
chengxing@boss:~$ head -5 userinfo.txt
alias   /var/qmail/alias
backup  /var/backups
bidl    /home/bidl
bin     /bin
boss    /home/boss
chengxing@boss:~$ tail -3 userinfo.txt
zhouyj  /home/zhouyj
zhukai  /home/zhukai
zuoyh   /home/zuoyh
chengxing@boss:~$


awk 字符处理程序
 默认是以空格为分隔符 
 -F:   是以:为分隔符
 -F|   
 表达式 '{}'   
 print 打印在命令行 
 
 print $1 打印第一列  "/t" 制表符 $6 第六列
 
 
 chengxing@boss:~$ who | awk '{print $1 "/t" $5}'

 unix/linux中四个命令很值得学习:
  1: awk
  2: sed
  3: lex  词法分析器
  4: yacc 语法分析器
  


   向上  k
   向下  j
   向左  h
   向右  l
 i 在光标当前位置插入
 a 在光标所在位置后插入
 o 在光标所在行下插入一空行

 <Esc> 退出插入状态
 x 删除一个字符
 dw 删除当前词
 3dw 删除三个词
 dd 删除当前行
 5dd 删除五行
 :5,10d
 
    r 替换一个字符
   cw 替换一个单词
   cc 替换一行
   C 替换从光标至行尾
   yw   拷贝词
yy   拷贝行(或Y)
p   当前行下粘贴
:1,2co3  拷贝行1,行2在行3之后
:4,5m6  移动行4,行5在行6之后


 :w  存盘
 :w newfile 存成新文件
 :wq   存盘退出Vi(或ZZ,或:x)
 :q!   强行退出不存盘

~  改变大小写
J  把当前行和下一行连起来
u  废除刚才的编辑操作(undo)
:set nu 显示行代码 (:set nonu)
:21 光标停在指定行
21G 光标停在指定行 (G 到文件尾,1G 到文件头)
/串 从当前行往下查找
?串 从当前行往上查找
n  查找继续


金字塔程序:
#include <iostream>
using namespace std;
int main()
{
 for(int i=0;i<10;i++){
` for(int j=10;j>i;j--){
  cout<<" ";
   }
  for(int j=0;j<i*2+1;j++){
   cout<<"$";
    }
   cout<<endl;
   }
}

 

============================================================================================================
聊天室程序:
import java.util.*;
import java.net.*;
import java.io.*;
public class Server{
 public static final int port=10000;

 public static final Vector users=new Vector();
 public static void main(String args[]){

  ServerSocket server=null;

  try{

   server=new ServerSocket(port);   System.out.println("Server start up on port :"+port);
   while(true){

    Socket s=server.accept();

    User user=new User(s);

    user.start();
   }   
  }catch(Exception e){

   e.printStackTrace();

  }finally{

   if(server!=null&&!server.isClosed()){

    try{server.close();}catch(Exception e){}

   } 

  }
 }
}

class User extends Thread{
 private Socket s;
 private String userName;
 private InetAddress ip;
 public User(Socket s){
  this.s=s;
 }
 public void run(){
  try{
   InputStream input=s.getInputStream();
   OutputStream output=s.getOutputStream();
   BufferedReader buf=new
    BufferedReader(new
    InputStreamReader(input));
   PrintWriter pw=new
   PrintWriter(new OutputStreamWriter(output),true);
      
   pw.println("welcome u ,enter your name :");
   userName=buf.readLine();
   Server.users.add(this);
   sendAll(userName+" has join us ");;
   long t=0;
   while(true){
    String line=buf.readLine();
    long s=System.currentTimeMillis();
    if((s-t)/1000<3){
     pw.println("flush denied ");
     continue;
    }
    t=s;

     if(line==null||line.trim().length()==0){

    pw.println("flush denied ");

    continue;
   }

    if(line.equals("bye")){

     sendAll(userName+" leave us ");

     Server.users.remove(this); 

     break;
   
    }


    sendAll(userName+" said :"+line);
   }  
  }catch(Exception e){

   //e.printStackTrace();
  }finally{
   if(s!=null)try{s.close();}catch(Exception e){}
  }
 }
 public  synchronized void sendMessage(String message){
  try{
   PrintWriter pw=new
   PrintWriter(new OutputStreamWriter(
   s.getOutputStream()));
   pw.println(message);
   pw.flush();
  }catch(Exception e){}
 }
 public void sendAll(String message){
  Iterator it=Server.users.iterator();
  while(it.hasNext()){
   User user=(User)it.next();
   user.sendMessage(message);
  }
 }

 
 
 

 

原创粉丝点击