Linux 面試基礎問題 – 2
自本系列的上一篇文章11個基本的 Linux 面試問題,我們分析了不同論壇對此作出的評論,這對我們將更好的文章提供給我們的讀者是很重要的。我們付出了時間和金錢,那我們又渴望從你們身上得到什麼回報呢?答案是沒有的。如果你不能讚揚我們的工作,但懇請不要在評論中詆毀我們的工作。
如果你在文章中沒有找到什麼新的東西,但也請不要忘記它對某些人卻是非常有用的,並且他或她會非常感激我們的工作。我們不能夠讓每一篇文章都使大家高興。但我希望讀者們能夠盡量理解。
Q.1:哪一條命令用於把用戶登錄會話記錄在文件中?
- macro
- read
- script
- record
- sessionrecord
答:『script』 命令是用來把用戶登錄的會話信息記錄在文件里。這條命令能夠用在 shell 腳本裡面,或者直接在終端中使用。下面是一個例子,它記錄了開始用 script 到輸入 exit 結束之間的所有東西。
如下命令記錄用戶登錄會話到一個文件中:
[root@tecmint ~]# script my-session-record.txt
Script started, file is my-session-record.txt
記錄的文件「my-session-record.txt」可以通過下述方式查看:
[root@tecmint ~]# nano my-session-record.txt
script started on Friday 22 November 2013 08:19:01 PM IST
[root@tecmint ~]# ls
^[[0m^[[01;34mBinary^[[0m ^[[01;34mDocuments^[[0m ^[[01;34mMusic^[[0m $
^[[01;34mDesktop^[[0m ^[[01;34mDownloads^[[0m my-session-record.txt ^[[01;34$
Q.2:以下那一條命令可以用來查看內核日誌信息
- dmesg
- kernel
- ls -i
- uname
- 以上全不是
答:執行 'dmesg' 命令可以查看內核的日誌信息。在上面的命令中,kernel 不是一個有效的命令,'ls -i' 是用來列出工作目錄中文件的索引節點,而 'uname' 是用來顯示操作系統信息的。
-
[root@tecmint ~]# dmesg
Initializing cgroup subsys cpuset
Initializing cgroup subsys cpu
Linux version 2.6.32-279.el6.i686 (mockbuild@c6b9.bsys.dev.centos.org) (gcc version 4.4.6 20120305 (Red Hat 4.4.6-4) (GCC) ) #1 SMP Fri Jun 22 10:59:55 UTC 2012
KERNEL supported cpus:
Intel GenuineIntel
AMD AuthenticAMD
NSC Geode by NSC
Cyrix CyrixInstead
Centaur CentaurHauls
Transmeta GenuineTMx86
Transmeta TransmetaCPU
UMC UMC UMC UMC
Disabled fast string operations
BIOS-provided physical RAM map:
...
Q.3:哪一條命令是用來顯示 Linux 內核發行信息的?
- uname -v
- uname -r
- uname -m
- uname -n
- uname -o
答:『uname -r』是用來顯示內核的發行信息。其它參數『-v』、『-m』、『-n』、『o』分別顯示內核版本、機器硬體名稱、網路節點、主機名和操作系統。
-
[root@tecmint ~]# uname -r
2.6.32-279.el6.i686
Q.4:那一條命令是被用來識別文件類型的?
- type
- info
- file
- which
- ls
答:『file』命令是用來識別文件類型的。其語法是『file [選項] 文件名』。
-
[root@tecmint ~]# file wtop
wtop: POSIX shell script text executable
Q.5:哪一條命令是被用來找一條命令的二進位文件、源和手冊的所在的路徑?
答:『whereis』駕到!『whereis』命令是用來找一條命令的二進位文件、源和手冊的所在的路徑。
-
[root@tecmint ~]# whereis /usr/bin/ftp
ftp: /usr/bin/ftp /usr/share/man/man1/ftp.1.gz
Q.6:當用戶登錄時,默認情況下哪些文件會被調用作為用戶配置?
答:在用戶的目錄下『.profile』和『.bashrc』會默認地被調用作為用戶配置。
-
[root@tecmint ~]# ls -al
-rw-r--r--. 1 tecmint tecmint 176 May 11 2012 .bash_profile
-rw-r--r--. 1 tecmint tecmint 124 May 11 2012 .bashrc
Q.7:『resolve.conf』文件是什麼的配置文件?
答:『/etc/resolve.conf』 是 DNS 客戶端的配置文件。
-
[root@tecmint ~]# cat /etc/resolv.conf
nameserver 172.16.16.94
Q.8:哪一條命令是用來創建一個文件的軟鏈接的?
- ln
- ln -s
- link
- link -soft
- 以上都不是
答:在 Linux 環境下,『ln -s』是被用來創建一個文件的軟鏈接的。
-
[root@tecmint ~]# ln -s /etc/httpd/conf/httpd.conf httpd.original.conf
Q.9:在Linux下,『pwd』命令是『passwd』命令的別名嗎?
答:不是!默認情況下『pwd』命令不是『passwd』命令的別名。『pwd』是『print working directory』(顯示工作目錄)的縮寫,也就是輸出當前的工作目錄,而『passwd』在 Linux 中是被用來更改用戶的帳號密碼。
-
[root@tecmint ~]# pwd
/home/tecmint
[root@tecmint ~]# passwd
Changing password for user root.
New password:
Retype new password:
Q.10:在 Linux 中,你會怎樣檢測 pci 設備的廠商和版本。
答:我們用的 Linux 命令是『lspci』。
-
[root@tecmint ~]# lspci
00:00.0 Host bridge: Intel Corporation 5000P Chipset Memory Controller Hub (rev b1)
00:02.0 PCI bridge: Intel Corporation 5000 Series Chipset PCI Express x8 Port 2-3 (rev b1)
00:04.0 PCI bridge: Intel Corporation 5000 Series Chipset PCI Express x8 Port 4-5 (rev b1)
00:06.0 PCI bridge: Intel Corporation 5000 Series Chipset PCI Express x8 Port 6-7 (rev b1)
00:08.0 System peripheral: Intel Corporation 5000 Series Chipset DMA Engine (rev b1)
...
現在就到這裡。我希望以上的問題也許對你很有用。在下星期我會再想出一些新的問題。到時請保持好的健康,繼續關注我們並且與 Tecmint 保持聯繫喔!
via: http://www.tecmint.com/basic-linux-interview-questions-and-answers-part-ii/
本文轉載來自 Linux 中國: https://github.com/Linux-CN/archive

















