Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the required Linux commands?

2025-03-30 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces what the must-learn Linux command has, which has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, let the editor take you to understand it.

Basic Linux commands for Linux beginners:

1 、 man

Man pages (man) commands are like software documentation, through which you can learn what specific commands do and how they work:

2 、 cd

Cd is an acronym for change directory. As the name implies, it is used to temporarily change the working directory.

Example:

Linuxmi@linuxmi:~$ cd www.linuxmi.com

3 、 ls

The ls command lists the contents of the directory.

Linuxmi@linuxmi:~/www.linuxmi.com$ ls

4 、 clear

As the name implies, clear is used to clear the terminal screen.

Focusblast@pop-os:~$ clear

5 、 pwd

PWD stands for printing working directory. This provides us with a quick way to find the working directory path.

Linuxmi@linuxmi:~/www.linuxmi.com$ pwd

6 、 cat

The function of the cat command is to output a file or combination of standard input to standard output. This command is often used to display the contents of a file, to connect several files to display, or to read and display the contents from standard input, and it is often used in conjunction with redirection symbols. The cat command is an abbreviation for concatenate.

Continuously displayed on the screen from the first line to the last line

Linuxmi@linuxmi:~/www.linuxmi.com$ cat linuxmi.cpp

The command to merge two files and create a new file or merge them into any two files is.

Linuxmi@linuxmi:~/www.linuxmi.com$ cat linuxmi.txt xxvi.txt > linux.txt # this merges linuxmi.txt and xxvi.txt into the new file linux.txt

You can use the command "man cat" to learn more.

7 、 mkdir

The name speaks for itself. The mkdir command in Linux is used to create a new directory or, if you are from Windows, a folder.

Linuxmi@linuxmi:~/www.linuxmi.com$ mkdir www.linuxmi.com

Where "www.linuxmi.com" is the name of the folder to be created.

8 、 echo

Echo is the simplest command in Linux. It is used to display the text passed after the command space.

Linuxmi@linuxmi:~/www.linuxmi.com$ echo www.linuxmi.com

The echo command seems useless, but it is used to debug code and determine the state of the program. If you know a little bit about programming, think of it as a print statement that only outputs strings.

9 、 MV

The mv command in Linux stands for "move". It is used to move files or directories from one location to another. Consider a file called "linuxmi.com". To move it to the "/ home/linuxmi/linuxmi" folder, the command we need to do is:

Linuxmi@linuxmi:~/www.linuxmi.com$ mv linuxmi.com / home/linuxmi/linuxmi

10 、 rm

The rm command is used to delete files and directories. You need to use both rm and-r (recursion) to delete the directory.

Linuxmi@linuxmi:~/www.linuxmi.com$ rm linuxmi.com.txt # Delete the file linuxmi@linuxmi:~/www.linuxmi.com$ sudo rm-rf www.linuxmi.com # Delete the directory

The f in "- rf" is used to tell rm to ignore files and parameters that do not exist.

11 、 zip/unzip

Zip is used to create new zip files, while Unzip is used to extract compressed files. This is how you compress and decompress the command.

Linuxmi@linuxmi:~/www.linuxmi.com$ zip linuxmi.zip debian.txt ubuntu.txt

In the above command, linuxmi.zip is the name of the compressed file, in which we will put two text files, debian.txt and ubuntu.txt.

Use the command to extract all files from the compressed file.

Linuxmi@linuxmi:~/www.linuxmi.com$ unzip linuxmi.zip

Replace "linuxmi.zip" with the name of the compressed file you want to extract.

12 、 wget

Wget is a convenient command that helps you download files from Internet. The method of use is as follows:

Linuxmi@linuxmi:~/www.linuxmi.com$ wget https://www.linuxmi.com/wp-content/uploads/2020/02/linuxmi.png

13 、 top

Similar to the Windows task manager, the top command shows you a list of running processes and the number of CPU in use.

Linuxmi@linuxmi:~/www.linuxmi.com$ top

14 、 history

The history command is used to display the commands you entered earlier.

Linuxmi@linuxmi:~/www.linuxmi.com$ history

15 、 wc

The wc command is used to count lines (- l), words (- w), bytes (- c), and characters (m).

Linuxmi@linuxmi:~/www.linuxmi.com$ wc linuxmi.com.py 27 52 537 linuxmi.com.py wc-l linuxmi.com.py

16 、 cp

The cp command copies and pastes the file into the directory specified as the second parameter.

Focusblast@pop-os:~/Desktop$ cp new.txt / home/focusblast/Downloads linuxmi@linuxmi:~/www.linuxmi.com$ cp linuxmi.com.txt / home/linuxmi/linuxmi

In the above command, "linuxmi.com.txt" is the file we copied to the directory "/ home/linuxmi/linuxmi".

