RPM: Linux directory structure and common commands

Source: Internet
Author: User
Tags system log reverse dns

Turn from: http://www.cnblogs.com/JCSU/articles/2770249.html for learning reference only

First, the Linux directory structure


Do you want to know why some programs are located under/bin, or/sbin, or/usr/bin, or/usr/sbin directories? For example, the less command is located in the/usr/bin directory. Why not in/bin, or/sbin, or/usr/sbin directory? What is the difference between all these directories?

In this article, let's review the file system architecture of Linux and understand the meanings of the top-level directories.

Blue: Indicates directory

Cyan: Indicates a link

Black: Indicates file

1,/-root
Each file and directory starts with the root directory.
Only the root user has write permissions to the directory. Please note that/root is the root user's home directory, which is not the same as/.

2,/bin -user binary files
Contains a binary executable file.
In single-user mode, the common Linux commands you need to use are located in this directory. The commands used by all users of the system are set here.
For example: PS, ls, ping, grep, CP

3./sbin Directory-System binaries
Just like/bin,/sbin also contains binary executables.
However, Linux commands in this directory are usually used by system administrators to maintain the system. Example: Iptables, reboot, Fdisk, ifconfig, swapon commands

4./etc -configuration file
Contains the configuration files that are required for all programs.
It also contains startup and shutdown shell scripts for starting/stopping a single program. For example:/etc/resolv.conf,/etc/logrotate.conf

Hosts: The resolution of the device name (or domain name) to the IP address, equivalent to the local presence of DNS functionality. See:

5./Dev -device files
Contains device files.
These include terminal equipment, USB or any device connected to the system. For example:/dev/tty1,/dev/usbmon0

6./proc -Process information
Contains information about the system process.
This is a virtual file system that contains information about the processes that are running. For example: The/proc/{pid} directory contains information related to a specific PID.
This is a virtual file system in which system resources exist as textual information. Example:/proc/uptime

7./var -variable file
var represents a variable file.
This directory allows you to find files that may grow in content.
This includes-system log files (/var/log), Package and database files (/var/lib), e-mail (/var/mail), print queue (/var/spool), lock Files (/var/lock), multiple restarts of required temporary files (/var/tmp) ;

8./tmp -temp file
Contains system and user-created temporary files.
When the system restarts, the files in this directory will be deleted.

9./usr -user program
Source code that contains binaries, library files, documents, and level two programs.
The/usr/bin contains a binary file of the user program. If you can't find the user binaries in/bin, go to the/usr/bin directory to see. For example: At, awk, CC, less, SCP.
The/usr/sbin contains the system administrator's binaries. If you can't find the system binaries in/sbin, go to the/usr/sbin directory to see it. For example: ATD, Cron, sshd, Useradd, Userdel.
The/usr/lib contains the libraries used by/usr/bin and/usr/sbin.
The user program installed from the source is included in the/usr/local. For example, when you install Apache from the source, it will be in/usr/local/apache2.

10. /home Directory
All users use the home directory to store their personal files.
For example:/home/john,/home/nikita

11./boot -Boot loader file
Contains the boot loader-related files.
The kernel's initrd, vmlinux, and grub files are located under/boot.
For example: Initrd.img-2.6.32-24-generic, Vmlinuz-2.6.32-24-generic

12./lib -System Library
Contains library files that support binary files located under/bin and/sbin.
The library file is named ld* or lib*.so.*
Example: ld-2.11.1.so,libncurses.so.5.7

13,/opt -Optional add-on app
OPT stands for optional.
Contains additional applications from individual vendors.
Additional applications should be installed in subdirectories of/opt/or/opt/.

14,/mnt -Mount Directory
A temporary installation directory where the system administrator can mount the file system.

15./media -removable media device
A temporary directory that is used to mount removable devices.
For example, mount the CD-ROM/media/cdrom, mount the floppy disk drive/media/floppy;

16./srv -Service data
The SRV Representative service.
Contains data related to server-specific services.
For example,/srv/cvs contains CVS-related data.

Reference

Linux Filesystem Hierarchy

Source and pre-formatted versions available 1. Linux Filesystem Hierarchy

1.1. Foreward
1.2. The Root Directory
1.3. /bin
1.4./ Boot
1.5./ Dev
1.6. etc
1.7. /Home
1.8. /INITRD
1.9. /lib
1.10. /lost+found
1.11. /media
1.12. /mnt
1.13. /opt
1.14. /proc
1.15. /root
1.16. /sbin
1.17./ usr
1.18./ var
1.19. /srv
1.20./ tmp

