Summary of common operation commands in Linux

Introduction to Linux and Ubuntu Installation

Common commands

system management commands

Packaging and compression related commands

Shutdown/Restart the machine

Linux pipes

Linux package management

vim use

User and user group management

File Rights Management


Introduction to Linux and Ubuntu Installation

Linux, free and open source, multi-user multi-tasking system. There are several derivatives based on Linux. RedHat, Ubuntu, CentOS, etc.
Install VMware or VirtualBox virtual machines. For specific installation steps, find Baidu.
Install Ubuntu again. For specific installation steps, find Baidu.
After installation, you can see the directory structure of the Linux system, see the link http://www.weixuehao.com/archives/492
and enter the linux terminal, or secureCRT, you can operate linux. Type help to see all the commands!

Common commands

ls Display a 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 a directory
-p Create a directory, if there is no parent directory, create it p(parent)
cd changes directory
touch creates an empty file
echo creates a file with content.
cat View file content
cp Copy
mv Move or rename
rm Delete file
-r Delete recursively, delete subdirectories and files (recursive)
-f Force delete (force)
find Search for a file in the file system
wc Count the number of lines and words in the text , number of characters
grep Find a string in a 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 commands

stat shows the detailed information of the specified file, more detailed than ls
who shows the online login user
whoami shows the current operating user
hostname shows the hostname
uname shows the system information
top dynamically shows the current process information that consumes the most resources
ps shows the instantaneous process status ps -aux
du View the directory Size du -h /home with units to display directory information
df to view disk size df -h to display disk information with units
ifconfig to view network conditions
ping to test network connectivity
netstat to display network status information
The man command will not work, looking for a man? For example: man ls
clear to clear the screen
alias Rename the command such as: alias showmeit=”ps -aux”, in addition to cancel the use of unaliax showmeit
kill 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 process.

Packaging and compression related commands

gzip:
bzip2:
tar: archive
-c archive
-x archive
-z gzip archive
-j bzip2 archive
-v show compression or decompression process v(view)
-f use filename
Example :
tar -cvf /home /abc.tar /home/abc only packs, does not compress
tar -zcvf /home/abc.tar.gz /home/abc packs, and uses gzip to compress
tar -jcvf /home/abc.tar.bz2 /home/abc packs, And use bzip2 compression
Of course , if you want to decompress, just replace the "c" in the above command tar -cvf / tar -zcvf / tar -jcvf with "x".

Shutdown/Restart the machine

shutdown
-r shutdown restart
-h shutdown without restart
now shutdown immediately
halt shutdown
reboot restart

Linux pipes

Use the standard output of one command as the standard input of another command. That is, several commands are used in combination, and the latter command divides the result of the previous command.
Example: grep -r "close" /home/* | more Find all files in the home directory, including the close files, and output them in paging.

Linux package management

dpkg (Debian Package) management tool, the package name is suffixed with .deb. This method is suitable when the system cannot be networked.
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 uninstall software
Note : There are many ways to transfer tree.deb to Linux system. VMwareTool, use the mount method; use winSCP tools, etc.;
APT (Advanced Packaging Tool) advanced software tools. This method is suitable when the system is able to connect to the Internet.
Still take tree as an example
sudo apt-get install tree install tree
sudo apt-get remove tree uninstall tree
sudo apt-get update update software
sudo apt-get upgrade

Convert .rpm files to .deb files
. 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 use

There are three modes in vim: command mode, insert mode, and edit mode. Use ESC or i or : to switch modes.
In command mode:
:q quit
:q! Force quit
:wq save and quit
:set number show line number
:set nonumber hide line number
/apache find apache in documentation press n to jump to next, shift+n to previous
yyp copy The line where the cursor is located, and paste
h (move left one character ←), j (next line ↓), k (previous line ↑), l (right move one character →)

User and user group management

/etc/passwd Store user accounts
/etc/group Store group accounts
/etc/shadow Store user account passwords
/etc/gshadow Store user group account passwords
useradd Add user name
userdel Delete user name
adduser Add user name
groupadd Add group name
groupdel Delete the group name
passwd root Set a password for root
su root
su – root
/etc/profile system environment variable
bash_profile user environment variable
.bashrc user environment variable
su user switch user, load configuration file. bashrc
su – user switch user, load configuration file / etc/profile , loads bash_profile

Change the user and user group of the file
sudo chown [-R] owner[:group] {File|Directory}
For example: also take jdk-7u21-linux-i586.tar.gz as an example. It belongs to the user hadoop, and the group hadoop
wants to switch the user and group to which this file belongs. Commands can be used.
sudo chown root:root jdk-7u21-linux-i586.tar.gz

File Rights Management

Three basic permissions
R The reading value is represented as 4
W The write value is represented as 2
X The executable value is represented as 1
write picture description here
As shown in the figure, the permission of the jdk-7u21-linux-i586.tar.gz file is -rw-rw-r–
-rw-rw-r – a total of ten characters, divided into four paragraphs.
The first character "-" indicates a normal file; there may also be an "l" link in this position; "d" indicates a directory
The second , third, and fourth characters "rw-" indicate the permissions of the current user. Therefore, the numerical value is expressed as 4+2=6
The fifth, sixth, and seventh characters "rw-" indicate the permissions of the current group. So the numerical representation is 4+2=6
The eighth and ninetieth characters "r-" represent other user permissions. So the value is expressed as 2
, so the permission to operate this file is expressed as 662


Change permissions

sudo chmod [u belongs to user g belongs to group o other user a all users] [+ increase permission - decrease permission] [rwx] directory name
For example : there is a file filename, the permission is "-rw-r—-x", change the permission The value is changed to "-rwxrw-rx", and the numerical value is 765
sudo chmod u+x g+w o+r filename
The above example can be numerically expressed
sudo chmod 765 filename

Some interesting commands used at work:

linux nc
tree

This article is reproduced from:
http://www.daniubiji.cn/archives/25#Linux%E7%AE%80%E4%BB%8B%E5%8F%8AUbuntu%E5%AE%89%E8%A3%85

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324772983&siteId=291194637