标签类目:Shell

Linux shell常用快捷键

分类:Shell下面是一些shell的常用快捷键,快捷键玩熟悉了在一定程度上是可以提高工作效率:

Ctrl + a 切换到命令行开始
Ctrl + e 切换到命令行末尾
Ctrl + l 清除屏幕内容
Ctrl + u 清除光标之前的内容
Ctrl + k 清除光标之后的内容
Ctrl + h 类似于退格键
Ctrl + r 在历史命令中查找 (这个非常好用,输入关键字就调出以前的命令了)
Ctrl + c 终止命令
Ctrl + d 退出shell
Ctrl + z 转入后台运行..

ALT键比较少用,因为很多地方与远程登陆工具是有冲突的..

Alt + f 切换光标前的字母
Alt + b 切换光标后的字母

History命令用法

分类:Shell如果你经常使用 Linux 命令行,那么使用 history命令可以有效地提升你的效率。本文将通过实例的方式向你介绍 history 命令的 若干个用法。

使用 HISTTIMEFORMAT 显示时间戳
当你从命令行执行 history 命令后,通常只会显示已执行命令的序号和命令本身。如果你想要查看命令历史的时间戳,那么可以执行:

引用

# export HISTTIMEFORMAT=’%F %T ‘
# history | more
1 2008-08-05 19:02:39 service network restart
2 2008-08-05 19:02:39 exit
3 2008-08-05 19:02:39 id
4 2008-08-05 19:02:39 cat /etc/redhat-release 继续阅读 »

python:创建Wscript.Shell进行自动化

分类:Python

  1. import win32com.client
  2.  
  3. execpath = 'cmd.exe'
  4. wsh = win32com.client.Dispatch("Wscript.Shell")
  5. wshe = wsh.Exec(execpath)
  6. pid = wshe.ProcessID
  7. wsh.AppActivate(pid)
  8. time.sleep(splashsec)
  9. wsh.SendKeys("{ENTER}")
  10. wsh.SendKeys("%n")#alt+n
  11. wsh.SendKeys("%a")
  12. wsh.SendKeys("10.0.0.1")
  13. wsh.SendKeys("{CAPSLOCK}")

继续阅读 »

rm 删除文件自动放到回收站shell脚本

分类:Shell很多人抱怨rm不能将删除的文件放到回收站,可是谁能保证万无一失呢? 我、DP……N多人貌似都失误过,如果设置每次删除文件都询问,一来麻烦,二来有时也会错误确认。

这个脚本只能把删除的文件小于100M的放到回收站,大于100M的会提示用户是否删除。主要考虑不同分区见文件拷贝占用空间和系统资源的问题,毕竟和图形界面放到回收站不一样。

0. 把此脚本拷贝到/usr/bin/myrm
1. 在~/.bashrc 添加一行 alias rm=’myrm’
2.配置脚本里的文件大小限制,默认为100M
继续阅读 »

使用sar进行综合分析

分类:Debiansar是System Activity Reporter(系统活动情况报告)的缩写。顾名思义,sar工具将对系统当前的状态进行取样,然后通过计算数据和比例来表达系统的当前运行状态。它的特点是可以连续对系统取样,获得大量的取样数据;取样数据和分析的结果都可以存入文件,所需的负载很小。sar是目前Linux上最为全面的系统性能分析工具之一,可以从14个大方面对系统的活动进行报告,包括文件的读写情况、系统调用的使用情况、串口、CPU效率、内存使用状况、进程活动及IPC有关的活动等,使用也是较为复杂。 继续阅读 »

Create Users And Change Passwords With A Bash Script

分类:ShellThese two scripts are very important for the system admin who regularly works with mail servers and somehow forgets to backup his system username and password! Let’s say somehow we lost the usernames and passwords of the mail server. In this case the admin has to manually create all the users and then change the passwords for all the users. Tedious job. Let’s make our life easier.
继续阅读 »

Shell script to restart MySQL server if it is killed or not working

分类:Shell分类:MySQL# mysql root/admin username
MUSER=”root”
# mysql admin/root password
MPASS=”SET-ROOT-PASSWORD”
# mysql server hostname
MHOST=”localhost”
#Shell script to start MySQL server i.e. path to MySQL daemon start/stop script.
# Debain uses following script, need to setup this according to your UNIX/Linux/BSD OS.
MSTART=”/etc/init.d/mysql start” 继续阅读 »


返回顶部