linux 基础命令 应用基础与实训

linux 第一课 联系


linux 基础命令


Xshell 5 (Build 0964)
Copyright (c) 2002-2016 NetSarang Computer, Inc. All rights reserved.


Type `help' to learn how to use Xshell prompt.
[c:\~]$ 


Connecting to 192.168.15.150:22...
Connection established.
To escape to local shell, press 'Ctrl+Alt+]'.


Last login: Wed Jul 27 06:47:24 2016 from 192.168.15.1
[root@million ~]# ls
install.log  install.log.syslog  test
[root@million ~]# pwd
/root
[root@million ~]# who

root     pts/0        2016-07-27 07:09 (192.168.15.1)
[root@million ~]# bash
[root@million ~]# bash
[root@million ~]# su
[root@million ~]# su -
[root@million ~]# basename
basename: 缺少操作数
请尝试执行"basename --help"来获取更多信息。
[root@million ~]# host

-bash: host: command not found
[root@million ~]# host
-bash: host: command not found
[root@million ~]# hostname
million
[root@million ~]# whoami

root
[root@million ~]# ls -al

总用量 64
dr-xr-x---.  4 root root  4096 6月   3 19:38 .
dr-xr-xr-x. 25 root root  4096 7月  27 07:01 ..
-rw-------.  1 root root  8345 7月  27 06:49 .bash_history
-rw-r--r--.  1 root root    18 5月  20 2009 .bash_logout
-rw-r--r--.  1 root root   176 5月  20 2009 .bash_profile
-rw-r--r--.  1 root root   176 9月  23 2004 .bashrc
-rw-r--r--.  1 root root   100 9月  23 2004 .cshrc
-rw-r--r--.  1 root root 12208 5月  31 19:35 install.log
-rw-r--r--.  1 root root  3827 5月  31 19:35 install.log.syslog
drwxr-----.  3 root root  4096 6月   1 22:39 .pki
-rw-r--r--.  1 root root   129 12月  4 2004 .tcshrc
drwxr-xr-x.  3 root root  4096 6月   3 19:38 test
[root@million ~]# who

root     pts/0        2016-07-27 07:09 (192.168.15.1)
[root@million ~]# who H
[root@million ~]# who h
[root@million ~]# who -h
who:无效选项 -- h
请尝试执行"who --help"来获取更多信息。
[root@million ~]# who -H
名称   线路       时间           备注
root     pts/0        2016-07-27 07:09 (192.168.15.1)
[root@million ~]# who -i

who:无效选项 -- i
请尝试执行"who --help"来获取更多信息。
[root@million ~]# who -u
root     pts/0        2016-07-27 07:09   .          1181 (192.168.15.1)
[root@million ~]# who -Hu
名称   线路       时间           空闲  进程号 备注
root     pts/0        2016-07-27 07:09   .          1181 (192.168.15.1)
[root@million ~]# who -Hu
名称   线路       时间           空闲  进程号 备注
root     pts/0        2016-07-27 07:09   .          1181 (192.168.15.1)
[root@million ~]# who -Huq
root
# 用户数=1
[root@million ~]# who -q
root
# 用户数=1
[root@million ~]# who -w
root     + pts/0        2016-07-27 07:09 (192.168.15.1)
[root@million ~]# who -Hw
名称     线路       时间           备注
root     + pts/0        2016-07-27 07:09 (192.168.15.1)
[root@million ~]# whoami
root
[root@million ~]# su test

[test@million root]$ whoami
test
[test@million root]$ su -
密码:
su: 密码不正确
[test@million root]$ su
密码:
su: 密码不正确
[test@million root]$ su -
密码:
[root@million ~]# exit

logout
[test@million root]$ who
root     pts/0        2016-07-27 07:09 (192.168.15.1)
[test@million root]$ whoami
test
[test@million root]$ su
密码:
[root@million ~]# who
root     pts/0        2016-07-27 07:09 (192.168.15.1)
[root@million ~]# whoami
root
[root@million ~]# exit
exit
[test@million root]$ who
root     pts/0        2016-07-27 07:09 (192.168.15.1)
[test@million root]$ whoami
test
[test@million root]$ exit
exit
[root@million ~]# whoami
root
[root@million ~]# wo】
-bash: wo】: command not found
[root@million ~]# who
root     pts/0        2016-07-27 07:09 (192.168.15.1)
[root@million ~]# date
2016年 07月 27日 星期三 07:26:09 CST
[root@million ~]# date +%T%n%D
07:26:22
07/27/16
[root@million ~]# date
2016年 07月 27日 星期三 07:26:35 CST
[root@million ~]# date +%B%D
七月07/27/16
[root@million ~]# date +%B%d
七月27
[root@million ~]# date --date 23:33:30
2016年 07月 27日 星期三 23:33:30 CST
[root@million ~]# date
2016年 07月 27日 星期三 07:27:59 CST
[root@million ~]# date
2016年 07月 27日 星期三 07:28:43 CST
[root@million ~]# date --date 11:23:23
2016年 07月 27日 星期三 11:23:23 CST
[root@million ~]# date
2016年 07月 27日 星期三 07:29:06 CST
[root@million ~]# date -s 23:37:30
2016年 07月 27日 星期三 23:37:30 CST
[root@million ~]# CLOCK -W
-bash: CLOCK: command not found
[root@million ~]# clock -w
[root@million ~]# date
2016年 07月 27日 星期三 23:37:47 CST
[root@million ~]# date
2016年 07月 27日 星期三 23:37:52 CST
[root@million ~]# date -s 23:37:50
2016年 07月 27日 星期三 23:37:50 CST
[root@million ~]# date
2016年 07月 27日 星期三 23:37:53 CST
[root@million ~]# date
2016年 07月 27日 星期三 23:37:58 CST
[root@million ~]# cd 。。、
-bash: cd: 。。、: 没有那个文件或目录
[root@million ~]# 成都
-bash: 成都: command not found
[root@million ~]# d
-bash: d: command not found
[root@million ~]# cd /
[root@million /]# cd usr/
[root@million usr]# ls
bin  etc  games  include  lib  libexec  local  sbin  share  src  tmp
[root@million usr]# cd s
sbin/  share/ src/   
[root@million usr]# cd share/
[root@million share]# ls
aclocal       automake-1.11  dbus-1               firstboot   gettext                      grub         info          lua        perl5      sgml                    themes       zoneinfo
aclocal-1.11  avahi          desktop-directories  fontconfig  ghostscript                  gtk-engines  intltool      magic      pixmaps    sounds                  wallpapers
alsa          awk            dict                 fonts       git-core                     hwdata       java          man        pkgconfig  swig                    X11
anaconda      backgrounds    doc                  games       gnome                        i18n         kde4          mime       plymouth   system-config-firewall  xemacs
applications  bison          dracut               GConf       gnome-2.0                    ibus         kde-settings  mime-info  polkit-1   systemtap               xml
augeas        cracklib       emacs                gcr         gnome-background-properties  ibus-table   libthai       misc       pygtk      tabset                  xsessions
authconfig    cscope         empty                gdb         gnupg                        icons        libtool       mysql      selinux    tc                      yum-cli
autoconf      cvs            file                 gdm         groff                        idl          locale        omf        setuptool  terminfo                yum-plugins
[root@million share]# cd zoneinfo/
[root@million zoneinfo]# cd a
-bash: cd: a: 没有那个文件或目录
[root@million zoneinfo]# ls
Africa      Asia       Canada   Cuba   EST      GB       GMT-0      HST      iso3166.tab  Kwajalein  MST      NZ-CHAT   posix       right      Turkey     UTC       Zulu
America     Atlantic   CET      EET    EST5EDT  GB-Eire  GMT+0      Iceland  Israel       Libya      MST7MDT  Pacific   posixrules  ROC        UCT        WET
Antarctica  Australia  Chile    Egypt  Etc      GMT      Greenwich  Indian   Jamaica      MET        Navajo   Poland    PRC         ROK        Universal  W-SU
Arctic      Brazil     CST6CDT  Eire   Europe   GMT0     Hongkong   Iran     Japan        Mexico     NZ       Portugal  PST8PDT     Singapore  US         zone.tab
[root@million zoneinfo]# cd as
-bash: cd: as: 没有那个文件或目录
[root@million zoneinfo]# cd asia
-bash: cd: asia: 没有那个文件或目录
[root@million zoneinfo]# cd asia
-bash: cd: asia: 没有那个文件或目录
[root@million zoneinfo]# cd Asia/
[root@million Asia]# ls
Aden      Ashkhabad  Bishkek     Colombo   Gaza         Istanbul   Kashgar       Kuching   Muscat        Pontianak  Sakhalin       Tashkent  Tomsk          Vladivostok
Almaty    Baghdad    Brunei      Dacca     Harbin       Jakarta    Kathmandu     Kuwait    Nicosia       Pyongyang  Samarkand      Tbilisi   Ujung_Pandang  Yakutsk
Amman     Bahrain    Calcutta    Damascus  Hebron       Jayapura   Katmandu      Macao     Novokuznetsk  Qatar      Seoul          Tehran    Ulaanbaatar    Yekaterinburg
Anadyr    Baku       Chita       Dhaka     Ho_Chi_Minh  Jerusalem  Khandyga      Macau     Novosibirsk   Qyzylorda  Shanghai       Tel_Aviv  Ulan_Bator     Yerevan
Aqtau     Bangkok    Choibalsan  Dili      Hong_Kong    Kabul      Kolkata       Magadan   Omsk          Rangoon    Singapore      Thimbu    Urumqi
Aqtobe    Barnaul    Chongqing   Dubai     Hovd         Kamchatka  Krasnoyarsk   Makassar  Oral          Riyadh     Srednekolymsk  Thimphu   Ust-Nera
Ashgabat  Beirut     Chungking   Dushanbe  Irkutsk      Karachi    Kuala_Lumpur  Manila    Phnom_Penh    Saigon     Taipei         Tokyo     Vientiane
[root@million Asia]# cd Shanghai 
-bash: cd: Shanghai: 不是目录
[root@million Asia]# vim Shanghai 
-bash: vim: command not found
[root@million Asia]# vi Shanghai 
[root@million Asia]# uanme
-bash: uanme: command not found
[root@million Asia]# uame
-bash: uame: command not found
[root@million Asia]# uname
Linux
[root@million Asia]# uae
-bash: uae: command not found
[root@million Asia]# uame
-bash: uame: command not found
[root@million Asia]# uname -a
Linux million 2.6.32-279.el6.i686 #1 SMP Fri Jun 22 10:59:55 UTC 2012 i686 i686 i386 GNU/Linux
[root@million Asia]# unae -
-bash: unae: command not found
[root@million Asia]# uname -r
2.6.32-279.el6.i686
[root@million Asia]# uname -m
i686
[root@million Asia]# cal
      七月 2016     
日 一 二 三 四 五 六
                1  2
 3  4  5  6  7  8  9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
31
[root@million Asia]# cal -l
cal:无效选项 -- l
usage: cal [-13smjyV] [[[day] month] year]
[root@million Asia]# cal -l
cal:无效选项 -- l
usage: cal [-13smjyV] [[[day] month] year]
[root@million Asia]# cal -1
      七月 2016     
日 一 二 三 四 五 六
                1  2
 3  4  5  6  7  8  9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
31
[root@million Asia]# cal -3
      六月 2016             七月 2016             八月 2016     
日 一 二 三 四 五 六  日 一 二 三 四 五 六  日 一 二 三 四 五 六
          1  2  3  4                  1  2      1  2  3  4  5  6
 5  6  7  8  9 10 11   3  4  5  6  7  8  9   7  8  9 10 11 12 13
12 13 14 15 16 17 18  10 11 12 13 14 15 16  14 15 16 17 18 19 20
19 20 21 22 23 24 25  17 18 19 20 21 22 23  21 22 23 24 25 26 27
26 27 28 29 30        24 25 26 27 28 29 30  28 29 30 31         
                      31                                        
[root@million Asia]# cal -2
cal:无效选项 -- 2
usage: cal [-13smjyV] [[[day] month] year]
[root@million Asia]# cal -3
      六月 2016             七月 2016             八月 2016     
日 一 二 三 四 五 六  日 一 二 三 四 五 六  日 一 二 三 四 五 六
          1  2  3  4                  1  2      1  2  3  4  5  6
 5  6  7  8  9 10 11   3  4  5  6  7  8  9   7  8  9 10 11 12 13
12 13 14 15 16 17 18  10 11 12 13 14 15 16  14 15 16 17 18 19 20
19 20 21 22 23 24 25  17 18 19 20 21 22 23  21 22 23 24 25 26 27
26 27 28 29 30        24 25 26 27 28 29 30  28 29 30 31         
                      31                                        
[root@million Asia]# cal -y
                               2016                               


        一月                   二月                   三月        
日 一 二 三 四 五 六   日 一 二 三 四 五 六   日 一 二 三 四 五 六
                1  2       1  2  3  4  5  6          1  2  3  4  5
 3  4  5  6  7  8  9    7  8  9 10 11 12 13    6  7  8  9 10 11 12
10 11 12 13 14 15 16   14 15 16 17 18 19 20   13 14 15 16 17 18 19
17 18 19 20 21 22 23   21 22 23 24 25 26 27   20 21 22 23 24 25 26
24 25 26 27 28 29 30   28 29                  27 28 29 30 31
31
        四月                   五月                   六月        
日 一 二 三 四 五 六   日 一 二 三 四 五 六   日 一 二 三 四 五 六
                1  2    1  2  3  4  5  6  7             1  2  3  4
 3  4  5  6  7  8  9    8  9 10 11 12 13 14    5  6  7  8  9 10 11
10 11 12 13 14 15 16   15 16 17 18 19 20 21   12 13 14 15 16 17 18
17 18 19 20 21 22 23   22 23 24 25 26 27 28   19 20 21 22 23 24 25
24 25 26 27 28 29 30   29 30 31               26 27 28 29 30


        七月                   八月                   九月        
日 一 二 三 四 五 六   日 一 二 三 四 五 六   日 一 二 三 四 五 六
                1  2       1  2  3  4  5  6                1  2  3
 3  4  5  6  7  8  9    7  8  9 10 11 12 13    4  5  6  7  8  9 10
10 11 12 13 14 15 16   14 15 16 17 18 19 20   11 12 13 14 15 16 17
17 18 19 20 21 22 23   21 22 23 24 25 26 27   18 19 20 21 22 23 24
24 25 26 27 28 29 30   28 29 30 31            25 26 27 28 29 30
31
        十月                  十一月                 十二月       
日 一 二 三 四 五 六   日 一 二 三 四 五 六   日 一 二 三 四 五 六
                   1          1  2  3  4  5                1  2  3
 2  3  4  5  6  7  8    6  7  8  9 10 11 12    4  5  6  7  8  9 10
 9 10 11 12 13 14 15   13 14 15 16 17 18 19   11 12 13 14 15 16 17
16 17 18 19 20 21 22   20 21 22 23 24 25 26   18 19 20 21 22 23 24
23 24 25 26 27 28 29   27 28 29 30            25 26 27 28 29 30 31
30 31


[root@million Asia]# cal -s
      七月 2016     
日 一 二 三 四 五 六
                1  2
 3  4  5  6  7  8  9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
31
[root@million Asia]# cal -m
      七月 2016     
一 二 三 四 五 六 日
             1  2  3
 4  5  6  7  8  9 10
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28 29 30 31


[root@million Asia]# cal -j
         七月 2016         
 日  一  二  三  四  五  六
                    183 184
185 186 187 188 189 190 191
192 193 194 195 196 197 198
199 200 201 202 203 204 205
206 207 208 209 210 211 212
213
[root@million Asia]# bc
-bash: bc: command not found
[root@million Asia]# bc -q
-bash: bc: command not found
[root@million Asia]# bc
-bash: bc: command not found
[root@million Asia]# cd /
[root@million /]# ls
bin  boot  dev  etc  ftp  home  lib  lost+found  media  mnt  opt  proc  root  sbin  selinux  soft-setup  software  srv  sys  tmp  usr  var  web
[root@million /]# cc=
[root@million /]# cc
cc: 没有输入文件
[root@million /]# cd root/
[root@million ~]# ls
install.log  install.log.syslog  test
[root@million ~]# bash
[root@million ~]# bc
bash: bc: command not found
[root@million ~]# where is bc
bash: where: command not found
[root@million ~]# whereis bc
bc:
[root@million ~]# whereis ls
ls: /bin/ls /usr/share/man/man1/ls.1.gz
[root@million ~]# whereis cla
cla:
[root@million ~]# whereis cal
cal: /usr/bin/cal /usr/share/man/man1/cal.1.gz
[root@million ~]# whereis bc
bc:
[root@million ~]# yum bc
Loaded plugins: fastestmirror
No such command: bc. Please use /usr/bin/yum --help
[root@million ~]# yum install bc
Loaded plugins: fastestmirror
Determining fastest mirrors
 * base: mirrors.tuna.tsinghua.edu.cn
 * extras: mirrors.btte.net
 * updates: mirrors.btte.net
base                                                                                                                                                                    | 3.7 kB     00:00     
epel                                                                                                                                                                    | 4.3 kB     00:00     
epel/primary_db                                                                                                                                                         | 5.0 MB     00:01     
extras                                                                                                                                                                  | 3.3 kB     00:00     
updates                                                                                                                                                                 | 3.4 kB     00:00     
updates/primary_db                                                                                                                                                      | 1.3 MB     00:00     
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package bc.i686 0:1.06.95-1.el6 will be installed
--> Finished Dependency Resolution


Dependencies Resolved


===============================================================================================================================================================================================
 Package                                   Arch                                        Version                                               Repository                                   Size
===============================================================================================================================================================================================
Installing:
 bc                                        i686                                        1.06.95-1.el6                                         base                                        106 k


Transaction Summary
===============================================================================================================================================================================================
Install       1 Package(s)


Total download size: 106 k
Installed size: 204 k
Is this ok [y/N]: y
Downloading Packages:
bc-1.06.95-1.el6.i686.rpm                                                                                                                                               | 106 kB     00:00     
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing : bc-1.06.95-1.el6.i686                                                                                                                                                       1/1 
  Verifying  : bc-1.06.95-1.el6.i686                                                                                                                                                       1/1 


Installed:
  bc.i686 0:1.06.95-1.el6                                                                                                                                                                      


Complete!
[root@million ~]# bc
bc 1.06.95
Copyright 1991-1994, 1997, 1998, 2000, 2004, 2006 Free Software Foundation, Inc.
This is free software with ABSOLUTELY NO WARRANTY.
For details type `warranty'. 
bc -q
0
11-1
10
11*0
0
11*9
99
11--1
(standard_in) 5: syntax error
11-1
10
11/1
11
11/2
5
1+1+1
3
:quite
(standard_in) 10: illegal character: :
:quit
(standard_in) 11: illegal character: :
[root@million ~]# echo "ibase=16:obase=2:B5-A4" |bc
(standard_in) 1: illegal character: :
(standard_in) 1: syntax error
(standard_in) 1: illegal character: :
(standard_in) 1: syntax error
[root@million ~]# echo "ibase=16;obase=2;B5-A4" |bc
10001
[root@million ~]# wc
^C
[root@million ~]# wc /etc/passwd
  22   32 1015 /etc/passwd
