日历

二月
28293031123
45678910
11121314151617
18192021222324
252627282912

分类

can't disable telnet please help~~

2014年2月09日 01:14 | Comments(0) | Category:linux | Tags:

参考资料

1.install and enalbe telent

2.enable ssh&telnet

3.diable telent


ubuntu系统在默认情况下是没有启动telent服务的,需要自行配置

1.安装启动基础服务

sudo apt-get install xinetd

2.配置基础文件,在/etc/xinet.conf加入如下几行

# Simple configuration file for xinetd

#

# Some defaults, and include /etc/xinetd.d/

defaults

{

# Please note that you need a log_type line to be able to use log_on_success

# and log_on_failure. The default is the following :

# log_type = SYSLOG daemon info

instances = 60

log_type = SYSLOG authpriv

log_on_success = HOST PID

log_on_failure = HOST

cps = 25 30

}

3.安装telent客户端

sudo apt-get install telnet

4.配置telent文件,nano /etc/xinetd.d/telnet,在此目录下没有telent文件的自己touch

# default: on
# description: The telnet server serves telnet sessions; it uses
# unencrypted username/password pairs for authentication.
service telnet
{
disable = no
flags = REUSE
socket_type = stream
wait = no
user = root
server = /usr/sbin/in.telnetd
log_on_failure += USERID
}

更高安全要求配置

only_from = 192.168.120.0/24 #Only users in 192.168.120.0 can access to

only_from = .bob.com #allow access from bob.com

no_access = 192.168.120.{101,105} #not allow access from the two IP.

access_times = 8:00-9:00 20:00-21:00 #allow access in the two times

5.重启xinet服务

sudo /etc/init.d/xinetd restart

6.关闭telent服务,网上的教程是这样做的,但是我却不成功,求搭救~~

把/etc/xinetd.d/telnet 文件的 disable=no 改为yes

重启xinetd服务 sudo /etc/init.d/xinetd restart

> ps:重启xinetd服务 service xinetd restart 也可以,不过我的ubuntu不知道为什么,用tab能调出xinetd但是执行命令却是

stop: Unknown job: xinetd

start: Unknown job: xinetd

>ps 网上的重启xinetd服务是 sudo /etc/rc.d/init.d/xinetd restart 但是我/etc下没有rc.d 不过有rc0~6.d,不知道这个有没有关系呢

 

 

shell 基础

2013年12月26日 20:44 | Comments(0) | Category:linux | Tags:

参考资料 :UNIX和shell程序设计权威教程 清华大学出版社

鸟哥的私房菜


 

1.验证当前shell

echo $0

2.重定向

类型 Korn shell or Bash shell
输入 0<file1
输出 1>>file1(追加) or 1>|file1(覆盖)
错误输入 2>>file1(追加形式) or 2>|file2(覆盖形式)
输出错误(不同文件) 1> file1 2>file2
输出错误(同一个文件) 1>file1 2&1

重定向到垃圾桶 /dev/null

3.管道

注意管道的左边命令必须能够发送数据至标准输出,右端命令必须能从标准输入接收数据

4.引号:斜干(\)、单引号('')、双引号("")
斜杆主要是用来转义、如果需要输出单引号,双引号也需要在引号前面加上 \
 
单双引号可以使其内的所有特殊字符失去特殊作用。不过单引号的能力比双引号的能力更强。爽引号保留诸如空格、制表符、换行符、自定义变量。单引号则不能
 
5.命令替代:在一段文本中使用某个命令 $(command)
 
6.作业控制
只有将工作挂起才能将工作置于前台或后台工作 (fg %n   bg  %n)
从前台后台停止工作 (ctrl+z stop)
从前台后台终止工作(ctrl +d kill)
 
7.别名
给命令自定义自己喜欢的名字(如果命令是家参数的需要用单引号或双引号) alias name=command
取消别名unalias name
显示所有的命令别名 alias
 
