Linux 面試基礎(chǔ)問題:第二部分
繼續(xù)我們這面試系列,在這篇文章里我們給出了10個問題。這些問題或者是在以后的文章中出現(xiàn)的問題不一定在面試中會被問到。然而通過這些文章我們呈現(xiàn)出的是一個交互的學(xué)習(xí)平臺,這必將會對你有很大的幫助。
自本系列的上一篇文章11個基本的 Linux 面試問題,我們分析了不同論壇對此作出的評論,這對我們將更好的文章提供給我們的讀者是很重要的。我們付出了時間和金錢,那我們又渴望從你們身上得到什么回報呢?答案是沒有的。如果你不能贊揚(yáng)我們的工作,但懇請不要在評論中詆毀我們的工作。
如果你在文章中沒有找到什么新的東西,但也請不要忘記它對某些人卻是非常有用的,并且他或她會非常感激我們的工作。我們不能夠讓每一篇文章都使大家高興。但我希望讀者們能夠盡量理解。
Q.1:哪一條命令用于把用戶登錄會話記錄在文件中?
- macro
- read
- script
- record
- sessionrecord
答:‘script’ 命令是用來把用戶登錄的會話信息記錄在文件里。這條命令能夠用在 shell 腳本里面,或者直接在終端中使用。下面是一個例子,它記錄了開始用 script 到輸入 exit 結(jié)束之間的所有東西。
如下命令記錄用戶登錄會話到一個文件中:
- [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:以下那一條命令可以用來查看內(nèi)核日志信息
- dmesg
- kernel
- ls -i
- uname
- 以上全不是
答:執(zhí)行 'dmesg' 命令可以查看內(nèi)核的日志信息。在上面的命令中,kernel 不是一個有效的命令,'ls -i' 是用來列出工作目錄中文件的索引節(jié)點(diǎn),而 'uname' 是用來顯示操作系統(tǒng)信息的。
- [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 內(nèi)核發(fā)行信息的?
- uname -v
- uname -r
- uname -m
- uname -n
- uname -o
答:‘uname -r’是用來顯示內(nèi)核的發(fā)行信息。其它參數(shù)‘-v’、‘-m’、‘-n’、‘o’分別顯示內(nèi)核版本、機(jī)器硬件名稱、網(wǎng)絡(luò)節(jié)點(diǎn)、主機(jī)名和操作系統(tǒng)。
- [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:哪一條命令是被用來找一條命令的二進(jìn)制文件、源和手冊的所在的路徑?
答:‘whereis’駕到!‘whereis’命令是用來找一條命令的二進(jìn)制文件、源和手冊的所在的路徑。
- [root@tecmint ~]# whereis /usr/bin/ftp
- ftp: /usr/bin/ftp /usr/share/man/man1/ftp.1.gz
Q.6:當(dāng)用戶登錄時,默認(rèn)情況下哪些文件會被調(diào)用作為用戶配置?
答:在用戶的目錄下‘.profile’和‘.bashrc’會默認(rèn)地被調(diào)用作為用戶配置。
- [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:哪一條命令是用來創(chuàng)建一個文件的軟鏈接的?
- ln
- ln -s
- link
- link -soft
- 以上都不是
答:在 Linux 環(huán)境下,‘ls -s’是被用來創(chuàng)建一個文件的軟鏈接的。
- [root@tecmint ~]# ln -s /etc/httpd/conf/httpd.conf httpd.original.conf
Q.9:在Linux下,‘pwd’命令是‘passwd’命令的別名嗎?
答:不是!默認(rèn)情況下‘pwd’命令不是‘passwd’命令的別名。‘pwd’是‘print working directory’(顯示工作目錄)的縮寫,也就是輸出當(dāng)前的工作目錄,而‘passwd’在 Linux 中是被用來更改用戶的帳號密碼。
- [root@tecmint ~]# pwd
- /home/tecmint
- [root@tecmint ~]# passwd
- Changing password for user root.
- New password:
- Retype new password:
Q.10:在 Linux 中,你會怎樣檢測 pci 設(shè)備的廠商和版本。
答:我們用的 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)
- ...
現(xiàn)在就到這里。我希望以上的問題也許對你很有用。在下星期我會再想出一些新的問題。到時請保持好的健康,繼續(xù)關(guān)注我們并且與 Tecmint 保持聯(lián)系喔!
via: http://www.tecmint.com/basic-linux-interview-questions-and-answers-part-ii/