Linux-安装-首次登录-命令行使用-帮助使用-关机

1.系统安装与首次登录

本章同步视频:https://edu.51cto.com/sd/e4874

1.1 Linux文化


1.2 Linux安装

1.2.1 VMWare安装

https://edu.51cto.com/sd/e4874

1.2.2 RHEL7安装

https://edu.51cto.com/sd/e4874

1.3 首次登录

1.3.1 图形界面登录

1.虚拟终端

(1)打开终端:右键-->open in terminal

(2)打开终端:Shift+Ctrl+N

(3)放大字号:Ctrl++

(4)缩小字号:Ctrl+-

2.远程终端

(1)Xshell

(2)putty

扫描二维码关注公众号,回复: 11122065 查看本文章

(3)ssh

3.tty命令

[root@localhost ~]# tty  #查看当前终端

/dev/pts/0

1.3.2 文本界面登录

 

1.3.3 运行级别

1.runlevel

# 0 - 停机 ,机器关闭。

# 1 - 单用户模式 。就像Win9x下的安全模式类似

# 2 - 多用户,但是没有NFS  进入无网络服务的多用户模式

# 3 - 完全多用户模式 ,是标准的运行级。

# 4 - 没有用到 ,一般不用,在一些特殊情况下可以用它来做一些事情。

# 5 - X11   ,进到X Window系统了。

# 6 - 重新启动 ,运行init 6机器就会重启

2.查看当前运行级别

[root@localhost ~]# runlevel

N 5

3.切换运行级别

[root@localhost ~]# init N   #N为需要切换的级别。

4.RHEL 7中的运行级别

[root@localhost ~]# cat /etc/inittab

multi-user.target: analogous to runlevel 3

graphical.target: analogous to runlevel 5

5.查看默认运行级别

[root@localhost ~]# systemctl get-default

6.更改默认运行级别

[root@localhost ~]# systemctl set-default multi-user.target  

#默认启动到文本界面

[root@localhost ~]# systemctl set-default graphical.target   

 #默认启动到图形界面

1.4 命令下达

1.4.1 命令格式

[root@localhost ~]#  command  [-options]  parameter1  parameter2 ...

                                      指令         选项           参数(1)         参数(2)

1.4.2 date  - print or set the system date and time

       date [OPTION]... [+FORMAT]

       date [-u|--utc|--universal] [MMDDhhmm[[CC]YY][.ss]]

[root@localhost ~]# date

Tue Feb 25 19:00:53 CST 2020

[root@localhost ~]# date +%Y/%m/%d

2020/02/25

[root@localhost ~]# date +%H:%M

19:03

1.4.3 cal - display a calendar

 cal [options] [[[day] month] year]

1.显示当前月日历

[root@localhost ~]# cal

    February 2020  

Su Mo Tu We Th Fr Sa

                   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

2.显示某年日历

[root@localhost ~]# cal 2020

3.显示某年某月日历

[root@localhost ~]# cal 2 2020

[root@localhost ~]# cal 25 2 2020

1.4.4 locale - get locale-specific information

locale [-a| -m]

locale [-ck] name...

1.查看系统语言

[root@localhost ~]# locale

LANG=en_US.UTF-8

LC_CTYPE="en_US.UTF-8"

LC_NUMERIC="en_US.UTF-8"

LC_TIME="en_US.UTF-8"

LC_COLLATE="en_US.UTF-8"

LC_MONETARY="en_US.UTF-8"

LC_MESSAGES="en_US.UTF-8"

LC_PAPER="en_US.UTF-8"

LC_NAME="en_US.UTF-8"

LC_ADDRESS="en_US.UTF-8"

LC_TELEPHONE="en_US.UTF-8"

LC_MEASUREMENT="en_US.UTF-8"

LC_IDENTIFICATION="en_US.UTF-8"

LC_ALL=

[root@localhost ~]# echo $LANG

en_US.UTF-8

2.查看系统语言(RHEL7)

[root@localhost ~]# cat /etc/locale.conf

LANG="en_US.UTF-8"

