歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux基礎 >> Linux技術 >> linux目錄結構常用命令詳細總結

linux目錄結構常用命令詳細總結

日期:2017/3/3 11:03:41   编辑:Linux技術
linux目錄結構圖
[root@localhost ~]# tree -L 1 /
/
├── bin
├── boot
├── dev
├── etc
├── home
├── lib
├── lost+found
├── media
├── mnt
├── opt
├── proc
├── root
├── sbin
├── selinux
├── srv
├── sys
├── tmp
├── usr
└── var




1、/- 根目錄
存放系統相關的程序,也就是At&t開發的Unix程序。每一個文件和目錄從根目錄開始。只有root用戶具有該目錄下的寫權限。
2、/usr 目錄
存放Unix系統商(比如IBM 和 HP)開發的程序。有關usr的定義,我們根據存放的數據反推,可以理解為usr,當然有的文章說是unix software resource,但是老師在FHS目錄層次標准中未查到以上的兩種說法。因此,上述兩種說法都是為了記憶而定,糾結到底是哪個無太大意義。
3、/usr/local 目錄
存放用戶自己安裝的程序,相當於c:/program files。一般編譯軟件的時候默認路徑,yum或rpm包安裝就不是這裡了。
4、/opt 目錄
在某些系統,用於存放第三方廠商開發的程序,所以取名為option,意為“選裝”。
5、/bin 目錄
(Essential user command binaries(for use by all users)),常用二進制命令所在的目錄。比如ls、cp、mkdir、rm、cut等命令:/bin目錄和/usr/bin類似。
[root@localhost ~]# which cat
/bin/cat
[root@localhost ~]# which mkdir
/bin/mkdir
There must be no subdirectories in /bin
The following commands,or symbolic links to commands,are required in /bin.
Command description
cat --->concatenate files to standard output
chgrp --->change file group ownership
chmod --->change file access permissions
chown --->change file owner and group
cp --->copy files and directories
date --->print or set the system data and time
dd --->convert and copy a file
df --->report filesystem disk space usage
dmesg --->print or control the kernel message buffer
echo --->display a line of text
false --->do nothing,unsuccessfully
hostname --->show or set the system's host name
kill --->send signals to processes
ln --->make links between files
login --->begin a session on the system
ls --->list directory contents
mkdir --->make directories
mknod --->make block or character special files
more --->page through text
mount --->mount a filesystem
mv --->move/rename files
ps --->report process status
pwd --->print name of current working directory
rm --->remove files or directories
rmdir --->remove empty directories
sed --->The 'sed' stream editor
sh --->The Bourne command shell
stty --->change and print terminal line settings
su --->change user ID
sync --->flush filesystem buffers
true --->do nothing, successfully
umount --->unmount file systems
uname --->print system information
6、/boot 目錄
(Static files of the boot loader)Linux 的內核及引導系統程序所需的文件目錄。安裝系統分區的時候一般要分一個boot分區。常見分區:/boot 128M swap內存的1.5倍 /全給。The operating system kernel must be located in eithe /or /boot
[root@localhost man]# ll /boot/
總用量 25597
-rw-r--r--. 1 root root   111786 7月  23 2015 config-2.6.32-573.el6.i686
drwxr-xr-x. 3 root root     1024 3月   8 05:26 efi
drwxr-xr-x. 2 root root     1024 3月   8 05:31 grub
-rw-------. 1 root root 19754536 3月   8 05:31 initramfs-2.6.32-573.el6.i686.img
drwx------. 2 root root    12288 3月   8 05:23 lost+found
-rw-r--r--. 1 root root   202247 7月  23 2015 symvers-2.6.32-573.el6.i686.gz
-rw-r--r--. 1 root root  2034619 7月  23 2015 System.map-2.6.32-573.el6.i686
-rwxr-xr-x. 1 root root  4081728 7月  23 2015 vmlinuz-2.6.32-573.el6.i686
[root@localhost man]# LANG=en
[root@localhost man]# tree /boot
7、/dev 目錄
(Device files)設備文件的目錄,比如聲卡、磁盤、光驅......。The following devices must exist under /dev
/dev/null(cat /dev/null >/oldboy/test.txt 清空文件的方法)
All date written to this.device is discarded. A read from this device will return an EOF condition
/dev/zero
This device is a source of zeroed out data.All data written to this discarded.A read from this
/dev/tty
This device is a synonym for the controlling terninal of a process.Once the device
8、/etc 目錄
(Host-specific system configuraation)
(1)二進制安裝包(yum,rpm)的配置文件默認路徑和
exports --->NFS filesystem access control list(optional)
fstab --->Static information about filesystems(optional)
hosts --->Static information about host names(optional)
inittab --->Configuration file for init(optional)
issue --->Pre-login message and identification file(optional)
ld.so.conf --->List of extra directories to search for shared libraries(optional)
motd --->Post-login message of the day file(optional)
networks --->Static information about network names(optional)
passwd --->The password file(optional)
profile --->Systemwide initialization file for sh shell logins(optional)
resolv.conf --->Resolver configuration file(optional)
services --->Port names for network services(optional)
syslog.conf --->Configuration file for syslogd(optional)
(2)服務啟動命令存放的目錄/etc/init.d/(yum,rpm)。
[root@localhost man]# ls -l /etc/init.d
lrwxrwxrwx. 1 root root 11 Mar  8 05:25 /etc/init.d -> rc.d/init.d
9、/home 目錄
(User home directories(optional))普通用戶的家目錄默認數據存放目錄。
10、/lib 目錄
(Essential shared libraries and kernel modules)庫存文件存放目錄
The /lib directory contains those shared library images needed to boot the system and run the commands in the root filesystem,ie.by binaries in/bin and /sbin
[root@localhost ~]# ll /lib
lib/ lib64
[root@localhost ~]# ll /lib
lib/ lib64
/lib64 and /lib32: 64/32-bit libraries(architecture dependent)
The 64-bit architectures PPC64.sparc64 and AMD64 must place 64-bit libraries in /lib64 and 32-bit
(or 31-bit on s390)libraries in/lib
The 64-BIT ARCHITECTURE la64 MUST PLACE 64-bit libraries in /lib
11、lost+found 目錄
在ext3文件系統中,當系統意外崩潰或機器意外關機,會產生一些文件碎片在這裡。當系統在開機啟動的過程中fsck工具會檢查這裡,並修復已經損壞的文件系統。當系統發生問題,可能會有文件被移支這個目錄中,可能需要用手工的方式來修復,或移到文件到原來的位置上。
12、/mnt 目錄
(Mount point for mounting a filesystem temporarily)一般是用於臨時掛載目錄的,比如有edrom,u盤等目錄。直接插入光驅無法使用,要先掛載後使用。掛載點-->文件系統的(設備)入口。
13、/opt(option) 目錄
(Add-on application software packages)表示的是可選擇的意思,有些軟件包也會被安裝在這裡,也就是自定義軟件包,我們自己編譯的軟件包,就可以安裝在這個目錄中;通過源碼包安裝的軟件,可以通過./configure --prefix=/opt/目錄,非必須這樣,視習慣或規范而定。
14、/proc 目錄
Kernel and process information virtual filesystem
The proc filesystem is the de-facto standard Linux method for handling process and system information,rather than /dev/kmem and other similar methods. We strongly encourage this for the storage and retrieval of process information as well as other kernel and memory information.
操作系統運行時,進程信息及內核信息(比如cpu、硬盤分區、內存信息等)存放在這裡。/proc目錄偽裝的文件系統proc的掛載目錄,proc 並不是真下的文件系統,它的定義可以參見/etc/fstab。
[root@localhost ~]# grep proc /etc/fstab
proc                    /proc                   proc    defaults        0 0
[root@localhost ~]# cat /proc/loadavg
0.00 0.00 0.00 1/137 1785
比較常見的/proc下面的內容:
cat /proc/meminfo
cat /proc/cpuinfo
cat /proc/loadavg
15、/root 目錄
(Home directory for the root user (optional))Linux超級權限用戶root的家目錄;win32管理員administrator。
16、/sbin 目錄
(Essential system binaries)大多是涉及系統管理的命令的存放,是超級權限用戶root的可執行命令存放地,這個目錄和/usr/sbin;/usr/X11R6/sbin或/usr/local/sbin目錄是相似的;
Command Description
fdisk --->Partition table manipulator(optional)
fsck --->File system check and repair utility(optional)
halt --->Command to stop the system(optional)
ifconfig --->Configure a network interface(optional)
init --->lnitatial process(optional)
mkfs --->Command to build a filesystem(optional)
mkfs.* --->Command to build a specific(optional)
mkswap --->Command to set up a swap area(oaptional)
reboot --->Command to reboot the system(optional)
route --->IP routing table utility(optional)
swapon --->Enable paging and swapping(optional)
swapoff --->Disable paging and swapping(optional)
Linux systems place these additional files into /sbin
Second extended filesystem commands(optiona);
badblocks
dumpe2fs
e2fsck
mke2fs
mklost+found
tune2fs
特別提示:對於5.X的系統,直接ifconfig是無法出結果的。
17、/tmp 目錄
(Temporary files)臨時文件目錄,有時用戶運行程序的時候,會產生臨時文件。/tmp就用來存放臨時文件的,權限比較特殊。/var/tmp目錄和這個目錄相似。
[root@localhost ~]# ls -ld /tmp/
drwxrwxrwt. 3 root root 4096 Jul 29 22:29 /tmp/
18、/usr 目錄
(Secondary hierarchy)這個是系統存放程序的目錄,比如命令、幫助文件等。這個目錄下有很多的文件和目錄。當我們安裝一個Linux發行版官方提供的軟件包時,大多安裝在這裡。
/usr is the second major section of the filesystem./usr is shareable,read-only data.That means that /usr should be shareable between various FHS-compliant hosts and must not be written to.Any information that is host-specific or varies with time is stored elsewhere.Large software packages must not use a direct subdirectory under the /usr hierarchy.
如果有涉及服務器配置文件的,會把配置文件安裝在/etc 目錄中。
Directory Description
/usr/bin --->Most user commands 用戶可執行文件目錄
/usr/include --->Header files included by C programs 程序的頭文件存放目錄
/usr/lib --->Libraries
/usr/local --->Local hierarchy(empty after main installation)
/usr/local/sbin
/usr/local/bin
/usr/sbin --->Non-vital system binaries
/usr/share --->Architecture-independent data
/usr/share/fonts --->字體目錄
/usr/share/man --->幫助目錄
/user/src:Source code(optional)<---程序源碼目錄
19、/var 目錄
(Variable data)這個目錄的內容是經常變動的,我們可以理解為vary的縮寫,/var 下有/var/log 這是用來存放系統日志的目錄,系統日志路徑/var/log/messages。/var/www目錄是定義Apache服務器站點存放目錄;/var/lib用來存放一些庫文件,比如MySQL的,以及MySQL數據庫的存放地;
Directory Description
/var/cache --->Application cache data
/var/lib --->Variable state information
/var/local --->Variable data for /usr/local
/var/lock --->Lock files
/var/log --->Log files and directories
/var/log/lastlog --->record of last login of eachuser
/var/log/messages --->system messages form syslogd(系統日志文件)
/var/log/secure --->system secure messages
/var/log/wtmp --->record of all logins and logouts
/var/opt --->Variable data for /opt
/var/run --->Data relevant to running processes
--->Run-time variable data
/var/spool --->Application spool data
/var/spool/cron:cron and at jobs(定時任務的配置文件路徑)
This directory contains the cron and at programs.
/var/tmp --->Temporary files preserved between system reboots
總的小結:
/dev/ 設備目錄
/etc/ 配置文件以及服務啟動的目錄
/proc 顯示內核及進程信息虛擬文件系統
/tmp 臨時文件目錄
/home 普通用戶家目錄
/var 變化目錄,一般日志文件的目錄。
/usr 用戶程序,及數據,幫助文件等的目錄。
/bin和/sbin和/usr/sbin 用戶命令的目錄
Directory Description
bin Essential command binaries
boot Static files of the boot loader
dev Device files
etc Host-specific system configuration
lib Essential shared libraries and kernel modules
media Mount point for removeable media
mnt Mount point for mounting a filesystem temporarily
opt Add-on application software packages
sbin Essential system binaries
srv Data for services provided by this system
tmp Temporary files
usr Secondary hierarchy
var Variable data
網絡
ifconfig 顯示網絡接口以及相應的IP地址。ifconfig可用於設置網絡接口
ifup eth0 運行eth0接口
ifdown eth0 關閉eth0接口
iwconfig 顯示無線網絡接口
route 顯示路由表。route還可以用於修改路由表
netstat 顯示當前的網絡連接狀態。
ping IP 發送ping包到地址IP
traceroute IP 探測前往地址IP的路由路徑
dhclient 向DHCP主機發送DHCP請求,以獲得IP地址以及其他設置信息
host domain DNS查詢,尋找域名domain對應的IP
host IP 反向DNS查詢
wget url 使用wget下載url指向的資源
wget -m url 鏡像下載
進程
top 顯示進程信息,並實時更新
ps 顯示當前shell下的進程
ps - lu username 顯示用戶username的進程
ps - ajx 以比較完整的格式顯示所有的進程
kill PID 殺死PID進程(PID為Process ID)
重要子目錄的說明
1、/etc/sysconfig/network-scripts/ifc-eth0
#->配置網絡地址及GW等,使得網卡生效
(1)重啟網卡/etc/init.d/network restart (所有網卡)
(2)ifdown eth0&&ifup eth0。只針對eth0網卡
通過setup-“network configuration” 修改網卡配置就是在改這個文件。
設置文件ifcfg-interface-name包含了初始化接口所需的大部分周詳信息。其中interface-name將根據網卡的類型和排序而不同,0表示第一塊網卡,1表示第二塊網卡,而ppp0則表示第一個point-to-poirt protocol網絡接口。在ifcfg文件中定義的各項目取決於接口類型。
下面的值比較常見:
DEVICE=name, 其中,name是物理設備名。
IPADDR=addr,其中,addr是IP地址。
NETMASK=mask,其中,mask是網絡掩碼值。
NETWORK=addr,其中addr是網絡地址
BROADCAST=addr,其中addr是廣播地址
GATEWAY=addr,其中addr是網關地址
ONBOOT=answer,answer是yes(引導時激活設備)或no(引導時不激活設備)
USERCTL=answer,其中answer是yes(非root用戶能控制該設備)或no
BOOTPROTO=proto,其中proto取下列值之一:none引導時不使用協議;static靜態分配地址;bootp,使用BOOTP協議,或dhcp,使用DHCP協議。
2、/etc/resolv.conf
#--->設置linux本地的客戶端DNS的文件,DNS可以實現域名和IP的互相解析。
3、/etc/hosts
#--->設定用戶IP與名字(或域名)的對應解析表,相當於本地LAN內DNS。
#--->類似C:\WINDOWS\system32\drivers\etc\hosts,LAN內IP域名解析文件。開發、測試 時常用,英文hosts-The static table lookup for host names。host 的解析在機房的服務器互相調用中也會常用,如門戶網站的解析真實案例。
1、用於通過域名測試。
2、服務器之間的調用可以用域名(內部的DNS).
4、/etc/sysconfig/network
#--->或修改機器名及網卡啟動,網關等配置。
5、/etc/fstab
#--->記錄開機要mount的文件系統的一個文件。/etc/rc.local
6、/etc/rc.local
存放開機自啟動程序命令的文件。(chkconfig只能管理yum/rpm安裝的程序的啟動服務)
7、/etc/inittab
#--->設定系統啟動時 init 進程將把系統設置成什麼樣的 runlevel及加載相關的啟動文件設置。Linux開機啟動流程
8、/etc/exports
#-->設定NFS網絡文件系統用的配置文件。
9、/etc/init.d
#--->這個目錄是用來存放系統或服務器以 System V 模式啟動的腳本,這在以 System V 模式啟動或初始化的系統中常見。比如 Centos/RedHat;
[root@localhost ~]# ll /etc/init.d
lrwxrwxrwx. 1 root root 11 3月   8 06:54 /etc/init.d -> rc.d/init.d
10、/etc/xinit.d
#--->如果服務器是通過xinetd模式運行的,它的腳本要放在這個目錄下。有些系統沒有這個目錄,比如Slackware,有些老的版本也沒有。在Rehat/Fedora 中比較新的版本中存在
[root@localhost ~]# ll /etc/init.d
lrwxrwxrwx. 1 root root 11 3月   8 06:54 /etc/init.d -> rc.d/init.d
11、/etc/profile
#--->系統全局環境變量配置路徑
alias rm=
PATH變量
12、/etc/profile.d
#--->加載系統登陸程序一個目錄,命令或文件獨立存在!
本文出自 “檸檬草的味道” 博客,請務必保留此出處http://huyaping.blog.51cto.com/11299841/1832063
Copyright © Linux教程網 All Rights Reserved