Host:
CPU: Intel(R) Core(TM) i3-6100 CPU @ 3.70GHz 3.70 GHz
核心數目: 2
邏輯處理器: 4
L1: 128KB L2: 512KB L3: 3.0MB
RAM: 16.0 GB
OS: Windows 10 企業版
IP:163.32.145.99/24
Guest:
IP:163.32.145.69/24
安裝
----------------------------------------------------------------------------------------------------------
參考 2023年11月26日 星期日 RockyLinux 安裝
VMware Workstation 17 Player
1.
2.
3.
4.
5.
6.
7.
8.
Rocky 安裝設定
1.
2.
3.
4.
5.
6.
7.
PuTTY 連結
1.
2.
su 與 sudo
----------------------------------------------------------------------------------------------------------
//su 切換到root (輸入root 密碼)
[kk@rocky ~]$ su -
密碼:
[root@rocky ~]# shutdown now
密碼:
[root@rocky ~]# shutdown now
//無法使用 sudo
//乃是系統安裝時,建立kk使用者未將:「讓使用者成為管理員」勾選。
//必須把使用者加入wheel這個群組,才可以用sudo (輸入 kk 密碼)
//必須把使用者加入wheel這個群組,才可以用sudo (輸入 kk 密碼)
[kk@rocky ~]$ sudo shutdown now
[sudo] kk 的密碼:
kk 不在 sudoers 檔案中。此事件將會回報。
[sudo] kk 的密碼:
kk 不在 sudoers 檔案中。此事件將會回報。
[kk@rocky ~]$ id
使用者id=1000(kk) id群組=1000(kk) 組=1000(kk) 上下文=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023
使用者id=1000(kk) id群組=1000(kk) 組=1000(kk) 上下文=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023
[root@rocky kk]# ls -l /etc/sudoers
-r--r-----. 1 root root 4328 4月 24 2023 /etc/sudoers
-r--r-----. 1 root root 4328 4月 24 2023 /etc/sudoers
[root@rocky kk]# vi /etc/sudoers
...
root ALL=(ALL) ALL
kk ALL=(ALL) ALL
...
%wheel ALL=(ALL) ALL
...
kk ALL=(ALL) ALL
...
%wheel ALL=(ALL) ALL
...
:wq!
##因為唯讀,所以要強制存檔離開
[root@rocky kk]# usermod -aG wheel kk
[root@rocky kk]# su kk
[kk@rocky ~]$ id
使用者id=1000(kk) id群組=1000(kk) 組=1000(kk),10(wheel) 上下文=unconfined_u:unco
[kk@rocky ~]$ cat /etc/group
...
wheel:x:10:kk
...
kk:x:1000:
...
wheel:x:10:kk
...
kk:x:1000:
[kk@rocky ~]$ sudo shutdown now
[sudo] kk 的密碼:
[sudo] kk 的密碼:
system information
----------------------------------------------------------------------------------------------------------
[kk@rocky ~]$ uname -a
Linux rocky.kk 5.14.0-362.8.1.el9_3.x86_64 #1 SMP PREEMPT_DYNAMIC Wed Nov 8 17:36:32 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux
Linux rocky.kk 5.14.0-362.8.1.el9_3.x86_64 #1 SMP PREEMPT_DYNAMIC Wed Nov 8 17:36:32 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux
[kk@rocky ~]$ cat /etc/rocky-release
Rocky Linux release 9.3 (Blue Onyx)
Rocky Linux release 9.3 (Blue Onyx)
[kk@rocky ~]$ cat /proc/version
Linux version 5.14.0-362.8.1.el9_3.x86_64 (mockbuild@iad1-prod-build001.bld.equ. rockylinux.org) (gcc (GCC) 11.4.1 20230605 (Red Hat 11.4.1-2), GNU ld version 35.2-42.el9) #1 SMP PREEMPT_DYNAMIC Wed Nov 8 17:36:32 UTC 2023
Linux version 5.14.0-362.8.1.el9_3.x86_64 (mockbuild@iad1-prod-build001.bld.equ. rockylinux.org) (gcc (GCC) 11.4.1 20230605 (Red Hat 11.4.1-2), GNU ld version 35.2-42.el9) #1 SMP PREEMPT_DYNAMIC Wed Nov 8 17:36:32 UTC 2023
關機、目錄
----------------------------------------------------------------------------------------------------------
Linux 根目錄 /
Windows 根目錄 \
Windows 根目錄 \
[kk@rocky ~]$
kk:使用者
rocky:主機名
~ :使用者家目錄
kk:使用者
rocky:主機名
~ :使用者家目錄
$ :一班使用者
# :最高權限管理者
//show who is logged on
# :最高權限管理者
//show who is logged on
[kk@rocky ~]$ who
kk pts/0 2024-04-23 14:05 (163.32.145.99)
kk pts/0 2024-04-23 14:05 (163.32.145.99)
//Show who is logged on and what they are doing
[kk@rocky ~]$ w
14:22:06 up 18 min, 1 user, load average: 0.00, 0.00, 0.00
USER TTY LOGIN@ IDLE JCPU PCPU WHAT
kk pts/0 14:05 0.00s 0.05s 0.00s w
14:22:06 up 18 min, 1 user, load average: 0.00, 0.00, 0.00
USER TTY LOGIN@ IDLE JCPU PCPU WHAT
kk pts/0 14:05 0.00s 0.05s 0.00s w
// 關機馬上 halt
# shutdown -h now
// 關機10分鐘後
# shutdown -h 10
//重開機 reboot
# shutdown -r
#reboot
# shutdown -h now
// 關機10分鐘後
# shutdown -h 10
//重開機 reboot
# shutdown -r
#reboot
//列出 檔案系統 根目錄 下
[kk@rocky ~]$ ls /
afs boot etc lib media opt root sbin sys usr
bin dev home lib64 mnt proc run srv tmp var
afs boot etc lib media opt root sbin sys usr
bin dev home lib64 mnt proc run srv tmp var
[kk@rocky ~]$ pwd
/home/kk
/home/kk
//Change the current directory to dir
[kk@rocky ~]$ cd /
[kk@rocky /]$ pwd
/
[kk@rocky /]$ pwd
/
[kk@rocky /]$ ls
afs boot etc lib media opt root sbin sys usr
bin dev home lib64 mnt proc run srv tmp var
afs boot etc lib media opt root sbin sys usr
bin dev home lib64 mnt proc run srv tmp var
//print name of current/working directory
[kk@rocky ~]$ pwd
/home/kk
/home/kk
//kk目錄底下
[kk@rocky ~]$ ls
[kk@rocky ~]$ ls .
[kk@rocky ~]$ ls ./
[kk@rocky ~]$ ls .
[kk@rocky ~]$ ls ./
//home 目錄底下
[kk@rocky ~]$ ls ..
kk
[kk@rocky ~]$ ls ../
kk
[kk@rocky ~]$ ls ..
kk
[kk@rocky ~]$ ls ../
kk
檔案系統階層標準 Filesystem Hierarchy Standard FHS 說明檔案與目錄在 Linux 階層架構與擺放位置。
地區時間
----------------------------------------------------------------------------------------------------------
[kk@rocky /]$ date
西元2024年04月23日 (週二) 14時47分48秒 CST
西元2024年04月23日 (週二) 14時47分48秒 CST
[kk@rocky /]$ echo $LANG
zh_TW.UTF-8
zh_TW.UTF-8
//取得語區資料特定的資訊 locale --help
[kk@rocky /]$ locale
LANG=zh_TW.UTF-8
...
LANG=zh_TW.UTF-8
...
[kk@rocky /]$ cat /etc/hostname
rocky.kk
rocky.kk
[kk@rocky /]$ vi /etc/hostname
rocky.kk
[kk@rocky /]$ hostnamectl
Static hostname: rocky.kk
Icon name: computer-vm
Chassis: vm 🖴
Machine ID: 97b2863dd3e344bfb13067a93c307344
Boot ID: b6025d9b086b4c668e8bfcb3bdeee234
Virtualization: vmware
Operating System: Rocky Linux 9.3 (Blue Onyx)
CPE OS Name: cpe:/o:rocky:rocky:9::baseos
Kernel: Linux 5.14.0-362.8.1.el9_3.x86_64
Architecture: x86-64
Hardware Vendor: VMware, Inc.
Hardware Model: VMware Virtual Platform
Firmware Version: 6.00
Static hostname: rocky.kk
Icon name: computer-vm
Chassis: vm 🖴
Machine ID: 97b2863dd3e344bfb13067a93c307344
Boot ID: b6025d9b086b4c668e8bfcb3bdeee234
Virtualization: vmware
Operating System: Rocky Linux 9.3 (Blue Onyx)
CPE OS Name: cpe:/o:rocky:rocky:9::baseos
Kernel: Linux 5.14.0-362.8.1.el9_3.x86_64
Architecture: x86-64
Hardware Vendor: VMware, Inc.
Hardware Model: VMware Virtual Platform
Firmware Version: 6.00
[kk@rocky /]$ sudo hostnamectl set-hostname rocky22.kk
[sudo] kk 的密碼:
[kk@rocky /]$ hostnamectl
Static hostname: rocky22.kk
Icon name: computer-vm
[sudo] kk 的密碼:
[kk@rocky /]$ hostnamectl
Static hostname: rocky22.kk
Icon name: computer-vm
...
cp, mv, rm,mkdir
----------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------
[kk@rocky ~]$ ls
[kk@rocky ~]$ ls /etc/dnf
aliases.d dnf.conf modules.d modules.defaults.d plugins protected.d vars
//copy files and directories
[kk@rocky ~]$ cp /etc/dnf/dnf.conf ./
[kk@rocky ~]$ ls
dnf.conf
[kk@rocky ~]$ ls
dnf.conf
[kk@rocky ~]$ ls /etc/dnf/vars/
contentdir rltype sigcontentdir stream
contentdir rltype sigcontentdir stream
[kk@rocky ~]$ cp -r /etc/dnf/vars/ ./
[kk@rocky ~]$ ls
dnf.conf vars
[kk@rocky ~]$ ls
dnf.conf vars
[kk@rocky ~]$ ls vars/
contentdir rltype sigcontentdir stream
contentdir rltype sigcontentdir stream
[kk@rocky ~]$ ls
dnf.conf vars
// move (rename) files
[kk@rocky ~]$ mv dnf.conf ddd.conf
[kk@rocky ~]$ ls
ddd.conf vars
[kk@rocky ~]$ ls
ddd.conf vars
//remove files or directories
[kk@rocky ~]$ rm ddd.conf
[kk@rocky ~]$ ls
vars
[kk@rocky ~]$ ls
vars
// --recursive --force
[kk@rocky ~]$ rm -rf vars/
[kk@rocky ~]$ ls
[kk@rocky ~]$
[kk@rocky ~]$ ls
[kk@rocky ~]$
// make directories
[kk@rocky ~]$ mkdir dir1
[kk@rocky ~]$ ls -l
drwxr-xr-x. 2 kk kk 6 4月 25 08:42 dir1
[kk@rocky ~]$ mkdir dir1
[kk@rocky ~]$ ls -l
drwxr-xr-x. 2 kk kk 6 4月 25 08:42 dir1
[kk@rocky ~]$ echo "HelloWorldlscat">dir1/readme.text
[kk@rocky ~]$ ls -l dir1/
總用量 4
-rw-r--r--. 1 kk kk 28 4月 25 08:44 readme.text
// -f, --force -r, -R, --recursive
[kk@rocky ~]$ rm -r dir1
[kk@rocky ~]$ ls
[kk@rocky ~]$ ls
touch, cat, more, less, head, tail
----------------------------------------------------------------------------------------------------------
//產生空白檔案
[kk@rocky ~]$ touch test.txt
[kk@rocky ~]$ ls -l
總用量 4
-rw-r--r--. 1 kk kk 0 4月 24 15:26 test.txt
[kk@rocky ~]$ ls -l
總用量 4
-rw-r--r--. 1 kk kk 0 4月 24 15:26 test.txt
//change file timestamps
[kk@rocky ~]$ cp /etc/dnf/dnf.conf ./
[kk@rocky ~]$ ls -l
總用量 4
-rw-r--r--. 1 kk kk 108 4月 24 15:04 dnf.conf
[kk@rocky ~]$ ls -l
總用量 4
-rw-r--r--. 1 kk kk 108 4月 24 15:04 dnf.conf
[kk@rocky ~]$ touch dnf.conf
[kk@rocky ~]$ ls -l
總用量 4
-rw-r--r--. 1 kk kk 108 4月 24 15:07 dnf.conf
[kk@rocky ~]$ ls -l
總用量 4
-rw-r--r--. 1 kk kk 108 4月 24 15:07 dnf.conf
// concatenate files and print on the standard output
[kk@rocky ~]$ ls
dnf.conf
dnf.conf
[kk@rocky ~]$ cat dnf.conf
[main]
gpgcheck=1
installonly_limit=3
clean_requirements_on_remove=True
best=True
skip_if_unavailable=False
[main]
gpgcheck=1
installonly_limit=3
clean_requirements_on_remove=True
best=True
skip_if_unavailable=False
//--number
[kk@rocky ~]$ cat -n dnf.conf
1 [main]
2 gpgcheck=1
3 installonly_limit=3
4 clean_requirements_on_remove=True
5 best=True
6 skip_if_unavailable=False
1 [main]
2 gpgcheck=1
3 installonly_limit=3
4 clean_requirements_on_remove=True
5 best=True
6 skip_if_unavailable=False
// 產生 test.txt , > 把輸入文字寫入 test.txt 中
[kk@rocky ~]$ cat>test.txt
I love linux !! //輸入完成按 Ctrl+D
I love linux !! //輸入完成按 Ctrl+D
[kk@rocky ~]$ ls
dnf.conf test.txt
dnf.conf test.txt
[kk@rocky ~]$ cat test.txt
I love linux !!
I love linux !!
硬碟空間、檔案大小使用情形
----------------------------------------------------------------------------------------------------------
//report file system disk space usage 各分割區使用情況
//-h, --human-readable
//-h, --human-readable
[kk@rocky ~]$ df -h
檔案系統 容量 已用 可用 已用% 掛載點
devtmpfs 4.0M 0 4.0M 0% /dev
tmpfs 3.8G 0 3.8G 0% /dev/shm
tmpfs 1.5G 9.0M 1.5G 1% /run
/dev/mapper/rl-root 17G 1.5G 16G 9% /
/dev/nvme0n1p1 960M 223M 738M 24% /boot
tmpfs 765M 0 765M 0% /run/user/1000
檔案系統 容量 已用 可用 已用% 掛載點
devtmpfs 4.0M 0 4.0M 0% /dev
tmpfs 3.8G 0 3.8G 0% /dev/shm
tmpfs 1.5G 9.0M 1.5G 1% /run
/dev/mapper/rl-root 17G 1.5G 16G 9% /
/dev/nvme0n1p1 960M 223M 738M 24% /boot
tmpfs 765M 0 765M 0% /run/user/1000
//estimate file space usage 目前目錄下( 含子目錄)已用空間
[kk@rocky ~]$ ls -lh /home/kk
總用量 4.0K
-rwxr--r--. 1 kk kk 11 4月 25 09:01 runMe
[kk@rocky ~]$ du -h runMe
4.0K runMe
總用量 4.0K
-rwxr--r--. 1 kk kk 11 4月 25 09:01 runMe
[kk@rocky ~]$ du -h runMe
4.0K runMe
沒有留言:
張貼留言