Summary of linux related commands

Jun 20, 2017 pm 01:18 PM
linux Order

I have been studying for a while and want to sort out what I have written before. If there is any incompleteness, I will slowly add it later

[1]Linux Notes:

  • Strictly case-sensitive

  • Linux commands are distinguished; file names are also strictly case-sensitive;

  • Linux is all Lowercase;

  • All content in Linux is saved in file form, including hardware

Hardware file/dev/sd[a-p]

The CD file is /dev/sr0

  • Linux has no extension

  1. #Compressed package: .gz, .bz , .tar.bz2,

  2. Script: .sh

  3. Configuration file: .conf

  4. Webpage files: .html, .php

  5. Webpage files: .html, .php

    ## All Linux storage devices must be mounted before they can be used, including hard disks, U disks and optical disks
  • 【2】Linux directory:

    • /bin
      bin is Abbreviation for Binary, this directory stores the most frequently used commands.

    • /boot:
      Stored here are some core files used when starting Linux, including some connection files and image files.

    • /dev:
      dev is the abbreviation of Device. This directory stores Linux external devices. Access the device in Linux. The way to access files is the same.

    • /etc:
      This directory is used to store all configuration files and subdirectories required for system management.

    • /home:
      The user’s home directory. In Linux, each user has his own directory. Generally, the directory name is based on the user named after the account.

    • /lib:
      This directory stores the most basic dynamic link shared library of the system, and its function is similar to the DLL file in Windows. Almost all applications require these shared libraries.

    • /lost+found:
      This directory is usually empty. When the system is shut down illegally, some files are stored here.

    • /media
      The Linux system will automatically recognize some devices, such as U disks, optical drives, etc. After recognition, Linux will Mount it in this directory.

    • /mnt:
      The system provides this directory to allow users to temporarily mount other file systems. We can mount the optical drive in /mnt /, and then enter the directory to view the contents of the CD-ROM drive.

    • /opt
      This is the directory where additional software is installed for the host. For example, if you install an ORACLE database, you can put it in this directory. The default is empty.

    • /proc:
      This directory is a virtual directory, which is a mapping of system memory. We can obtain system information by directly accessing this directory. .
      The content of this directory is not on the hard disk but in the memory. We can also directly modify some files in it. For example, we can use the following command to block the ping command of the host so that others cannot ping your machine:

      echo 1 > /proc/sys/net/ipv4/icmp_echo_ignore_all
      Copy after login
    • /root:
      This directory is the user home directory of the system administrator, also known as the super authority.

    • /sbin:
      s means Super User. The system management program used by the system administrator is stored here.

    • /selinux
      This directory is unique to Redhat/CentOS. Selinux is a security mechanism, similar to the Windows firewall, but this The mechanism is more complicated. This directory stores selinux-related files.

    • /srv:
      This directory stores some data that needs to be extracted after the service is started.

    • /sys
      This is a big change in the linux2.6 kernel. A new file system sysfs that appeared in the 2.6 kernel is installed in this directory.

      The sysfs file system integrates the information of the following three file systems: the proc file system for process information, the devfs file system for devices, and the devpts file system for pseudo terminals.

      This file system is an intuitive reflection of the kernel device tree.

      When a kernel object is created, the corresponding files and directories are also created in the kernel object subsystem.

    • /tmp:
      This directory is used to store some temporary files.

    • /usr
      This is a very important directory. Many of the user's applications and files are placed in this directory, similar to Windows. program files directory.

    • /usr/bin:
      Applications used by system users.

    • /usr/sbin:
      A relatively advanced management program and system daemon used by super users.

    • /usr/src: The default placement directory for kernel source code.

    • /var:
      This directory stores things that are constantly expanding. We are used to placing directories that are frequently modified in this directory. . Includes various log files.

    In the Linux system, there are several directories that are relatively important. You need to be careful not to accidentally delete or change internal files at will.

    /etc: As mentioned above, this is the configuration file in the system. If you change a file in this directory, the system may not start.

    /bin, /sbin, /usr/bin, /usr/sbin: This is the system’s default directory for placing executable files. For example, ls is in the /bin/ls directory.

    It is worth mentioning that /bin and /usr/bin are commands for system users (normal users except root), while /sbin and /usr/sbin are commands for root.

    /var: This is a very important directory. There are many programs running on the system, so each program will have corresponding logs, and these logs are recorded in this directory, specifically in the /var/log directory Next, the default placement of mail is also here.


    【3】lsCommand

    • ls View the current File

    • ls -a View all files, including . and .. File

    • ls -A View all files, excluding . and .. files

    • ls -l View files to display file attributes, including file owners, all groups , permissions, creation time, etc.

    Example: -rw-------. 1 root root 1191 May 21 17:45 anaconda- ks.cfg

  1. -: represents ordinary file

  2. d: file directory

  3. l: Soft link

