系统相关
首页 > 系统相关> > linux 常用命令

linux 常用命令

作者:互联网

文件与目录

ls

选项与参数

[root@VM-20-7-centos var]# ls
adm                cache  db     games   kerberos  local  log   nis  preserve  spool  yp
bt_setupPath.conf  crash  empty  gopher  lib       lock   mail  opt  run       tmp
[root@VM-20-7-centos var]# ls -a
.   adm                cache  db     games   kerberos  local  log   nis  preserve  spool  .updated
..  bt_setupPath.conf  crash  empty  gopher  lib       lock   mail  opt  run       tmp    yp
[root@VM-20-7-centos var]# ls -d
.
[root@VM-20-7-centos var]# ls -l
total 72
drwxr-xr-x.  2 root root 4096 Apr 11  2018 adm
-rw-r--r--   1 root root    4 Feb 19 18:59 bt_setupPath.conf
drwxr-xr-x.  6 root root 4096 Jan 14 11:23 cache
drwxr-xr-x.  2 root root 4096 Jun 10  2021 crash
drwxr-xr-x.  3 root root 4096 Nov 23 20:10 db
drwxr-xr-x.  3 root root 4096 Mar  7  2019 empty
drwxr-xr-x.  2 root root 4096 Apr 11  2018 games
drwxr-xr-x.  2 root root 4096 Apr 11  2018 gopher
drwxr-xr-x.  3 root root 4096 Dec  2 23:32 kerberos
drwxr-xr-x. 28 root root 4096 Jan 14 11:24 lib
drwxr-xr-x.  2 root root 4096 Apr 11  2018 local
lrwxrwxrwx.  1 root root   11 Mar  7  2019 lock -> ../run/lock
drwxr-xr-x. 10 root root 4096 Feb 20 03:15 log
lrwxrwxrwx.  1 root root   10 Mar  7  2019 mail -> spool/mail
drwxr-xr-x.  2 root root 4096 Apr 11  2018 nis
drwxr-xr-x.  2 root root 4096 Apr 11  2018 opt
drwxr-xr-x.  2 root root 4096 Apr 11  2018 preserve
lrwxrwxrwx.  1 root root    6 Mar  7  2019 run -> ../run
drwxr-xr-x. 11 root root 4096 Mar  7  2019 spool
drwxrwxrwt.  5 root root 4096 Feb 19 18:59 tmp
drwxr-xr-x.  2 root root 4096 Apr 11  2018 yp
[root@VM-20-7-centos var]# ls -al
total 84
drwxr-xr-x. 19 root root 4096 Jan 14 11:27 .
dr-xr-xr-x. 20 root root 4096 Feb 22 21:52 ..
drwxr-xr-x.  2 root root 4096 Apr 11  2018 adm
-rw-r--r--   1 root root    4 Feb 19 18:59 bt_setupPath.conf
drwxr-xr-x.  6 root root 4096 Jan 14 11:23 cache
drwxr-xr-x.  2 root root 4096 Jun 10  2021 crash
drwxr-xr-x.  3 root root 4096 Nov 23 20:10 db
drwxr-xr-x.  3 root root 4096 Mar  7  2019 empty
drwxr-xr-x.  2 root root 4096 Apr 11  2018 games
drwxr-xr-x.  2 root root 4096 Apr 11  2018 gopher
drwxr-xr-x.  3 root root 4096 Dec  2 23:32 kerberos
drwxr-xr-x. 28 root root 4096 Jan 14 11:24 lib
drwxr-xr-x.  2 root root 4096 Apr 11  2018 local
lrwxrwxrwx.  1 root root   11 Mar  7  2019 lock -> ../run/lock
drwxr-xr-x. 10 root root 4096 Feb 20 03:15 log
lrwxrwxrwx.  1 root root   10 Mar  7  2019 mail -> spool/mail
drwxr-xr-x.  2 root root 4096 Apr 11  2018 nis
drwxr-xr-x.  2 root root 4096 Apr 11  2018 opt
drwxr-xr-x.  2 root root 4096 Apr 11  2018 preserve
lrwxrwxrwx.  1 root root    6 Mar  7  2019 run -> ../run
drwxr-xr-x. 11 root root 4096 Mar  7  2019 spool
drwxrwxrwt.  5 root root 4096 Feb 19 18:59 tmp
-rw-r--r--   1 root root  163 Mar  7  2019 .updated
drwxr-xr-x.  2 root root 4096 Apr 11  2018 yp

