新聞中心

創(chuàng)新互聯(lián)主要從事網(wǎng)站建設(shè)、網(wǎng)站制作、網(wǎng)頁設(shè)計、企業(yè)做網(wǎng)站、公司建網(wǎng)站等業(yè)務(wù)。立足成都服務(wù)吉利,10余年網(wǎng)站建設(shè)經(jīng)驗,價格優(yōu)惠、服務(wù)專業(yè),歡迎來電咨詢建站服務(wù):18982081108
B.1. Shell 和基本命令
在Uinx 世界中,每一個管理員遲早都要使用命令行;例如,當(dāng)系統(tǒng)可能啟動失敗后只給了一個命令行恢復(fù)模式。所以在這樣的環(huán)境種能夠使用命令行是一種基本的生存技能。
速覽啟動命令解釋器
A command-line environment can be run from the graphical desktop, by an application known as a “terminal”. In GNOME, you can start it from the “Activities” overview (that you get when you move the mouse in the top-left corner of the screen) by typing the first letters of the application name. In Plasma, you will find it in the
K →
Applications →
System menu. 這一部分只會展示各個命令的簡單用法,它們還有許多此處尚未描述的可用選項。請閱讀它們對應(yīng)的手冊頁,其中詳細的文檔可供你參考。
B.1.1. 瀏覽目錄與管理文件
打開會話之后,
pwd 命令(
print working directory)會顯示當(dāng)前位置。當(dāng)前目錄可以通過
cd 目錄命令(
cd即
change directory)。上級目錄叫
..(兩個點),當(dāng)前目錄為
.(一個點)。
ls 命令會
列舉目錄中的內(nèi)容,若沒有參數(shù),則其將對當(dāng)前目錄進行操作。
$pwd/home/rhertzog $cd 桌面$pwd/home/rhertzog/桌面 $cd .$pwd/home/rhertzog/桌面 $cd ..$pwd/home/rhertzog $ls桌面 下載 圖片 模板 文檔 音樂 公共 視頻
您可以使用
mkdir 目錄名 命令創(chuàng)建一個新的目錄,且可以使用
rmdir 目錄名 命令刪除一個已存在的(空的)目錄。
mv 命令可以
移動和/或重命名文件和目錄;
刪除一個文件可以使用
rm 文件名 命令來完成。
$mkdir test$ls桌面 下載 圖片 模板 視頻 文檔 音樂 公共 test $mv test new$ls桌面 下載 new 公共 視頻 文檔 音樂 圖片 模板 $rmdir new$ls桌面 下載 圖片 模板 視頻 文檔 音樂 公共
B.1.2. 顯示和修改文本文件
cat 文件名命令(用于
連接(concatenate)文件并將內(nèi)容送至標準輸出設(shè)備)讀取文件并將其內(nèi)容顯示在終端上。如果文件過大而不適合屏幕顯示的話,可以使用一個分頁器進行輔助,例如
less(或者
more)以按頁在屏幕上顯示內(nèi)容。 The
editor command starts a text editor (such as
vi or
nano) and allows creating, modifying and reading text files. The simplest files can sometimes be created directly from the command interpreter thanks to redirection:
echo "text" >file creates a file named
file with “
text” as its contents. Adding a line at the end of this file is possible too, with a command such as
echo "moretext" >>file. Note the
>> in this example.
B.1.3. 搜索文件和在文件中搜索
The
find directory criteria command looks for files in the hierarchy under
directory according to several criteria. The most commonly used criterion is
-name name: that allows looking for a file by its name. The
grep expression files command searches the contents of the files and extracts the lines matching the regular expression (see sidebar
BACK TO BASICS Regular expression). Adding the
-r option enables a recursive search on all files contained in the directory passed as a parameter. This allows looking for a file when only a part of the contents are known.
B.1.4. 管理進程
The
ps aux command lists the processes currently running and helps identifying them by showing their
pid (process id). Once the
pid of a process is known, the
kill -signal pid command allows sending it a signal (if the process belongs to the current user). Several signals exist; most commonly used are
TERM (a request to terminate gracefully) and
KILL (a forced kill). The command interpreter can also run programs in the background if the command is followed by a “&”. By using the ampersand, the user resumes control of the shell immediately even though the command is still running (hidden from the user; as a background process). The
jobs command lists the processes running in the background; running
fg %job-number (for
foreground) restores a job to the foreground. When a command is running in the foreground (either because it was started normally, or brought back to the foreground with
fg), the
Control+
Z key combination pauses the process and resumes control of the command-line. The process can then be restarted in the background with
bg %job-number (for
background).
B.1.5. 系統(tǒng)信息:內(nèi)存、磁盤空間、身份信息
The
free command displays information on memory;
df (
disk free) reports on the available disk space on each of the disks mounted in the filesystem. Its
-h option (for
human readable) converts the sizes into a more legible unit (usually mebibytes or gibibytes). In a similar fashion, the
free command supports the
-m and
-g options, and displays its data either in mebibytes or in gibibytes, respectively.
$freetotal used free shared buff/cache available Mem: 16279260 5910248 523432 871036 9845580 9128964 Swap: 16601084 240640 16360444 $dfFilesystem 1K-blocks Used Available Use% Mounted on udev 8108516 0 8108516 0% /dev tmpfs 1627928 161800 1466128 10% /run /dev/mapper/vg_main-root 466644576 451332520 12919912 98% / tmpfs 8139628 146796 7992832 2% /dev/shm tmpfs 5120 4 5116 1% /run/lock tmpfs 8139628 0 8139628 0% /sys/fs/cgroup /dev/sda1 523248 1676 521572 1% /boot/efi tmpfs 1627924 88 1627836 1% /run/user/1000
The
id command displays the identity of the user running the session, along with the list of groups they belong to. Since access to some files or devices may be limited to group members, checking available group membership may be useful.
$iduid=1000(rhertzog) gid=1000(rhertzog) groups=1000(rhertzog),24(cdrom),25(floppy),27(sudo),29(audio),30(dip),44(video),46(plugdev),108(netdev),109(bluetooth),115(scanner)
分享題目:【Debian管理員手冊】附錄?B.?簡短輔導(dǎo)課程
瀏覽路徑:http://www.5511xx.com/article/codcgjp.html


咨詢
建站咨詢
