linux 基本操作

linux的基本操

   前言:linux的基本操作是为了在linux系统中能够进行位置跳转,显示文件,显示当前路径,新建文件及文件夹

 

在linux中使用者必须要会的一定要有   man  (源词manual)这个命令,它是一个帮助手册,用来介绍命令的使用方法。

其他的还有--help、 info 、 man1、 man5  等。一般使用man。


[root@localhost 桌面]#    在这里面 [ ]  是分隔符,root是当前的登陆用户,@分隔符,localhost是主机名 ,桌面 是当前所在的位置,# 说明当前用户是管理员(普通用户是$)

 [root@localhost 桌面]# cd /                    无论在哪,cd  /    命令都会将你送到根目录下。cd 就是目录转换,后接路径回车就直接进入
[root@localhost /]# ls                              ls   (源词list)显示、列出当前目录(文件夹)下的文件
bin  boot  dev  etc  home  lib  lost+found  media  mirror  misc  mnt  net  oo  opt  proc  redhat  root  sbin  selinux  srv  sys  tmp  usr  var
[root@localhost /]# ls -l                  —l    是列出详细信息,如时间 权限 大小 等
总用量 108
dr-xr-xr-x.   2 root root  4096 1月  28 21:20 bin
drwxr-xr-x. 116 root root 12288 3月  21 07:54 etc
。。。。。。。。
drwxr-xr-x.  12 root root  4096 12月  9 21:27 usr
drwxr-xr-x.  23 root root  4096 12月 11 18:33 var
[root@localhost /]# ls -a      -a 列出所有的文件,包括隐藏文件,当前 "  . "    上一目录“ ..” 
.   .autofsck  boot   dev  home  lost+found  mirror  mnt  oo   proc    .pulse-cookie       redhat  sbin     srv  tmp  var
..  bin        .dbus  etc  lib   media       misc    net  opt  .pulse  .readahead_collect  root    selinux  sys  usr
[root@localhost /]# ls -la         后接选项可以多个同时使用,显示的后接选项的综合效果
总用量 128
dr-xr-xr-x.  28 root root  4096 3月  20 18:53 .
-rw-r--r--.   1 root root     0 3月  18 16:27 .autofsck
。。。。。。
drwxrwxrwt.  21 root root  4096 3月  21 07:55 tmp
drwxr-xr-x.  23 root root  4096 12月 11 18:33 var
[root@localhost /]# ls -i      -i 是显示inode信息,是文件数据磁盘保存的位置,以后会学到。
 131073 bin   1835009 etc        11 lost+found    13710 misc  2883586 oo       1856 redhat        1 selinux  2359297 tmp
      2 boot        2 home  1703937 media       2621441 mnt   2752513 opt   1441793 root     655361 srv       524289 usr
      4 dev   2490369 lib    262146 mirror        13714 net         1 proc  1966081 sbin          1 sys      3014657 var
[root@localhost /]# ls -li   一般文件不是很多时,接 -l  的显示更加直观,根据个人爱好
总用量 108
 131073 dr-xr-xr-x.   2 root root  4096 1月  28 21:20 binetc
      2 drwxr-xr-x.   7 root root  4096 2月  25 20:02 home
2490369 dr-xr-xr-x.  18 root root 12288 12月 11 13:18 lib
。。。。。。
 655361 drwxr-xr-x.   2 root root  4096 6月  28 2011 srv
3014657 drwxr-xr-x.  23 root root  4096 12月 11 18:33 var
[root@localhost /]# pwd              显示当前路径,就是所在的位置,在哪个文件目录(文件夹)中
/
[root@localhost /]# cd etc
[root@localhost etc]# ls
       etc下是配置文件,每个软件(rpm)安装后一般都有至少1个配置文件
abrt                   cron.hourly              gai.conf          jvm             motd                          polkit-1          resolv.conf    statetab.d
aliases                cron.weekly              gdm               kdump-adv-conf  my.cnf                        postfix           rpm            sudo-ldap.conf
。。。。。。。
ConsoleKit             fonts                    iproute2          maven           plymouth                      redhat-lsb        ssh            yum.conf
[root@localhost etc]# cd passwd
bash: cd: passwd: 不是目录                     cd切换必须在目录间转换,passwd是普通文件不是目录
[root@localhost etc]# cd httpd/      当前目录下有某个目录,可以直接接目录名Enter就可以进入   如下 
[root@localhost httpd]# pwd
/etc/httpd                
[root@localhost httpd]# cd /
[root@localhost /]# cd /etc/httpd
         如过接绝对路径,无论当前在哪都会直接进入目标目录。
