linux常用命令

1.删除
   rm <filename>   #删除文件
     rm -fr <dir>       #删除文件夹
2.复制
   cp <srcfile> <dstfile>
    cp -av <srcdir> <dstdir>

3.更名
  mv <src> <dst>

4.比较目录
  diff <dir1> <dir2>

5.显示文件内容
  cat <file>
   cat <file> |less  #分页显示
6. 操作系统时间
  date
   date -s <time> #设置时间

7. BIOS时间
  clock -r   #读BIOS时间
   clock -w #写时间至BIOS

8.弹出光驱
  eject
9.计算目录容量
  du -sm <dir> #计算dir目录使用的容量用M为单位
10. 查找文件
   find -name <dir> <file> #在dir目录下查找文件

11.在文件中查找内容
  grep -ir "abc"  #在当前目录下查找字符串abc

12.
   reboot  #重启
   halt    #关机
   init 0  #关闭所有应用程序
   init 1  #重新启动应用各服务
   init 6  #重启计算机
   sleep 9  #将系统挂起9秒
13.解压缩
  tar xzvf file.tar.gz #解压
  tar xf file.tar       #解包
   tar czvf <dir>   #压缩,生成.tar.gz
  tar c <dir>        #打包.生成.tar
   gzip file.tar       #压缩file.tar.生成file.tar.gz
   gunzip file.tar.gz #解压
  upzip -a file.zip #解压zip文件并把dos换行符改为linux换行符(0D0A改为0D)
  
14.系统信息
dmesg   #显示kernel启动及驱动装载信息
uname -a #显示操作系统内核版本等信息

15.安装
  rpm -ihv file.rpm  #安装
  rpm -e file            #反安装
  rpm -q file            #是否安装

16.切换用户
  su root

17.修改文件属性
  chmod a+x <file>
   chmod 777 <file>

18.创建临时文件
  touch /temp/running  #running临时文件创建

19.设备文件
mknod /dev/hda1 b 3 1  #创建块设备hda1,主设备号为3,从设备为1
mknod /dev/tty1 c 4 1    #创建字符设备tty1,主设备号为4,从设备为1

20.打印      
lpd stop       #停止打印服务
  lpd start      #启动打印服务
  lpd restart   #重启打印服务
  lpr  <file>    #打印文件

21.文件系统
  df #显示文件系统装载信息
   mount -t iso9660 /dev/cdrom /mnt/cdrom #挂载CDROM
   mount -t smb //192.168.1.5/sharedir /mnt -O username=<username>;password=<password> #挂载网上邻居
   sync #装CACHE中的内容与磁盘同步
   swapon /dev/hda9  #把hda9作为交换分区
  swapoff /dev/hda9  #hda9作为交换分区去掉

22.编程相关
  ldd <program> #显示程序使用哪些库
  gcc -static -o hello hello.c
   gcc hello.c -o hello
   gcc -I/usr/include/mysql -o hello hello.c -L/usr/lib/mysql/ -lmysqlclient
   objcopy -s <program> #去掉debug信息
  strace <program>  #跟踪程序运行
  ar crv libfoo.a <file1.o> <file2.o> ...   #Create static library with object files
   ranlib libfoo.a                                     #
  
23.常用系统命令
  ps -ef                #显示所有进程
  kill -9 <PID>      #
  top                    #
  free                    #显示系统内存使用情况
  time <program> #计算程序运行时间
  route                 #显示路由
  dhcp
  dhcpclient
  
24.网络
   traceroute  <host>  #跟踪route   (在window里是tracer)
   tcpdump -s 1500 -w log.cap host 210.22.26.246 and port 5060  #抓包

25.LINUX下命令行下的配置
setup     #所有配置
ntsysv    #配置服务
system-config-securitylevel   #配置防火墙


26.xinetd已代替inetd,tcpwrapper
配置文件在/etc/xinetd.d/和/etc/xinetd.conf
可配置服务程序,重启xinetd,/etc/rc.d/init.d/xinetd restart


27.Linux系统服务
服务自动运行配置目录在/etc/rc.d/init.d/
删除服务 chkconfig --del mysql
增加服务 chkconfig --add mysql
重启服务 service httpd restart
配置服务 ntsysv

28.驱动程序相关的
lsmod                 #显示已装载的驱动程序
modprobe          #动态装载驱动程序.
insmod               # 动态装载驱动程序
rmmod               #卸载驱动程序

你可能感兴趣的:(linux,职场,休闲)