初涉linux(一)

[size=small][color=red] 所有的文档命令都基于Fedora8[/color][/size]
1. linux命令基础 2009-02-23 by hayabusa
1.1 讲义
1.1.1.linux的内核版本 格式为主版本号:次版本号:末版本号 比如:2.3.36,奇数次版本号为开发版本,偶数次版本号为稳定版本
1.1.2.切换终端 Ctrl+Alt+F[1-7]或者chvt n(顺便鄙视下自己,前种方式要按住一两秒,与手机关机有点像)
1.1.3.clear
reboot
init 0 // shun down
init 6 // same as [i]reboot[/i]
1.1.4.date
date -d "20090223 09:12:12" +%F" "%T //echo:2009-02-23 09:12:12
date -d "10000 days ago" +%D //echo:10/08/81
1.1.5.
w
who
whoami
who am I(i) //与前一种区别:whoami 只显示当前用户。
1.1.6.
pwd // the current directory
1.1.7.
id
groups
1.1.8.
System->Administration->Users and Groups // add/list users or groups
System->Peferences->About me->Change password //change your password
passwd
1.1.9.
vi
vi test.txt // edit test.txt
when editing test.txt :
<ESC> //from the insert mode to the command mode
:wq! //w:save q:exit !:force exit
: x //same as :wq!
:w filename //save as filename
:set nu //add the line number for each
:N //go to the line N
:/search //search ,using n/N going to the next/previous searched phrase
dd //delete a line
Nd //delete N line
yy //copy a line
p //stick up the copied content
dw //delete a phrase
k,j,h,l //move up,down,left,right
u //undo
i //from the command mode to the insert mode
1.1.10.history
history
modify the histsize to 50:
su - root
cd /etc/
vi profile
HISTSIZE=50//modify HISTSIZE=50
cd /etc/skel/
//edit .bash_logout,add the command:rm -f $HOME/.bash_history
reboot
1.1.11.
cal filename //echo the content of the file
1.1.12.
hostname
vi /etc/hosts
//modify localhost:localdomain to myhost:mydomain
//the same action in the /etc/sysconfig/network
1.1.13.
touch {a,b}{c,d}
1.1.14.
.tar
tar cvf test.tar *.txt
tar xvf test.tar //zip/unzip the .tar file

tar zcvf test.tar.gz *.txt
tar zxvf test.tar.gz //zip/unzip the .tar.gz file

tar jcvf test.tar.bz2 *.txt
tar jxvf test.tar.bz2 //zip/unzip the .tar.bz2 file

 [color=gray] 解包: tar xvf FileName.tar
  打包:tar cvf FileName.tar DirName
  (注:tar是打包,不是压缩!)
  ---------------------------------------------
  .gz
  解压1:gunzip FileName.gz
  解压2:gzip -d FileName.gz
  压缩:gzip FileName
  .tar.gz 和 .tgz
  解压:tar zxvf FileName.tar.gz
  压缩:tar zcvf FileName.tar.gz DirName
  ---------------------------------------------
  .bz2
  解压1:bzip2 -d FileName.bz2
  解压2:bunzip2 FileName.bz2
  压缩: bzip2 -z FileName
  .tar.bz2
  解压:tar jxvf FileName.tar.bz2
  压缩:tar jcvf FileName.tar.bz2 DirName
  ---------------------------------------------
  .bz
  解压1:bzip2 -d FileName.bz
  解压2:bunzip2 FileName.bz
  压缩:未知
  .tar.bz
  解压:tar jxvf FileName.tar.bz
  压缩:未知
  ---------------------------------------------
  .Z
  解压:uncompress FileName.Z
  压缩:compress FileName
  .tar.Z
  解压:tar Zxvf FileName.tar.Z
  压缩:tar Zcvf FileName.tar.Z DirName
  ---------------------------------------------
  .zip
  解压:unzip FileName.zip
  压缩:zip FileName.zip DirName
  ---------------------------------------------
  .rar
  解压:rar a FileName.rar
  压缩:r ar e FileName.rar
  
  rar请到:http://www.rarsoft.com/download.htm 下载!
  解压后请将rar_static拷贝到/usr/bin目录(其他由$PATH环境变量指定的目录也可以):
  # cp rar_static /usr/bin/rar
  ---------------------------------------------
  .lha
  解压:lha -e FileName.lha
  压缩:lha -a FileName.lha FileName [/color]

1.2 扩展
1.2.1.在修改完hosts与network之后,reboot系统时发现在starting sendmail的时候,总是需要等大约十几分钟到半个小时不能,google之后得出两种解决方案。
第一种:[quote]
try add a line like the following to /etc/hosts
Code:

192.168.0.205 computername computername.domanname

where you replace the IP with your IP and the computername and domainname of your computer[/quote]
第二种:[quote]I use
Code:

chkconfig --levels 345 sendmail off

sendmail is off at starting. And I think when I want to use it again,I can use
Code:

chkconfig --levels 345 sendmail on

[/quote]
这两种方式都试过,应该说是各有优点。当使用静态IP时,选第一种还是不错的。当然第二种方法也是非常方便的。在这里提醒下自己,在Fedora8上使用chkconfig命令时,不仅要使用root,而且shell也必须使用root用户的,即使用su - root命令进入。
1.2.2 find
1.2.2.1寻找当前目录及所有的子目录下叫hello的文档
find . -name hello
1.2.2.2 找出七天内未被修改的文档
find / -mtime +7
1.2.2.3 找出大小超过2000 bytes的文档
find / -size 2000c
1.2.2.4 在/tmp下属于flm的文档
find /tmp -user flm
1.2.2.5 显示当前目录及所有的子目录文件名前4位为test的文件名
find . -name "test*"
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值