首页 技术 正文
技术 2022年11月13日
0 收藏 781 点赞 4,119 浏览 5890 个字

1. pwd – 打印当前工作目录

[root@VM_0_171_centos ~]# pwd
/root

2. cd – Change the shell working directory.

[root@VM_0_171_centos ~]# cd /usr/local[root@VM_0_171_centos local]# cd .[root@VM_0_171_centos local]# cd ..[root@VM_0_171_centos usr]# cd -/usr/local[root@VM_0_171_centos local]# cd[root@VM_0_171_centos ~]#

3. ls – list directory contents

SYNOPSIS

ls [OPTION]... [FILE]...

OPTIONS

-a, --all    do not ignore entries starting with .-A, --almost-all    do not list implied . and ..-d, --directory    list directories themselves, not their contents-G, --no-group   in a long listing, don't print group names-h, --human-readable     with -l, print sizes in human readable format (e.g., 1K 234M 2G)-i, --inode    print the index number of each file--sort=WORDsort by WORD instead of name: none (-U), size (-S), time (-t), version (-v),extension (-X)-l    use a long listing format-m    fill width with a comma separated list of entries-r, --reverse    reverse order while sorting

EXAMPLES

[root@VM_0_171_centos ~]# ls -l /etc/yum.repos.d/
总用量 8
-rw-r--r-- 1 root root 1410 3月 16 20:18 CentOS-Base.repo
-rw-r--r-- 1 root root 220 3月 16 20:18 CentOS-Epel.repo
[root@VM_0_171_centos ~]# ls -la /etc/yum.repos.d/
总用量 16
drwxr-xr-x. 2 root root 4096 3月 16 20:18 .
drwxr-xr-x. 90 root root 4096 4月 4 23:32 ..
-rw-r--r-- 1 root root 1410 3月 16 20:18 CentOS-Base.repo
-rw-r--r-- 1 root root 220 3月 16 20:18 CentOS-Epel.repo
[root@VM_0_171_centos ~]# ls -lr /etc/yum.repos.d/
总用量 8
-rw-r--r-- 1 root root 220 3月 16 20:18 CentOS-Epel.repo
-rw-r--r-- 1 root root 1410 3月 16 20:18 CentOS-Base.repo
[root@VM_0_171_centos ~]# ls -i /etc/yum.repos.d/
458776 CentOS-Base.repo 458777 CentOS-Epel.repo
[root@VM_0_171_centos ~]#

4. stat – display file or file system status

5. touch – change file timestamps

SYNOPSIS

touch [OPTION]... FILE...

特殊用法:不加选项时,则创建文件

OPTIONS

-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(如果加了时间字符串则不使用当前时间)-h, --no-dereference    只作用于软链接而非链接文件-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(如果加了时间戳则不使用当前时间)

EXAMPLES

6. mkdir – make directories

SYNOPSIS

mkdir [OPTION]... DIRECTORY...

OPTIONS

-m, --mode=MODE    set file mode (as in chmod), not a=rwx - umask-p, --parents     no error if existing, make parent directories as needed-v, --verbose    print a message for each created directory-Z    set SELinux security context of each created directory to the default type

EXAMPLES

7. mv – move (rename) files

移动文件或者重命名文件(在同一目录下移动即重命名)

  • 1.mv 文件 文件|目录

  • 2.mv 多个文件 目录(移动到目标目录下)

  • 3.mv 目录 目录(移动到目标目录下)

SYNOPSIS

mv [OPTION]... [-T] SOURCE DESTmv [OPTION]... SOURCE... DIRECTORYmv [OPTION]... -t DIRECTORY SOURCE...

OPTIONS

-f, --force    do not prompt before overwriting-i, --interactive    prompt before overwrite-n, --no-clobber    do not overwrite an existing fileIf you specify more than one of -i, -f, -n, only the final one takes effect.--strip-trailing-slashes  remove any trailing slashes from each SOURCE argument-S, --suffix=SUFFIX    override the usual backup suffix-t, --target-directory=DIRECTORY  move all SOURCE arguments into DIRECTORY-T, --no-target-directory    treat DEST as a normal file-v, --verbose  explain what is being done-Z, --context  set SELinux security context of destination file to default type

EXAMPLES

当前目录下有2个字目录mydir1,mydir2,mydir1中有a,b,c三个文件,mydir2中有d,e,f三个文件:

1.将mydir1/a移动至mydir2,文件名改为aa

2.将mydir2/aa移动至mydir1

3.将mydir1下的所有文件移动至mydir2

4.将mydir2及其下的所有文件移动至mydir1

[root@VM_0_171_centos ~]# tree
.
├── anaconda-ks.cfg
├── mydir1
│ ├── a
│ ├── b
│ └── c
└── mydir2
├── d
├── e
└── f
2 directories, 7 files
[root@VM_0_171_centos ~]# mv mydir1/a mydir2/aa
[root@VM_0_171_centos ~]# tree
.
├── anaconda-ks.cfg
├── mydir1
│ ├── b
│ └── c
└── mydir2
├── aa
├── d
├── e
└── f
2 directories, 7 files
[root@VM_0_171_centos ~]# mv mydir2/aa mydir1
[root@VM_0_171_centos ~]# tree
.
├── anaconda-ks.cfg
├── mydir1
│ ├── aa
│ ├── b
│ └── c
└── mydir2
├── d
├── e
└── f
2 directories, 7 files
[root@VM_0_171_centos ~]# mv mydir1/* mydir2
[root@VM_0_171_centos ~]# tree
.
├── anaconda-ks.cfg
├── mydir1
└── mydir2
├── aa
├── b
├── c
├── d
├── e
└── f
2 directories, 7 files
[root@VM_0_171_centos ~]# mv mydir2 mydir1
[root@VM_0_171_centos ~]# tree
.
├── anaconda-ks.cfg
└── mydir1
└── mydir2
├── aa
├── b
├── c
├── d
├── e
└── f
2 directories, 7 files
[root@VM_0_171_centos ~]#

8. cp – copy files and directories

SYNOPSIS

cp [OPTION]... [-T] SOURCE DESTcp [OPTION]... SOURCE... DIRECTORYcp [OPTION]... -t DIRECTORY SOURCE...

OPTIONS

-a, --archive    same as -dR --preserve=all--copy-contents    copy contents of special files when recursive-d    same as --no-dereference --preserve=links-f, --force    if an existing destination file cannot be opened, remove it and try again (this option is ignored when the -n option is also used)-i, --interactive    prompt before overwrite (overrides a previous -n option)-H    follow command-line symbolic links in SOURCE-l, --link    hard link files instead of copying-L, --dereference    always follow symbolic links in SOURCE-n, --no-clobber    do not overwrite an existing file (overrides a previous -i option)-P, --no-dereference    never follow symbolic links in SOURCE-p    same as --preserve=mode,ownership,timestamps-c    deprecated, same as --preserve=context--no-preserve=ATTR_LIST    don't preserve the specified attributes--parents    use full source file name under DIRECTORY-R, -r, --recursive    copy directories recursively--sparse=WHEN     control creation of sparse files. See below--strip-trailing-slashes    remove any trailing slashes from each SOURCE argument-s, --symbolic-link    make symbolic links instead of copying-S, --suffix=SUFFIX    override the usual backup suffix-t, --target-directory=DIRECTORY  copy all SOURCE arguments into DIRECTORY-T, --no-target-directory     treat DEST as a normal file-u, --updatecopy only when the SOURCE file is newer than the destination file or when the destination file is missing-v, --verbose    explain what is being done-x, --one-file-system    stay on this file system-Z    set SELinux security context of destination file to default type

EXAMPLES

用法与mv类似

9. rm – remove files or directories

删除文件或目录

SYNOPSIS

rm [OPTION]... FILE...

OPTIONS

-f, --force    ignore nonexistent files and arguments, never prompt-i    prompt before every removal-I    prompt once before removing more than three files, or  when  removing  recursively;  less  intrusive  than -i, while still giving protection against most mistakes-r, -R, --recursive     remove directories and their contents recursively(递归)

EXAMPLES

rm -rf 文件或目录(习惯用法)

10. file – determine file type

识别文件类型,辨别文件编码格式。

它通过查看文件的头部信息获取文件类型,而不是像windows通过扩展名来确定文件类型,linux中文件名的后缀只是辅助识别文件类型(规范),并不能真正决定文件的类型。

EXAMPLES

[root@VM_0_171_centos ~]# file anaconda-ks.cfg
anaconda-ks.cfg: ASCII text
相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:9,114
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,586
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,432
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,203
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:7,838
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:4,923