Linux directory structure and common commands __linux

Source: Internet
Author: User
Tags system log reverse dns

first, Linux directory structure


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 Linux file system architecture and understand the meaning of each upper directory.

Blue: Presentation Directory

Cyan: Indicates link

Black: Representing files

1,/-root
Each file and directory starts from the root directory.
Only the root user has write permissions in the directory. Please note that/root is the home directory of the root user, 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 located here.
For example: PS, ls, ping, grep, CP

3,/sbin directory-system binary files
Just like/bin,/sbin also contains binary executables.
However, Linux commands in this directory are typically used by system administrators to maintain the system. For example: Iptables, reboot, Fdisk, ifconfig, Swapon command

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

Hosts: The device name (or domain name) to the IP address resolution, equivalent to the existence of local DNS functions. See figure below:

5/Dev -Equipment 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 that is relevant to a particular PID.
This is a virtual file system, the system resources in the form of text information. For example:/proc/uptime

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

8./tmp -Temporary documents
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 for the user program. If you can't find the user binaries in the/bin, go to the/usr/bin directory. For example: At, awk, CC, less, SCP.
The/usr/sbin contains the system administrator's binary files. If you can't find the system binaries in the/sbin, go to the/usr/sbin directory. For example: ATD, Cron, sshd, Useradd, Userdel.
The/usr/lib contains libraries used by/usr/bin and/usr/sbin.
The/usr/local contains user programs that are installed from the source. For example, when you install Apache from the source, it will be in/usr/local/apache2.

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

11,/boot -Boot loader files
Contains the files associated with the bootstrap loader.
The kernel's initrd, vmlinux, 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 binaries located under/bin and/sbin.
Library file name is ld* or lib*.so.*
For example: ld-2.11.1.so,libncurses.so.5.7

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

14,/mnt -Mount Directory
The temporary installation directory allows the system administrator to mount the file system.

15,/media -removable media device
A temporary directory 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.& Nbsp;/lib 1.10. /lost+found 1.11. /media 1.12. /mnt 1.13. /opt 1.14. /proc 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 documentation License. GNU Free 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 the License for your documents

ii. Common Commands

1. Order Help
2, users
3. SHELL
4, display hard disk, partition, CPU, memory information
5, Network
6. Process
7, Documents1. Order Help[root@localhost ~] #man PS2, users$finger Username Displays information about the user username
$who Display the current login user
$who am I
$su become the root user
$sudo command executes as root
$PASSWD Change Password3. SHELL$history Display command history under the current shell
$alias Show all the commands alias
$alias new_command= ' command ' to call New_command
$env Show all the environment variables
$export var=value Set environment variable var to value4, display hard disk, partition, CPU, memory information$DF-LH Displays the usage of all hard disks $du-sh * Displays the size of each directory and file under the current directory $mount Show all hard disk partition mounts
$mount partition path hangs in partition path
$umount Partition Uninstall partition
$sudo fdisk-l Show All the partitions
$sudo fdisk device creates a partitioned table for device (such as/DEV/SDC). Select N, p, w after entering
$sudo mkfs-t ext3 partition format partition patition (e.g./DEV/SDC1)
Modify the/etc/fstab to mount the partitions automatically. Add Line:
/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 usage5, Network$ifconfig Display the network interface and the corresponding IP address. Ifconfig can be used to set up network interfaces
$ifup eth0 Run Eth0 interface
$ifdown eth0 shutdown eth0 Interface
$iwconfig Show Wireless network interface
$route Display the routing table. Route can also be used to modify the routing table
$netstat Display the current network connection status
$ping IP Send ping packet to address IP
$traceroute IP Probe routing path to address IP
$dhclient send DHCP requests to the DHCP host to obtain IP addresses and other settings information.
$host domain DNS query to find the IP domain
$host IP Reverse DNS Query
$wget URL uses wget to download the resource that the URL points to
$wget-m URL mirroring download6. Process$top display process information and update it in real time
$ps Show processes under the current shell
$ps-lu username Display the user username process
$ps-AJX shows all processes in a more complete format
$kill PID kill PID Process (PID for process ID)7, Documents$touch filename If the file does not exist, create a blank file, and update the file read and modify time if the file exists.
Delete file $rm filename
$CP file1 file2 copy File1 as File2
$ls-L path displays file and file-related information
Create dir folder $mkdir dir
$mkdir-P path recursion creates all folders on the path path
$rmdir dir Deletes the dir folder, dir must be an empty folder.
$rm-R dir deletes the Dir folder and all the files it contains
$file filename File filename type description
$chown username:groupname filename To change the owner of the file owner, with group
$chmod 755 filename Changes the file's permissions to 755:owner r+w+x, Group:r+x, others:r+x
$od-c filename displays files in ASCII characters

Display files $cat filename
$cat file1 file2 Connection shows File1 and file2
$head-1 filename Displays the first line of the file
$tail-5 filename Displays the fifth line of the countdown 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 duplicated in file filename (same content, but not adjacent rows, not duplicates)
Number of characters, words, and rows in the $WC filename statistics file
Number of rows in $WC-l filename Statistics file

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.