Home Backend Development PHP Tutorial Commonly used operating commands in linux

Commonly used operating commands in linux

Nov 14, 2017 am 11:46 AM
linux Order operate

Introduction to Linux and Ubuntu installation

Linux, free and open source, multi-user and multi-tasking system. There are multiple versions based on Linux. RedHat, Ubuntu, Debian

Install VMware or VirtualBox virtual machine. For specific installation steps, please find Baidu.

Then install Ubuntu. For specific installation steps, please find Baidu.

After installation, you can see the directory structure of the Linux system.

Common commands

ls Display files or directories

-l List file details l(list)

-a List all files and directories in the current directory, including hidden a(all)

mkdir Create directory

-p Create a directory, if there is no parent directory, create it P (Parent)

CD Switch Catalog

Touch Create empty files

# Echo Create a file with content.

cat                                                                                                                         ous                         ous     d                                           ient     ous Recursive deletion can Delete subdirectories and files

-f                                            -                                                  -                                                                     ‐   ’ s ’ s ’ s ’ ’ ’ ’ history with with with with with with with with 2 Number

GREP Find a string in the text file

# RMDIR to delete the empty directory

TREE tree structure display directory. PWD display current directory

Ln Create link files

# More, LESS pages display text file content # Head, tail display file header, tail content

Ctrl +alt+F1 Command line full screen mode

System management command

stat Display detailed information of the specified file, more detailed than ls

who Display online Login user

Whoami Show the current operating user

# Hostname display host name

# UNAME display system information

TOP dynamic display currently consume the most current process information

#ps                                                                                                                                                                                                               Disk information

ifconfig                                                                                                                                                                                                                                                                                         # Man ls

Clear Clear the screen

# Alias ​​renamed the command, such as: Alias ​​Showmeit = "PS -AUX". First use the ps or top command to check the ID of the process, and then use the kill command to kill the process.

# Packing and compressed related commands

# GZIP:

BZIP2:

## Tar: Packing compression

##- Archive file

-x Compressed file

-z gzip compressed file

-j bzip2 compressed file

-v -v Display the compression or decompression process v( view)

                                                                Use the file name

Example:

tar -cvf /home/abc.tar /home/abc                                                                                                                                                                                             View)

tar -zcvf /home/abc.tar.gz /home/abc Packed and compressed with gzip

tar -jcvf /home/abc.tar.bz2 /home/abc Packed and compressed with bzip2

Of course, if you want to decompress, just replace the "c" in the above command tar -cvf / tar -zcvf / tar -jcvf with "x".

Shut down/restart the machine

shutdown

-r Shut down and restart

-h Shut down without restarting

now Shut down immediately

halt Shut down

reboot Restart

Linux pipe

Use the standard output of one command as the standard output of another command standard input. That is to say, several commands are used in combination, and the result of the latter command is divided by the previous command.

