学习Linux第四天

---恢复内容开始---

1.常用的命令:

reset  清屏

leave +hhmm  建立离开提醒

sudo apt-get yum  安装yum程序

sudo su  切换root身份

see test.c  可以直接查看文件,神奇

fmt  file.txt  格式化文件

zip distination.zip source  压缩文件

zip -r distination.zip source_fold  压缩文件夹

mkdir  创建文件夹

touch  创建文件

gzip source_file  压缩为.gz格式,会删除源文件

gzip -c source_file  不会删除源文件

gunzip  解压

cd  回家

bzip2 -k source_file  压缩为.bz2格式并保留源文件

tar -zvf distination_filename.tar source_filename 压缩为tar格式,-z压缩,-v显示过程,-f指定打包文件名

tar -xvf source_filename.tar  解压

当命令为-zxvf  解压tar.gz格式的文件

-jxvf -C source_fold 解压tar.bz2格式的文件,到其他目录

runlevel  查看系统当前运行级别

logout  退出登录

w  查看系统信息

---恢复内容结束---

5.Some tips from youtube

pwd  print write direct path

cat textfile.txt  直接查看文本文档

cat text1.txt text2.txt > sdstaff.txt  合并文档

 -----补录(根据记忆)------

alias  查看命令的别名

alias   new_command_name   'source_command_name'  给命令起别名

ctrl+a  ahead 光标回到行首

ctrl+e  end 光标回到行尾

ctrl+c  cancel 强制取消当前执行的命令

ctrl+l  reset清屏

--编写shell指令--

1.直接输出:

echo "this is a Linux command!"

echo -e "e[1;32mThis is a e[1;36mLinuxe[0m commande[0m";  可以解析转意字符(这个命令有颜色)

2.编写shell脚本:

vim hello_world.sh  使用vim建立shell脚本

还可以使用: vm hello_world.sh  touch hello_world.sh

#!bash/powershell
#this is an annotation
echo 'this is a linux shell command!';

3.执行:

bash hello_world.sh  强制执行

chmod 755 hello_world.sh  ./hello_world.sh  先修改权限,再执行

4.缓存:

echo -PATH  输出系统的环境变量

原文地址:https://www.cnblogs.com/hujun1992/p/linux-4.html