Common Linux commands
Common commands
Ls display file or directory
-L list file DETAILS l (list)
-A: List all files and directories in the current directory, including hidden a (all)
Mkdir create directory
-P: Creates a directory. If no parent directory exists, p (parent) is created)
Cd switch directory
Touch creates an empty file
Echo creates a file with content.
Cat View File Content
Cp copy
Move or rename music videos
Rm delete file
-R recursively deletes sub-directories and files.
-F force Delete
Find searches for a file in the file system
Wc counts the number of rows, words, and characters in the text
Grep searches for a string in a text file.
Rmdir Delete empty directory
Tree structure display directory, you need to install the tree package
Pwd displays the current directory
Ln create link file
More and less display text file content by PAGE
Head and tail show file header and tail content
Ctrl + alt + F1 command line full screen mode
System Management commands
Stat displays the details of the specified file, which is more detailed than ls.
Who displays online login users
Whoami displays the current user
Hostname display Host Name
Uname: displays system information
Top dynamically displays the process information that currently consumes the most resources
Ps displays the Instantaneous Process status ps-aux
Du: view the directory size. du-h/home displays the directory information in units.
Df view disk size df-h Displays disk information in units
Ifconfig
Ping test network connection
Netstat displays network status information
Man Command won't be used anymore. Looking for a man? For example, man ls
Clear Screen
Alias rename the command, for example, alias showmeit = "ps-aux", and unaliax showmeit
Kill to kill a process. You can view the process id with the ps or top command, and then kill the process with the kill command.
Compress related commands
gzip:
bzip2:
Tar: Package and Compression
-C. archive file
-X compressed file
-Z gzip compressed file
-J bzip2: compressed file
-V shows the compression or decompression process v (view)
-F indicates the file name.
Example:
Tar-cvf/home/abc.tar/home/abc Package only, not compressed
Package tar-zcvf/home/abc.tar.gz/home/abc and compress it with gzip
Package tar-jcvf/home/abc.tar.bz2/home/abc and compress it with bzip2
If you want to decompress the package, replace "c" in the tar-cvf/tar-zcvf/tar-jcvf command with "x. Shut down/restart the machine
shutdown
-R: shutdown and restart
-H Shutdown without restarting
Now shut down immediately
Halt Shutdown
Reboot restart
The Linux pipeline uses the standard output of one command as the standard input of another command. That is, several commands are combined for use, and the result of the last command is exclusive to the previous one. For example, grep-r "close"/home/* | more searches for all files in the home directory, including close files, and outputs them by page. Linux software package management
Dpkg (Debian Package) management tool. The Package name is suffixed with. deb. 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 upload tree. deb to the Linux system. Run the following command to install the SDK.
Sudo dpkg-I tree_1.5.3-1_i386.deb Installation Software
Sudo dpkg-r tree uninstall software
Note: There are multiple methods to upload tree. deb to Linux. VMwareTool, using the mounting method; using the winSCP tool;APT (Advanced Packaging Tool) Advanced software tools. This method is suitable when the system can connect to the Internet. Tree is used as an example.
Sudo apt-get install tree installation tree
Sudo apt-get remove tree uninstall tree
Sudo apt-get update Software
sudo apt-get upgrade
Set.Convert the rpm file.Deb file. rpm is the software format used by RedHat. It cannot be used directly in Ubuntu, so you need to convert it.
sudo alien abc.rpm
Vim uses vim three modes: Command mode, insert mode, and edit mode. Use ESC or I or: to switch the mode. In command mode:
: Q exit
: Q! Force exit
: Wq save and exit
: Set number: displays the row number.
: Set nonumber hide row number
/Apache finds in the document that apache jumps to the next one by pressing n, shift + n
Copy and paste the row where the cursor is located.
H (move one character to the left), j (next line), k (last line), l (move one character to the right →)
User and User Group Management
/Etc/passwd storage User Account
/Etc/group storage group account
/Etc/shadow stores the password of the user account
/Etc/gshadow: password used to store user group accounts
Useradd Add User Name
Userdel delete user name
Adduser
Groupadd add group name
Groupdel Delete group name
Passwd root SET Password for root
su root
su – root
/Etc/profile system environment variable
Bash_profile user environment variables
. Bashrc user environment variable
Su user switches users and loads the configuration file. bashrc
Su-user: Switch the user, load the configuration file/etc/profile, and load the bash_profile
Users and user groups who change files
sudo chown [-R] owner[:group] {File|Directory}
For example, jdk-7u21-linux-i586.tar.gz is used as an example. Belongs to the user hadoop. to switch the user and group to which this file belongs to the group hadoop. You can use commands.
sudo chown root:root jdk-7u21-linux-i586.tar.gz
File Permission management three basic permissions R read value expressed as 4 W write value expressed as 2X executable numeric value 1. jdk-7u21-linux-i586.tar.gz File Permission is-rw-r -- rw-r-total 10 characters, it is divided into four sections. The first character "-" indicates a common file. The "l" link may appear at this location; "d" indicates the second, third, and fourth characters of the directory. "rw-" indicates the permissions of the current user. Therefore, the value is 4 + 2 = 6, the fifth, sixth, and seventh characters "rw-" to indicate the permissions of the current group. Therefore, the value is 4 + 2 = 6. The second character "r-" indicates other user permissions. So the value is 2. So the permission to operate this file is expressed as 662 in number? Change permission sudo chmod [u user g owner group o all users of another user a] [+ Add permission-revoke permission] [r w x] Directory Name example: there is a file filename, the permission is "-rw-r -- x", and the permission value is changed to "-rwxrw-r-x". The value is 765.
sudo chmod u+x g+w o+r filename
The preceding example can be represented by numerical values.
sudo chmod 765 filename
Some interesting commands used in work:
linux nc
tree