cd [相对路径或绝对路径]

[root@VM-20-7-centos var]# ls
adm                cache  db     games   kerberos  local  log   nis  preserve  spool  yp
bt_setupPath.conf  crash  empty  gopher  lib       lock   mail  opt  run       tmp
[root@VM-20-7-centos var]# cd log
[root@VM-20-7-centos log]# cd ./var/lib
-bash: cd: ./var/lib: No such file or directory
[root@VM-20-7-centos log]# cd /var/lib
[root@VM-20-7-centos lib]# 

**pwd **

选项与参数:

[root@VM-20-7-centos lib]# pwd
/var/lib

mkdir

选项与参数

[root@VM-20-7-centos home]# mkdir foo
[root@VM-20-7-centos home]# ls
foo  lighthouse  www
[root@VM-20-7-centos home]# mkdir foo
mkdir: cannot create directory ‘foo’: File exists
[root@VM-20-7-centos home]# mkdir foo/fooo
[root@VM-20-7-centos home]# mkdir foo/fooo/foooo/fooooo
mkdir: cannot create directory ‘foo/fooo/foooo/fooooo’: No such file or directory
[root@VM-20-7-centos home]# mkdir -p foo/fooo/foooo/fooooo
[root@VM-20-7-centos home]# mkdir defaultAuthFolder
[root@VM-20-7-centos home]# mkdir -m 711  CustomAuthFolder
[root@VM-20-7-centos home]# ls -l
total 20
drwx--x--x 2 root       root       4096 Feb 22 22:12 CustomAuthFolder
drwxr-xr-x 2 root       root       4096 Feb 22 22:11 defaultAuthFolder
drwxr-xr-x 3 root       root       4096 Feb 22 22:06 foo
drwx------ 5 lighthouse lighthouse 4096 Feb 15 19:40 lighthouse
drwxr-xr-x 2 root       root       4096 Jan 14 11:27 www


rmdir

选项与参数:

[root@VM-20-7-centos home]# rmdir foo
rmdir: failed to remove ‘foo’: Directory not empty
[root@VM-20-7-centos home]# rmdir -p foo/fooo
rmdir: failed to remove ‘foo/fooo’: Directory not empty
[root@VM-20-7-centos home]# rmdir -p foo/fooo/foooo/fooooo
[root@VM-20-7-centos home]# ls
CustomAuthFolder  defaultAuthFolder  lighthouse  www
[root@VM-20-7-centos home]# mkdir CustomAuthFolder/test
[root@VM-20-7-centos home]# cd CustomAuthFolder/test ls
[root@VM-20-7-centos test]# mkdir helloworld
[root@VM-20-7-centos test]# cd /home/ CustomAuthFolder/test ls
[root@VM-20-7-centos home]# cd /home/CustomAuthFolder/test ls
[root@VM-20-7-centos test]# ls
helloworld
[root@VM-20-7-centos test]# cd ..
[root@VM-20-7-centos CustomAuthFolder]# ls
test
[root@VM-20-7-centos CustomAuthFolder]# rmdir test/
rmdir: failed to remove ‘test/’: Directory not empty
[root@VM-20-7-centos CustomAuthFolder]# rmdir -p test/
rmdir: failed to remove ‘test/’: Directory not empty
[root@VM-20-7-centos CustomAuthFolder]# rmdir -f test/
rmdir: invalid option -- 'f'
Try 'rmdir --help' for more information.
[root@VM-20-7-centos CustomAuthFolder]# rmdir test/helloworld
[root@VM-20-7-centos CustomAuthFolder]# ls
test


标签:20,4096,centos,常用命令,VM,linux,xr,root
来源: https://www.cnblogs.com/weichangk/p/15925281.html