Glossary A. UNIX System V signals B. Sources c. about the Author D. Contributors E. Disclaimer F. Donations G. Feedback H. GNU free documentation License

H.1. Preamble
H.2. Applicability and Definitions
H.3. Verbatim COPYING
H.4. COPYING in QUANTITY
H.5. Modifications
H.6. Combining DOCUMENTS
h.7. collections of DOCUMENTS
H.8. AGGREGATION with independent WORKS
H.9. translation
h.10. termination
h.11. Future revisions of this LICENSE
h.12. Addendum:how to use this License for your documents

Ii. Common Commands

1. Command Help
2. Users
3. SHELL
4, display hard disk, partition, CPU, memory information
5. Network
6. Process
7. Documents

1. Command Help
[[Email protected] ~] #man PS
2. Users
$finger Username Display user username information
$who show current logged in user
$who am I
$su become the root user
$sudo command executes as the root user
$PASSWD Change your password
3. SHELL
$history Show command history under the current shell
$alias Show all the commands for the nickname
$alias new_command= ' command ' is called New_command
$env Show all the environment variables
$export var=value Set environment variable var to value
4, display hard disk, partition, CPU, memory information
$DF-LH Show the usage of all hard drives
$du-sh * Displays the size of each directory and file in the current directory
$mount Show all hard disk partition mounts
$mount partition path hangs on partition path
$umount Partition Uninstall partition
$sudo fdisk-l Show All the partitions
$sudo fdisk device to create a partitioned table for device (such as/DEV/SDC). After entering, select N, p, W
$sudo mkfs-t ext3 partition formatted partition patition (e.g./DEV/SDC1)
Modify the/etc/fstab to mount the partition automatically. Add Rows:
/DEV/SDC1 Path (mount point) ext3 defaults 0 0
$arch Display Schema
$cat/proc/cpuinfo Display CPU Information
$cat/proc/meminfo Display Memory information
$free Show Memory usage
5. Network
The $ifconfig displays the network interface and the corresponding IP address. Ifconfig can be used to set the network interface
$ifup eth0 running Eth0 interface
$ifdown eth0 Close the Eth0 interface
$iwconfig Show Wireless network interface
$route Show the routing table. The route can also be used to modify the routing table
$netstat Display the current network connection status
Send ping packets to address IP $ping IP
$traceroute IP Probe routing path to address IP
$dhclient send DHCP requests to the DHCP host for IP addresses and other setup information.
$host domain DNS query to find the IP
$host IP Reverse DNS Query
$wget URL uses wget to download the resource that the URL points to
$wget-m URL image download
6. Process
$top display process information and update it in real time
$ps shows the process under the current shell
$ps-lu username shows the process of user username
$ps-AJX Show All processes in a more complete format
$kill PID kills the PID process (PID is the process ID)
7. Documents
$touch filename    If the file does not exist, create a blank file, or update the file read and modify times if the file exists.
$rm filename       Delete files
$cp file1 file2    copy file1 to File2
$ls -l path        displaying file and file-related information
$mkdir dir          Create dir folder
$mkdir-P path     recursively create paths to all folders on path
$rmdir dir   & nbsp;     Delete dir folder, dir must be an empty folder.
$rm-R dir         Delete the Dir folder and all files it contains
$file filename      file filename type description
$chown username:groupname filename    The owner of the changed file is owner, and owns group
$ chmod 755 filename Change the permissions for a file to 755:owner r+w+x, group:r+x, others:r+x
$od-C filename    display the file in ASCII characters /dt>

$cat filename Display file
$cat file1 file2 Connection displays file1 and File2
$head-1 filename Displays the first line of the file
$tail-5 filename Displays the fifth line of the file
$diff file1 file2 shows the difference between File1 and file2
$sort filename to sort the rows in the file and display
$sort-f filename is sorted regardless of case
$sort-u filename Sort, and remove duplicate rows
$uniq filename Displays the rows that are not duplicates in the file filename (the same content but not adjacent rows, not duplicates)
$WC the number of characters, words, and lines in the filename statistic file
$WC the number of rows in the-l filename statistic file

RPM: Linux directory structure and common commands

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.