Home  >  Article  >  System Tutorial  >  Linux common command manual

Linux common command manual

WBOY
WBOYOriginal
2024-02-18 14:12:23577browse

Comprehensive list of commonly used Linux commands, specific code examples are required

1. Introduction

As a free and open source operating system, Linux has become the platform of choice for many developers and system administrators. Whether in server rental, website building, software development or daily use, familiarity with common Linux commands is essential. This article will introduce some commonly used Linux commands in detail and provide specific code examples.

2. File and directory operations

  1. Create directory (directory name newdir)

    mkdir newdir
  2. Delete directory (directory name is olddir)

    rmdir olddir
  3. Enter the directory (the directory name is mydir)

    cd mydir
  4. Display the current directory

    pwd
  5. Display all files and directories in the current directory

    ls
  6. Copy files (copy file file1 to directory dir1)

    cp file1 dir1
  7. Delete file (delete file file1)

    rm file1
  8. Move file (move file file1 to directory dir1)

    mv file1 dir1
  9. Find file (find file File whose name contains test)

    find / -name "test"

3. File content operation

  1. Display file content (display the content of file file1)

    cat file1
  2. Display the first n lines of the file (display the first 10 lines of the file file1)

    head -n 10 file1
  3. Display the last n lines of the file (display the last 10 lines of the file file1 Line)

    tail -n 10 file1
  4. Find the line containing a certain keyword in the file (find the line containing "hello" in the file file1)

    grep "hello" file1
  5. Statistics on the number of lines, words and characters of the file (statistics on the number of lines, words and characters of the file file1)

    wc file1

4. System Management

  1. Shutdown

    shutdown -h now
  2. Restart

    reboot
  3. Check the system version

    cat /etc/*-release
  4. Check the system time

    date
  5. Check the system load

    uptime

5. Network operation

  1. View the IP address (View IP address of network interface eth0)

    ifconfig eth0
  2. Test network connection (test connectivity to target host)

    ping target.com
  3. Download file (from URL url download file)

    wget url
  4. Upload file (upload file file1 to the remote host)

    scp file1 remoteuser@remotehost:/path/to/destination
  5. Port monitoring (view all open files in the system Port)

    netstat -tuln

6. Permission management

  1. Modify file permissions (modify the owner permissions of file file1 to read and write)

    chmod 600 file1
  2. Modify the file owner (change the owner of file file1 to user1)

    chown user1 file1
  3. Modify the group to which the file belongs (change the owner of file file1 Group modified to group1)

    chgrp group1 file1
  4. View file permissions and owners

    ls -l file1

7. Process Management

  1. View all processes

    ps -ef
  2. End the process (end the process with process PID 1234)

    kill 1234
  3. Run the program in the background (change the program prog1 Put it into the background to run)

    prog1 &
  4. Check the CPU and memory usage of the process

    top

The above are some commonly used Linux command examples, I hope they can Help you better master the Linux operating system. Of course, Linux is very powerful, and there are many other commands and usages that can be further explored and learned.

The above is the detailed content of Linux common command manual. For more information, please follow other related articles on the PHP Chinese website!

Statement:
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