In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-13 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
In this issue, the editor will bring you about the common operation commands of Linux refer to those, the article is rich in content and professional analysis and description for you, after reading this article, I hope you can get something.
Common Linux commands in actual combat
In Linux, we often use command fetch operations, so for now, let's talk about common instructions
1234567ls check what files and folders are under the current directory cd enter the current directory mkdir create folder touch create files
Common instruction
12345678910111213141516171su enter the root permission account to solve the problem of insufficient account permissions 2cd enter the root directory 3ls to view the current directory 4cd.. / return to the previous directory cd / directly return to the root directory 5rm delete files or folders rm- f delete files rm-rf delete folders 6mkdir create folders 7 cp copy files cp / mv mobile files mv / 8 vim open txt file editing Cat view txt file 9 find / name file retrieval
Su access to root
Mkdir create a new file
Ls View Catalog
Rm deletes a file
Touch creates a file eg: touch a.txt
Tar decompression
Vim edits the contents of the file
Cat View Files
Find is mainly used to find files with names of what and why.
1.1 pwd command
The command is interpreted as print working directory (print working directory) in English. Enter the pwd command, and Linux outputs the current directory.
1.2 cd command
The cd command is used to change the directory.
Cd / go to the root directory
Cd ~ go to / home/user user directory
Cd / usr go to the usr directory under the root directory-absolute path
Cd test goes to the test subdirectory under the current directory-relative path
1.3 ls command
The ls command is used to view the contents of the directory.
The meaning of the option-an enumerates all the files in the directory, including hidden files-l enumerates the details in the directory, including permissions, owner, group, size, creation date, whether the file is a link, etc.-f enumerates the file type-r reverse, enumerates the contents of the directory from back to forward-R recursion, this option recursively enumerates the contents of all subdirectories under the current directory-s size Sort by file size-h displays the size of the file in a human-readable manner, such as using K, M, G as units ls-l examples.doc enumerates all the information of the file examples.doc
1.4 cat command
The cat command can be used to merge files or to display the contents of the entire file on the screen.
Cat snow.txt this command displays the contents of the file snow.txt, and ctrl+D exits cat.
1.5 grep command
The greatest function of the grep command is to find a specific string in a pile of files.
Grep money test.txt
The above command looks for the string money in test.txt, and the grep lookup is case-sensitive.
1.6 touch command
The touch command is used to create a new file, and it can create a blank file to which you can add text and data.
Touch newfile this command creates a blank file called newfile.
1.7 cp command
The cp command is used to copy files. To copy files, enter the command:
Cp
Cp t.txt Document/t this command will copy the file t.txt to the Document directory and name it t.
Option meaning-I interaction: if the file will overwrite the file in the target, he will prompt to confirm-r recursion: this option will copy the entire directory tree, subdirectories and other-v details: show the copy progress of the file
1.8 mv command
The mv command is used to move files.
Option description-I interaction: if the selected file will overwrite the file in the target, he will prompt to confirm that-f force: it will go beyond the interactive mode and move the file without prompting, which is a very dangerous option-v details: displays the progress of the file movement.
Mv t.txt Document moves the file t.txt to the directory Document.
1.9 rm command
The rm command is used to delete files.
Option description-I interaction: prompt to confirm deletion-f force: instead of interactive mode, do not prompt to confirm deletion-v details: show file deletion progress-r recursion: a directory and all files and subdirectories in it will be deleted
Rm t.txt this command deletes the file t.txt
1.10 rmdir command
The rmdir command is used to delete directories.
Common instruction
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849ls display files or directories-l list file details l (list)-a lists all files and directories under the current directory, including hidden a (all) mkdir create directory-p create directory, if there is no parent directory, then create p (parent) cd switch directory touch create empty files echo create files with content. Cat view file contents cp copy mv move or rename rm delete file-r delete subdirectories and files-f force delete find search a file in the file system wc count the number of lines, words, characters in the text grep look for a string in the text file rmdir delete empty directory tree tree structure display directory Need to install tree package pwd display current directory ln create link file more, less paging display text file content head, tail display file header, tail content ctrl+alt+F1 command line full screen mode
System management command
123456789101112131415161718192021222324252627282930313233stat displays the details of the specified file More detailed than ls who display online login user whoami display current operation user hostname display hostname uname display system information top dynamic display current most resource consuming process information ps display instant process status ps-auxdu view directory size du-h / home with unit display directory information df view disk size df-h with unit display disk information ifconfig view network ping test network connectivity Netstat displays network status information man command will not be used Find men such as: man lsclear clear screen alias to rename commands such as: alias showmeit= "ps-aux", and remove the use of unaliax showmeitkill to kill the process, you can first use the ps or top command to view the id of the process, and then use the kill command to kill the process.
Packaging Compression related commands
1234567891011121314151617gzip:bzip2:tar: packaged compressed-c archive file-x compressed file-z gzip compressed file-j bzip2 compressed file-v shows compression or decompression process v (view)-f using file name
Example:
Tar-cvf / home/abc.tar / home/abc is packaged only, not compressed
Tar-zcvf / home/abc.tar.gz / home/abc is packaged and compressed with gzip
Tar-jcvf / home/abc.tar.bz2 / home/abc is packaged and compressed with bzip2
Of course, if you want to extract it, just replace the "c" in the above command tar-cvf / tar-zcvf / tar-jcvf with "x".
Shut down and restart the machine
1234567891011shutdown-r shutdown restart-h shutdown do not restart now shutdown immediately halt shutdown reboot restart
Linux pipeline
Use the standard output of one command as the standard input of another command. That is, several commands are used together, and the latter command is the result of dividing the previous command.
Example: grep-r "close" / home/* | more looks in all files in the home directory, including close files, and outputs them in pages.
Linux software package management
Dpkg (Debian Package) administrative tool with the package name suffixed with .deb. This method is suitable for the case that the system can not be connected to the Internet.
For example, to install the installation package of the tree command, first transfer the tree.deb to the Linux system. Then use the following command to install.
Sudo dpkg-I tree_1.5.3-1_i386.deb installation software
Sudo dpkg-r tree Uninstall Software
Note: there are several ways to transfer tree.deb to the Linux system. VMwareTool, using mount mode, using winSCP tools, etc.
APT (Advanced Packaging Tool) advanced software tools. This method is suitable for the situation where the system can connect to the Internet.
Still take tree as an example
1234567sudo apt-get install tree installs treesudo apt-get remove tree uninstalls treesudo apt-get update update software sudo apt-get upgrade
Convert a .rpm file to a .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 usage
There are three modes of vim: command mode, insert mode and edit mode. Use ESC or I or: to switch modes.
In command mode:
1234567891011121314151617purl Q exit: Q! Forced exit: wq Save and exit: set number Show Line number: set nonumber Hidden Line number / apache look for apache in the document jump to the next one by n, the yyp on the shift+n copies the line of the cursor and paste h (move one character to the left), j (the next line ↓), k (the previous line ↑), l (move one character to the right →)
User and user group management
123456789101112131415161718192021222324252627282930313233/etc/passwd stores user account / etc/group storage group account / etc/shadow stores password of user account / etc/gshadow stores password of user group account useradd user name userdel user name adduser group name groupdel group name passwd root sets password su rootsu-root/etc/profile system environment variable bash_profile user environment variable for root .bashrc user environment variable su user switch user, load configuration file. Bashrcsu-user switch user Load configuration file / etc/profile, load bash_profile
Change the users and user groups 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 hadoop
To switch between the users and groups to which this file belongs. You can use the command.
Sudo chown root:root jdk-7u21-linux-i586.tar.gz
File rights management
Three basic permissions
12345R read values expressed as 4W write values expressed as 2X executable values expressed as 1 common Linux command operations
Use a virtual machine on the Windows to connect to the Linux server, so the terminal is connected to the windows (later, the connection to the Ali cloud server, etc.) is connected through the terminal.
How do I connect to the Linux server?
We usually connect to the remote Linux server through the terminal tool, and our remote Linux server is on the virtual machine, so we can use the terminal tool to connect directly to the Linux server on the virtual machine on the Windows, and then actually operate the Linux server.
First connect the virtual machine, and then configure the network. Before configuring the network, you need to enter the Linux system.
Connect windows and Linux. By configuring the network connection, how can you see if the network is connected?
We can test it at the terminal and enter ifconfig.
Common Linux commands in actual combat
In Linux, we often use command fetch operations, so for now, let's talk about common instructions
1234567ls check what files and folders are under the current directory cd enter the current directory mkdir create folder touch create files
Common instruction
12345678910111213141516171su enter the root permission account to solve the problem of insufficient account permissions 2cd enter the root directory 3ls to view the current directory 4cd.. / return to the previous directory cd / directly return to the root directory 5rm delete files or folders rm- f delete files rm-rf delete folders 6mkdir create folders 7 cp copy files cp / mv mobile files mv / 8 vim open txt file editing Cat view txt file 9 find / name file retrieval
Su access to root
Mkdir create a new file
Ls View Catalog
Rm deletes a file
Touch creates a file eg: touch a.txt
Tar decompression
Vim edits the contents of the file
Cat View Files
Find is mainly used to find files with names of what and why.
1.1 pwd command
The command is interpreted as print working directory (print working directory) in English. Enter the pwd command, and Linux outputs the current directory.
1.2 cd command
The cd command is used to change the directory.
Cd / go to the root directory
Cd ~ go to / home/user user directory
Cd / usr go to the usr directory under the root directory-absolute path
Cd test goes to the test subdirectory under the current directory-relative path
1.3 ls command
The ls command is used to view the contents of the directory.
The meaning of the option-an enumerates all the files in the directory, including hidden files-l enumerates the details in the directory, including permissions, owner, group, size, creation date, whether the file is a link, etc.-f enumerates the file type-r reverse, enumerates the contents of the directory from back to forward-R recursion, this option recursively enumerates the contents of all subdirectories under the current directory-s size Sort by file size-h displays the size of the file in a human-readable manner, such as using K, M, G as units ls-l examples.doc enumerates all the information of the file examples.doc
1.4 cat command
The cat command can be used to merge files or to display the contents of the entire file on the screen.
Cat snow.txt this command displays the contents of the file snow.txt, and ctrl+D exits cat.
1.5 grep command
The greatest function of the grep command is to find a specific string in a pile of files.
Grep money test.txt
The above command looks for the string money in test.txt, and the grep lookup is case-sensitive.
1.6 touch command
The touch command is used to create a new file, and it can create a blank file to which you can add text and data.
Touch newfile this command creates a blank file called newfile.
1.7 cp command
The cp command is used to copy files. To copy files, enter the command:
Cp
Cp t.txt Document/t this command will copy the file t.txt to the Document directory and name it t.
Option meaning-I interaction: if the file will overwrite the file in the target, he will prompt to confirm-r recursion: this option will copy the entire directory tree, subdirectories and other-v details: show the copy progress of the file
1.8 mv command
The mv command is used to move files.
Option description-I interaction: if the selected file will overwrite the file in the target, he will prompt to confirm that-f force: it will go beyond the interactive mode and move the file without prompting, which is a very dangerous option-v details: displays the progress of the file movement.
Mv t.txt Document moves the file t.txt to the directory Document.
1.9 rm command
The rm command is used to delete files.
Option description-I interaction: prompt to confirm deletion-f force: instead of interactive mode, do not prompt to confirm deletion-v details: show file deletion progress-r recursion: a directory and all files and subdirectories in it will be deleted
Rm t.txt this command deletes the file t.txt
1.10 rmdir command
The rmdir command is used to delete directories.
Common instruction
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849ls display files or directories-l list file details l (list)-a lists all files and directories under the current directory, including hidden a (all) mkdir create directory-p create directory, if there is no parent directory, then create p (parent) cd switch directory touch create empty files echo create files with content. Cat view file contents cp copy mv move or rename rm delete file-r delete subdirectories and files-f force delete find search a file in the file system wc count the number of lines, words, characters in the text grep look for a string in the text file rmdir delete empty directory tree tree structure display directory Need to install tree package pwd display current directory ln create link file more, less paging display text file content head, tail display file header, tail content ctrl+alt+F1 command line full screen mode
System management command
123456789101112131415161718192021222324252627282930313233stat displays the details of the specified file More detailed than ls who display online login user whoami display current operation user hostname display hostname uname display system information top dynamic display current most resource consuming process information ps display instant process status ps-auxdu view directory size du-h / home with unit display directory information df view disk size df-h with unit display disk information ifconfig view network ping test network connectivity Netstat displays network status information man command will not be used Find men such as: man lsclear clear screen alias to rename commands such as: alias showmeit= "ps-aux", and remove the use of unaliax showmeitkill to kill the process, you can first use the ps or top command to view the id of the process, and then use the kill command to kill the process.
Packaging Compression related commands
1234567891011121314151617gzip:bzip2:tar: packaged compressed-c archive file-x compressed file-z gzip compressed file-j bzip2 compressed file-v shows compression or decompression process v (view)-f using file name
Example:
Tar-cvf / home/abc.tar / home/abc is packaged only, not compressed
Tar-zcvf / home/abc.tar.gz / home/abc is packaged and compressed with gzip
Tar-jcvf / home/abc.tar.bz2 / home/abc is packaged and compressed with bzip2
Of course, if you want to extract it, just replace the "c" in the above command tar-cvf / tar-zcvf / tar-jcvf with "x".
Shut down and restart the machine
1234567891011shutdown-r shutdown restart-h shutdown do not restart now shutdown immediately halt shutdown reboot restart
Linux pipeline
Use the standard output of one command as the standard input of another command. That is, several commands are used together, and the latter command is the result of dividing the previous command.
Example: grep-r "close" / home/* | more looks in all files in the home directory, including close files, and outputs them in pages.
Linux software package management
Dpkg (Debian Package) administrative tool with the package name suffixed with .deb. This method is suitable for the case that the system can not be connected to the Internet.
For example, to install the installation package of the tree command, first transfer the tree.deb to the Linux system. Then use the following command to install.
Sudo dpkg-I tree_1.5.3-1_i386.deb installation software
Sudo dpkg-r tree Uninstall Software
Note: there are several ways to transfer tree.deb to the Linux system. VMwareTool, using mount mode, using winSCP tools, etc.
APT (Advanced Packaging Tool) advanced software tools. This method is suitable for the situation where the system can connect to the Internet.
Still take tree as an example
1234567sudo apt-get install tree installs treesudo apt-get remove tree uninstalls treesudo apt-get update update software sudo apt-get upgrade
Convert a .rpm file to a .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 usage
There are three modes of vim: command mode, insert mode and edit mode. Use ESC or I or: to switch modes.
In command mode:
1234567891011121314151617purl Q exit: Q! Forced exit: wq Save and exit: set number Show Line number: set nonumber Hidden Line number / apache look for apache in the document jump to the next one by n, the yyp on the shift+n copies the line of the cursor and paste h (move one character to the left), j (the next line ↓), k (the previous line ↑), l (move one character to the right →)
User and user group management
123456789101112131415161718192021222324252627282930313233/etc/passwd stores user account / etc/group storage group account / etc/shadow stores password of user account / etc/gshadow stores password of user group account useradd user name userdel user name adduser group name groupdel group name passwd root sets password su rootsu-root/etc/profile system environment variable bash_profile user environment variable for root .bashrc user environment variable su user switch user, load configuration file. Bashrcsu-user switch user Load configuration file / etc/profile, load bash_profile
Change the users and user groups 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 hadoop
To switch between the users and groups to which this file belongs. You can use the command.
Sudo chown root:root jdk-7u21-linux-i586.tar.gz
File rights management
Three basic permissions
one hundred and twenty three
R read value expressed as 4W write value expressed as 2X executable value expressed as 1 above is the common operation command of Linux shared by Xiaobian refers to those, if you happen to have similar doubts, you might as well refer to the above analysis to understand. If you want to know more about it, you are welcome to follow the industry information channel.
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.