Common instructions for Linux development, daily essentials

Recently, I often need to operate Linux by myself, so I summarize the commonly used Linux operation instructions and
give you an address for online practice of Linux commands. It may be very slow to open foreign websites: Linux command online practice
Operation method: click the second line of open terminal to log in with the guest account , and then you can start the operation.

nohup java -jar hello.jar --spring.profiles.active=dev >>hello.log &   Java启动命令

	>> 符号是指将前一条命令的输出内容追加到>>后面的文件中
ss -tanl  查看端口
ps -aux | grep "mosquitto" 查看mosquitto使用的端口
firewall-cmd --list-all    查看开放的端口号
firewall-cmd --add-service=http -permanent 设置开放的端口号
sudo firewall-cmd --add-port=80/tcp --permanent 栗子开80为tcp端口
firewall-cmd-reload  重启防火墙
command - ps
ps -A   查看所有进程
ps -ef|grep java   查看java进程
ps -ef    显示所有进程信息,连同命令行
browse file command
cat a.txt    输出a文件所有的内容
more a.txt   输出文档所有的内容,分页输出,空格浏览下一屏,q退出
less a.txt   用法和more相同,只是通过PgUp、PgOn键来控制
tail a.txt   用于显示文件后几号,使用频繁
tail -100f a.txt  实时查看a.txt的最后100行
tail –f nginx.conf 动态查看日志,方便查看日志新增的信息
ctrl+c 结束查看
file permission operation
ls -l   log.txt  查看文件和权限
chmod 777 /home/app  把/home/app  目录的权限设置为rwxrwxrwx(每个人都有读写和执行的权限) 文件同理

delete action command
rm n.txt         提示y删除 n放弃
rm –f n.txt      不提示删除
rm –rf dirname   不提示递归删除目录下所以内容
rm –rf /*        删除所有子目录所有和文件  
rm –rf *         删除所有文件  --此命令在公司禁用
rmdir            删除目录(如果目录里有文件,则不能用此命令)
rm -rf /usr/app/*   删除/usr/app/目录下的所有内容
Directory manipulation commands
mkdir           创建目录
mkdir a         创建 a目录
mkdir -p a/b    创建 a目录,并在a目录里创建b目录
mkdir -m 777 c  创建一个权限为777的C目录
Directory operation command cd
cd ..   进入上级目录
cd ~    进入当前用户主目录
cd /usr/local   进入local目录
mv command to move files/directories
mv abb.tar.gz ../    移动文件到上级目录
mv test.txt a.txt    将文件test.txt重命名为a.txt
mv a.txt ../         将a文件移动到上级目录
mv b.txt ./app/      将当前目录下的b.txt移动到当前子目录app下
mv ./app/b.txt  ../  将当前子目录app下的b.txt移动到当前当前的上级目录
vi/vim mode - view/edit files
命令行:Esc切换到命令行模式。
编辑模式:
按i,在光标前开始编辑
按a,在光标后开始编辑
按o,在当前行的下一行开始编辑
按u, 表示撤销
底行模式:按  shift+:冒号。
:q! 不保存退出
:wq 保存退出
:/world 从当前光标处,向上查找world关键字
:?world 从当前光标处,向后查找world关键字
View history using commands - history
history         查看历史命令执行记录 
history | grep mkdir  查看命令mkdir 的历史执行记录 
!178           执行历史记录中,序号为178的命令
compression command tar
tar -cvf abc.tar abc.txt           将 abc.txt压缩为abc.tar ,压缩之后不会覆盖原文件
tar -cvf all.tar abc.txt abb.txt abd.txt     压缩abc.txt abb.txt abd.txt,压缩之后不会覆盖原文件
tar -cvf my.tar app/         压缩app文件夹,压缩之后不会覆盖原文件
tar -cvf myjpg.tar *.jpg     将当前目录,所有jpg文件打包成myjpg.tar
tar -xvf my.tar              解压my.tar文件
find command find
find /app/ -name *.txt    查找 app目录下扩展名为txt的文件
find /app/ -name ad*      查找 app目录下名字为ad开头的文件
find / -name nginx.conf   在跟目录下查找nginx.conf

nginx operation instructions
nginx -s stop —快速关机
nginx -s reload —重新加载配置文件
clear
clear   清除当前屏幕  我常用
System common commands
top       显示系统目前最占资源的进程
date      打印系统时间
dh -f     查看系统磁盘资源占用情况
reboot    重启linux

Operation when command is entered

ctrl + w delete a word backwards, the cursor is at the end
ctrl + u delete the character before the cursor
ctrl + k delete the character after the cursor
ctrl + a move the cursor to the character head
ctrl + e move the cursor to the end of the character

The above are all used by me, welcome to add! Thank you, please correct me if there are any mistakes!

Guess you like

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