8.变量
8.1修改系统级变量
《私房菜》P377
增加变量 方式  -> 变量名=$"变量名":增加内容
将变量转变成环境变量 export 变量名
方式 结果
$(variable#key) 从变量的开头删除一直到key之后
$(variable##key) 从变量的开头删除最长的字符串一直到key之后
$(variable%key) 从变量的尾部开始删除一直到key之前
$(variable%%key) 从变量的尾部开始删除最长的字符串一知道key之前
$(varible/old_k/new_key)

用new_key替换第一个符合的old_k

$(varible//old_key/new_key) 用new_key替换所有的old_k

 

8.2修改个人变量
8.3变量的测试
 
9终端的区别
终端分为两种一种是需要登录的终端(login shell)指的是tty1~6,一种是不需要登录的(no-login shell),指的是在x-windows下启动的图形终端。两种终端启动的配置文件是不同的
login shell 对应 /etc/profile
no-login shell对应~/.bash_profile or ~/.bash_login or ~/.profile  (优先顺序从左到右)
 
详见《私房菜》P384 ~392 Bash Shell的环境操作
 
 
 
《私房菜》P380                              ps:乱码语系P371
 

grep

2013年12月25日 15:56 | Comments(1) | Category:linux | Tags:

The useful options of grep,egrep,fgrep

-i, Ignore case distinctions in both the patten and files

-v Invert the sense of matching,to selsect non-matching lines

-c Suppress normal output;instead print a count of matching line

-n Prefix each line of output with the 1-based line number

正则表达式

2013年12月22日 23:27 | Comments(0) | Category:linux | Tags:

参考书籍:unix和shell程序设计权威指南 清华出版社

                    正则表达式


一、原子

点:. 匹配任意ACII字符

类:[]匹配方括号内任意一个字符

     注:方括号内使用转义字符\,非运算符^

             [A-Za-z]:任意字符

锚:^  : 行首

         $  :行尾

         \<  :单词词首

        \>   :单词词尾

                     注:锚和原子经常结合一起使用,如^Q表示已Q开头的一个字符串

向后引用

重新使用在一个正则表达式定义过的规则,不过这是有要求的,规则必须出现在()中,/1调用第一个括号里的规则、/2 /3……以此类推。加入多个括号嵌套使用系统会自动给最先出现的'('分配.

二、正则表达式的运算符

序列运算符:序列算符为空,它的含义是:如果有原子系列出现在正则表达式中则表示在原子之间有一个不可见的序列运算符

    注:[0-9][0-9]任意数字

替换:|   相当于是 A or B,AB中的任意一个

重复:\{m,n\}

             说明:最多n个可以是0到n \{,n\}

                          最少n个必须比n个多\{n,\}

                          精确n个\{n\}

缩写形式运算符:?匹配前面的原子0到1次

                                  +匹配前面的原子1到多次

                                  *匹配前面的原子0到多次

组运算符:()相当于四则运算里的括号,被括起来的部分先进行运算

                    注:*(?=xxxx)匹配*的右边必须是xxxx *(?>=xxxx)匹配的左边必须是xxxx


 

\r,\n carriage return,newline character
\t Tabs
\d Any digit character,any ont of 0~9
\w any alpha,numeric,underline
\s Any one of space,tab,newline, or\n
. Any character except \n
\b Match a word boundary
   
   
   

English Version

common 普通字符

escaped character 转义字符

character sets 字符集合

custom sets 次数集合

quantifier

special puncts 特殊字符(点)

backward 向后引用

assertion  预搜索

greedy  reluctant 贪婪 懒惰

prompts 提示


 


 

日志

2013年12月17日 20:20 | Comments(0) | Category:linux | Tags:

这是我删除的软件包的日志,以后再也不乱删东西了后果真的很严重@依云说可以查看apt日志自己删除了什么包然后从新安装这些包就可以了。但是我都不知道那些包是有用的那些是可以删的。现在知道更声卡有关的就只有 
inux-sound-base
alsa-base
alsa-utils
在ubuntu官网上这个包有嵌套那个包啊,是在是搞不清他们的依赖关系。
只能是从新安装 alsa驱动了
 
 
Start-Date: 2013-12-08  15:12:06
Commandline: apt-get autoremove
Remove: efibootmgr:amd64 (0.5.4-4ubuntu1), libvte-common:amd64 (0.28.2-5ubuntu1), libconfuse-common:amd64 (2.7-4), libvte9:amd64 (0.28.2-5ubuntu1), libconfuse0:amd64 (2.7-4), grub-efi-amd64-bin:amd64 (2.00-13ubuntu3)
End-Date: 2013-12-08  15:12:17
 
Start-Date: 2013-12-08  15:26:05
Commandline: apt-get install aptitude
Install: aptitude:amd64 (0.6.8.1-2ubuntu2), libcwidget3:amd64 (0.5.16-3.4ubuntu1, automatic), libboost-iostreams1.49.0:amd64 (1.49.0-3.2ubuntu1, automatic), libept1.4.12:amd64 (1.0.9, automatic), aptitude-common:amd64 (0.6.8.1-2ubuntu2, automatic)
End-Date: 2013-12-08  15:26:15
 
Start-Date: 2013-12-08  15:27:02
Purge: vim-gui-common:amd64 (), vim-common:amd64 (), libwxbase2.8-0:amd64 (), grub-efi-amd64:amd64 (), libwxsqlite3-2.8-0:amd64 (), libeventviews4:amd64 (), libcalendarsupport4:amd64 (), vim-tiny:amd64 (), tilda:amd64 (), libkdepim4:amd64 (), libwxgtk2.8-0:amd64 (), guayadeque:amd64 (), vim-gnome:amd64 (), libincidenceeditorsng4-mobile:amd64 (), libvte9:amd64 (), libkdepimdbusinterfaces4:amd64 (), libkdgantt2:amd64 (), im-switch:amd64 (), libkdepimui-mobile:amd64 (), libconfuse0:amd64 (), vim-runtime:amd64 ()
End-Date: 2013-12-08  15:27:29
 
Start-Date: 2013-12-08  15:27:41
Purge: linux-image-extra-3.8.0-19-generic:amd64 (3.8.0-19.30), linux-headers-3.8.0-19:amd64 (3.8.0-19.30), linux-headers-3.8.0-30:amd64 (3.8.0-30.44), linux-headers-3.8.0-29:amd64 (3.8.0-29.42), linux-image-3.8.0-29-generic:amd64 (3.8.0-29.42), linux-image-3.8.0-19-generic:amd64 (3.8.0-19.30), linux-headers-3.8.0-29-generic:amd64 (3.8.0-29.42), linux-image-extra-3.8.0-30-generic:amd64 (3.8.0-30.44), linux-headers-3.8.0-19-generic:amd64 (3.8.0-19.30), linux-image-3.8.0-30-generic:amd64 (3.8.0-30.44), linux-image-extra-3.8.0-29-generic:amd64 (3.8.0-29.42), linux-headers-3.8.0-30-generic:amd64 (3.8.0-30.44)
Error: Sub-process /usr/bin/dpkg returned an error code (1)
End-Date: 2013-12-08  15:29:09
 
Start-Date: 2013-12-08  15:39:46
Commandline: aptdaemon role='role-remove-packages' sender=':1.385'
Remove: linux-image-extra-3.8.0-19-generic:amd64 (3.8.0-19.30), linux-image-3.8.0-19-generic:amd64 (3.8.0-19.30), unity-webapps-common:amd64 (2.4.14-0ubuntu1)
End-Date: 2013-12-08  15:39:52
 
Start-Date: 2013-12-08  15:42:02
Commandline: aptdaemon role='role-remove-packages' sender=':1.385'
Remove: libopenal1:amd64 (1.14-4ubuntu1), libopenal1:i386 (1.14-4ubuntu1), libpam-winbind:amd64 (3.6.9-1ubuntu1.1), ttf-umefont:amd64 (444-1ubuntu1), wine1.4-amd64:amd64 (1.4.1-0ubuntu5), ttf-liberation:amd64 (1.07.2-6ubuntu1), wine1.4:amd64 (1.4.1-0ubuntu5), libcapi20-3:amd64 (3.12.20071127-0ubuntu11), libopenal-data:amd64 (1.14-4ubuntu1), unixodbc:amd64 (2.2.14p2-5ubuntu4), wine-gecko1.4:amd64 (1.4.0-0ubuntu2), winetricks:amd64 (0.0+20121030+svn918-2), wine1.4-i386:i386 (1.4.1-0ubuntu5), ttf-unfonts-core:amd64 (1.0.3.is.1.0.2-080608-5ubuntu3), winbind:amd64 (3.6.9-1ubuntu1.1), libodbc1:amd64 (2.2.14p2-5ubuntu4), libnss-winbind:amd64 (3.6.9-1ubuntu1.1), ttf-droid:amd64 (4.2.r1-1ubuntu1)
End-Date: 2013-12-08  15:42:28
 
Start-Date: 2013-12-08  15:48:10
Commandline: aptdaemon role='role-remove-packages' sender=':1.385'
Remove: claws-mail-i18n:amd64 (3.8.1-2), claws-mail:amd64 (3.8.1-2)
End-Date: 2013-12-08  15:48:16
 
Start-Date: 2013-12-08  16:18:19
Commandline: aptdaemon role='role-remove-packages' sender=':1.385'
Remove: totem-plugins:amd64 (3.6.3-0ubuntu6), totem:amd64 (3.6.3-0ubuntu6), totem-mozilla:amd64 (3.6.3-0ubuntu6)
End-Date: 2013-12-08  16:18:24
 
Start-Date: 2013-12-08  17:27:31
Commandline: apt-get install deborphan -y
Install: deborphan:amd64 (1.7.28.8)
End-Date: 2013-12-08  17:27:41
 

清理linxu垃圾文件

2013年12月08日 18:52 | Comments(4) | Category:linux | Tags:

今天用df命令查看了自己的磁盘空间发现/分区已经使用了91%,特意上网找了一些方法以下是总结

1.使用命令 du --max-depth=1 -h 来查看各个目录的大小

参数说明  --max-depth=x ,x可以是0~n的数字,表示查看子目录的深度

                   -h 表示适合阅读

 
2.删除垃圾文件所在的目录
    rm -rf /tmp/*
    rm -rf /var/log/*
    rm -rf /home/.mozilla/firefox/*
 
3.清理旧版本的软件缓存
sudo apt-get autoclean
4.清理所有软件缓存
sudo apt-get clean
5.删除系统不再使用的孤立软件
sudo apt-get autoremove
6.清理linux下孤立的包
sudo apt-get install deborphan -y
7.删除多余的内核
          查看内核文件 (有image的就是内核文件)
dpkg --get-selections|grep linxu
          删除内核文件
sudo apt-get remove  内核文件名
参考IBM的文章 给linux系统“减肥”

linux系统剪切板与vim剪切板

2013年12月08日 12:56 | Comments(3) | Category:linux | Tags:

这都是一些零散的知识

1.在vim中的复制粘贴就是在寄存器中寄放和提取字符串。你可以用:reg来查看所有的寄存器

在vim复制一个字符串 "Ny  :N表示寄存器名称

在vim粘贴一个字符串  "Np

2.其中"+是也是x-windows中的寄存器,通过"+p可以在vim中调用系统中通过ctrl+c得到的内容

注意:在vim中,"+y 是复制一整行

3.yw可以复制一个字符串,不过需要光标在字符串的首字符

4.dw删除一个单词

i don konw

2013年12月02日 16:02 | Comments(3) | Category:linux | Tags:

#include <stdio.h>
int main()
{
printf("goagent");
}
basice
for (int i=1;i<10;i++)

在终端设置目录变量

2013年12月02日 15:38 | Comments(2) | Category:linux | Tags:

我有一个很深层次的目录里面存放着我工作的文件,每次读取这些文件都需要通过敲打cd命令进入,虽然tab键能够减轻输入的负担。但是对于进入一个既有中文又有英文的目录来说我还是觉得比较麻烦。于是如果在shell中设置一个目录路径的变量,只要调用这个变量不就可以减轻负担了吗!

具体步骤

  1. 修改profile文件

               sudo vi /etc/profile

    2.添加语句 export study=/home/been/WINE/学习/源代码 

   3.更新配置 source /etc/profile

tar命令分类

2013年12月01日 19:01 | Comments(0) | Category:linux | Tags:

tar压缩解压命令分类总结

以前一直都及记不住tar命令的参数,不过今天看了别人的网站原来给参数分类总结是很好的记忆方法

tar命令参数

-c创建压缩文档

-x解压

-t查看内容

-r向压缩归档文件尾追加文件

-u更新原压缩文件中文件

这五个参数是独立的,在使用tar命令时必须使用其中一个;注意-f参数是必须要添加的而且f参数必须是在所有参数的最后添加

其他参数

-z:有gzip属性

-j:有bz2属性

-Z:有compress属性

-v:显示所有过程

-O:将文件解压到标准输出

tar命令格式:tar -cvf file.tar filename 创建一个file.tar归档文件