linux基本命令

1.linux命令

    命令    参数      目标

ls          -s                test

ls             --size        test

注意:1.参数用来指定命令的默写功能,可以加也可以不加
2.命令和参数目标之间要用空格隔开
3.参数中”-”表示单词的缩写,“--”表示单词的全拼
4.在执行命令时遵循的这些规则,特殊情况除外
5.命令必须在提示符之后输入,没有提示符的输入是无效的

       6.使用参数时 -a -b -c=-abc=-bac=-cab

2.文件建立
key 1: touch filename(创建多个文件 touch file{1..10})
touch:(修改文件的时间戳)
功能:
1.用于把已存在文件时间标签更新为系统当前时间(默认方式),他们的数据将原封不动的保留下来
2.创建新的空文件
linux基本命令
命令参数:

-a change only the access time
-c, --no-create do not create any files
-d, --date=STRING parse STRING and use it instead of current time
-f (ignored)
-h, --no-dereference affect each symbolic link instead of any referenced
file (useful only on systems that can change the
timestamps of a symlink)
-m change only the modification time
-r, --reference=FILE use this file's times instead of current time
-t STAMP use [[CC]YY]MMDDhhmm[.ss] instead of current time
--time=WORD change the specified time:
WORD is access, atime, or use: equivalent to -a
WORD is modify or mtime: equivalent to -m
--help display this help and exit
--version output version information and exit

常用三个参数: atime:文件内容被访问的时间标示
mtime:文件内容被修改的时间
ctime:文件属性或者文件内容被修改的时间的表示
注:用stat 文件名可以查看文件的状态(有三个转态access modefy(对文件的内容进行修改) change(可以对文件的内容和权限进行修改))
用命令gnome -t 时间 文件名 可以对文件的时间进行修改

touch常用命令(在时间上):

touch -t 时间(年月日时分) 文件名

touch -r 目标文件 源文件

key 2: gedit(只能在图形界面)gedit file ##必须有图形

key3:vim(在图形界面和文本界面都可以)vim file -->按[i]进入insert模式-->书写内容-->按[esc]退出insert模式-->:wq退出保存

批注:vim异常退出:(vim异常退出时会出现.file.swp文件)

   file name: ~kiosk/Desktop/hello
      modified: YES
     user name: kiosk   host name: foundation0.ilt.example.com
    process ID: 31820
If this already, delete the swap file ".hello.swp" <<<此文件中存放大是未保存的数据

Swap file ".hello.swp" already exists!
[O]pen Read-Only, (E)dit anyway, (R)ecover, (D)elete it, (Q)uit, (A)bort:
只读打开 继续编辑 恢复数据 删除swap文件 退出 退出

注:无论按[O] (E) (R) (Q) (A) 任何一个都不会删除.swp文件
那么再次打开hello文件是还会出现以上界面直到按(D),.swp文件被删除

解决办法:1.重新进入,输入R

       2.esc  -->:wq退出文件

       3 在此进入 D删除 q退出,在此进入
                 (备注:如果不行可以利用ls -a命令查看所有文件,删除未保存文件的.swp隐藏文件即可)

3目录建立
1.mkdir directory
2.mkdir -p dir1/dir2/dir3 (-p建立递归目录时,当上层目录不存在自动建立,必须通过-p进行操作)
linux基本命令
4文件、目录删除
1.文件:rm file
rm -f file -f表示--force(表示强制删除)
2.目录:rm -r directory -r 表示递归删除(类似于-p),也就是删除目录本身和里面内容
rm -r -f dir 删除目录不提示 == rm -rf dir ==rm -fr dir
linux基本命令
5文件复制(注意文件到文件 还是目录到目录的使用 注意Mv命令时如果换了磁盘会发生Id位置的变化)

cp
源文件 目的地文件

cp -r
源文目录 目的地目录
cp
源文件1 源文件2 目的地目录
cp -r
源目录1 源目录2
目的地目录

6文件移动

mv 源文件 目的地文件
mv 源目录
目的地目录
mv dir/* .

注:相同磁盘的文件移动只是一个重明名过程
不同磁盘的文件移动是复制删除过程

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章