rread w write x execute
three bytes per permission
rw- r-- r--
u Owner user g Group to which group o others other
1) 1 represents the citation coefficient
3) The third part is the owner
4) The fourth part is Group to which it belongs
5) The fifth part of the file size in bytes
6) The last modification time of the file
7) Part of the file name
  • The difference between ls -lh and ls -l is the size of the file

Example: -rw-------. 1 root root 1.2K May 21 17:45 anaconda-ks.cfg
  • ls -i query File i node, file unique identifier

Example: 262497 anaconda-ks.cfg 262147 install.log 262148 install.log.syslog
【4】Directory processing command
  • mkdir creates directory

  • mkdir -pCreate multi-level directories

  • touch create files

  • ##rmdir Delete directory

  • rm -r Delete directory

  • rm Delete file

  • rm -rf force deletion, no confirmation required

  • cp Copy the file: cp to The destination directory for the copied files to be copied

  • cp -rCopy the file and rename it

  • mv Switch filemv Switch the file to the switching destination

  • pwd Display the current directory

  • file: Read r: cat, more, less, head, tail

    ## Write w: vim
  • Execute x: scrip, command
  • directory Read: ls
  • Write: touch, mkdir , rmdir, rm
  • Execution: cd
【5】
Permission management command
  1. chmod [ugoa +-=] [file or directory]

  2. chmod 777 file name
  3. chgrp changes the group to which the file belongs chgrp [user group] [file or directory]
  4. umsk -S displays the default permissions of the file

    u:userowner
  • g: The group to which group belongs
  • o:otherOthers
  • a:allEveryone
  • Use Numbers represent permissions: r--4 w--2 x--1 rwx:[421]:7 rw-[420]:6 r--[400]:4
【6】
File search command
find [Search range] [Matching conditions]
  • find / etc -name init: Only init

  • appears in the file name find /etc -name *init*: The file name contains init
  • find /etc -name init*: The file name starts with init
  • find /etc -name init???: The file name starts with init and is followed by three characters
  • find /etc -iname init???: File name search is not case sensitive
  • find /etc -size +204800: By file name Size search + means the search element is greater than - means the search is less than the file size. According to the data block, one data block is 0.5k, then 100M=102400k=204800 data blocks
