Linux 系統介紹
linux 基本概念及操作
shell 命令:
· echo "Hello world" ==> 每一種語言都有的打印hello world
<小技巧 , 當你忘記命令的時候 可以用Tab 去查看相關字母開頭的所有命令>
· 無意中多輸入了些命令,或者寫錯了。 可以用ctrl+c 去退出。 比如如下命令:
Allens-MacBook-Air:~ allenliu$ tail
^C
Allens-MacBook-Air:~ allenliu$
· 常用快捷鍵:
Ctrl+d 鍵盤輸入結束或者退出
Ctrl+s 暫停當前程序
Ctrl+z 將程序放置到后臺,恢復到前臺的命令是fg
Ctrl+a 講光標移動到行頭
Ctrl+e 將光標移動到行尾
Ctrl+K 刪除光標所在位置到行尾
Alt+ Backspace 向前刪除一個單詞
· 使用通配符
實際上相當于正則的用法。可以用* 跟 ? 來進行模糊匹配
Allens-MacBook-Air:desktop allenliu$ ls *.plist
QT0-NED.plist QT0-NED_units_dictionary.plist
QT0-NED_units.plist QT0-NED_units_dictionary_modified.plist
Allens-MacBook-Air:desktop allenliu$
· 批量創建文件
touch 命令:
Allens-MacBook-Air:desktop allenliu$ touch Love_{1..2}_text.txt
Allens-MacBook-Air:desktop allenliu$
查看幫助
命令如下: man man
man 命令包括的主要區段如下
一般命令
系統調用
庫函數,涵蓋了C標準庫
特殊文件和驅動程序
文件格式和約定
游戲和屏保
雜項
系統管理命令和守護進程
使用的具體方法:
Allens-MacBook-Air:desktop allenliu$ man 1 ls
LS(1) BSD General Commands Manual LS(1)
NAME
ls -- list directory contents
SYNOPSIS
ls [-ABCFGHLOPRSTUW@abcdefghiklmnopqrstuwx1] [file ...]
DESCRIPTION
For each operand that names a file of a type other than directory, ls
displays its name as well as any requested, associated information. For
each operand that names a file of type directory, ls displays the names
of files contained within that directory, as well as any requested, asso-
ciated information.
Linux 用戶及文件權限管理
用戶管理
- 查看用戶:
Allens-MacBook-Air:desktop allenliu$ who am i
allenliu ttys000 Oct 5 21:24
who 下面的常用參數:
Allens-MacBook-Air:desktop allenliu$ who -a
reboot ~ Oct 5 20:57 . 1
allenliu console Oct 5 20:58 00:56 107
allenliu ttys000 Oct 5 21:24 . 2384
. run-level 3
Allens-MacBook-Air:desktop allenliu$ who -d
Allens-MacBook-Air:desktop allenliu$ who -m
allenliu ttys000 Oct 5 21:24
Allens-MacBook-Air:desktop allenliu$ who -q
allenliu allenliu
# users = 2
Allens-MacBook-Air:desktop allenliu$ who -u
allenliu console Oct 5 20:58 00:57 107
allenliu ttys000 Oct 5 21:24 . 2384
Allens-MacBook-Air:desktop allenliu$ who -r
. run-level 3
Allens-MacBook-Air:desktop allenliu$
- 創建用戶
sudo 用來執行一些需要特權的命令,比如 adduser
su 用來切換用戶
- Cat 命令
Cat 命令用來讀取制定文件的內容把那個打印到終端輸出, | sort 表示將讀取的文本進行一個字典排序。
Allens-MacBook-Air:desktop allenliu$ cat /etc/group | sort
#
#
# Group Database
# Note that this file is consulted directly only when the system is running
# Open Directory.
# Open Directory.
# See the opendirectoryd(8) man page for additional information about
# in single-user mode. At other times this information is provided by
##
##
_amavisd:*:83:
_appleevents:*:55:
_applepay:*:260:
_appowner:*:87:
_appserveradm:*:81:
_appserverusr:*:79:
_appstore:*:33:
_ard:*:67:
_assetcache:*:235:
_astris:*:245:
_atsserver:*:97:
_calendar:*:93:_teamsserver
_captiveagent:*:258:
_ces:*:32:
_clamav:*:82:
_coreaudiod:*:202:
_coremediaiod:*:236:
_ctkd:*:259:
_cvms:*:212:
_cvs:*:72:
· 刪除用戶
sudo deluser Allen --remove -home
文件權限
用較長的格式列出文件:
ls -l

image

image

iamge
· 變更文件所有者
cd /home/lilei
ls iphone6
sudo chown allen iphone6 ==> change ownship
cp iphone6 /home/allen ==> copy file
改變文件的權限
- 二進制表示:
每個文件有三種權限,(擁有者,所屬用戶組,其他用戶)。每組權限都對應著一個r'w'x。也就是如圖所示的7

image
echo "echo \"hello world\"" >iphone6
chmod 700 iphone6
2, 另外一種方式是:加減賦權的方法
g->group
o->other
u->user
對于文件還可以這樣
chmod go -rw iphone