[root@localhost ~]# localectl status

   System Locale:.UTF-8

       VC Keymap: us

      X11 Layout: us

3.查看系统支持的语言

[root@localhost ~]# localectl list-locales

4.修改系统语言

[root@localhost ~]# localectl set-locale.utf8

[root@localhost ~]# localectl set-locale.utf8

1.4.5 排错

1.命令不存在或者拼写错误

[root@localhost ~]# Date

bash: Date: command not found...

Similar command is: 'date'

2.参数无效

[root@localhost ~]# cal 13 2020

cal: illegal month value: use 1-12

3.选项不存在

[root@localhost ~]# cal -l 2020

cal: invalid option -- 'l'

Usage:

 cal [options] [[[day] month] year]

Options:

 -1, --one        show only current month (default)

 -3, --three      show previous, current and next month

 -s, --sunday     Sunday as first day of week

 -m, --monday     Monday as first day of week

 -j, --julian     output Julian dates

 -y, --year       show whole current year

 -V, --version    display version information and exit

 -h, --help       display this help text and exit

1.4.6 热键

1.Ctrl+C:中止前台命令的执行

[root@localhost ~]# ^C

2.Tab:自动补全

(1)命令补全

[root@localhost ~]#his[tab]

[root@localhost ~]# ca[tab][tab]

(2)文件名补全

[root@localhost ~]#cd /e[tab]

(3)选项补全

 [root@localhost ~]#date --[tab][tab]

3.Ctrl+D:结束键盘输入

 

1.5 帮助系统

1.5.1 man - an interface to the on-line reference manuals

[root@localhost ~]# man date

1.5.2 info - read Info documents

[root@localhost ~]# info date

1.5.3 help

[root@localhost ~]# date --help

 

1.6 关机

1.6.1 sync - flush file system buffers

sync [OPTION]

[root@localhost ~]# sync

1.6.2 shutdown - Halt, power-off or reboot the machine

shutdown [OPTIONS...] [TIME] [WALL...]

(1)立即关机

[root@localhost ~]# shutdown -h now

(2)10分钟后关机

[root@localhost ~]# shutdown -h 10 'I will shutdown after 10 mins'

(3)晚上8:25关机

[root@localhost ~]# shutdown -h 20:25

(4)立即重启

[root@localhost ~]# shutdown -r now

(5)只发关机消息,但不真的关机

[root@localhost ~]# shutdown -k now 'This system will reboot'

(6)撤销已经发出、但还未执行的关机命令

[root@localhost ~]# shutdown -c

1.6.3 halt, poweroff, reboot - Halt, power-off or reboot the machine

halt [OPTIONS...]

poweroff [OPTIONS...]

reboot [OPTIONS...]

[root@localhost ~]# halt

[root@localhost ~]# reboot

[root@localhost ~]# poweroff

1.6.4 systemctl

[root@localhost ~]# systemctl poweroff

[root@localhost ~]# systemctl halt

[root@localhost ~]# systemctl reboot

1.6.5 init

[root@localhost ~]# init 0    #关机

[root@localhost ~]# init  6   #重启

1.6.6 注意事项

[calflyok@localhost sbit]$ shutdown -h

Must be root.

#注:1.关机命令只能由root完成。

          2.可以授权给其他用户执行关机的权限。

1.7 总结

l  养成良好的操作习惯,尽量不要使用 root 直接登入系统;

l  预设情况下,Linux提供tty1~tty6的终端机界面;

l  在终端机环境中,可依据提示字符为$或#判断为一般账号或root账号;

l  date可显示日期、cal可显示日历、bc可以做为计算器软件;

l  [tab]按键可做为(1)命令补齐 (2)档名补齐 (3)参数选项补齐;

l  [ctrl]-[c]可以中断目前正在运作中的程序;

l  Linux 系统上的英文大小写为不同的资料;

l  线上说明系统有man及info两个常见的指令;

l  系统需正确的关机,可使用shutdown, poweroff等指令关机。

 

 

 


猜你喜欢

转载自blog.51cto.com/5482173/2490138