[root@million ~]# wc -c /etc/passwd
1015 /etc/passwd
[root@million ~]# wc -m /etc/passwd
1015 /etc/passwd
[root@million ~]# wc -w /etc/passwd
32 /etc/passwd
[root@million ~]# wc -l /etc/passwd
22 /etc/passwd
[root@million ~]# wc -L /etc/passwd
73 /etc/passwd
[root@million ~]# su - test
[test@million ~]$ pwd
/home/test
[test@million ~]$ who
root     pts/0        2016-07-27 07:09 (192.168.15.1)
[test@million ~]$ whoami
test
[test@million ~]$ hostname
million
[test@million ~]$ hostname whb
hostname: you must be root to change the host name
[test@million ~]$ su
密码:
[root@million test]# hostname whb
[root@million test]# hostname
whb
[root@million test]# echo hello
hello
[root@million test]# echo hello word
hello word
[root@million test]# echo hello -n
hello -n
[root@million test]# echo -n sdlkjjjjjjjjjjjjjjjjjjlkjdslkjds
sdlkjjjjjjjjjjjjjjjjjjlkjdslkjds[root@million test]# echo -n cc
cc[root@million test]# echo cc
cc
[root@million test]# echo -l cc
-l cc
[root@million test]# echo hellow
hellow
[root@million test]# hello wor
bash: hello: command not found
[root@million test]# echo hello 
hello
[root@million test]# echo hello word
hello word
[root@million test]# echo $lang


[root@million test]# echo $LANG
zh_CN.UTF-8
[root@million test]# echo $PATH
/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:/home/test/bin
[root@million test]# 



发布了16 篇原创文章 · 获赞 19 · 访问量 1万+

猜你喜欢

转载自blog.csdn.net/eastnow/article/details/52040984
今日推荐