English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
This article is a collection of Linux command knowledge collected and sorted by the editor for everyone's daily use, which is very good and has reference value. The specific content details are as follows:
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 files a(all)
mkdir Create a directory
-p Create a directory, if no parent directory, create p(parent)
cd Change directory
touch Create an empty file
echo Create a file with content.
cat View file content
cp Copy
mv Move or rename
rm Delete file
-r 递归删除,可删除子目录及文件
-f 强制删除
find 在文件系统中搜索某文件
wc 统计文本中行数、字数、字符数
grep 在文本文件中查找某个字符串
rmdir 删除空目录
tree 树形结构显示目录,需要安装tree包
pwd 显示当前目录
ln 创建链接文件
more、less 分页显示文本文件内容
head、tail 显示文件头、尾内容
ctrl+alt+F1 命令行全屏模式
系统管理命令
stat 显示指定文件的详细信息,比ls更详细
who 显示在线登陆用户
whoami 显示当前操作用户
hostname 显示主机名
uname 显示系统信息
top 动态显示当前耗费资源最多进程信息
ps 显示瞬间进程状态 ps -aux
du 查看目录大小 du -h /home带有单位显示目录信息
df 查看磁盘大小 df -h 带有单位显示磁盘信息
ifconfig 查看网络情况
ping 测试网络连通
netstat 显示网络状态信息
man 命令不会用了,找男人 如:man ls
clear 清屏
alias 对命令重命名 如:alias showmeit="ps -aux" ,另外解除使用unaliax showmeit
kill 杀死进程,可以先用ps 或 top命令查看进程的id,然后再用kill命令杀死进程。
打包压缩相关命令
gzip:
bzip2:
tar: 打包压缩
-archive file
-compressed file
-gzip compressed file
-bzip2compressed file
-v
-f
Example:
tar -cvf /home/abc.tar /home/abc
tar -zcvf /home/abc.tar.gz /home/abc
tar -jcvf /home/abc.tar.bz2 /home/abc2compression
Of course, if you want to decompress, just replace the above command with tar -cvf / tar -zcvf / tar -Replace the 'c' in jcvf with 'x' to do so.
shutdown/restart the machine
shutdown
-r
-h
now
halt
reboot
Linux pipeline
Take the standard output of one command as the standard input of another command. That is, combine several commands to use, and the result of the last command is divided by the result of the previous command.
Example: grep -r "close" /home/* | more
Linux software package management
dpkg (Debian Package) management tool, software package name with .deb suffix. This method is suitable for systems that cannot connect to the internet.
For example, to install the package for 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
sudo dpkg -r tree
Note: There are many ways to transfer tree.deb to a Linux system. VMwareTool, using mounting method; using winSCP tool, etc.
APT (Advanced Packaging Tool) advanced software tool. This method is suitable for systems that can connect to the internet.
still take tree as an example
sudo apt-get 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 usage
Vim has three modes: command mode, insert mode, and edit mode. Use ESC or i or : to switch modes.
Command mode:
:q Exit
:q! Force exit
:wq Save and exit
:set number Show line numbers
:set nonumber Hide line numbers
/apache Find apache in the document, press n to jump to the next, shift+n Previous
yyp Copy the line where the cursor is, and paste
h(Left one character ←), j(Next line ↓), k(Previous line ↑), l(Right one character →)
User and user group management
/etc/passwd Stores the user account
/etc/group Stores the group account
/etc/shadow Stores the password of the user account
/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 user, load configuration file .bashrc
su - user Switch user, load configuration file/etc/profile, load bash_profile
Change the user and group of the file
sudo chown [-R] owner[:group] {File|Directory}
For example: still using jdk-7u21-linux-i586.tar.gz as an example. It belongs to the user hadoop, group hadoop
To switch the user and group of this file, you can use the command.
sudo chown root:root jdk-7u21-linux-i586.tar.gz
File Permission Management
Three basic permissions
R Read Numeric representation4
W Write Numeric representation2
X Executable Numeric representation1
As shown in the figure, jdk-7u21-linux-i586The permission of the .tar.gz file is-rw-rw-r--
-rw-rw-r--A total of ten characters, divided into four parts.
The first character "-" represents a normal file; this position may also appear "l" link; "d" represents a directory
The second, third, and fourth characters "rw-" represents the permissions of the current user. So the numeric representation is4+2=6
The fifth, sixth, and seventh characters "rw-" represents the permissions of the current group. So the numeric representation is4+2=6
The eight, nine, and ten characters "r--" represents other users' permissions. So the numeric representation is2
So the operation permissions of this file are represented by numbers as662
Change permissions
sudo chmod [u owner g group o others a all] [+Increase permissions -Reduce permissions] [r w x] Directory name
For example, a file named filename has the permission of "-rw-r----" Change the permission value to "-rwxrw-r-" with numeric representation765
sudo chmod u+x g+w o+r filename
The above examples can be represented by numbers
sudo chmod 765 filename
The above is a collection of daily Linux commonly used commands (collect) collected by the editor, hoping it will be helpful to everyone.
Declaration: The content of this article is from the network, and the copyright belongs to the original author. The content is contributed and uploaded by Internet users spontaneously. This website does not own the copyright, has not been manually edited, and does not assume relevant legal liability. If you find any content suspected of copyright infringement, please send an email to: notice#w3Please replace # with @ when sending an email for reporting. Provide relevant evidence, and once verified, the website will immediately delete the infringing content.