[7 】
Help command
  • man [Command or configuration file]

  • man ls

  • ## /Configuration options

  • more /etc/services: View configuration file

  • man services

  • whatis Command: Check the fate

  • apropos configuration file: only view the configuration file content

  • Command--help

【8】

Change the system time

  • 1. Date: View the system time

  • 2 ,[root@localhost ~]# date 020612214317.33

  • ##Tue Feb 6 12:21:33 CST 4317
  • [root@ localhost ~]# date 0612214317.33//////month, day, hour, minute, year.second

  • ##Mon Jun 12 21:43:33 CST 2017
  • 【9】
  • File compression format

1, .gz compression format
  • Compressed file: gzip file name
  • Decompressed file: gunzip file name
  • gzip -d file
  • Compressed directory: tar -cvf generated directory Directory to be packaged

The above is the detailed content of Summary of linux related commands. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: How To Unlock Everything In MyRise
1 months ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

What is Linux actually good for? What is Linux actually good for? Apr 12, 2025 am 12:20 AM

Linux is suitable for servers, development environments, and embedded systems. 1. As a server operating system, Linux is stable and efficient, and is often used to deploy high-concurrency applications. 2. As a development environment, Linux provides efficient command line tools and package management systems to improve development efficiency. 3. In embedded systems, Linux is lightweight and customizable, suitable for environments with limited resources.

Using Docker with Linux: A Comprehensive Guide Using Docker with Linux: A Comprehensive Guide Apr 12, 2025 am 12:07 AM

Using Docker on Linux can improve development and deployment efficiency. 1. Install Docker: Use scripts to install Docker on Ubuntu. 2. Verify the installation: Run sudodockerrunhello-world. 3. Basic usage: Create an Nginx container dockerrun-namemy-nginx-p8080:80-dnginx. 4. Advanced usage: Create a custom image, build and run using Dockerfile. 5. Optimization and Best Practices: Follow best practices for writing Dockerfiles using multi-stage builds and DockerCompose.

What to do if the apache80 port is occupied What to do if the apache80 port is occupied Apr 13, 2025 pm 01:24 PM

When the Apache 80 port is occupied, the solution is as follows: find out the process that occupies the port and close it. Check the firewall settings to make sure Apache is not blocked. If the above method does not work, please reconfigure Apache to use a different port. Restart the Apache service.

How to start apache How to start apache Apr 13, 2025 pm 01:06 PM

The steps to start Apache are as follows: Install Apache (command: sudo apt-get install apache2 or download it from the official website) Start Apache (Linux: sudo systemctl start apache2; Windows: Right-click the "Apache2.4" service and select "Start") Check whether it has been started (Linux: sudo systemctl status apache2; Windows: Check the status of the "Apache2.4" service in the service manager) Enable boot automatically (optional, Linux: sudo systemctl

How to start monitoring of oracle How to start monitoring of oracle Apr 12, 2025 am 06:00 AM

The steps to start an Oracle listener are as follows: Check the listener status (using the lsnrctl status command) For Windows, start the "TNS Listener" service in Oracle Services Manager For Linux and Unix, use the lsnrctl start command to start the listener run the lsnrctl status command to verify that the listener is started

How to monitor Nginx SSL performance on Debian How to monitor Nginx SSL performance on Debian Apr 12, 2025 pm 10:18 PM

This article describes how to effectively monitor the SSL performance of Nginx servers on Debian systems. We will use NginxExporter to export Nginx status data to Prometheus and then visually display it through Grafana. Step 1: Configuring Nginx First, we need to enable the stub_status module in the Nginx configuration file to obtain the status information of Nginx. Add the following snippet in your Nginx configuration file (usually located in /etc/nginx/nginx.conf or its include file): location/nginx_status{stub_status

How to set up a recycling bin in Debian system How to set up a recycling bin in Debian system Apr 12, 2025 pm 10:51 PM

This article introduces two methods of configuring a recycling bin in a Debian system: a graphical interface and a command line. Method 1: Use the Nautilus graphical interface to open the file manager: Find and start the Nautilus file manager (usually called "File") in the desktop or application menu. Find the Recycle Bin: Look for the Recycle Bin folder in the left navigation bar. If it is not found, try clicking "Other Location" or "Computer" to search. Configure Recycle Bin properties: Right-click "Recycle Bin" and select "Properties". In the Properties window, you can adjust the following settings: Maximum Size: Limit the disk space available in the Recycle Bin. Retention time: Set the preservation before the file is automatically deleted in the recycling bin

How to add a listener in oracle How to add a listener in oracle Apr 11, 2025 pm 08:51 PM

To add an Oracle listener: 1. Create a listener configuration file that contains configuration parameters. 2. Save the configuration file at $ORACLE_HOME/network/admin/listener.ora. 3. Use the lsnrctl start LISTENER command to start the listener. 4. Use the lsnrctl status LISTENER command to verify that the listener is running.

See all articles