Example: grep -r "close" /home/* | more Search all files in the home directory, including close files, and output them in pages.

Linux software package management

dpkg (Debian Package) management tool, the software package name has the .deb suffix. This method is suitable when the system cannot be connected to the Internet.

For example, to install the installation package of the tree command, first transfer tree.deb to the Linux system. Then use the following command to install.

sudo dpkg -i tree_1.5.3-1_i386.deb Install software

sudo dpkg -r tree                                                                                                                                                                                           Use   use dpkg through   using  -  There are many ways to transfer it to the Linux system. VMwareTool, use mounting method; use winSCP tool, etc.;

APT (Advanced Packaging Tool) advanced software tool. This method is suitable if the system can connect to the Internet.

Still taking tree as an example

sudo apt-get install tree                                                                                                   use using                       ’ ‐ ’ s       ‐   ‐ ‐ ‐ ‐ t-get to ​Update software

sudo apt-get upgrade

Convert .rpm file to .deb file

.rpm is the software format used by RedHat. It cannot be used directly under Ubuntu, so it needs to be converted.

sudo alien abc.rpm

vim uses

vim three modes:

command mode

, insert mode,

EditMode

. Use ESC or i or : to switch modes.

command mode:

: q exit : q! Mandatory exit ##: wq save and exit ##: Set Number Show line number

:set nonumber Hide line number

/apache Find apache in the document Press n to jump to the next one, shift+n to the previous one

yyp Copy the cursor location line, and paste

h (move one character left ←), j (next row ↓), k (previous row ↑), l (move right one character →)

User and user group management

/etc/passwd Storage of user accounts

/etc/group Storage of group accounts

/etc/shadow Storage of passwords for user accounts

/etc/gshadow stores the password of the user group account

useradd username

userdel username

adduser username

groupadd group Name

groupdel Group name

passwd root Set password for root

su root

su - root

/etc/profile System Environment variables

bash_profile User environment variables

.bashrc User environment variables

su user Switch users and load the

configuration file

.bashrc

su - user Switch user, load configuration file /etc/profile, load bash_profile

Change the user and user group of the file

sudo chown [-R] owner[:group] {File| Directory}

For example: Take jdk-7u21-linux-i586.tar.gz as an example. Belongs to user hadoop, group hadoopTo switch the user and group to which this file belongs. Commands are available.

sudo chown root:root jdk-7u21-linux-i586.tar.gz

File

Permission management

三Basic permissions

R Reading value is expressed as 4

# W. Write the value as 2

x The executable value can be represented as 1

Commonly used operating commands in linux

As shown in the figure, the permissions of the jdk-7u21-linux-i586.tar.gz file are -rw-rw-r--

-rw-rw-r--a total of ten characters, divided into four sections.

The first character "-" represents an ordinary file; a "l" link may also appear at this location; "d" represents a directory

The second, third, and fourth characters "rw-" represent Permissions of the current user. Therefore, the numerical value is expressed as 4+2=6

The fifth, sixth and seventh characters "rw-" represent the permissions of the current group. So the numerical value is expressed as 4+2=6

The 890th character "r--" represents other user permissions. So the numerical value is expressed as 2

So the permission to operate this file is expressed as 662

Change permissions

sudo chmod [u belongs to the user g belongs to the group o other users a All users] [+Increase permissions -Decrease permissions] [r w x] Directory name

For example: there is a file filename with permissions "-rw-r----x", change the permissions value to "-rwxrw-r-x", expressed as a numerical value is 765

sudo chmod u+x g+w o+r filename

The above example can be expressed as a numerical value

sudo chmod 765 filename

For friends who are not familiar with basic commands, you still need more practice. I hope it can help you.


Related reading:

Example of how to use inode to delete specified files under Linux

The file directory structure in Linux Detailed introduction

Detailed explanation of the pmap command for Linux performance testing

How to obtain the local source port number through socket communication in Linux

The above is the detailed content of Commonly used operating commands in linux. 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

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

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 computer configuration is required for vscode What computer configuration is required for vscode Apr 15, 2025 pm 09:48 PM

VS Code system requirements: Operating system: Windows 10 and above, macOS 10.12 and above, Linux distribution processor: minimum 1.6 GHz, recommended 2.0 GHz and above memory: minimum 512 MB, recommended 4 GB and above storage space: minimum 250 MB, recommended 1 GB and above other requirements: stable network connection, Xorg/Wayland (Linux)

vscode cannot install extension vscode cannot install extension Apr 15, 2025 pm 07:18 PM

The reasons for the installation of VS Code extensions may be: network instability, insufficient permissions, system compatibility issues, VS Code version is too old, antivirus software or firewall interference. By checking network connections, permissions, log files, updating VS Code, disabling security software, and restarting VS Code or computers, you can gradually troubleshoot and resolve issues.

Can vscode be used for mac Can vscode be used for mac Apr 15, 2025 pm 07:36 PM

VS Code is available on Mac. It has powerful extensions, Git integration, terminal and debugger, and also offers a wealth of setup options. However, for particularly large projects or highly professional development, VS Code may have performance or functional limitations.

What is vscode What is vscode for? What is vscode What is vscode for? Apr 15, 2025 pm 06:45 PM

VS Code is the full name Visual Studio Code, which is a free and open source cross-platform code editor and development environment developed by Microsoft. It supports a wide range of programming languages ​​and provides syntax highlighting, code automatic completion, code snippets and smart prompts to improve development efficiency. Through a rich extension ecosystem, users can add extensions to specific needs and languages, such as debuggers, code formatting tools, and Git integrations. VS Code also includes an intuitive debugger that helps quickly find and resolve bugs in your code.

How to use VSCode How to use VSCode Apr 15, 2025 pm 11:21 PM

Visual Studio Code (VSCode) is a cross-platform, open source and free code editor developed by Microsoft. It is known for its lightweight, scalability and support for a wide range of programming languages. To install VSCode, please visit the official website to download and run the installer. When using VSCode, you can create new projects, edit code, debug code, navigate projects, expand VSCode, and manage settings. VSCode is available for Windows, macOS, and Linux, supports multiple programming languages ​​and provides various extensions through Marketplace. Its advantages include lightweight, scalability, extensive language support, rich features and version

How to run java code in notepad How to run java code in notepad Apr 16, 2025 pm 07:39 PM

Although Notepad cannot run Java code directly, it can be achieved by using other tools: using the command line compiler (javac) to generate a bytecode file (filename.class). Use the Java interpreter (java) to interpret bytecode, execute the code, and output the result.

What is the main purpose of Linux? What is the main purpose of Linux? Apr 16, 2025 am 12:19 AM

The main uses of Linux include: 1. Server operating system, 2. Embedded system, 3. Desktop operating system, 4. Development and testing environment. Linux excels in these areas, providing stability, security and efficient development tools.

How to check the warehouse address of git How to check the warehouse address of git Apr 17, 2025 pm 01:54 PM

To view the Git repository address, perform the following steps: 1. Open the command line and navigate to the repository directory; 2. Run the "git remote -v" command; 3. View the repository name in the output and its corresponding address.

See all articles