[root@localhost httpd]# pwd
/etc/http
[root@localhost httpd]# cd /
[root@localhost /]# ls

bin  boot  dev  etc  home  lib  lost+found  media  mirror  misc  mnt  net  oo  opt  proc  redhat  root  sbin  selinux  srv  sys  tmp  usr  var
[root@localhost /]# mkdir test1             新建目录命令mkdir(make directories)
[root@localhost /]# ls
bin  boot  dev  etc  home  lib  lost+found  media  mirror  misc  mnt  net  oo  opt  proc  redhat  root  sbin  selinux  srv  sys  test1  tmp  usr  var
[root@localhost /]# ll
总用量 112
dr-xr-xr-x.   2 root root  4096 1月  28 21:20 bin
dr-xr-xr-x.   5 root root  1024 12月  9 22:07 boot
drwxr-xr-x.  19 root root  4100 3月  18 16:27 dev
。。。。。。
drwxrwxrwt.  21 root root  4096 3月  21 07:55 tmp
drwxr-xr-x.  12 root root  4096 12月  9 21:27 usr
drwxr-xr-x.  23 root root  4096 12月 11 18:33 var
[root@localhost /]# cd test1/
[root@localhost test1]# pwd
/test1
[root@localhost test1]# mkdir test12 test13 test13   同时建立多个目录
mkdir: 无法创建目录"test13": 文件已存在     如果文件已经存在就不能再次创建
[root@localhost test1]# ls
test12  test13
[root@localhost test1]# mkdir test12/test21/test31/test41
mkdir: 无法创建目录"test12/test21/test31/test41": 没有那个文件或目录       在建立test41时,没有test21 ,test31 ;就不能建立 但。。。
[root@localhost test1]# mkdir test12/test21/test31/test41 -p        后接-p就会:如果没有上一级目录就会自动建立
[root@localhost test1]# cd test12/test21/test31/test41/
[root@localhost test41]# pwd
/test1/test12/test21/test31/test41
[root@localhost test41]# touch a      touch是建立一个普通文件件的命令。普通文件可以没有后缀名,也可以为任意后缀名。如
[root@localhost test41]# ls
a
[root@localhost test41]# touch a.txt
[root@localhost test41]# touch a.sh a.pl  .b.txt
[root@localhost test41]# ls

a  a.pl  a.sh  a.txt
[root@localhost test41]# ll
总用量 0
-rw-r--r--. 1 root root 0 3月  21 08:00 a
-rw-r--r--. 1 root root 0 3月  21 08:01 a.pl
-rw-r--r--. 1 root root 0 3月  21 08:01 a.sh
-rw-r--r--. 1 root root 0 3月  21 08:00 a.txt
[root@localhost test41]# ls -a
.  ..  a  a.pl  a.sh  a.txt  .b.txt

 

总结:

    ls    cd    pwd     mkdir    touch      是linux中的操作的最基本的命令,详细信息可以man(minual)一下。如:

 

[root@localhost test41]# man mkdir

MKDIR(1)                         User Commands                        MKDIR(1)

NAME
       mkdir - make directories

SYNOPSIS
       mkdir [OPTION]... DIRECTORY...

DESCRIPTION
       Create the DIRECTORY(ies), if they do not already exist.

       Mandatory arguments to long options are mandatory for short options too.

       -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, --context=CTX
              set the SELinux security context of each created directory to CTX

       --help display this help and exit

       --version
              output version information and exit

AUTHOR
       Written by David MacKenzie.

 

REPORTING BUGS
       Report mkdir bugs to bug-coreutils@gnu.org
       GNU coreutils home page: <http://www.gnu.org/software/coreutils/>
       General help using GNU software: <http://www.gnu.org/gethelp/>
       Report mkdir translation bugs to <http://translationproject.org/team/>

COPYRIGHT
       Copyright © 2010 Free Software Foundation, Inc.  License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.
       This is free software: you are free to change and redistribute it.  There is NO WARRANTY, to the extent permitted by law.

SEE ALSO
       mkdir(2)

       The  full  documentation  for  mkdir is maintained as a Texinfo manual.  If the info and mkdir programs are properly installed at your site, the
       command

              info coreutils 'mkdir invocation'

       should give you access to the complete manual.

GNU coreutils 8.4                 April 2012                          MKDIR(1)
(END)

看完之后按"q"就会自动退出帮助文件,所有的命令都可以man。除此还有man 1.    men 5      info      --help   都可以查看帮助文件 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值