Home > Backend Development > PHP Tutorial > Commonly used operating commands in linux

Commonly used operating commands in linux

肚皮会动
Release: 2023-03-17 13:24:01
Original
1836 people have browsed it

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!

Related labels:
source:php.cn
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
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template