17 、 passwd

You guessed right! The passwd command is used to change the password of a user account. To use it, type passwd, and then enter the user name.

Linuxmi@linuxmi:~/www.linuxmi.com$ passwd linuxmi

18 、 apt

Apt stands for advanced packaging tools. It is one of the most popular and powerful package managers for Ubuntu / Debian. First of all, the package manager is essentially the process of automating the installation and removal of applications.

The following command installs the vlc application, and the VLC multimedia player is the multimedia player planned by VideoLAN.

Linuxmi@linuxmi:~/www.linuxmi.com$ sudo apt install vlc

19 、 chown

The chown command is used to change ownership of the file. Suppose you have a file called linuxmi.com.txt, and you are linuxmi. You want to transfer ownership to mysql.

Linuxmi@linuxmi:~/www.linuxmi.com$ sudo chown mysql linuxmi.com.txt

You can also use the following command to transfer ownership to the root user.

Linuxmi@linuxmi:~/www.linuxmi.com$ sudo chown root linuxmi.com.txt

20 、 reboot

The name speaks for itself. The Reboot command is used to reboot, shut down, or stop the system.

Linuxmi@linuxmi:~/www.linuxmi.com$ reboot

21 、 chmod

The chmod command is used to change the read (- r), write (- w), and execute (- x) instructions of the file. An example of the chmod command is:

Linuxmi@linuxmi:~/www.linuxmi.com$ sudo chmod 711 linuxmi.com.sh

That's what numbers mean.

Numeric permission indicates that 0 does not have permission-1 execute permission-x2 write permission-wmur3 write and execute permission-wx4 read and execute permission r-x6 read and write permission r-x6 read and write permission rw-7 read, write and execute rwx

Linux permission

The first number (7) in the above command represents the permissions you grant to the user, that is, read, write, and execute.

The second number (1) is the permission granted to the file itself, in which case the group user has execute permission.

The third and last digit (1) indicates that other users are granted only execute permissions.

Related: https://www.linuxmi.com/linux-chmod.html

22 、 grep

The grep command is used to search and find text in a file.

Linuxmi@linuxmi:~/www.linuxmi.com$ grep "return" linuxmi.com.py

Related: https://www.linuxmi.com/linux-grep-mingling-gaoji.html

23 、 locate

Similar to the search command in Windows, the locate command is used to find files in Linux.

Linuxmi@linuxmi:~/www.linuxmi.com$ locate linuxmi.cpp / home/linuxmi/www.linuxmi.com/linuxmi.cpp

24 、 sudo

Eventually you will use the only command that you use the most. The abbreviation for Sudo is SuperUser Do, and you can use SuperUser Do to find files that require root permissions.

Note that if the file requires root privileges, it may be important to the operating system. Therefore, if you do not know what you are doing, we recommend that you do not misuse it.

25 、 hostname

The hostname command is used to know your device name. In addition, using the-I parameter will help you understand the IP address.

Linuxmi@linuxmi:~/www.linuxmi.com$ hostname linuxmi linuxmi@linuxmi:~/www.linuxmi.com$ hostname-I

192.168.150.135

26 、 exit

The exit command can be used to quickly close the terminal.

Linuxmi@linuxmi:~/www.linuxmi.com$ exit

twenty-seven。 Df

Suppose you want to know the space in each disk partition, type df. The default space metric is kilobytes, but you can change it to megabytes using the parameter "- m".

Linuxmi@linuxmi:~/www.linuxmi.com$ df-m

28 、 netstat

The netstat command can be used to check network statistics, interface statistics, routing table information, and so on.

Linuxmi@linuxmi:~/www.linuxmi.com$ netstat

29 、 fdisk

The fdisk command lists all partitions as well as information such as partition name, sector, size, and partition type. Fdisk requires superuser privileges to run.

Linuxmi@linuxmi:~/www.linuxmi.com$ sudo fdisk-l

30 、 find

The Linux find command is used to find files in the specified directory. Any string that precedes a parameter is treated as the name of the directory you are looking for. If you use this command without setting any parameters, the find command looks for subdirectories and files under the current directory. And all the subdirectories and files found are displayed.

List all files under the current directory and its subdirectories with the suffix .cpp:

Linuxmi@linuxmi:~/www.linuxmi.com$ find. -name "* .cpp"

Give a Linux command for entertainment.

Sl

You can install sl using apt, and as long as you type sl instead of the ls command we mentioned earlier, a train will appear.

Linuxmi@linuxmi:~/www.linuxmi.com$ sudo apt install sl

Thank you for reading this article carefully. I hope the article "what must learn Linux commands" shared by the editor will be helpful to everyone. At the same time, I also hope that you will support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report