Shell

查看当前使用的 shell

1
2
[root@localhost ~]# echo $SHELL
/bin/bash

查看系统中已安装的 shell

1
2
3
4
5
6
7
[root@localhost ~]# cat /etc/shells
/bin/sh
/bin/bash
/usr/bin/sh
/usr/bin/bash
/bin/tcsh
/bin/csh

安装 zsh

1
[root@localhost ~]# yum -y install zsh

安装 git

1
[root@localhost ~]# yum -y install git

安装 oh-my-zsh

1
[root@localhost ~]# sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"

修改 root 用户默认 shell

1
2
[root@localhost ~]# usermod -s /bin/zsh root
[root@localhost ~]# su - root

修改当前用户 shell

1
[gg@localhost ~]# chsh -s /bin/zsh

过程记录

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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
[root@localhost ~]# yum install zsh
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
extras | 2.9 kB 00:00:00
os | 3.6 kB 00:00:00
updates | 2.9 kB 00:00:00
Resolving Dependencies
Running transaction check
Package zsh.x86_64 0:5.0.2-34.el7_8.2 will be installed
Finished Dependency Resolution

Dependencies Resolved

========================================================================================================
Package Arch Version Repository Size
========================================================================================================
Installing:
zsh x86_64 5.0.2-34.el7_8.2 os 2.4 M

Transaction Summary
========================================================================================================
Install 1 Package

Total download size: 2.4 M
Installed size: 5.6 M
Is this ok [y/d/N]: y
Downloading packages:
warning: /var/cache/yum/x86_64/7/os/packages/zsh-5.0.2-34.el7_8.2.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY
Public key for zsh-5.0.2-34.el7_8.2.x86_64.rpm is not installed
zsh-5.0.2-34.el7_8.2.x86_64.rpm | 2.4 MB 00:00:08
Retrieving key from http://mirrors.cloud.tencent.com/centos/RPM-GPG-KEY-CentOS-7
Importing GPG key 0xF4A80EB5:
Userid : "CentOS-7 Key (CentOS 7 Official Signing Key) <security@centos.org>"
Fingerprint: 6341 ab27 53d7 8a78 a7c2 7bb1 24c6 a8a7 f4a8 0eb5
From : http://mirrors.cloud.tencent.com/centos/RPM-GPG-KEY-CentOS-7
Is this ok [y/N]: y
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : zsh-5.0.2-34.el7_8.2.x86_64 1/1
Verifying : zsh-5.0.2-34.el7_8.2.x86_64 1/1

Installed:
zsh.x86_64 0:5.0.2-34.el7_8.2

Complete!
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
[root@localhost ~]# yum -y install git
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
Resolving Dependencies
Running transaction check
Package git.x86_64 0:1.8.3.1-23.el7_8 will be installed
Processing Dependency: perl-Git = 1.8.3.1-23.el7_8 for package: git-1.8.3.1-23.el7_8.x86_64
Processing Dependency: perl(Term::ReadKey) for package: git-1.8.3.1-23.el7_8.x86_64
Processing Dependency: perl(Git) for package: git-1.8.3.1-23.el7_8.x86_64
Processing Dependency: perl(Error) for package: git-1.8.3.1-23.el7_8.x86_64
Running transaction check
Package perl-Error.noarch 1:0.17020-2.el7 will be installed
Package perl-Git.noarch 0:1.8.3.1-23.el7_8 will be installed
Package perl-TermReadKey.x86_64 0:2.30-20.el7 will be installed
Finished Dependency Resolution

Dependencies Resolved

==================================================================================================================================================
Package Arch Version Repository Size
==================================================================================================================================================
Installing:
git x86_64 1.8.3.1-23.el7_8 os 4.4 M
Installing for dependencies:
perl-Error noarch 1:0.17020-2.el7 os 32 k
perl-Git noarch 1.8.3.1-23.el7_8 os 56 k
perl-TermReadKey x86_64 2.30-20.el7 os 31 k

Transaction Summary
==================================================================================================================================================
Install 1 Package (+3 Dependent packages)

Total download size: 4.5 M
Installed size: 22 M
Downloading packages:
(1/4): perl-Error-0.17020-2.el7.noarch.rpm | 32 kB 00:00:00
(2/4): perl-Git-1.8.3.1-23.el7_8.noarch.rpm | 56 kB 00:00:00
(3/4): perl-TermReadKey-2.30-20.el7.x86_64.rpm | 31 kB 00:00:00
(4/4): git-1.8.3.1-23.el7_8.x86_64.rpm | 4.4 MB 00:00:03
--------------------------------------------------------------------------------------------------------------------------------------------------
Total 1.2 MB/s | 4.5 MB 00:00:03
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : 1:perl-Error-0.17020-2.el7.noarch 1/4
Installing : perl-TermReadKey-2.30-20.el7.x86_64 2/4
Installing : perl-Git-1.8.3.1-23.el7_8.noarch 3/4
Installing : git-1.8.3.1-23.el7_8.x86_64 4/4
Verifying : git-1.8.3.1-23.el7_8.x86_64 1/4
Verifying : 1:perl-Error-0.17020-2.el7.noarch 2/4
Verifying : perl-Git-1.8.3.1-23.el7_8.noarch 3/4
Verifying : perl-TermReadKey-2.30-20.el7.x86_64 4/4

Installed:
git.x86_64 0:1.8.3.1-23.el7_8

Dependency Installed:
perl-Error.noarch 1:0.17020-2.el7 perl-Git.noarch 0:1.8.3.1-23.el7_8 perl-TermReadKey.x86_64 0:2.30-20.el7

Complete!
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
32
33
34
35
[root@localhost ~]# sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
Cloning Oh My Zsh...
Cloning into '/root/.oh-my-zsh'...
remote: Enumerating objects: 1206, done.
remote: Counting objects: 100% (1206/1206), done.
remote: Compressing objects: 100% (1172/1172), done.
remote: Total 1206 (delta 20), reused 1094 (delta 15), pack-reused 0
Receiving objects: 100% (1206/1206), 843.10 KiB | 342.00 KiB/s, done.
Resolving deltas: 100% (20/20), done.

Looking for an existing zsh config...
Using the Oh My Zsh template file and adding it to ~/.zshrc.

Time to change your default shell to zsh:
Do you want to change your default shell to zsh? [Y/n] y
Changing the shell...
Changing shell for root.
Shell changed.
Shell successfully changed to '/bin/zsh'.

__ __
____ / /_ ____ ___ __ __ ____ _____/ /_
/ __ \/ __ \ / __ `__ \/ / / / /_ / / ___/ __ \
/ /_/ / / / / / / / / / / /_/ / / /_(__ ) / / /
\____/_/ /_/ /_/ /_/ /_/\__, / /___/____/_/ /_/
/____/ ....is now installed!


Before you scream Oh My Zsh! please look over the ~/.zshrc file to select plugins, themes, and options.

• Follow us on Twitter: https://twitter.com/ohmyzsh
• Join our Discord server: https://discord.gg/ohmyzsh
• Get stickers, shirts, coffee mugs and other swag: https://shop.planetargon.com/collections/oh-my-zsh

➜ ~