1.
last
df
free
free -mdu
du -h
topps
kill
killall
find *. CRL-ALT-F6 进入命令行 alt+f7 退出命令行 less chmod tar :tar -czvf bob_backup.tar.gz *untar:tar -zxvpf my_tar_file.tar.gz
atcp -r /home/bob/tonyd/ /home/fred/cp -i file1.txt file2.txt
in liunx,everything is a file
mv
Any learning experience means opening up to new ideas and new ways of doing things.rm -ir directory1mkdir my_friendsrmdir my_friends/touch -t 05070915 my_report.txtfind -name *hawaii*find -mmin +0 -mmin -10grep Mary mary*.txtwho'tee', '>', '2>'ls -l | tee directory_listing <==> ls -l > directory_listing //('>' 等效于 ‘|tee’)date | tee -a directory_listing <===> date >> directory_listingwhoami whatis whereis whereis nginx which echo dir=ls -l pwd datedate +%Ddate +%Texit
calcal 2015cal 12 2025clear <===> ctrl + l'man' - manual pages in Linuxcat /etc/passwd|grep robapt-get install package-nameapt-cache search packageapt-get dist-upgraderm
'chown' -> change ownerchown bob.bob the_fileshutdown -h now --->Shutting down Linuxshutdown -h 20:01shutdown -h +5shutdown -r now --->Rebooting Your Computerman [the command]cp --help | less
info [command name]apropos xterm //列出xterm相关信息Liunx file system:
Liunx directories:
cd ==》change directorycd /文件系统Ext2: This is like UNIX file system. It has the concepts of blocks, inodes and directories.
Ext3: It is backwards compatible with the ext2 file system, except that it has added journal ing capabilities.
automate tasks on a Linux system
Use of 'at'
at 时间
时间后回车
就可以进入编辑了.
完成后按ctrl+d提交
例子 :
三天后的下午 5 点锺执行 /bin/ls :
at 5pm + 3 days /bin/ls
三个星期后的下午 5 点锺执行 /bin/ls :
at 5pm + 2 weeks /bin/ls
明天的 17:20 执行 /bin/date :
at 17:20 tomorrow /bin/date
1999 年的最后一天的最后一分钟印出 the end of world !
at 23:59 12/31/1999 echo the end of world !
crontab 命令的功能是在一定的时间间隔调度一些命令的执行。在 /etc 目录下有一个 crontab 文件,这里存放有系统运行的一些调度程序。每个用户可以建立自己的调度 crontab
任务调度设置文件的写法
其格式如下:
Minute Hour Day Month Dayofweek command
分钟 小时 天 月 天每星期 命令
每个字段代表的含义如下:
Minute 每个小时的第几分钟执行该任务
Hour 每天的第几个小时执行该任务
Day 每月的第几天执行该任务
Month 每年的第几个月执行该任务
DayOfWeek 每周的第几天执行该任务
Command 指定要执行的程序
在这些字段里,除了“ Command ”是每次都必须指定的字段以外,其它字段皆为可选字段,可视需要决定。对于不指定的字段,要用“ * ”来填补其位置。
举例如下:
1 、指定每小时的第 5 分钟执行一次 ls 命令
5 * * * * ls
2 、指定每天的 5:30 执行 ls 命令
30 5 * * * ls
3 、指定每月 8 号的 7 : 30 分执行 ls 命令
30 7 8 * * ls
4 、指定每年的 6 月 8 日 5 : 30 执行 ls 命令
30 5 8 6 * ls
5 、指定每星期日的 6:30 执行 ls 命令
30 6 * * 0 ls
注: 0 表示星期天, 1 表示星期 1 ,以此类推,也可以用英文来表示, sun 表示星期天, mon 表示星期一等。
6 、每月 10 号及 20 号的 3 : 30 执行 ls 命令
30 3 10,20 * * ls
注:“,”用来连接多个不连续的时段
7 、每天 8-11 点的第 25 分钟执行 ls 命令
25 8-11 * * * ls
注:“ - ”用来连接连续的时段
8 、每 15 分钟执行一次 ls 命令
*/15 * * * * ls
即每个小时的第 0 15 30 45 60 分钟执行 ls 命令
9 、每个月中,每隔 10 天 6:30 执行一次 ls 命令
30 6 */10 * * ls
即每月的 1 、 11 、 21 、 31 日是的 6 : 30 执行一次 ls 命令。
10 、每天 7 : 50 以 root 身份执行 /etc/cron.daily 目录中的所有可执行文件
50 7 * * * root run-parts /etc/cron.daily
注: run-parts 参数表示,执行后面目录中的所有可执行文件
新增调度任务可用两种方法:
1 、在命令行输入 : crontab -e 然后添加相应的任务, wq 存盘退出。
2 、直接编辑 /etc/crontab 文件,即 vi /etc/crontab ,添加相应的任务。
删除任务调度工作
crontab -r // 删除所有任务调度工作
每天 5 : 30 执行 ls 命令,并把结果输出到 /jp/test 文件中
30 5 * * * ls >/jp/test 2>&1
注: 2>&1 表示执行结果及错误信息。
1、定时关机
命令:at 21:00 ShutDown –S –T30
该命令运行后,到了21:00点,电脑会出现“系统关机”对话框,并默认30秒延时自动关机。
2、定时提醒
命令:at 12:00 Net Send 10.10.36
.122与朋友约会的时间到了,快点准备出发吧!
其中Net Send是Windows内部程序,可以发送消息到网络上的其他用户、计算机。10.10.36.122是本机电脑的IP地址。这个功能在Windows中也称作“信使服务”。
3、自动运行批处理文件
如果公司的数据?渲匾?,要求在指定的日期/时间进行备份,那么运行:
命令:at 1:00AM /Every:Saturday My_BackUp.bat
这样,在每个Saturday(周六)的早上1:00点,电脑定时启动My_BackUp.bat批处理文件。My_BackUp.bat是一个你自行编制的批处理文件,它包含能对系统进行数据完全备份的多条命令。
4、取消已经安排的计划
命令:at 5 /Delete
vi /etc/hosts.allow
Esc+i
Esc+w
Esc+q
Esc+q!
Esc+d
Esc+u`````
find word:
ESC + /word
replace word "abc" to "efg" :
Esc: s/abc/efg
replace all word "abc" to "efg" in the page:
Esc: %s/abc/efg/g
SSH远程连接: